diff --git a/application/Espo/Core/defaults/config.php b/application/Espo/Core/defaults/config.php index ec35ff541d..7d3ad7565d 100644 --- a/application/Espo/Core/defaults/config.php +++ b/application/Espo/Core/defaults/config.php @@ -91,7 +91,7 @@ return array ( 'Lead', 'Opportunity', ), - "tabList" => ["Account", "Contact", "Lead", "Opportunity", "Calendar", "Meeting", "Call", "Task", "Case", "Email", "Document", "Campaign"], + "tabList" => ["Account", "Contact", "Lead", "Opportunity", "Calendar", "Meeting", "Call", "Task", "Case", "Email", "Document", "Campaign", "KnowledgeBaseArticle"], "quickCreateList" => ["Account", "Contact", "Lead", "Opportunity", "Meeting", "Call", "Task", "Case"], 'calendarDefaultEntity' => 'Meeting', 'exportDisabled' => false, diff --git a/application/Espo/Modules/Crm/Controllers/KnowledgeBaseArticle.php b/application/Espo/Modules/Crm/Controllers/KnowledgeBaseArticle.php new file mode 100644 index 0000000000..250c7cca7f --- /dev/null +++ b/application/Espo/Modules/Crm/Controllers/KnowledgeBaseArticle.php @@ -0,0 +1,35 @@ +{{{search}}}
- {{#unless foldersDisabled}} -
{{{folders}}}
+ {{#unless categoriesDisabled}} +
{{{categories}}}
{{/unless}} -
{{{list}}}
+
{{{list}}}
diff --git a/frontend/client/modules/crm/res/templates/document/modals/select-records.tpl b/frontend/client/modules/crm/res/templates/document/modals/select-records.tpl index 995d78e960..4d2d5c2a4b 100644 --- a/frontend/client/modules/crm/res/templates/document/modals/select-records.tpl +++ b/frontend/client/modules/crm/res/templates/document/modals/select-records.tpl @@ -1,12 +1,14 @@
{{{search}}}
-
{{{folders}}}
-
{{{list}}}
+ {{#unless categoriesDisabled}} +
{{{cateoiries}}}
+ {{/unless}} +
{{{list}}}
{{#if createButton}}
- +
{{/if}} diff --git a/frontend/client/modules/crm/res/templates/knowledge-base-article/list.tpl b/frontend/client/modules/crm/res/templates/knowledge-base-article/list.tpl new file mode 100644 index 0000000000..db00915dd4 --- /dev/null +++ b/frontend/client/modules/crm/res/templates/knowledge-base-article/list.tpl @@ -0,0 +1,10 @@ + +
{{{search}}}
+ +
+ {{#unless categoriesDisabled}} +
{{{categories}}}
+ {{/unless}} +
{{{list}}}
+
+ diff --git a/frontend/client/modules/crm/res/templates/knowledge-base-article/modals/select-records.tpl b/frontend/client/modules/crm/res/templates/knowledge-base-article/modals/select-records.tpl new file mode 100644 index 0000000000..4d2d5c2a4b --- /dev/null +++ b/frontend/client/modules/crm/res/templates/knowledge-base-article/modals/select-records.tpl @@ -0,0 +1,14 @@ +
{{{search}}}
+ +
+ {{#unless categoriesDisabled}} +
{{{cateoiries}}}
+ {{/unless}} +
{{{list}}}
+
+ +{{#if createButton}} +
+ +
+{{/if}} diff --git a/frontend/client/modules/crm/src/views/document/list.js b/frontend/client/modules/crm/src/views/document/list.js index 038feb8cf5..4e28827927 100644 --- a/frontend/client/modules/crm/src/views/document/list.js +++ b/frontend/client/modules/crm/src/views/document/list.js @@ -34,32 +34,38 @@ Espo.define('crm:views/document/list', 'views/list', function (Dep) { quickCreate: true, - currentFolderId: null, + currentCategoryId: null, - currentFolderName: '', + currentCategoryName: '', + + categoryScope: 'DocumentFolder', + + categoryField: 'folder', + + categoryFilterType: 'inCategory', data: function () { var data = {}; - data.foldersDisabled = this.foldersDisabled; + data.categoriesDisabled = this.categoriesDisabled; return data; }, setup: function () { Dep.prototype.setup.call(this); - this.foldersDisabled = this.foldersDisabled || - this.getMetadata().get('scopes.DocumentFolder.disabled') || - !this.getAcl().checkScope('DocumentFolder'); + this.categoriesDisabled = this.categoriesDisabled || + this.getMetadata().get('scopes.' + this.categoryScope + '.disabled') || + !this.getAcl().checkScope(this.categoryScope); }, afterRender: function () { Dep.prototype.afterRender.call(this); - if (!this.foldersDisabled && !this.hasView('folders')) { - this.loadFolders(); + if (!this.categoriesDisabled && !this.hasView('categories')) { + this.loadCategories(); } }, getTreeCollection: function (callback) { - this.getCollectionFactory().create('DocumentFolder', function (collection) { + this.getCollectionFactory().create(this.categoryScope, function (collection) { collection.url = collection.name + '/action/listTree'; this.collection.treeCollection = collection; @@ -71,36 +77,36 @@ Espo.define('crm:views/document/list', 'views/list', function (Dep) { }, this); }, - loadFolders: function () { + loadCategories: function () { this.getTreeCollection(function (collection) { - this.createView('folders', 'views/record/list-tree', { + this.createView('categories', 'views/record/list-tree', { collection: collection, - el: this.options.el + ' .folders-container', + el: this.options.el + ' .categories-container', selectable: true, createDisabled: true, showRoot: true, - rootName: this.translate('Document', 'scopeNamesPlural'), + rootName: this.translate(this.scope, 'scopeNamesPlural'), buttonsDisabled: true, checkboxes: false, - showEditLink: this.getAcl().check('DocumentFolder', 'edit') + showEditLink: this.getAcl().check(this.categoryScope, 'edit') }, function (view) { view.render(); this.listenTo(view, 'select', function (model) { - this.currentFolderId = null; - this.currentFolderName = ''; + this.currentCategoryId = null; + this.currentCategoryName = ''; if (model && model.id) { - this.currentFolderId = model.id; - this.currentFolderName = model.get('name'); + this.currentCategoryId = model.id; + this.currentCategoryName = model.get('name'); } this.collection.whereAdditional = null; - if (this.currentFolderId) { + if (this.currentCategoryId) { this.collection.whereAdditional = [ { - field: 'folder', - type: 'inCategory', + field: this.categoryField, + type: this.categoryFilterType, value: model.id } ]; @@ -120,10 +126,10 @@ Espo.define('crm:views/document/list', 'views/list', function (Dep) { getCreateAttributes: function () { return { - folderId: this.currentFolderId, - folderName: this.currentFolderName + folderId: this.currentCategoryId, + folderName: this.currentCategoryName }; - }, + } }); diff --git a/frontend/client/modules/crm/src/views/document/modals/select-records.js b/frontend/client/modules/crm/src/views/document/modals/select-records.js index c2e3069ab7..0d5a7294a0 100644 --- a/frontend/client/modules/crm/src/views/document/modals/select-records.js +++ b/frontend/client/modules/crm/src/views/document/modals/select-records.js @@ -26,44 +26,68 @@ * these Appropriate Legal Notices must retain the display of the "EspoCRM" word. ************************************************************************/ -Espo.define('Crm:Views.Document.Modals.SelectRecords', 'Views.Modals.SelectRecords', function (Dep) { +Espo.define('crm:views/document/modals/select-records', 'views/modals/select-records', function (Dep) { return Dep.extend({ - template: 'crm:document.modals.select-records', + template: 'crm:document/modals/select-records', - loadFolders: function () { - this.getCollectionFactory().create('DocumentFolder', function (collection) { + categoryScope: 'DocumentFolder', + + categoryField: 'folder', + + categoryFilterType: 'inCategory', + + data: function () { + var data = Dep.prototype.data.call(this); + data.categoriesDisabled = this.categoriesDisabled; + return data; + }, + + setup: function () { + Dep.prototype.setup.call(this); + this.categoriesDisabled = this.categoriesDisabled || + this.getMetadata().get('scopes.' + this.categoryScope + '.disabled') || + !this.getAcl().checkScope(this.categoryScope); + }, + + loadList: function () { + this.loadCategories(); + Dep.prototype.loadList.call(this); + }, + + loadCategories: function () { + this.getCollectionFactory().create(this.categoryScope, function (collection) { collection.url = collection.name + '/action/listTree'; this.listenToOnce(collection, 'sync', function () { - this.createView('folders', 'Record.ListTree', { + this.createView('categories', 'views/record/list-tree', { collection: collection, - el: this.options.el + ' .folders-container', + el: this.options.el + ' .categories-container', selectable: true, createDisabled: true, showRoot: true, - rootName: this.translate('Document', 'scopeNamesPlural'), + rootName: this.translate(this.scope, 'scopeNamesPlural'), buttonsDisabled: true, checkboxes: false }, function (view) { view.render(); this.listenTo(view, 'select', function (model) { - this.currentFolderId = null; - this.currentFolderName = ''; + this.currentCategoryId = null; + this.currentCategoryName = ''; if (model && model.id) { - this.currentFolderId = model.id; - this.currentFolderName = model.get('name'); + this.currentCategoryId = model.id; + this.currentCategoryName = model.get('name'); } this.collection.whereAdditional = null; - if (this.currentFolderId) { + if (this.currentCategoryId) { this.collection.whereAdditional = [ { - field: 'folder', - type: 'inCategory', + field: this.categoryField, + type: this.categoryFilterType, value: model.id } ]; @@ -79,13 +103,8 @@ Espo.define('Crm:Views.Document.Modals.SelectRecords', 'Views.Modals.SelectRecor }, this); collection.fetch(); }, this); - }, + } - loadList: function () { - this.loadFolders(); - Dep.prototype.loadList.call(this); - - }, }); }); diff --git a/frontend/client/modules/crm/src/views/knowledge-base-article/fields/language.js b/frontend/client/modules/crm/src/views/knowledge-base-article/fields/language.js new file mode 100644 index 0000000000..88dce55483 --- /dev/null +++ b/frontend/client/modules/crm/src/views/knowledge-base-article/fields/language.js @@ -0,0 +1,42 @@ +/************************************************************************ + * This file is part of EspoCRM. + * + * EspoCRM - Open Source CRM application. + * Copyright (C) 2014-2015 Yuri Kuznetsov, Taras Machyshyn, Oleksiy Avramenko + * Website: http://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. + ************************************************************************/ + +Espo.define('crm:views/knowledge-base-article/fields/language', 'views/fields/enum', function (Dep) { + + return Dep.extend({ + + setupOptions: function () { + this.params.options = this.getConfig().get('languageList') || []; + this.params.options.unshift(''); + this.translatedOptions = this.getLanguage().translate('language', 'options') || {}; + this.translatedOptions[''] = this.translate('Global', 'labels', 'KnowledgeBaseArticle') + } + + }); + +}); diff --git a/frontend/client/modules/crm/src/views/knowledge-base-article/list.js b/frontend/client/modules/crm/src/views/knowledge-base-article/list.js new file mode 100644 index 0000000000..1e9e210f2e --- /dev/null +++ b/frontend/client/modules/crm/src/views/knowledge-base-article/list.js @@ -0,0 +1,52 @@ +/************************************************************************ + * This file is part of EspoCRM. + * + * EspoCRM - Open Source CRM application. + * Copyright (C) 2014-2015 Yuri Kuznetsov, Taras Machyshyn, Oleksiy Avramenko + * Website: http://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. + ************************************************************************/ + +Espo.define('crm:views/knowledge-base-article/list', 'crm:views/document/list', function (Dep) { + + return Dep.extend({ + + categoryScope: 'KnowledgeBaseCategory', + + categoryField: 'categories', + + categoryFilterType: 'inCategories', + + getCreateAttributes: function () { + if (this.currentCategoryId) { + var names = {}; + names[this.currentCategoryId] = this.currentCategoryName; + return { + categoriesIds: [this.currentCategoryId], + categoriesNames: names + }; + } + } + + }); + +}); diff --git a/frontend/client/modules/crm/src/views/knowledge-base-article/modals/select-records.js b/frontend/client/modules/crm/src/views/knowledge-base-article/modals/select-records.js new file mode 100644 index 0000000000..f92b779be8 --- /dev/null +++ b/frontend/client/modules/crm/src/views/knowledge-base-article/modals/select-records.js @@ -0,0 +1,41 @@ +/************************************************************************ + * This file is part of EspoCRM. + * + * EspoCRM - Open Source CRM application. + * Copyright (C) 2014-2015 Yuri Kuznetsov, Taras Machyshyn, Oleksiy Avramenko + * Website: http://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. + ************************************************************************/ + +Espo.define('crm:views/knowledge-base-article/modals/select-records', 'crm:views/document/modals/select-records', function (Dep) { + + return Dep.extend({ + + categoryScope: 'KnowledgeBaseCategory', + + categoryField: 'categories', + + categoryFilterType: 'inCategories' + + }); + +}); diff --git a/frontend/client/modules/crm/src/views/knowledge-base-article/record/detail-quick.js b/frontend/client/modules/crm/src/views/knowledge-base-article/record/detail-quick.js new file mode 100644 index 0000000000..362aa99801 --- /dev/null +++ b/frontend/client/modules/crm/src/views/knowledge-base-article/record/detail-quick.js @@ -0,0 +1,39 @@ +/************************************************************************ + * This file is part of EspoCRM. + * + * EspoCRM - Open Source CRM application. + * Copyright (C) 2014-2015 Yuri Kuznetsov, Taras Machyshyn, Oleksiy Avramenko + * Website: http://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. + ************************************************************************/ + +Espo.define('crm:views/knowledge-base-article/record/detail-quick', 'views/record/detail-small', function (Dep, Detail) { + + return Dep.extend({ + + isWide: true, + + sideView: false + + }); +}); + diff --git a/frontend/client/modules/crm/src/views/knowledge-base-article/record/edit-quick.js b/frontend/client/modules/crm/src/views/knowledge-base-article/record/edit-quick.js new file mode 100644 index 0000000000..1939cc1ed2 --- /dev/null +++ b/frontend/client/modules/crm/src/views/knowledge-base-article/record/edit-quick.js @@ -0,0 +1,39 @@ +/************************************************************************ + * This file is part of EspoCRM. + * + * EspoCRM - Open Source CRM application. + * Copyright (C) 2014-2015 Yuri Kuznetsov, Taras Machyshyn, Oleksiy Avramenko + * Website: http://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. + ************************************************************************/ + +Espo.define('crm:views/knowledge-base-article/record/edit-quick', 'views/record/edit-small', function (Dep, Detail) { + + return Dep.extend({ + + isWide: true, + + sideView: false + + }); +}); + diff --git a/frontend/client/src/views/fields/enum.js b/frontend/client/src/views/fields/enum.js index f4c424ad54..42a16b0c78 100644 --- a/frontend/client/src/views/fields/enum.js +++ b/frontend/client/src/views/fields/enum.js @@ -26,19 +26,19 @@ * these Appropriate Legal Notices must retain the display of the "EspoCRM" word. ************************************************************************/ -Espo.define('Views.Fields.Enum', ['Views.Fields.Base', 'lib!Selectize'], function (Dep) { +Espo.define('views/fields/enum', ['views/fields/base', 'lib!Selectize'], function (Dep) { return Dep.extend({ type: 'enum', - listTemplate: 'fields.enum.detail', + listTemplate: 'fields/enum/detail', - detailTemplate: 'fields.enum.detail', + detailTemplate: 'fields/enum/detail', - editTemplate: 'fields.enum.edit', + editTemplate: 'fields/enum/edit', - searchTemplate: 'fields.enum.search', + searchTemplate: 'fields/enum/search', translatedOptions: null, @@ -56,6 +56,8 @@ Espo.define('Views.Fields.Enum', ['Views.Fields.Base', 'lib!Selectize'], functio } } + this.setupOptions(); + if ('translatedOptions' in this.options) { this.translatedOptions = this.options.translatedOptions; } @@ -104,6 +106,9 @@ Espo.define('Views.Fields.Enum', ['Views.Fields.Base', 'lib!Selectize'], functio } }, + setupOptions: function () { + }, + afterRender: function () { Dep.prototype.afterRender.call(this);