email filter move to folder

This commit is contained in:
Yuri Kuznetsov
2022-10-12 18:35:43 +03:00
parent a7d3073861
commit 4e31fc89d4
18 changed files with 446 additions and 299 deletions
+118
View File
@@ -0,0 +1,118 @@
/************************************************************************
* This file is part of EspoCRM.
*
* EspoCRM - Open Source CRM application.
* Copyright (C) 2014-2022 Yurii Kuznietsov, Taras Machyshyn, Oleksii Avramenko
* Website: https://www.espocrm.com
*
* EspoCRM is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* EspoCRM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with EspoCRM. If not, see http://www.gnu.org/licenses/.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU General Public License version 3.
*
* In accordance with Section 7(b) of the GNU General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
define('handlers/email-filter', ['dynamic-handler'], (Dep) => {
return Dep.extend({
init: function () {
if (this.model.isNew()) {
if (!this.recordView.getUser().isAdmin()) {
this.recordView.hideField('isGlobal');
}
}
if (
!this.model.isNew() &&
!this.recordView.getUser().isAdmin() &&
!this.model.get('isGlobal')
) {
this.recordView.hideField('isGlobal');
}
if (this.model.isNew() && !this.model.get('parentId')) {
this.model.set('parentType', 'User');
this.model.set('parentId', this.recordView.getUser().id);
this.model.set('parentName', this.recordView.getUser().get('name'));
if (!this.recordView.getUser().isAdmin()) {
this.recordView.setFieldReadOnly('parent');
}
}
else if (
this.model.get('parentType') &&
!this.recordView.options.duplicateSourceId &&
this.model.get('parentType') !== 'User'
) {
this.recordView.setFieldReadOnly('parent');
this.recordView.setFieldReadOnly('isGlobal');
}
this.recordView.listenTo(this.model, 'change:isGlobal', (model, value, o) => {
if (!o.ui) {
return;
}
if (value) {
this.model.set('action', 'Skip');
this.model.set('parentType', null);
this.model.set('parentId', null);
this.model.set('emailFolderId', null);
this.model.set('groupEmailFolderId', null);
}
});
this.recordView.listenTo(this.model, 'change:parentType', (model, value, o) => {
if (!o.ui) {
return;
}
// Avoiding side effects.
setTimeout(() => {
if (value === 'EmailAccount') {
this.model.set('action', 'Skip');
this.model.set('emailFolderId', null);
this.model.set('groupEmailFolderId', null);
return;
}
if (value !== 'InboundEmail') {
if (this.model.get('action') === 'Move to Group Folder') {
this.model.set('action', 'Skip');
}
this.model.set('groupEmailFolderId', null);
return;
}
if (value !== 'User') {
if (this.model.get('action') === 'Move to Folder') {
this.model.set('action', 'Skip');
}
this.model.set('groupFolderId', null);
return;
}
}, 40);
});
},
});
});
+1 -22
View File
@@ -28,26 +28,5 @@
define('views/email-filter/fields/action', ['views/fields/enum'], function (Dep) {
return Dep.extend({
setup: function () {
Dep.prototype.setup.call(this);
this.controlActionOptions();
this.listenTo(this.model, 'change:parentType', this.controlActionOptions, this);
},
controlActionOptions: function () {
if (this.model.get('parentType') === 'User') {
this.params.options = ['Skip', 'Move to Folder'];
} else {
this.params.options = ['Skip'];
}
if (this.isRendered()) {
this.reRender();
}
},
});
return Dep.extend({});
});
@@ -25,7 +25,8 @@
* In accordance with Section 7(b) of the GNU General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
Espo.define('views/email-filter/fields/email-folder', 'views/fields/link', function (Dep) {
define('views/email-filter/fields/email-folder', ['views/fields/link'], function (Dep) {
return Dep.extend({
@@ -42,27 +43,12 @@ Espo.define('views/email-filter/fields/email-folder', 'views/fields/link', funct
attribute: 'assignedUserId',
value: this.model.get('parentId'),
data: {
nameValue: this.model.get('parentName')
}
nameValue: this.model.get('parentName'),
},
}
};
}
}
},
setup: function () {
Dep.prototype.setup.call(this);
this.listenTo(this.model, 'change:parentId', function (model, e, data) {
if (data.ui) {
this.model.set({
emailFolderId: null,
emailFolderName: null
});
}
}, this);
}
});
});
@@ -1,35 +0,0 @@
/************************************************************************
* This file is part of EspoCRM.
*
* EspoCRM - Open Source CRM application.
* Copyright (C) 2014-2022 Yurii Kuznietsov, Taras Machyshyn, Oleksii Avramenko
* Website: https://www.espocrm.com
*
* EspoCRM is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* EspoCRM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with EspoCRM. If not, see http://www.gnu.org/licenses/.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU General Public License version 3.
*
* In accordance with Section 7(b) of the GNU General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
define('views/email-filter/record/detail-small', ['views/email-filter/record/detail'], function (Dep) {
return Dep.extend({
bottomView: null,
});
});
@@ -1,105 +0,0 @@
/************************************************************************
* This file is part of EspoCRM.
*
* EspoCRM - Open Source CRM application.
* Copyright (C) 2014-2022 Yurii Kuznietsov, Taras Machyshyn, Oleksii Avramenko
* Website: https://www.espocrm.com
*
* EspoCRM is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* EspoCRM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with EspoCRM. If not, see http://www.gnu.org/licenses/.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU General Public License version 3.
*
* In accordance with Section 7(b) of the GNU General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
define('views/email-filter/record/detail', ['views/record/detail'], function (Dep) {
return Dep.extend({
setup: function () {
Dep.prototype.setup.call(this);
this.setupFilterFields();
},
setupFilterFields: function () {
this.controlIsGlobal();
this.listenTo(this.model, 'change:isGlobal', (model, value, data) => {
this.controlIsGlobal();
if (data.ui) {
if (model.get('isGlobal')) {
this.model.set({
parentId: null,
parentType: null,
parentName: null
});
} else {
this.model.set('parentType', 'User');
this.model.set('parentId', this.getUser().id);
this.model.set('parentName', this.getUser().get('name'));
}
}
});
if (!this.getUser().isAdmin()) {
this.setFieldReadOnly('parent');
this.setFieldReadOnly('isGlobal');
}
if (this.model.isNew()) {
if (!this.model.get('parentId')) {
this.model.set('parentType', 'User');
this.model.set('parentId', this.getUser().id);
this.model.set('parentName', this.getUser().get('name'));
}
if (!this.getUser().isAdmin()) {
this.hideField('isGlobal');
}
this.setFieldRequired('parent');
} else {
this.setFieldReadOnly('isGlobal');
this.setFieldReadOnly('parent');
}
this.controlEmailFolder();
this.listenTo(this.model, 'change', () => {
this.controlEmailFolder();
});
},
controlIsGlobal: function () {
if (this.model.get('isGlobal')) {
this.hideField('parent');
} else {
this.showField('parent');
}
},
controlEmailFolder: function () {
if (this.model.get('action') !== 'Move to Folder' || this.model.get('parentType') !== 'User') {
this.hideField('emailFolder');
} else {
this.showField('emailFolder');
}
},
});
});
@@ -1,36 +0,0 @@
/************************************************************************
* This file is part of EspoCRM.
*
* EspoCRM - Open Source CRM application.
* Copyright (C) 2014-2022 Yurii Kuznietsov, Taras Machyshyn, Oleksii Avramenko
* Website: https://www.espocrm.com
*
* EspoCRM is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* EspoCRM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with EspoCRM. If not, see http://www.gnu.org/licenses/.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU General Public License version 3.
*
* In accordance with Section 7(b) of the GNU General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
define('views/email-filter/record/edit-small', ['views/email-filter/record/edit'], function (Dep) {
return Dep.extend({
bottomView: null,
});
});
@@ -1,49 +0,0 @@
/************************************************************************
* This file is part of EspoCRM.
*
* EspoCRM - Open Source CRM application.
* Copyright (C) 2014-2022 Yurii Kuznietsov, Taras Machyshyn, Oleksii Avramenko
* Website: https://www.espocrm.com
*
* EspoCRM is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* EspoCRM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with EspoCRM. If not, see http://www.gnu.org/licenses/.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU General Public License version 3.
*
* In accordance with Section 7(b) of the GNU General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
define('views/email-filter/record/edit',
['views/record/edit', 'views/email-filter/record/detail'],
function (Dep, Detail) {
return Dep.extend({
setup: function () {
Dep.prototype.setup.call(this);
Detail.prototype.setupFilterFields.call(this);
},
controlIsGlobal: function () {
Detail.prototype.controlIsGlobal.call(this);
},
controlEmailFolder: function () {
Detail.prototype.controlEmailFolder.call(this);
},
});
});