EspoCRM – Open Source CRM Application
PHP calendarcontactscrmcrm-platformcrm-systemcustomer-portalcustomer-supportcustomizabledocumentsemail-marketingkanbanleadsopen-sourcephpplatformsales-automationsingle-page-applicationsupport
Save filter shortcut and focus
Yuriib5876784776e
diff --git a/client/res/templates/modals/save-filters.tpl b/client/res/templates/modals/save-filters.tpldeleted file mode 100644index bb5b305f50..0000000000--- a/client/res/templates/modals/save-filters.tpl+++ /dev/null@@ -1,12 +0,0 @@-<div class="panel panel-default no-side-margin">-<div class="panel-body">--<div class="cell form-group" data-name="name">- <label class="control-label" data-name="name">{{translate 'name' category='fields'}}</label>- <div class="field" data-name="name">- {{{name}}}- </div>-</div>--</div>-</div>diff --git a/client/src/views/modals/save-filters.js b/client/src/views/modals/save-filters.jsindex 0b7d41b2c9..7c42a1aec9 100644--- a/client/src/views/modals/save-filters.js+++ b/client/src/views/modals/save-filters.js@@ -28,13 +28,34 @@import ModalView from 'views/modal';import Model from 'model';+import VarcharFieldView from 'views/fields/varchar';class SaveFiltersModalView extends ModalView {- template = 'modals/save-filters'++ // language=Handlebars+ templateContent = `+ <div class="panel panel-default no-side-margin">+ <div class="panel-body">+ <div class="cell form-group" data-name="name">+ <label+ class="control-label"+ data-name="name"+ >{{translate 'name' category='fields'}}</label>+ <div class="field" data-name="name">{{{nameField}}}</div>+ </div>+ </div>+ </div>+ `cssName = 'save-filters'+ /**+ * @private+ * @type {VarcharFieldView}+ */+ nameFieldView+data() {return {dashletList: this.dashletList,@@ -42,57 +63,72 @@ class SaveFiltersModalView extends ModalView {}setup() {+ this.shortcutKeys = {+ 'Control+Enter': (e) => {+ e.preventDefault();+ e.stopPropagation();++ this.actionSave();+ },+ };+this.buttonList = [{name: 'save',label: 'Save',style: 'primary',+ onClick: () => this.actionSave(),},{name: 'cancel',label: 'Cancel',+ onClick: () => this.actionCancel(),},];this.headerText = this.translate('Save Filter');- const model = new Model();+ this.formModel = new Model();- this.createView('name', 'views/fields/varchar', {- selector: '.field[data-name="name"]',- defs: {- name: 'name',- params: {- required: true- }+ this.nameFieldView = new VarcharFieldView({+ name: 'name',+ params: {+ required: true},mode: 'edit',- model: model,+ model: this.formModel,labelText: this.translate('name', 'fields'),- });+ })++ this.assignView('nameField', this.nameFieldView);}- /**- * @param {string} field- * @return {module:views/fields/base}- */- getFieldView(field) {- return this.getView(field);+ afterRender() {+ setTimeout(() => {+ this.nameFieldView.element.querySelector('input')?.focus();+ }, 1);}actionSave() {- const nameView = this.getFieldView('name');+ this.fetchToModel();- nameView.fetchToModel();-- if (nameView.validate()) {+ if (this.nameFieldView.validate()) {return;}- this.trigger('save', nameView.model.get('name'));+ this.trigger('save', this.formModel.attributes.name);return true;}++ /**+ * @private+ */+ fetchToModel() {+ this.formModel.setMultiple({+ ...this.nameFieldView.fetch(),+ });+ }}export default SaveFiltersModalView;