diff --git a/frontend/client/src/views/modal.js b/frontend/client/src/views/modal.js index 5d026627e7..de24c16946 100644 --- a/frontend/client/src/views/modal.js +++ b/frontend/client/src/views/modal.js @@ -51,6 +51,7 @@ Espo.define('Views.Modal', 'View', function (Dep) { if (action) { var method = 'action' + Espo.Utils.upperCaseFirst(action); if (typeof this[method] == 'function') { + e.preventDefault(); this[method].call(this, data); } } @@ -131,8 +132,8 @@ Espo.define('Views.Modal', 'View', function (Dep) { }); }, - actionCancel: function (dialog) { - dialog.close(); + actionCancel: function () { + this.dialog.close(); }, close: function () { diff --git a/frontend/client/src/views/modals/array-field-add.js b/frontend/client/src/views/modals/array-field-add.js index 13b799ee81..7f77036679 100644 --- a/frontend/client/src/views/modals/array-field-add.js +++ b/frontend/client/src/views/modals/array-field-add.js @@ -17,32 +17,32 @@ * * You should have received a copy of the GNU General Public License * along with EspoCRM. If not, see http://www.gnu.org/licenses/. - ************************************************************************/ + ************************************************************************/ Espo.define('Views.Modals.ArrayFieldAdd', 'Views.Modal', function (Dep) { return Dep.extend({ - + cssName: 'add-modal', - + template: 'modals.array-field-add', - + data: function () { return { optionList: this.options.options, translatedOptions: this.options.translatedOptions }; }, - + events: { 'click button[data-action="add"]': function (e) { var value = $(e.currentTarget).data('value'); this.trigger('add', value); }, }, - + setup: function () { - + this.buttons = [ { name: 'cancel', @@ -50,8 +50,8 @@ Espo.define('Views.Modals.ArrayFieldAdd', 'Views.Modal', function (Dep) { onClick: function (dialog) { dialog.close(); } - } - ]; + } + ]; }, diff --git a/frontend/client/src/views/modals/change-password.js b/frontend/client/src/views/modals/change-password.js index 965c36d199..f0968a4ca2 100644 --- a/frontend/client/src/views/modals/change-password.js +++ b/frontend/client/src/views/modals/change-password.js @@ -17,7 +17,7 @@ * * You should have received a copy of the GNU General Public License * along with EspoCRM. If not, see http://www.gnu.org/licenses/. - ************************************************************************/ + ************************************************************************/ Espo.define('Views.Modals.ChangePassword', 'Views.Modal', function (Dep) { @@ -25,10 +25,10 @@ Espo.define('Views.Modals.ChangePassword', 'Views.Modal', function (Dep) { cssName: 'change-password', - template: 'modals.change-password', + template: 'modals.change-password', setup: function () { - + this.buttons = [ { name: 'change', @@ -45,15 +45,15 @@ Espo.define('Views.Modals.ChangePassword', 'Views.Modal', function (Dep) { dialog.close(); } } - ]; - + ]; + this.header = this.translate('Change Password', 'labels', 'User'); - + this.wait(true); - - this.getModelFactory().create('User', function (user) { + + this.getModelFactory().create('User', function (user) { this.model = user; - + this.createView('password', 'Fields.Password', { model: user, mode: 'edit', @@ -73,29 +73,29 @@ Espo.define('Views.Modals.ChangePassword', 'Views.Modal', function (Dep) { name: 'passwordConfirm', params: { required: true, - } + } } }); - + this.wait(false); - }, this); + }, this); }, - - - changePassword: function () { + + + changePassword: function () { this.getView('password').fetchToModel(); - this.getView('passwordConfirm').fetchToModel(); - + this.getView('passwordConfirm').fetchToModel(); + var notValid = this.getView('password').validate() || this.getView('passwordConfirm').validate(); - + if (notValid) { return; } - + this.$el.find('button[data-name="change"]').addClass('disabled'); - - $.ajax({ + + $.ajax({ url: 'User/action/changeOwnPassword', type: 'POST', data: JSON.stringify({ @@ -103,12 +103,12 @@ Espo.define('Views.Modals.ChangePassword', 'Views.Modal', function (Dep) { }), error: function () { this.$el.find('button[data-name="change"]').removeClass('disabled'); - }.bind(this) - }).done(function () { - Espo.Ui.success(this.translate('passwordChanged', 'messages', 'User')); + }.bind(this) + }).done(function () { + Espo.Ui.success(this.translate('passwordChanged', 'messages', 'User')); this.trigger('changed'); this.close(); - }.bind(this)); + }.bind(this)); }, }); diff --git a/frontend/client/src/views/modals/compose-email.js b/frontend/client/src/views/modals/compose-email.js index 71546f5cc3..5e7ddd5138 100644 --- a/frontend/client/src/views/modals/compose-email.js +++ b/frontend/client/src/views/modals/compose-email.js @@ -52,7 +52,9 @@ Espo.define('Views.Modals.ComposeEmail', 'Views.Modals.Edit', function (Dep) { this.header = this.getLanguage().translate('Compose Email'); }, - actionSend: function (dialog) { + actionSend: function () { + var dialog = this.dialog; + var editView = this.getView('edit'); var model = editView.model; @@ -77,7 +79,9 @@ Espo.define('Views.Modals.ComposeEmail', 'Views.Modals.Edit', function (Dep) { editView.send(); }, - actionSaveDraft: function (dialog) { + actionSaveDraft: function () { + var dialog = this.dialog; + var editView = this.getView('edit'); var model = editView.model; diff --git a/frontend/client/src/views/modals/detail.js b/frontend/client/src/views/modals/detail.js index c8f5f357bd..5e05859202 100644 --- a/frontend/client/src/views/modals/detail.js +++ b/frontend/client/src/views/modals/detail.js @@ -135,7 +135,7 @@ Espo.define('Views.Modals.Detail', 'Views.Modal', function (Dep) { }.bind(this), 50); }, - actionEdit: function (dialog) { + actionEdit: function () { this.createView('quickEdit', 'Modals.Edit', { scope: this.scope, id: this.id, @@ -143,8 +143,8 @@ Espo.define('Views.Modals.Detail', 'Views.Modal', function (Dep) { }, function (view) { view.once('after:render', function () { Espo.Ui.notify(false); - dialog.hide(); - }); + this.dialog.hide(); + }, this); this.listenToOnce(view, 'remove', function () { this.close(); @@ -158,7 +158,7 @@ Espo.define('Views.Modals.Detail', 'Views.Modal', function (Dep) { }.bind(this)); }, - actionFullForm: function (dialog) { + actionFullForm: function () { var url; var router = this.getRouter(); @@ -179,8 +179,7 @@ Espo.define('Views.Modals.Detail', 'Views.Modal', function (Dep) { this.trigger('leave'); - dialog.close(); - + this.dialog.close(); } }); }); diff --git a/frontend/client/src/views/modals/duplicate.js b/frontend/client/src/views/modals/duplicate.js index e0705a8c2b..a22f1a7fe8 100644 --- a/frontend/client/src/views/modals/duplicate.js +++ b/frontend/client/src/views/modals/duplicate.js @@ -17,7 +17,7 @@ * * You should have received a copy of the GNU General Public License * along with EspoCRM. If not, see http://www.gnu.org/licenses/. - ************************************************************************/ + ************************************************************************/ Espo.define('Views.Modals.Duplicate', 'Views.Modal', function (Dep) { @@ -42,9 +42,9 @@ Espo.define('Views.Modals.Duplicate', 'Views.Modal', function (Dep) { name: 'save', label: 'Save', style: 'danger', - onClick: function (dialog) { + onClick: function (dialog) { this.trigger('save'); - dialog.close(); + dialog.close(); }.bind(this), }, { diff --git a/frontend/client/src/views/modals/edit.js b/frontend/client/src/views/modals/edit.js index 16da6ae6ca..ac954d101d 100644 --- a/frontend/client/src/views/modals/edit.js +++ b/frontend/client/src/views/modals/edit.js @@ -82,7 +82,11 @@ Espo.define('Views.Modals.Edit', 'Views.Modal', function (Dep) { this.header += ' ' + this.getLanguage().translate(this.scope, 'scopeNames'); if (!this.fullFormDisabled) { - this.header = '' + this.header + ''; + if (!this.id) { + this.header = '' + this.header + ''; + } else { + this.header = '' + this.header + ''; + } } this.waitForView('edit'); @@ -122,16 +126,16 @@ Espo.define('Views.Modals.Edit', 'Views.Modal', function (Dep) { this.createView('edit', viewName, options, callback); }, - actionSave: function (dialog) { + actionSave: function () { var editView = this.getView('edit'); var model = editView.model; editView.once('after:save', function () { this.trigger('after:save', model); - dialog.close(); + this.dialog.close(); }, this); - var $buttons = dialog.$el.find('.modal-footer button'); + var $buttons = this.dialog.$el.find('.modal-footer button'); $buttons.addClass('disabled'); editView.once('cancel:save', function () { @@ -177,7 +181,7 @@ Espo.define('Views.Modals.Edit', 'Views.Modal', function (Dep) { } this.trigger('leave'); - dialog.close(); + this.dialog.close(); } }); }); diff --git a/frontend/client/src/views/modals/save-filters.js b/frontend/client/src/views/modals/save-filters.js index 18e02d5a96..0cbf762e94 100644 --- a/frontend/client/src/views/modals/save-filters.js +++ b/frontend/client/src/views/modals/save-filters.js @@ -17,7 +17,7 @@ * * You should have received a copy of the GNU General Public License * along with EspoCRM. If not, see http://www.gnu.org/licenses/. - ************************************************************************/ + ************************************************************************/ Espo.define('Views.Modals.SaveFilters', 'Views.Modal', function (Dep) { @@ -41,7 +41,7 @@ Espo.define('Views.Modals.SaveFilters', 'Views.Modal', function (Dep) { label: 'Save', style: 'primary', onClick: function (dialog) { - this.save(); + this.save(); }.bind(this) }, { @@ -52,30 +52,30 @@ Espo.define('Views.Modals.SaveFilters', 'Views.Modal', function (Dep) { } } ]; - + this.header = this.translate('Save Filters'); - + var model = new Espo.Model(); - this.createView('name', 'Fields.Varchar', { - el: this.options.el + ' .field-name', + this.createView('name', 'Fields.Varchar', { + el: this.options.el + ' .field-name', defs: { name: 'name', params: { required: true - } + } }, mode: 'edit', model: model }); }, - - save: function () { + + save: function () { var nameView = this.getView('name'); - nameView.fetchToModel(); + nameView.fetchToModel(); if (nameView.validate()) { return; - } - this.trigger('save', nameView.model.get('name')); + } + this.trigger('save', nameView.model.get('name')); return true; }, });