From a68d7112491e8884888f6e1cd46d2bff0b2291d1 Mon Sep 17 00:00:00 2001 From: yuri Date: Mon, 12 Aug 2019 15:15:57 +0300 Subject: [PATCH 01/10] summernote fix fullscreen --- client/src/views/fields/wysiwyg.js | 81 +++++++++++++++++++++++++++++- 1 file changed, 79 insertions(+), 2 deletions(-) diff --git a/client/src/views/fields/wysiwyg.js b/client/src/views/fields/wysiwyg.js index 9b751036de..54a230693f 100644 --- a/client/src/views/fields/wysiwyg.js +++ b/client/src/views/fields/wysiwyg.js @@ -71,7 +71,7 @@ define('views/fields/wysiwyg', ['views/fields/text', 'lib!Summernote'], function ['para', ['ul', 'ol', 'paragraph']], ['height', ['height']], ['table', ['table', 'espoLink', 'espoImage', 'hr']], - ['misc',['codeview', 'fullscreen']] + ['misc', ['codeview', 'fullscreen']] ]; this.buttons = {}; @@ -368,6 +368,8 @@ define('views/fields/wysiwyg', ['views/fields/text', 'lib!Summernote'], function keyMap.pc['CTRL+K'] = 'espoLink.show'; keyMap.mac['CMD+K'] = 'espoLink.show'; + var toolbar = this.toolbar; + var options = { espoView: this, lang: this.getConfig().get('language'), @@ -408,7 +410,7 @@ define('views/fields/wysiwyg', ['views/fields/text', 'lib!Summernote'], function onCreateLink: function (link) { return link; }, - toolbar: this.toolbar, + toolbar: toolbar, buttons: this.buttons, dialogsInBody: this.$el, codeviewFilter: true, @@ -710,6 +712,81 @@ define('views/fields/wysiwyg', ['views/fields/text', 'lib!Summernote'], function } }, + 'fullscreen': function (context) { + var ui = $.summernote.ui; + var options = context.options; + var self = options.espoView; + var lang = options.langInfo; + + this.$window = $(window); + this.$scrollbar = $('html, body'); + + this.initialize = function () { + this.$editor = context.layoutInfo.editor; + this.$toolbar = context.layoutInfo.toolbar; + this.$editable = context.layoutInfo.editable; + this.$codable = context.layoutInfo.codable; + + this.$modal = self.$el.closest('.modal'); + this.isInModal = this.$modal.length > 0; + }; + + this.resizeTo = function (size) { + this.$editable.css('height', size.h); + this.$codable.css('height', size.h); + if (this.$codable.data('cmeditor')) { + this.$codable.data('cmeditor').setsize(null, size.h); + } + }; + + this.onResize = function () { + this.resizeTo({ + h: this.$window.height() - this.$toolbar.outerHeight(), + }); + }; + + this.isFullscreen = function () { + return this.$editor.hasClass('fullscreen'); + }; + + this.destroy = function () { + this.$window.off('resize.summernote' + self.cid); + if (this.isInModal) { + this.$modal.css('overflow-y', ''); + } else { + this.$scrollbar.css('overflow', ''); + } + } + + this.toggle = function () { + this.$editor.toggleClass('fullscreen'); + if (this.isFullscreen()) { + this.$editable.data('orgHeight', this.$editable.css('height')); + this.$editable.data('orgMaxHeight', this.$editable.css('maxHeight')); + this.$editable.css('maxHeight', ''); + this.$window.on('resize.summernote' + self.cid, this.onResize.bind(this)).trigger('resize'); + if (this.isInModal) { + this.$modal.css('overflow-y', 'hidden'); + } else { + this.$scrollbar.css('overflow', 'hidden'); + } + this._isFullscreen = true; + } else { + this.$window.off('resize.summernote' + self.cid); + this.resizeTo({ h: this.$editable.data('orgHeight') }); + this.$editable.css('maxHeight', this.$editable.css('orgMaxHeight')); + if (this.isInModal) { + this.$modal.css('overflow-y', ''); + } else { + this.$scrollbar.css('overflow', ''); + } + this._isFullscreen = false; + } + + context.invoke('toolbar.updateFullscreen', this.isFullscreen()); + }; + }, + }); }, }); From a97d516c4f5d9663f6a4d572eda3bd1fe4bd3126 Mon Sep 17 00:00:00 2001 From: yuri Date: Tue, 13 Aug 2019 17:03:28 +0300 Subject: [PATCH 02/10] restrict common entity type name --- application/Espo/Core/Utils/EntityManager.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/Espo/Core/Utils/EntityManager.php b/application/Espo/Core/Utils/EntityManager.php index 3f974401a9..adc956ad26 100644 --- a/application/Espo/Core/Utils/EntityManager.php +++ b/application/Espo/Core/Utils/EntityManager.php @@ -54,7 +54,7 @@ class EntityManager private $linkForbiddenNameList = ['posts', 'stream', 'subscription', 'followers', 'action', 'null', 'false', 'true']; - private $forbiddenEntityTypeNameList = ['PortalUser', 'ApiUser', 'Timeline', 'About', 'Admin', 'Null', 'False', 'True']; + private $forbiddenEntityTypeNameList = ['Common', 'PortalUser', 'ApiUser', 'Timeline', 'About', 'Admin', 'Null', 'False', 'True']; public function __construct(Metadata $metadata, Language $language, File\Manager $fileManager, Config $config, Container $container = null) { From 5312c1d1419c79d07ed98bdca5ef9e54b67c8c01 Mon Sep 17 00:00:00 2001 From: yuri Date: Wed, 14 Aug 2019 12:07:51 +0300 Subject: [PATCH 03/10] image original link --- client/res/templates/modals/image-preview.tpl | 6 ++---- client/src/views/modals/image-preview.js | 10 ++++++++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/client/res/templates/modals/image-preview.tpl b/client/res/templates/modals/image-preview.tpl index fa8c2517a3..d124e4960c 100644 --- a/client/res/templates/modals/image-preview.tpl +++ b/client/res/templates/modals/image-preview.tpl @@ -2,8 +2,6 @@ -{{#if size}} -
-{{translate 'Original'}}: {{name}} + -{{/if}} diff --git a/client/src/views/modals/image-preview.js b/client/src/views/modals/image-preview.js index 6ca6c5f68c..ba8f29999f 100644 --- a/client/src/views/modals/image-preview.js +++ b/client/src/views/modals/image-preview.js @@ -53,7 +53,7 @@ Espo.define('views/modals/image-preview', ['views/modal', 'lib!exif'], function name: this.options.name, url: this.getImageUrl(), originalUrl: this.getOriginalImageUrl(), - size: this.size + showOriginalLink: this.size, }; }, @@ -99,7 +99,9 @@ Espo.define('views/modals/image-preview', ['views/modal', 'lib!exif'], function $img.on('load', function () { var self = this; - EXIF.getData($img.get(0), function () { + var imgEl = $img.get(0); + + EXIF.getData(imgEl, function () { var orientation = EXIF.getTag(this, 'Orientation'); switch (orientation) { case 2: @@ -128,6 +130,10 @@ Espo.define('views/modals/image-preview', ['views/modal', 'lib!exif'], function break; } }); + + if (imgEl.naturalWidth > imgEl.clientWidth) { + this.$el.find('.original-link-container').removeClass('hidden'); + } }.bind(this)); if (this.navigationEnabled) { From a9a30d7237826e5a7f95951a3ffb7977611e5908 Mon Sep 17 00:00:00 2001 From: yuri Date: Wed, 14 Aug 2019 13:09:22 +0300 Subject: [PATCH 04/10] duplicate silent confict exception --- .../Espo/Core/Exceptions/ConflictSilent.php | 35 +++++++++++++++++++ application/Espo/Services/Record.php | 3 +- 2 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 application/Espo/Core/Exceptions/ConflictSilent.php diff --git a/application/Espo/Core/Exceptions/ConflictSilent.php b/application/Espo/Core/Exceptions/ConflictSilent.php new file mode 100644 index 0000000000..45b21195df --- /dev/null +++ b/application/Espo/Core/Exceptions/ConflictSilent.php @@ -0,0 +1,35 @@ + 'Duplicate', 'data' => $data ]; - throw new Conflict(json_encode($reason)); + throw new ConflictSilent(json_encode($reason)); } } } From fe0dcc53427174ffdf59aa36fc8c5a96f757b271 Mon Sep 17 00:00:00 2001 From: yuri Date: Mon, 19 Aug 2019 11:24:34 +0300 Subject: [PATCH 05/10] remove duplicate label --- application/Espo/Resources/i18n/en_US/Settings.json | 1 - 1 file changed, 1 deletion(-) diff --git a/application/Espo/Resources/i18n/en_US/Settings.json b/application/Espo/Resources/i18n/en_US/Settings.json index 8cc0f1856b..f40b800393 100644 --- a/application/Espo/Resources/i18n/en_US/Settings.json +++ b/application/Espo/Resources/i18n/en_US/Settings.json @@ -91,7 +91,6 @@ "massEmailOpenTracking": "Email Open Tracking", "activitiesEntityList": "Activities Entity List", "historyEntityList": "History Entity List", - "b2cMode": "B2C Mode", "currencyFormat": "Currency Format", "currencyDecimalPlaces": "Currency Decimal Places", "aclStrictMode": "ACL Strict Mode", From 5c00a7ad43f44ffc40fc3e5db7499e89e1cc1ada Mon Sep 17 00:00:00 2001 From: yuri Date: Mon, 19 Aug 2019 11:44:25 +0300 Subject: [PATCH 06/10] fix email fitler duplicate --- application/Espo/Services/EmailFilter.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/application/Espo/Services/EmailFilter.php b/application/Espo/Services/EmailFilter.php index bc3f9dea7f..00ea52cfea 100644 --- a/application/Espo/Services/EmailFilter.php +++ b/application/Espo/Services/EmailFilter.php @@ -41,5 +41,10 @@ class EmailFilter extends Record if (!$this->getAcl()->check($entity, 'edit')) { throw new Forbidden(); } + + if ($entity->get('isGlobal')) { + $entity->set('parentId', null); + $entity->set('parentType', null); + } } } From 371fbf98644394477af973b22d8607e8b66cae27 Mon Sep 17 00:00:00 2001 From: yuri Date: Wed, 21 Aug 2019 16:35:45 +0300 Subject: [PATCH 07/10] email skip index if filter --- application/Espo/SelectManagers/Email.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/Espo/SelectManagers/Email.php b/application/Espo/SelectManagers/Email.php index 4eebe04449..276757c9cf 100644 --- a/application/Espo/SelectManagers/Email.php +++ b/application/Espo/SelectManagers/Email.php @@ -51,7 +51,7 @@ class Email extends \Espo\Core\SelectManagers\Base $skipIndex = true; break; } else { - if (isset($item['attribute']) && $this->getSeed()->getAttributeParam($item['attribute'], 'type') === 'foreignId') { + if (isset($item['attribute'])) { $skipIndex = true; break; } From 790355fb6370be77cd3de17cf2d5916c5520a51a Mon Sep 17 00:00:00 2001 From: yuri Date: Thu, 22 Aug 2019 11:46:46 +0300 Subject: [PATCH 08/10] lead converted at --- .../Espo/Modules/Crm/Repositories/Lead.php | 12 ++++++++- .../Crm/Resources/i18n/en_US/Lead.json | 1 + .../Resources/metadata/clientDefs/Lead.json | 25 +++++++++++++++++++ .../Resources/metadata/entityDefs/Lead.json | 6 +++++ .../views/lead/record/panels/converted-to.js | 3 +-- 5 files changed, 44 insertions(+), 3 deletions(-) diff --git a/application/Espo/Modules/Crm/Repositories/Lead.php b/application/Espo/Modules/Crm/Repositories/Lead.php index 38f2d5844f..5cc4c9b754 100644 --- a/application/Espo/Modules/Crm/Repositories/Lead.php +++ b/application/Espo/Modules/Crm/Repositories/Lead.php @@ -33,7 +33,17 @@ use Espo\ORM\Entity; class Lead extends \Espo\Core\ORM\Repositories\RDB { - public function afterSave(Entity $entity, array $options = array()) + public function beforeSave(Entity $entity, array $options = []) + { + if (!$entity->get('convertedAt') && $entity->get('status') === 'Converted' && $entity->isAttributeChanged('status')) { + $convertedAt = date('Y-m-d H:i:s'); + $entity->set('convertedAt', $convertedAt); + } + + parent::beforeSave($entity, $options); + } + + public function afterSave(Entity $entity, array $options = []) { parent::afterSave($entity, $options); diff --git a/application/Espo/Modules/Crm/Resources/i18n/en_US/Lead.json b/application/Espo/Modules/Crm/Resources/i18n/en_US/Lead.json index 1e0a0f8c75..bd3218dcee 100644 --- a/application/Espo/Modules/Crm/Resources/i18n/en_US/Lead.json +++ b/application/Espo/Modules/Crm/Resources/i18n/en_US/Lead.json @@ -22,6 +22,7 @@ "createdAccount": "Account", "createdContact": "Contact", "createdOpportunity": "Opportunity", + "convertedAt": "Converted At", "campaign": "Campaign", "targetLists": "Target Lists", "targetList": "Target List", diff --git a/application/Espo/Modules/Crm/Resources/metadata/clientDefs/Lead.json b/application/Espo/Modules/Crm/Resources/metadata/clientDefs/Lead.json index c39e2fdd78..827936e358 100644 --- a/application/Espo/Modules/Crm/Resources/metadata/clientDefs/Lead.json +++ b/application/Espo/Modules/Crm/Resources/metadata/clientDefs/Lead.json @@ -6,6 +6,11 @@ "recordViews":{ "detail":"crm:views/lead/record/detail" }, + "defaultSidePanelFieldList": [ + ":assignedUser", + "teams", + "convertedAt" + ], "sidePanels":{ "detail":[ { @@ -132,6 +137,26 @@ } ] } + }, + "convertedAt": { + "visible": { + "conditionGroup": [ + { + "type": "and", + "value": [ + { + "type": "equals", + "attribute": "status", + "value": "Converted" + }, + { + "type": "isNotEmpty", + "attribute": "convertedAt" + } + ] + } + ] + } } }, "panels": { diff --git a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Lead.json b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Lead.json index ed48db92ce..58e98f6a05 100644 --- a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Lead.json +++ b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Lead.json @@ -100,6 +100,12 @@ "description": { "type": "text" }, + "convertedAt": { + "type": "datetime", + "layoutDetailDisabled": true, + "layoutMassUpdateDisabled": true, + "readOnly": true + }, "createdAt": { "type": "datetime", "readOnly": true diff --git a/client/modules/crm/src/views/lead/record/panels/converted-to.js b/client/modules/crm/src/views/lead/record/panels/converted-to.js index 735483eca9..61b28deb76 100644 --- a/client/modules/crm/src/views/lead/record/panels/converted-to.js +++ b/client/modules/crm/src/views/lead/record/panels/converted-to.js @@ -43,8 +43,7 @@ Espo.define('crm:views/lead/record/panels/converted-to', 'views/record/panels/si if (this.getAcl().check('Opportunity') && !this.getMetadata().get('scopes.Opportunity.disabled')) { this.fieldList.push('createdOpportunity'); } - } + }, }); - }); From e30838cf272ad282ec522b30e284671fef54a887 Mon Sep 17 00:00:00 2001 From: yuri Date: Thu, 22 Aug 2019 12:10:08 +0300 Subject: [PATCH 09/10] link fields empty name fix --- client/modules/crm/src/views/contact/fields/accounts.js | 2 ++ client/src/views/fields/link-multiple-with-columns.js | 2 +- client/src/views/fields/link-multiple-with-primary.js | 4 +++- client/src/views/fields/link-multiple-with-role.js | 4 +++- client/src/views/fields/link-multiple.js | 2 ++ client/src/views/fields/link-parent.js | 2 +- client/src/views/fields/link.js | 4 ++-- 7 files changed, 14 insertions(+), 6 deletions(-) diff --git a/client/modules/crm/src/views/contact/fields/accounts.js b/client/modules/crm/src/views/contact/fields/accounts.js index 410e54fb47..92c434cc94 100644 --- a/client/modules/crm/src/views/contact/fields/accounts.js +++ b/client/modules/crm/src/views/contact/fields/accounts.js @@ -154,6 +154,8 @@ Espo.define('crm:views/contact/fields/accounts', 'views/fields/link-multiple-wit }, addLinkHtml: function (id, name) { + name = name || id; + if (this.mode == 'search') { return Dep.prototype.addLinkHtml.call(this, id, name); } diff --git a/client/src/views/fields/link-multiple-with-columns.js b/client/src/views/fields/link-multiple-with-columns.js index 70ff43d9d7..e5ef06afea 100644 --- a/client/src/views/fields/link-multiple-with-columns.js +++ b/client/src/views/fields/link-multiple-with-columns.js @@ -106,7 +106,7 @@ Espo.define('views/fields/link-multiple-with-columns', 'views/fields/link-multip }, getDetailLinkHtml: function (id, name) { - name = name || this.nameHash[id]; + name = name || this.nameHash[id] || id; var roleHtml = ''; diff --git a/client/src/views/fields/link-multiple-with-primary.js b/client/src/views/fields/link-multiple-with-primary.js index c790478338..6f98f03699 100644 --- a/client/src/views/fields/link-multiple-with-primary.js +++ b/client/src/views/fields/link-multiple-with-primary.js @@ -123,6 +123,8 @@ Espo.define('views/fields/link-multiple-with-primary', 'views/fields/link-multip }, addLinkHtml: function (id, name) { + name = name || id; + if (this.mode == 'search') { return Dep.prototype.addLinkHtml.call(this, id, name); } @@ -130,7 +132,7 @@ Espo.define('views/fields/link-multiple-with-primary', 'views/fields/link-multip var $container = this.$el.find('.link-container'); var $el = $('