From 0b77c4cdfe2e03cbf9ee65217044a9e60d825b4e Mon Sep 17 00:00:00 2001 From: yuri Date: Wed, 6 May 2015 10:40:22 +0300 Subject: [PATCH] move inbound email to core --- .../Crm => }/Controllers/InboundEmail.php | 2 +- .../Crm => }/Entities/InboundEmail.php | 4 +- .../Crm/Resources/i18n/en_US/Global.json | 2 - .../Espo/Resources/i18n/en_US/Global.json | 2 + .../Resources/i18n/en_US/InboundEmail.json | 2 +- .../layouts/InboundEmail/detail.json | 2 +- .../Resources/layouts/InboundEmail/list.json | 0 .../metadata/clientDefs/InboundEmail.json | 6 +-- .../metadata/entityDefs/InboundEmail.json | 4 +- .../metadata/scopes/InboundEmail.json | 3 +- .../Crm => }/Services/InboundEmail.php | 2 +- .../inbound-email/fields/folder/edit.tpl | 0 .../inbound-email/modals/select-folder.tpl | 0 .../crm => }/src/controllers/inbound-email.js | 12 ++--- .../src/views/inbound-email/fields/folder.js | 46 +++++++++---------- .../src/views/inbound-email/fields/folders.js | 20 ++++---- .../fields/target-user-position.js | 4 +- .../inbound-email/fields/test-connection.js | 2 +- .../inbound-email/modals/select-folder.js | 22 ++++----- .../src/views/inbound-email/record/detail.js | 2 +- .../src/views/inbound-email/record/edit.js | 4 +- .../src/views/inbound-email/record/list.js | 2 +- 22 files changed, 71 insertions(+), 72 deletions(-) rename application/Espo/{Modules/Crm => }/Controllers/InboundEmail.php (98%) rename application/Espo/{Modules/Crm => }/Entities/InboundEmail.php (95%) rename application/Espo/{Modules/Crm => }/Resources/i18n/en_US/InboundEmail.json (97%) rename application/Espo/{Modules/Crm => }/Resources/layouts/InboundEmail/detail.json (96%) rename application/Espo/{Modules/Crm => }/Resources/layouts/InboundEmail/list.json (100%) rename application/Espo/{Modules/Crm => }/Resources/metadata/clientDefs/InboundEmail.json (92%) rename application/Espo/{Modules/Crm => }/Resources/metadata/entityDefs/InboundEmail.json (95%) rename application/Espo/{Modules/Crm => }/Resources/metadata/scopes/InboundEmail.json (62%) rename application/Espo/{Modules/Crm => }/Services/InboundEmail.php (99%) rename frontend/client/{modules/crm => }/res/templates/inbound-email/fields/folder/edit.tpl (100%) rename frontend/client/{modules/crm => }/res/templates/inbound-email/modals/select-folder.tpl (100%) rename frontend/client/{modules/crm => }/src/controllers/inbound-email.js (90%) rename frontend/client/{modules/crm => }/src/views/inbound-email/fields/folder.js (72%) rename frontend/client/{modules/crm => }/src/views/inbound-email/fields/folders.js (78%) rename frontend/client/{modules/crm => }/src/views/inbound-email/fields/target-user-position.js (93%) rename frontend/client/{modules/crm => }/src/views/inbound-email/fields/test-connection.js (89%) rename frontend/client/{modules/crm => }/src/views/inbound-email/modals/select-folder.js (85%) rename frontend/client/{modules/crm => }/src/views/inbound-email/record/detail.js (96%) rename frontend/client/{modules/crm => }/src/views/inbound-email/record/edit.js (86%) rename frontend/client/{modules/crm => }/src/views/inbound-email/record/list.js (92%) diff --git a/application/Espo/Modules/Crm/Controllers/InboundEmail.php b/application/Espo/Controllers/InboundEmail.php similarity index 98% rename from application/Espo/Modules/Crm/Controllers/InboundEmail.php rename to application/Espo/Controllers/InboundEmail.php index 8e87659543..bf21a6ea30 100644 --- a/application/Espo/Modules/Crm/Controllers/InboundEmail.php +++ b/application/Espo/Controllers/InboundEmail.php @@ -20,7 +20,7 @@ * along with EspoCRM. If not, see http://www.gnu.org/licenses/. ************************************************************************/ -namespace Espo\Modules\Crm\Controllers; +namespace Espo\Controllers; class InboundEmail extends \Espo\Core\Controllers\Record { diff --git a/application/Espo/Modules/Crm/Entities/InboundEmail.php b/application/Espo/Entities/InboundEmail.php similarity index 95% rename from application/Espo/Modules/Crm/Entities/InboundEmail.php rename to application/Espo/Entities/InboundEmail.php index 0224962112..ef4dc46037 100644 --- a/application/Espo/Modules/Crm/Entities/InboundEmail.php +++ b/application/Espo/Entities/InboundEmail.php @@ -18,9 +18,9 @@ * * You should have received a copy of the GNU General Public License * along with EspoCRM. If not, see http://www.gnu.org/licenses/. - ************************************************************************/ + ************************************************************************/ -namespace Espo\Modules\Crm\Entities; +namespace Espo\Entities; class InboundEmail extends \Espo\Core\ORM\Entity { diff --git a/application/Espo/Modules/Crm/Resources/i18n/en_US/Global.json b/application/Espo/Modules/Crm/Resources/i18n/en_US/Global.json index bef334cd37..0daa12c083 100644 --- a/application/Espo/Modules/Crm/Resources/i18n/en_US/Global.json +++ b/application/Espo/Modules/Crm/Resources/i18n/en_US/Global.json @@ -10,7 +10,6 @@ "Call": "Call", "Task": "Task", "Case": "Case", - "InboundEmail": "Inbound Email", "Document": "Document", "Campaign": "Campaign", "TargetList": "Target List" @@ -26,7 +25,6 @@ "Call": "Calls", "Task": "Tasks", "Case": "Cases", - "InboundEmail": "Inbound Emails", "Document": "Documents", "Campaign": "Campaigns", "TargetList": "Target Lists" diff --git a/application/Espo/Resources/i18n/en_US/Global.json b/application/Espo/Resources/i18n/en_US/Global.json index 5bd3f1cdd0..2c4506aa22 100644 --- a/application/Espo/Resources/i18n/en_US/Global.json +++ b/application/Espo/Resources/i18n/en_US/Global.json @@ -12,6 +12,7 @@ "ExternalAccount": "External Account", "Extension": "Extension", "Dashboard": "Dashboard", + "InboundEmail": "Inbound Email Account", "Stream": "Stream", "Import": "Import" }, @@ -28,6 +29,7 @@ "ExternalAccount": "External Accounts", "Extension": "Extensions", "Dashboard": "Dashboard", + "InboundEmail": "Inbound Email Accounts", "Stream": "Stream", "Import": "Import Results" }, diff --git a/application/Espo/Modules/Crm/Resources/i18n/en_US/InboundEmail.json b/application/Espo/Resources/i18n/en_US/InboundEmail.json similarity index 97% rename from application/Espo/Modules/Crm/Resources/i18n/en_US/InboundEmail.json rename to application/Espo/Resources/i18n/en_US/InboundEmail.json index e5dfcd1cdb..e755415c53 100644 --- a/application/Espo/Modules/Crm/Resources/i18n/en_US/InboundEmail.json +++ b/application/Espo/Resources/i18n/en_US/InboundEmail.json @@ -43,7 +43,7 @@ } }, "labels": { - "Create InboundEmail": "Create Inbound Email", + "Create InboundEmail": "Create Email Account", "IMAP": "IMAP", "Actions": "Actions", "Main": "Main" diff --git a/application/Espo/Modules/Crm/Resources/layouts/InboundEmail/detail.json b/application/Espo/Resources/layouts/InboundEmail/detail.json similarity index 96% rename from application/Espo/Modules/Crm/Resources/layouts/InboundEmail/detail.json rename to application/Espo/Resources/layouts/InboundEmail/detail.json index 87e885f128..7e6a3f68e6 100644 --- a/application/Espo/Modules/Crm/Resources/layouts/InboundEmail/detail.json +++ b/application/Espo/Resources/layouts/InboundEmail/detail.json @@ -27,7 +27,7 @@ [ {"name":"monitoredFolders"},{"name":"password"} ], - [{"name": "testConnection", "customLabel": null, "view": "Crm:InboundEmail.Fields.TestConnection"}] + [{"name": "testConnection", "customLabel": null, "view": "InboundEmail.Fields.TestConnection"}] ] }, { diff --git a/application/Espo/Modules/Crm/Resources/layouts/InboundEmail/list.json b/application/Espo/Resources/layouts/InboundEmail/list.json similarity index 100% rename from application/Espo/Modules/Crm/Resources/layouts/InboundEmail/list.json rename to application/Espo/Resources/layouts/InboundEmail/list.json diff --git a/application/Espo/Modules/Crm/Resources/metadata/clientDefs/InboundEmail.json b/application/Espo/Resources/metadata/clientDefs/InboundEmail.json similarity index 92% rename from application/Espo/Modules/Crm/Resources/metadata/clientDefs/InboundEmail.json rename to application/Espo/Resources/metadata/clientDefs/InboundEmail.json index f3a9aeff8a..2783b7ef75 100644 --- a/application/Espo/Modules/Crm/Resources/metadata/clientDefs/InboundEmail.json +++ b/application/Espo/Resources/metadata/clientDefs/InboundEmail.json @@ -1,8 +1,8 @@ { "recordViews":{ - "detail":"Crm:InboundEmail.Record.Detail", - "edit":"Crm:InboundEmail.Record.Edit", - "list":"Crm:InboundEmail.Record.List" + "detail":"InboundEmail.Record.Detail", + "edit":"InboundEmail.Record.Edit", + "list":"InboundEmail.Record.List" }, "formDependency": { "createCase": { diff --git a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/InboundEmail.json b/application/Espo/Resources/metadata/entityDefs/InboundEmail.json similarity index 95% rename from application/Espo/Modules/Crm/Resources/metadata/entityDefs/InboundEmail.json rename to application/Espo/Resources/metadata/entityDefs/InboundEmail.json index 6791625612..c7c91b0311 100644 --- a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/InboundEmail.json +++ b/application/Espo/Resources/metadata/entityDefs/InboundEmail.json @@ -31,7 +31,7 @@ "type": "varchar", "required": true, "default": "INBOX", - "view": "Crm:InboundEmail.Fields.Folders" + "view": "InboundEmail.Fields.Folders" }, "fetchData": { "type": "text", @@ -57,7 +57,7 @@ }, "targetUserPosition": { "type": "enum", - "view": "Crm:InboundEmail.Fields.TargetUserPosition", + "view": "InboundEmail.Fields.TargetUserPosition", "tooltip": true }, "reply": { diff --git a/application/Espo/Modules/Crm/Resources/metadata/scopes/InboundEmail.json b/application/Espo/Resources/metadata/scopes/InboundEmail.json similarity index 62% rename from application/Espo/Modules/Crm/Resources/metadata/scopes/InboundEmail.json rename to application/Espo/Resources/metadata/scopes/InboundEmail.json index da59fcc7a4..7469fbdbdc 100644 --- a/application/Espo/Modules/Crm/Resources/metadata/scopes/InboundEmail.json +++ b/application/Espo/Resources/metadata/scopes/InboundEmail.json @@ -2,6 +2,5 @@ "entity": true, "layouts": false, "tab": false, - "acl": false, - "module": "Crm" + "acl": false } diff --git a/application/Espo/Modules/Crm/Services/InboundEmail.php b/application/Espo/Services/InboundEmail.php similarity index 99% rename from application/Espo/Modules/Crm/Services/InboundEmail.php rename to application/Espo/Services/InboundEmail.php index c3471d20c4..7f63479f35 100644 --- a/application/Espo/Modules/Crm/Services/InboundEmail.php +++ b/application/Espo/Services/InboundEmail.php @@ -20,7 +20,7 @@ * along with EspoCRM. If not, see http://www.gnu.org/licenses/. ************************************************************************/ -namespace Espo\Modules\Crm\Services; +namespace Espo\Services; use \Espo\ORM\Entity; diff --git a/frontend/client/modules/crm/res/templates/inbound-email/fields/folder/edit.tpl b/frontend/client/res/templates/inbound-email/fields/folder/edit.tpl similarity index 100% rename from frontend/client/modules/crm/res/templates/inbound-email/fields/folder/edit.tpl rename to frontend/client/res/templates/inbound-email/fields/folder/edit.tpl diff --git a/frontend/client/modules/crm/res/templates/inbound-email/modals/select-folder.tpl b/frontend/client/res/templates/inbound-email/modals/select-folder.tpl similarity index 100% rename from frontend/client/modules/crm/res/templates/inbound-email/modals/select-folder.tpl rename to frontend/client/res/templates/inbound-email/modals/select-folder.tpl diff --git a/frontend/client/modules/crm/src/controllers/inbound-email.js b/frontend/client/src/controllers/inbound-email.js similarity index 90% rename from frontend/client/modules/crm/src/controllers/inbound-email.js rename to frontend/client/src/controllers/inbound-email.js index b40b7ebb1e..33ba6af0d6 100644 --- a/frontend/client/modules/crm/src/controllers/inbound-email.js +++ b/frontend/client/src/controllers/inbound-email.js @@ -17,20 +17,20 @@ * * 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('Controllers.InboundEmail', 'Controllers.Record', function (Dep) { -Espo.define('Crm:Controllers.InboundEmail', 'Controllers.Record', function (Dep) { - return Dep.extend({ - + checkAccess: function () { if (this.getUser().isAdmin()) { return true; } return false; }, - - }); + + }); }); diff --git a/frontend/client/modules/crm/src/views/inbound-email/fields/folder.js b/frontend/client/src/views/inbound-email/fields/folder.js similarity index 72% rename from frontend/client/modules/crm/src/views/inbound-email/fields/folder.js rename to frontend/client/src/views/inbound-email/fields/folder.js index 27a415ad57..f0858c3314 100644 --- a/frontend/client/modules/crm/src/views/inbound-email/fields/folder.js +++ b/frontend/client/src/views/inbound-email/fields/folder.js @@ -17,36 +17,36 @@ * * 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('Crm:Views.InboundEmail.Fields.Folder', 'Views.Fields.Base', function (Dep) { +Espo.define('Views.InboundEmail.Fields.Folder', 'Views.Fields.Base', function (Dep) { return Dep.extend({ - - editTemplate: 'crm:inbound-email.fields.folder.edit', - + + editTemplate: 'inbound-email.fields.folder.edit', + events: { - 'click [data-action="selectFolder"]': function () { + 'click [data-action="selectFolder"]': function () { var self = this; - + this.notify('Please wait...'); - + var data = { host: this.model.get('host'), port: this.model.get('port'), ssl: this.model.get('ssl'), username: this.model.get('username'), }; - + if (this.model.has('password')) { - data.password = this.model.get('password'); - } else { - if (!this.model.isNew()) { + data.password = this.model.get('password'); + } else { + if (!this.model.isNew()) { data.id = this.model.id; } } - - + + $.ajax({ type: 'GET', url: 'InboundEmail/action/getFolders', @@ -56,23 +56,23 @@ Espo.define('Crm:Views.InboundEmail.Fields.Folder', 'Views.Fields.Base', functio xhr.errorIsHandled = true; }, }).done(function (folders) { - this.createView('modal', 'Crm:InboundEmail.Modals.SelectFolder', { - folders: folders + this.createView('modal', 'InboundEmail.Modals.SelectFolder', { + folders: folders }, function (view) { self.notify(false); view.render(); - - self.listenToOnce(view, 'select', function (folder) { + + self.listenToOnce(view, 'select', function (folder) { view.close(); - self.addFolder(folder); + self.addFolder(folder); }); }); - }.bind(this)); - } + }.bind(this)); + } }, - + addFolder: function (folder) { this.$element.val(folder); }, - }); + }); }); diff --git a/frontend/client/modules/crm/src/views/inbound-email/fields/folders.js b/frontend/client/src/views/inbound-email/fields/folders.js similarity index 78% rename from frontend/client/modules/crm/src/views/inbound-email/fields/folders.js rename to frontend/client/src/views/inbound-email/fields/folders.js index 6db1f4bb6b..3f6de1602b 100644 --- a/frontend/client/modules/crm/src/views/inbound-email/fields/folders.js +++ b/frontend/client/src/views/inbound-email/fields/folders.js @@ -17,24 +17,24 @@ * * 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('Crm:Views.InboundEmail.Fields.Folders', 'Crm:Views.InboundEmail.Fields.Folder', function (Dep) { +Espo.define('Views.InboundEmail.Fields.Folders', 'Views.InboundEmail.Fields.Folder', function (Dep) { - return Dep.extend({ - - addFolder: function (folder) { + return Dep.extend({ + + addFolder: function (folder) { var value = this.$element.val(); - - var folders = []; + + var folders = []; if (value != '') { folders = value.split(','); } - + if (!~folders.indexOf(folder)) { - folders.push(folder); + folders.push(folder); } this.$element.val(folders.join(',')); }, - }); + }); }); diff --git a/frontend/client/modules/crm/src/views/inbound-email/fields/target-user-position.js b/frontend/client/src/views/inbound-email/fields/target-user-position.js similarity index 93% rename from frontend/client/modules/crm/src/views/inbound-email/fields/target-user-position.js rename to frontend/client/src/views/inbound-email/fields/target-user-position.js index 92ee392256..d912689210 100644 --- a/frontend/client/modules/crm/src/views/inbound-email/fields/target-user-position.js +++ b/frontend/client/src/views/inbound-email/fields/target-user-position.js @@ -19,7 +19,7 @@ * along with EspoCRM. If not, see http://www.gnu.org/licenses/. ************************************************************************/ -Espo.define('Crm:Views.InboundEmail.Fields.TargetUserPosition', 'Views.Fields.Enum', function (Dep) { +Espo.define('Views.InboundEmail.Fields.TargetUserPosition', 'Views.Fields.Enum', function (Dep) { return Dep.extend({ @@ -27,7 +27,7 @@ Espo.define('Crm:Views.InboundEmail.Fields.TargetUserPosition', 'Views.Fields.En Dep.prototype.setup.call(this); this.translatedOptions = { - '': '--' + this.translate('All') + '--' + '': '--' + this.translate('All') + '--' }; this.params.options = ['']; diff --git a/frontend/client/modules/crm/src/views/inbound-email/fields/test-connection.js b/frontend/client/src/views/inbound-email/fields/test-connection.js similarity index 89% rename from frontend/client/modules/crm/src/views/inbound-email/fields/test-connection.js rename to frontend/client/src/views/inbound-email/fields/test-connection.js index ecb9a4273e..0354017219 100644 --- a/frontend/client/modules/crm/src/views/inbound-email/fields/test-connection.js +++ b/frontend/client/src/views/inbound-email/fields/test-connection.js @@ -19,7 +19,7 @@ * along with EspoCRM. If not, see http://www.gnu.org/licenses/. ************************************************************************/ -Espo.define('Crm:Views.InboundEmail.Fields.TestConnection', 'Views.EmailAccount.Fields.TestConnection', function (Dep) { +Espo.define('Views.InboundEmail.Fields.TestConnection', 'Views.EmailAccount.Fields.TestConnection', function (Dep) { return Dep.extend({ diff --git a/frontend/client/modules/crm/src/views/inbound-email/modals/select-folder.js b/frontend/client/src/views/inbound-email/modals/select-folder.js similarity index 85% rename from frontend/client/modules/crm/src/views/inbound-email/modals/select-folder.js rename to frontend/client/src/views/inbound-email/modals/select-folder.js index 2dcd77ac8c..318968b978 100644 --- a/frontend/client/modules/crm/src/views/inbound-email/modals/select-folder.js +++ b/frontend/client/src/views/inbound-email/modals/select-folder.js @@ -17,31 +17,31 @@ * * 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('Crm:Views.InboundEmail.Modals.SelectFolder', 'Views.Modal', function (Dep) { +Espo.define('Views.InboundEmail.Modals.SelectFolder', 'Views.Modal', function (Dep) { return Dep.extend({ - + cssName: 'select-folder-modal', - - template: 'crm:inbound-email.modals.select-folder', - + + template: 'inbound-email.modals.select-folder', + data: function () { return { folders: this.options.folders, }; }, - + events: { 'click button[data-action="select"]': function (e) { var value = $(e.currentTarget).data('value'); this.trigger('select', value); }, }, - + setup: function () { - + this.buttons = [ { name: 'cancel', @@ -49,8 +49,8 @@ Espo.define('Crm:Views.InboundEmail.Modals.SelectFolder', 'Views.Modal', functio onClick: function (dialog) { dialog.close(); } - } - ]; + } + ]; }, diff --git a/frontend/client/modules/crm/src/views/inbound-email/record/detail.js b/frontend/client/src/views/inbound-email/record/detail.js similarity index 96% rename from frontend/client/modules/crm/src/views/inbound-email/record/detail.js rename to frontend/client/src/views/inbound-email/record/detail.js index 65239f7301..aacbcfc43e 100644 --- a/frontend/client/modules/crm/src/views/inbound-email/record/detail.js +++ b/frontend/client/src/views/inbound-email/record/detail.js @@ -19,7 +19,7 @@ * along with EspoCRM. If not, see http://www.gnu.org/licenses/. ************************************************************************/ -Espo.define('Crm:Views.InboundEmail.Record.Detail', 'Views.Record.Detail', function (Dep) { +Espo.define('Views.InboundEmail.Record.Detail', 'Views.Record.Detail', function (Dep) { return Dep.extend({ diff --git a/frontend/client/modules/crm/src/views/inbound-email/record/edit.js b/frontend/client/src/views/inbound-email/record/edit.js similarity index 86% rename from frontend/client/modules/crm/src/views/inbound-email/record/edit.js rename to frontend/client/src/views/inbound-email/record/edit.js index d28d296bbc..992212dceb 100644 --- a/frontend/client/modules/crm/src/views/inbound-email/record/edit.js +++ b/frontend/client/src/views/inbound-email/record/edit.js @@ -19,7 +19,7 @@ * along with EspoCRM. If not, see http://www.gnu.org/licenses/. ************************************************************************/ -Espo.define('Crm:Views.InboundEmail.Record.Edit', ['Views.Record.Edit', 'Crm:Views.InboundEmail.Record.Detail'], function (Dep, Detail) { +Espo.define('Views.InboundEmail.Record.Edit', ['Views.Record.Edit', 'Views.InboundEmail.Record.Detail'], function (Dep, Detail) { return Dep.extend({ @@ -30,7 +30,7 @@ Espo.define('Crm:Views.InboundEmail.Record.Edit', ['Views.Record.Edit', 'Crm:Vie }, afterRender: function () { - Dep.prototype.afterRender.call(this); + Dep.prototype.afterRender.call(this); Detail.prototype.initSslFieldListening.call(this); }, diff --git a/frontend/client/modules/crm/src/views/inbound-email/record/list.js b/frontend/client/src/views/inbound-email/record/list.js similarity index 92% rename from frontend/client/modules/crm/src/views/inbound-email/record/list.js rename to frontend/client/src/views/inbound-email/record/list.js index 7d64e74518..debfddd30f 100644 --- a/frontend/client/modules/crm/src/views/inbound-email/record/list.js +++ b/frontend/client/src/views/inbound-email/record/list.js @@ -19,7 +19,7 @@ * along with EspoCRM. If not, see http://www.gnu.org/licenses/. ************************************************************************/ -Espo.define('Crm:Views.InboundEmail.Record.List', 'Views.Record.List', function (Dep) { +Espo.define('Views.InboundEmail.Record.List', 'Views.Record.List', function (Dep) { return Dep.extend({