Modal.User = Modal.User || {}; Modal.User.Edit = class extends _modal { /** * Get class name. * @return {string} */ getClassName() { return 'Modal.User.Edit'; } /** * * @param {object} parameters * @param {string} parameters.id * @param {jQuery} parameters.$context * @param {function()} parameters.onClose */ constructor(parameters) { super(parameters); this.init(); } /** * Initialize modal. */ init() { Core.API.call({ url: this.getURI(), data: { func: 'apiGetModal', id: this.parameters.id }, callback: (data) => { this.create( data.modal_id, data.modal ); }, $context: this.parameters.$context, fadeParameters: 'Loading edit user modal...' }); } /** * Bind modal. */ bind() { Core.UI.Bind.get( this.$modal, { instance: this, buttons: { 'change-password': (data) => { new Modal.User.ChangePassword({ id: data.id }); }, 'send-confirm-account-email': (data) => { this.sendConfirmAccountEmail( data.id ); }, 'end-session': (data) => { this.endSession( data.id, () => Core.UI.Table.get('sessions', this).deleteRow(data.id) ); } } } ); } /** * Bind tab actions. * @param {string} tabName * @param {jQuery} $tab */ bindTab(tabName, $tab) { switch (tabName) { case 'sessions': Core.UI.Table.get( 'sessions', { instance: this, $container: $tab } ); } } /** * Send email to confirm account. * @param {string} id */ sendConfirmAccountEmail(id) { Core.API.call({ url: this.getURI(), data: { func: 'apiSendActivateAccountEmail', id: id }, fadeParameters: 'Sending confirm account email...' }); } /** * End session in database. * @param {string} id * @param {function()} callback */ endSession(id, callback) { Core.API.call({ url: this.getURI(), data: { func: 'apiEndSession', id: id }, callback: (data) => { if ($.isFunction(callback)) { callback(); } }, fadeParameters: 'Ending session...' }); } };