check_required fix
This commit is contained in:
parent
158e7751a8
commit
d47efd57ac
@ -1,13 +0,0 @@
|
||||
<div class="layout-wrapper">
|
||||
<a class="close" onclick="window.history.back();">×</a>
|
||||
<h1>Users</h1>
|
||||
<hr>
|
||||
<div class="help" style="margin-bottom: 20px">Add, disable, delete users and change their roles, passwords and security settings</div>
|
||||
<div style="margin: 11px">
|
||||
<button class="btn btn-small add-user" onclick="wn.pages.users.add_user()"
|
||||
><i class="icon-plus"></i> Add User</button>
|
||||
</div>
|
||||
<div class="users-area">
|
||||
</div>
|
||||
<div style="clear: both"></div>
|
||||
</div>
|
@ -16,26 +16,37 @@
|
||||
|
||||
$.extend(wn.pages.users, {
|
||||
onload: function(wrapper) {
|
||||
wn.pages.users.profiles = {};
|
||||
wn.pages.users.refresh();
|
||||
wn.pages.users.setup();
|
||||
wn.pages.users.role_editor = new erpnext.RoleEditor();
|
||||
var w = wn.pages.users;
|
||||
wn.ui.make_app_page({
|
||||
parent: w,
|
||||
title: "Users",
|
||||
single_column: true
|
||||
});
|
||||
w.profiles = {};
|
||||
w.refresh();
|
||||
w.setup();
|
||||
w.role_editor = new erpnext.RoleEditor();
|
||||
},
|
||||
setup: function() {
|
||||
wn.pages.users.appframe.add_button('+ Add User', function() {
|
||||
wn.pages.users.add_user();
|
||||
});
|
||||
|
||||
// set roles
|
||||
$('.users-area').on('click', '.btn.user-roles', function() {
|
||||
var w = wn.pages.users;
|
||||
$(w).on('click', '.btn.user-roles', function() {
|
||||
var uid = $(this).parent().parent().attr('data-name');
|
||||
wn.pages.users.role_editor.show(uid);
|
||||
});
|
||||
|
||||
// settings
|
||||
$('.users-area').on('click', '.btn.user-settings', function() {
|
||||
$(w).on('click', '.btn.user-settings', function() {
|
||||
var uid = $(this).parent().parent().attr('data-name');
|
||||
wn.pages.users.show_settings(uid);
|
||||
});
|
||||
|
||||
// delete
|
||||
$('.users-area').on('click', 'a.close', function() {
|
||||
$(w).on('click', 'a.close', function() {
|
||||
$card = $(this).parent();
|
||||
var uid = $card.attr('data-name');
|
||||
$card.css('opacity', 0.6);
|
||||
@ -55,7 +66,7 @@ $.extend(wn.pages.users, {
|
||||
wn.call({
|
||||
method:'utilities.page.users.users.get',
|
||||
callback: function(r, rt) {
|
||||
$('.users-area').empty();
|
||||
$(wn.pages.users).find('.layout-main').empty();
|
||||
for(var i in r.message) {
|
||||
var p = r.message[i];
|
||||
wn.pages.users.profiles[p.name] = p;
|
||||
@ -91,7 +102,7 @@ $.extend(wn.pages.users, {
|
||||
if(!data.enabled)
|
||||
data.delete_html = '<a class="close" title="delete">×</a>';
|
||||
|
||||
$('.users-area').append(repl('<div class="user-card" data-name="%(name)s">\
|
||||
$(wn.pages.users).find('.layout-main').append(repl('<div class="user-card" data-name="%(name)s">\
|
||||
%(delete_html)s\
|
||||
<img src="%(imgsrc)s">\
|
||||
<div class="user-info">\
|
||||
@ -103,7 +114,7 @@ $.extend(wn.pages.users, {
|
||||
</div>', data));
|
||||
|
||||
if(!data.enabled) {
|
||||
$('.users-area .user-card:last')
|
||||
$(wn.pages.users).find('.layout-main .user-card:last')
|
||||
.addClass('disabled')
|
||||
.find('.user-fullname').html('Disabled');
|
||||
}
|
||||
@ -225,8 +236,7 @@ $.extend(wn.pages.users, {
|
||||
var me = wn.pages.users;
|
||||
var active_users = $('.user-card:not(.disabled)');
|
||||
if(wn.boot.max_users && (active_users.length >= wn.boot.max_users)) {
|
||||
msgprint(repl("Alas! <br />\
|
||||
You already have <b>%(active_users)s</b> active users, \
|
||||
msgprint(repl("You already have <b>%(active_users)s</b> active users, \
|
||||
which is the maximum number that you are currently allowed to add. <br /><br /> \
|
||||
So, to add more users, you can:<br /> \
|
||||
1. <b>Upgrade to the unlimited users plan</b>, or<br /> \
|
||||
|
@ -850,7 +850,7 @@ wn.ui.AppFrame=Class.extend({init:function(parent,title){this.buttons={};this.$w
|
||||
<span class="appframe-title"></span>\
|
||||
<span class="close">×</span>\
|
||||
</div>').appendTo(this.$w);this.$w.find('.close').click(function(){window.history.back();})
|
||||
if(title)this.title(title);},title:function(txt){this.$titlebar.find('.appframe-title').html(txt);},make_toolbar:function(){if(!this.$w.find('.appframe-toolbar').length)
|
||||
if(title)this.title(title);},title:function(txt){this.clear_breadcrumbs();this.add_breadcrumb(txt);},make_toolbar:function(){if(!this.$w.find('.appframe-toolbar').length)
|
||||
this.$w.append('<div class="appframe-toolbar"></div>');},add_button:function(label,click,icon){this.make_toolbar();args={label:label,icon:''};if(icon){args.icon='<i class="icon '+icon+'"></i>';}
|
||||
this.buttons[label]=$(repl('<button class="btn btn-small">\
|
||||
%(icon)s %(label)s</button>',args)).click(click).appendTo(this.$w.find('.appframe-toolbar'));return this.buttons[label];},add_help_button:function(txt){this.make_toolbar();$('<button class="btn btn-small" style="float:right;" button-type="help">\
|
||||
@ -1375,7 +1375,7 @@ return;}
|
||||
var _save=function(){$c('webnotes.widgets.form.save.savedocs',{'docs':compress_doclist(doclist),'docname':dn,'action':save_action,'user':user},function(r,rtxt){if(f){f.savingflag=false;}
|
||||
if(r.saved){if(onsave)onsave(r);}else{if(onerr)onerr(r);}},function(){if(f){f.savingflag=false;}},0,(f?'Saving...':''));}
|
||||
if(doc.__islocal&&(doctype&&doctype.autoname&&doctype.autoname.toLowerCase()=='prompt')){var newname=prompt('Enter the name of the new '+dt,'');if(newname){doc.__newname=strip(newname);_save();}else{msgprint('Not Saved');onerr();}}else{_save();}}
|
||||
function check_required(dt,dn,parent_dt){var doc=locals[dt][dn];if(doc.docstatus>1)return true;var fl=wn.meta.docfield_list[dt];if(!fl)return true;var all_clear=true;var errfld=[];for(var i=0;i<fl.length;i++){var key=fl[i].fieldname;var v=doc[key];if(fl[i].fieldtype=='Table'){var no_value=true;$.each(locals[fl[i].options],function(k,d){if(d.parent==doc.name&&d.parenttype==doc.doctype&&d.parentfield==fl[i].fieldname){no_value=false;}});}else{var no_value=is_null(v);}
|
||||
function check_required(dt,dn,parent_dt){var doc=locals[dt][dn];if(doc.docstatus>1)return true;var fl=wn.meta.docfield_list[dt];if(!fl)return true;var all_clear=true;var errfld=[];for(var i=0;i<fl.length;i++){var key=fl[i].fieldname;var v=doc[key];if(fl[i].fieldtype=='Table'){var no_value=true;$.each(locals[fl[i].options]||{},function(k,d){if(d.parent==doc.name&&d.parenttype==doc.doctype&&d.parentfield==fl[i].fieldname){no_value=false;}});}else{var no_value=is_null(v);}
|
||||
if(fl[i].reqd&&no_value&&fl[i].fieldname){errfld[errfld.length]=fl[i].label;if(cur_frm){var f=cur_frm.fields_dict[fl[i].fieldname];if(f){if(f.set_as_error)f.set_as_error(1);if(!cur_frm.error_in_section&&f.parent_section){cur_frm.error_in_section=1;}}}
|
||||
if(all_clear)all_clear=false;}}
|
||||
if(errfld.length)msgprint('<b>Mandatory fields required in '+
|
||||
|
@ -508,7 +508,7 @@ wn.ui.AppFrame=Class.extend({init:function(parent,title){this.buttons={};this.$w
|
||||
<span class="appframe-title"></span>\
|
||||
<span class="close">×</span>\
|
||||
</div>').appendTo(this.$w);this.$w.find('.close').click(function(){window.history.back();})
|
||||
if(title)this.title(title);},title:function(txt){this.$titlebar.find('.appframe-title').html(txt);},make_toolbar:function(){if(!this.$w.find('.appframe-toolbar').length)
|
||||
if(title)this.title(title);},title:function(txt){this.clear_breadcrumbs();this.add_breadcrumb(txt);},make_toolbar:function(){if(!this.$w.find('.appframe-toolbar').length)
|
||||
this.$w.append('<div class="appframe-toolbar"></div>');},add_button:function(label,click,icon){this.make_toolbar();args={label:label,icon:''};if(icon){args.icon='<i class="icon '+icon+'"></i>';}
|
||||
this.buttons[label]=$(repl('<button class="btn btn-small">\
|
||||
%(icon)s %(label)s</button>',args)).click(click).appendTo(this.$w.find('.appframe-toolbar'));return this.buttons[label];},add_help_button:function(txt){this.make_toolbar();$('<button class="btn btn-small" style="float:right;" button-type="help">\
|
||||
@ -686,7 +686,7 @@ return;}
|
||||
var _save=function(){$c('webnotes.widgets.form.save.savedocs',{'docs':compress_doclist(doclist),'docname':dn,'action':save_action,'user':user},function(r,rtxt){if(f){f.savingflag=false;}
|
||||
if(r.saved){if(onsave)onsave(r);}else{if(onerr)onerr(r);}},function(){if(f){f.savingflag=false;}},0,(f?'Saving...':''));}
|
||||
if(doc.__islocal&&(doctype&&doctype.autoname&&doctype.autoname.toLowerCase()=='prompt')){var newname=prompt('Enter the name of the new '+dt,'');if(newname){doc.__newname=strip(newname);_save();}else{msgprint('Not Saved');onerr();}}else{_save();}}
|
||||
function check_required(dt,dn,parent_dt){var doc=locals[dt][dn];if(doc.docstatus>1)return true;var fl=wn.meta.docfield_list[dt];if(!fl)return true;var all_clear=true;var errfld=[];for(var i=0;i<fl.length;i++){var key=fl[i].fieldname;var v=doc[key];if(fl[i].fieldtype=='Table'){var no_value=true;$.each(locals[fl[i].options],function(k,d){if(d.parent==doc.name&&d.parenttype==doc.doctype&&d.parentfield==fl[i].fieldname){no_value=false;}});}else{var no_value=is_null(v);}
|
||||
function check_required(dt,dn,parent_dt){var doc=locals[dt][dn];if(doc.docstatus>1)return true;var fl=wn.meta.docfield_list[dt];if(!fl)return true;var all_clear=true;var errfld=[];for(var i=0;i<fl.length;i++){var key=fl[i].fieldname;var v=doc[key];if(fl[i].fieldtype=='Table'){var no_value=true;$.each(locals[fl[i].options]||{},function(k,d){if(d.parent==doc.name&&d.parenttype==doc.doctype&&d.parentfield==fl[i].fieldname){no_value=false;}});}else{var no_value=is_null(v);}
|
||||
if(fl[i].reqd&&no_value&&fl[i].fieldname){errfld[errfld.length]=fl[i].label;if(cur_frm){var f=cur_frm.fields_dict[fl[i].fieldname];if(f){if(f.set_as_error)f.set_as_error(1);if(!cur_frm.error_in_section&&f.parent_section){cur_frm.error_in_section=1;}}}
|
||||
if(all_clear)all_clear=false;}}
|
||||
if(errfld.length)msgprint('<b>Mandatory fields required in '+
|
||||
|
Loading…
Reference in New Issue
Block a user