text: var BitsRightGroups=BaseClass.extend({mUrlUpdateGroup:null,mDialogGroup:null,mGroups:null,onCreate:function(aUrlUpdateGroup,aGroups){this.mUrlUpdateGroup=aUrlUpdateGroup;this.mGroups=aGroups;},setup:function(){this.mDialogGroup=$('#dialog_group');$(document).on('click','#btn_add_group',this.asCB('onAddGroupClick'));$(document).on('click','.btn_edit_group',this.asCB('onEditGroupClick'));this.mDialogGroup.on('click','#btn_save_dialog_group',this.asCB('onGroupSaveClick'));if(this.mGroups){var e=$('#group_parent',this.mDialogGroup);e.append($('<option value="" selected></option>'));$.each(this.mGroups,function(key,row){e.append($("<option></option>").attr("value",key).text(row));});}}});BitsRightGroups.prototype.onAddGroupClick=function(e){e.preventDefault();$('#dialog_title_add',this.mDialogGroup).show();$('#dialog_title_edit',this.mDialogGroup).hide();$('#group_id',this.mDialogGroup).val('');$('#group_name',this.mDialogGroup).val('');$('#group_parent',this.mDialogGroup).val('');$('select option',this.mDialogGroup).prop('disabled',false);$('#group_reg_code',this.mDialogGroup).val('');this.mDialogGroup.modal('show');};BitsRightGroups.prototype.onEditGroupClick=function(e){e.preventDefault();$('#dialog_title_add',this.mDialogAccount).hide();$('#dialog_title_edit',this.mDialogAccount).show();var id=e.currentTarget.getAttribute('data-group_id');var gn=e.currentTarget.getAttribute('data-group_name');var gp=e.currentTarget.getAttribute('data-group_parent');var rc=e.currentTarget.getAttribute('data-group_reg_code');$('#group_id',this.mDialogGroup).val(id);$('#group_name',this.mDialogGroup).val(gn);$('#group_parent',this.mDialogGroup).val('');$('select option',this.mDialogGroup).prop('disabled',false);var e=$('select option[value="'+id+'"]',this.mDialogGroup);if(e)
  e.attr('disabled','disabled');if(gp){$('select option[value="'+gp+'"]',this.mDialogGroup).attr('selected','selected');}
  $('#group_reg_code',this.mDialogGroup).val(rc);this.mDialogGroup.modal('show');};BitsRightGroups.prototype.onGroupSaveClick=function(e){var thisone=this;var id=$('#group_id',this.mDialogGroup).val();var gn=$('#group_name',this.mDialogGroup).val();var gp=$('#group_parent',this.mDialogGroup).val();if(gp=='UNKNOWN'||gp=="")gp=undefined;var rc=$('#group_reg_code',this.mDialogGroup).val();if(gn){$.post(thisone.mUrlUpdateGroup,{group_id:id,group_name:gn,parent_group_id:gp,reg_code:rc}).then(function(data){window.location.reload();})}}
  var BitsAuthBasicAccounts=BaseClass.extend({mUrlCreateAccount:null,mUrlUpdateAccount:null,mDialogAccount:null,mUrlToUse:null,mAlertErrorDialog:null,onCreate:function(aUrlCreateAccount,aUrlUpdateAccount){this.mUrlCreateAccount=aUrlCreateAccount;this.mUrlUpdateAccount=aUrlUpdateAccount;},setup:function(){this.mDialogAccount=$('#dialog_account');$(document).on('click','#btn_add_account',this.asCB('onAddClick'));$(document).on('click','.btn_edit_account',this.asCB('onEditClick'));this.mDialogAccount.on('click','#btn_save_dialog_account',this.asCB('onSaveClick'));this.mAlertErrorDialog=$('meta[itemprop=js-dialog_error]').data('bootbox_dialog_argument');}});BitsAuthBasicAccounts.prototype.getGroupIdArray=function(){var theGroupIds=$('input:checkbox:checked',$('#list_account_groups',this.mDialogAccount)).map(function(){return this.value;}).toArray();if(theGroupIds.length<1)
  theGroupIds=undefined;return theGroupIds;}
  BitsAuthBasicAccounts.prototype.setGroupIdArray=function(aList){if(aList){var theGroupIds=$('input:checkbox',$('#list_account_groups',this.mDialogAccount)).each(function(){if($.inArray(Number(this.value),aList)<0)
  $(this).prop('checked',false);else
  $(this).prop('checked',true);});}}
  BitsAuthBasicAccounts.prototype.resetDialog=function(){$('#list_account_groups',this.mDialogAccount).show();$('#empty_text',this.mDialogAccount).hide();$('#account_id',this.mDialogAccount).val('-1');$('#account_name',this.mDialogAccount).val('');$('#email',this.mDialogAccount).val('');$('#account_is_active',this.mDialogAccount).prop('checked',true);$('#account_password',this.mDialogAccount).val('');this.setGroupIdArray(null);};BitsAuthBasicAccounts.prototype.onAddClick=function(e){e.preventDefault();$('#dialog_title_add',this.mDialogAccount).show();$('#dialog_title_edit',this.mDialogAccount).hide();$('#row_account_password',this.mDialogAccount).show();this.mUrlToUse=this.mUrlCreateAccount;this.resetDialog(e);this.mDialogAccount.modal('show');};BitsAuthBasicAccounts.prototype.onEditClick=function(e){e.preventDefault();$('#dialog_title_add',this.mDialogAccount).hide();$('#dialog_title_edit',this.mDialogAccount).show();$('#row_account_password',this.mDialogAccount).hide();this.mUrlToUse=this.mUrlUpdateAccount;this.resetDialog(e);var id=e.currentTarget.getAttribute('data-account_id');var an=e.currentTarget.getAttribute('data-account_name');var ae=e.currentTarget.getAttribute('data-email');var ia=e.currentTarget.getAttribute('data-is_active');var gl=$.parseJSON(e.currentTarget.getAttribute('data-groups'));$('#account_id',this.mDialogAccount).val(id);$('#account_name',this.mDialogAccount).val(an);$('#email',this.mDialogAccount).val(ae);$('#account_is_active',this.mDialogAccount).prop('checked',ia!=false);this.setGroupIdArray(gl);if(gl.indexOf(1)>=0){$('#list_account_groups',this.mDialogAccount).hide();$('#empty_text',this.mDialogAccount).show();}else{$('#list_account_groups',this.mDialogAccount).show();$('#empty_text',this.mDialogAccount).hide();}
  this.mDialogAccount.modal('show');};BitsAuthBasicAccounts.prototype.onSaveClick=function(e){var id=Number($('#account_id',this.mDialogAccount).val());if(id<0)id=undefined;var an=$('#account_name',this.mDialogAccount).val();if(an=="")an=undefined;var ap=$('#account_password',this.mDialogAccount).val();if(ap=="")ap=undefined;var ae=$('#email',this.mDialogAccount).val();if(ae=="")ae=undefined;var ia=$('#account_is_active',this.mDialogAccount).prop('checked')?1:0;var theGroupIds=this.getGroupIdArray();if(an&&ae&&(ap||this.mUrlToUse==this.mUrlUpdateAccount)){$.post(this.mUrlToUse,{account_id:id,account_name:an,email:ae,account_password:ap,account_is_active:ia,account_group_ids:theGroupIds}).fail(function(jqXHR,textStatus,errorMsg){if(jqXHR.responseJSON.error){var theErr=jqXHR.responseJSON.error;errorMsg='['+theErr.cause+']<br>'+theErr.message;if(this.mAlertErrorDialog){this.mAlertErrorDialog.message=errorMsg;bootbox.dialog(this.mAlertErrorDialog);}else bootbox.alert(errorMsg);}else bootbox.alert(errorMsg);console.log(textStatus,errorMsg);}).done(function(data){window.location.reload();});}}