From 43e398e078b2a5a8facab3912e6e555b27d86b7d Mon Sep 17 00:00:00 2001 From: yuri Date: Mon, 28 Jan 2019 11:28:12 +0200 Subject: [PATCH 1/4] css fix --- client/res/layout-types/list-row-expanded.tpl | 11 ++-------- frontend/less/espo/custom.less | 20 +++++++++++++------ 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/client/res/layout-types/list-row-expanded.tpl b/client/res/layout-types/list-row-expanded.tpl index b75c4d367b..d1dd5a57b6 100644 --- a/client/res/layout-types/list-row-expanded.tpl +++ b/client/res/layout-types/list-row-expanded.tpl @@ -5,10 +5,7 @@ <% } %> <% _.each(layout.rows, function (row, key) { %> -
- <% _.each(row, function (defs, key) { %> - {{#if this.<%= defs.name %>}} - <% +
<% _.each(row, function (defs, key) { %>{{#if this.<%= defs.name %>}}<% var tag = 'tag' in defs ? defs.tag : false; if (tag) { print( '<' + tag); @@ -24,9 +21,5 @@ if (tag) { print( ''); } - %> - {{/if}} - <% }); %> -
+ %>
{{/if}}<% }); %>
<% }); %> - diff --git a/frontend/less/espo/custom.less b/frontend/less/espo/custom.less index c0b4ae3e68..2ac38441f0 100644 --- a/frontend/less/espo/custom.less +++ b/frontend/less/espo/custom.less @@ -1342,6 +1342,15 @@ table.no-margin { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; + margin-bottom: 2px; + + &:last-child { + margin-bottom: 0; + } + + &:empty { + margin-bottom: -2px; + } } .expanded-row .cell .complex-text { @@ -1929,14 +1938,12 @@ h4.panel-title span.fas.color-icon { position: relative; top: -1px; } + + padding-left: 26px; } .stream-head-container { - padding-bottom: 3px; -} - -.stream-head-text-container { - padding-left: 26px; + margin-bottom: 4px; } .stream-head-container > img.avatar { @@ -1975,7 +1982,8 @@ stream-head-text-container .span { .stream-details-container, .stream-subject-container, { - padding: 2px 0 5px 26px; + padding: 2px 0 2px 26px; + margin-bottom: 2px; } .stream-details-container > ul { From 750d15134f8c0dd145e8328528d5948af72a28ae Mon Sep 17 00:00:00 2001 From: yuri Date: Mon, 28 Jan 2019 12:20:19 +0200 Subject: [PATCH 2/4] entity more link multiple methods --- application/Espo/Core/ORM/Entity.php | 79 +++++++++++++++++++--------- 1 file changed, 54 insertions(+), 25 deletions(-) diff --git a/application/Espo/Core/ORM/Entity.php b/application/Espo/Core/ORM/Entity.php index a163004617..b6f80fbe1d 100644 --- a/application/Espo/Core/ORM/Entity.php +++ b/application/Espo/Core/ORM/Entity.php @@ -218,14 +218,43 @@ class Entity extends \Espo\ORM\Entity $this->set($field . 'Name', $entityName); } + public function getLinkMultipleName($field, $id) + { + $namesAttribute = $field . 'Names'; + if (!$this->has($namesAttribute)) return; + + $names = $this->get($namesAttribute); + if ($names instanceof \StdClass) { + if (isset($names->$id)) { + if (isset($names->$id)) { + return $names->$id; + } + } + } + } + + public function setLinkMultipleName($field, $id, $value) + { + $namesAttribute = $field . 'Names'; + if (!$this->has($namesAttribute)) return; + + $object = $this->get($namesAttribute); + if (!isset($object) || !($object instanceof \StdClass)) { + $object = (object) []; + } + + $object->$id = $value; + $this->set($namesAttribute, $object); + } + public function getLinkMultipleColumn($field, $column, $id) { - $columnsField = $field . 'Columns'; + $columnsAttribute = $field . 'Columns'; - if (!$this->has($columnsField)) { + if (!$this->has($columnsAttribute)) { return; } - $columns = $this->get($columnsField); + $columns = $this->get($columnsAttribute); if ($columns instanceof \StdClass) { if (isset($columns->$id)) { if (isset($columns->$id->$column)) { @@ -237,11 +266,11 @@ class Entity extends \Espo\ORM\Entity public function setLinkMultipleColumn($field, $column, $id, $value) { - $columnsField = $field . 'Columns'; - if (!$this->hasAttribute($columnsField)) { + $columnsAttribute = $field . 'Columns'; + if (!$this->hasAttribute($columnsAttribute)) { return; } - $object = $this->get($columnsField); + $object = $this->get($columnsAttribute); if (!isset($object) || !($object instanceof \StdClass)) { $object = (object) []; } @@ -253,35 +282,35 @@ class Entity extends \Espo\ORM\Entity } $object->$id->$column = $value; - $this->set($columnsField, $object); + $this->set($columnsAttribute, $object); } public function setLinkMultipleIdList($field, array $idList) { - $idsField = $field . 'Ids'; - $this->set($idsField, $idList); + $idsAttribute = $field . 'Ids'; + $this->set($idsAttribute, $idList); } public function addLinkMultipleId($field, $id) { - $idsField = $field . 'Ids'; + $idsAttribute = $field . 'Ids'; - if (!$this->hasAttribute($idsField)) return; + if (!$this->hasAttribute($idsAttribute)) return; - if (!$this->has($idsField)) { + if (!$this->has($idsAttribute)) { if (!$this->isNew()) { $this->loadLinkMultipleField($field); } else { - $this->set($idsField, []); + $this->set($idsAttribute, []); } } - if (!$this->has($idsField)) { + if (!$this->has($idsAttribute)) { return; } - $idList = $this->get($idsField); + $idList = $this->get($idsAttribute); if (!in_array($id, $idList)) { $idList[] = $id; - $this->set($idsField, $idList); + $this->set($idsAttribute, $idList); } } @@ -300,16 +329,16 @@ class Entity extends \Espo\ORM\Entity public function getLinkMultipleIdList($field) { - $idsField = $field . 'Ids'; + $idsAttribute = $field . 'Ids'; - if (!$this->hasAttribute($idsField)) return null; + if (!$this->hasAttribute($idsAttribute)) return null; - if (!$this->has($idsField)) { + if (!$this->has($idsAttribute)) { if (!$this->isNew()) { $this->loadLinkMultipleField($field); } } - $valueList = $this->get($idsField); + $valueList = $this->get($idsAttribute); if (empty($valueList)) { return []; } @@ -318,21 +347,21 @@ class Entity extends \Espo\ORM\Entity public function hasLinkMultipleId($field, $id) { - $idsField = $field . 'Ids'; + $idsAttribute = $field . 'Ids'; - if (!$this->hasAttribute($idsField)) return null; + if (!$this->hasAttribute($idsAttribute)) return null; - if (!$this->has($idsField)) { + if (!$this->has($idsAttribute)) { if (!$this->isNew()) { $this->loadLinkMultipleField($field); } } - if (!$this->has($idsField)) { + if (!$this->has($idsAttribute)) { return; } - $idList = $this->get($idsField); + $idList = $this->get($idsAttribute); if (in_array($id, $idList)) { return true; } From a0535c812736990976282dd094746fecb167905d Mon Sep 17 00:00:00 2001 From: yuri Date: Mon, 28 Jan 2019 12:25:26 +0200 Subject: [PATCH 3/4] meeting support assigned users --- .../Espo/Modules/Crm/Repositories/Meeting.php | 49 ++++++------------- 1 file changed, 16 insertions(+), 33 deletions(-) diff --git a/application/Espo/Modules/Crm/Repositories/Meeting.php b/application/Espo/Modules/Crm/Repositories/Meeting.php index a825ae5195..0ea03569b0 100644 --- a/application/Espo/Modules/Crm/Repositories/Meeting.php +++ b/application/Espo/Modules/Crm/Repositories/Meeting.php @@ -116,41 +116,24 @@ class Meeting extends \Espo\Core\Repositories\Event parent::beforeSave($entity, $options); - $assignedUserId = $entity->get('assignedUserId'); - if ($assignedUserId) { - if ($entity->has('usersIds')) { - $usersIds = $entity->get('usersIds'); - if (!is_array($usersIds)) { - $usersIds = []; - } - if (!in_array($assignedUserId, $usersIds)) { - $usersIds[] = $assignedUserId; - $entity->set('usersIds', $usersIds); - $hash = $entity->get('usersNames'); - if ($hash instanceof \StdClass) { - $hash->$assignedUserId = $entity->get('assignedUserName'); - $entity->set('usersNames', $hash); - } - } - } else { + if ($entity->hasLinkMultipleField('assignedUsers')) { + $assignedUserIdList = $entity->getLinkMultipleIdList('assignedUsers'); + foreach ($assignedUserIdList as $assignedUserId) { $entity->addLinkMultipleId('users', $assignedUserId); + $entity->setLinkMultipleName('users', $assignedUserId, $entity->getLinkMultipleName('assignedUsers', $assignedUserId)); } - if ($entity->isNew()) { - $currentUserId = $this->getEntityManager()->getUser()->id; - if (isset($usersIds) && in_array($currentUserId, $usersIds)) { - $usersColumns = $entity->get('usersColumns'); - if (empty($usersColumns)) { - $usersColumns = new \StdClass(); - } - if ($usersColumns instanceof \StdClass) { - if (empty($usersColumns->$currentUserId) || !($usersColumns->$currentUserId instanceof \StdClass)) { - $usersColumns->$currentUserId = new \StdClass(); - } - if (empty($usersColumns->$currentUserId->status)) { - $usersColumns->$currentUserId->status = 'Accepted'; - } - } - } + } else { + $assignedUserId = $entity->get('assignedUserId'); + if ($assignedUserId) { + $entity->addLinkMultipleId('users', $assignedUserId); + $entity->setLinkMultipleName('users', $assignedUserId, $entity->get('assignedUserName')); + } + } + + if ($entity->isNew()) { + $currentUserId = $this->getEntityManager()->getUser()->id; + if ($entity->hasLinkMultipleId('users', $currentUserId)) { + $entity->setLinkMultipleColumn('users', 'status', $currentUserId, 'Accepted'); } } } From 200f70c8139ae69532797087fbc81ac5b44f9159 Mon Sep 17 00:00:00 2001 From: yuri Date: Mon, 28 Jan 2019 13:08:14 +0200 Subject: [PATCH 4/4] address state list and fixes --- .../Espo/Resources/i18n/en_US/Settings.json | 1 + .../Espo/Resources/i18n/fa_IR/Global.json | 27 ++-------- .../Resources/layouts/Settings/settings.json | 3 +- .../metadata/entityDefs/Settings.json | 3 ++ .../Resources/metadata/fields/address.json | 24 +++++---- .../res/templates/fields/address/edit-1.tpl | 10 ++-- .../res/templates/fields/address/edit-2.tpl | 10 ++-- .../res/templates/fields/address/edit-3.tpl | 10 ++-- .../res/templates/fields/address/edit-4.tpl | 10 ++-- client/res/templates/fields/address/edit.tpl | 10 ++-- client/src/views/fields/address-state.js | 41 +++++++++++++++ client/src/views/fields/address.js | 50 ++++++++++++++++++- 12 files changed, 138 insertions(+), 61 deletions(-) create mode 100644 client/src/views/fields/address-state.js diff --git a/application/Espo/Resources/i18n/en_US/Settings.json b/application/Espo/Resources/i18n/en_US/Settings.json index 1e000bf961..4dcbd73f9d 100644 --- a/application/Espo/Resources/i18n/en_US/Settings.json +++ b/application/Espo/Resources/i18n/en_US/Settings.json @@ -107,6 +107,7 @@ "cleanupDeletedRecords": "Clean up deleted records", "addressCountryList": "Address Country Autocomplete List", "addressCityList": "Address City Autocomplete List", + "addressStateList": "Address State Autocomplete List", "fiscalYearShift": "Fiscal Year Start", "jobRunInParallel": "Jobs Run in Parallel", "jobMaxPortion": "Jobs Max Portion", diff --git a/application/Espo/Resources/i18n/fa_IR/Global.json b/application/Espo/Resources/i18n/fa_IR/Global.json index 951d801c58..ef22459bae 100644 --- a/application/Espo/Resources/i18n/fa_IR/Global.json +++ b/application/Espo/Resources/i18n/fa_IR/Global.json @@ -367,30 +367,9 @@ "assignSelf": "{user} خود اختصاص {entityType} {entity}" }, "lists": { - "dayNames": [ - "یکشنبه", - "دوشنبه", - "سه شنبه", - "چهارشنبه", - " پنجشنبه", - "جمعه شنبه" - ], - "dayNamesShort": [ - "یکشنبه", - "دوشنبه", - "سه شنبه", - "چهارشنبه", - " پنجشنبه", - "جمعه شنبه" - ], - "dayNamesMin": [ - "یکشنبه", - "دوشنبه", - "سه شنبه", - "چهارشنبه", - " پنجشنبه", - "جمعه شنبه" - ] + "dayNames": [ "یکشنبه", "دوشنبه", "سه شنبه", "چهارشنبه", " پنجشنبه", "جمعه", "شنبه" ], + "dayNamesShort": [ "یکشنبه", "دوشنبه", "سه شنبه", "چهارشنبه", " پنجشنبه", "جمعه", "شنبه" ], + "dayNamesMin": [ "یکشنبه", "دوشنبه", "سه شنبه", "چهارشنبه", " پنجشنبه", "جمعه", "شنبه" ] }, "options": { "salutationName": { diff --git a/application/Espo/Resources/layouts/Settings/settings.json b/application/Espo/Resources/layouts/Settings/settings.json index a23128c4b7..57535a135d 100644 --- a/application/Espo/Resources/layouts/Settings/settings.json +++ b/application/Espo/Resources/layouts/Settings/settings.json @@ -18,7 +18,8 @@ [{"name": "timeFormat"}, {"name": "thousandSeparator"}], [{"name": "fiscalYearShift"}, {"name": "decimalMark"}], [{"name": "addressFormat"}, {"name": "addressPreview"}], - [{"name": "addressCountryList"}, {"name": "addressCityList"}] + [{"name": "addressCountryList"}, {"name": "addressCityList"}], + [{"name": "addressStateList"}, false] ] }, { diff --git a/application/Espo/Resources/metadata/entityDefs/Settings.json b/application/Espo/Resources/metadata/entityDefs/Settings.json index 284586e63e..bb4606dbc4 100644 --- a/application/Espo/Resources/metadata/entityDefs/Settings.json +++ b/application/Espo/Resources/metadata/entityDefs/Settings.json @@ -508,6 +508,9 @@ "addressCityList": { "type": "multiEnum" }, + "addressStateList": { + "type": "multiEnum" + }, "jobRunInParallel": { "type": "bool", "tooltip": true diff --git a/application/Espo/Resources/metadata/fields/address.json b/application/Espo/Resources/metadata/fields/address.json index c25a508dc3..157ec02d5a 100644 --- a/application/Espo/Resources/metadata/fields/address.json +++ b/application/Espo/Resources/metadata/fields/address.json @@ -6,30 +6,36 @@ "country", "postalCode" ], - "fields":{ - "street":{ + "fields": { + "street": { "type": "text", "maxLength": 255, "dbType": "varchar" }, - "city":{ + "city": { "type":"varchar", "trim": true, + "maxLength": 255, "view": "views/fields/address-city", "customizationOptionsDisabled": true }, - "state":{ - "type":"varchar", - "trim": true - }, - "country":{ + "state": { "type":"varchar", "trim": true, + "maxLength": 255, + "view": "views/fields/address-state", + "customizationOptionsDisabled": true + }, + "country": { + "type":"varchar", + "trim": true, + "maxLength": 255, "view": "views/fields/address-country", "customizationOptionsDisabled": true }, - "postalCode":{ + "postalCode": { "type":"varchar", + "maxLength": 40, "trim": true }, "map": { diff --git a/client/res/templates/fields/address/edit-1.tpl b/client/res/templates/fields/address/edit-1.tpl index ad84714eae..9dfe02b86c 100644 --- a/client/res/templates/fields/address/edit-1.tpl +++ b/client/res/templates/fields/address/edit-1.tpl @@ -1,13 +1,13 @@ - +
- +
- +
- +
- + diff --git a/client/res/templates/fields/address/edit-2.tpl b/client/res/templates/fields/address/edit-2.tpl index e9d9ee791b..d9e1d3dd1c 100644 --- a/client/res/templates/fields/address/edit-2.tpl +++ b/client/res/templates/fields/address/edit-2.tpl @@ -1,17 +1,17 @@ - +
- +
- +
- +
- +
diff --git a/client/res/templates/fields/address/edit-3.tpl b/client/res/templates/fields/address/edit-3.tpl index fa850e24a7..e43dd87666 100644 --- a/client/res/templates/fields/address/edit-3.tpl +++ b/client/res/templates/fields/address/edit-3.tpl @@ -1,14 +1,14 @@ - +
- +
- +
- +
- + diff --git a/client/res/templates/fields/address/edit-4.tpl b/client/res/templates/fields/address/edit-4.tpl index eb739a429c..8dab430cac 100644 --- a/client/res/templates/fields/address/edit-4.tpl +++ b/client/res/templates/fields/address/edit-4.tpl @@ -1,14 +1,14 @@ - - + +
- +
- +
- +
diff --git a/client/res/templates/fields/address/edit.tpl b/client/res/templates/fields/address/edit.tpl index ad84714eae..9dfe02b86c 100644 --- a/client/res/templates/fields/address/edit.tpl +++ b/client/res/templates/fields/address/edit.tpl @@ -1,13 +1,13 @@ - +
- +
- +
- +
- + diff --git a/client/src/views/fields/address-state.js b/client/src/views/fields/address-state.js new file mode 100644 index 0000000000..59b77ef956 --- /dev/null +++ b/client/src/views/fields/address-state.js @@ -0,0 +1,41 @@ +/************************************************************************ + * This file is part of EspoCRM. + * + * EspoCRM - Open Source CRM application. + * Copyright (C) 2014-2018 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('views/fields/address-state', 'views/fields/varchar', function (Dep) { + + return Dep.extend({ + + setupOptions: function () { + var stateList = this.getConfig().get('addressStateList') || []; + if (stateList.length) { + this.params.options = Espo.Utils.clone(stateList); + } + }, + + }); +}); diff --git a/client/src/views/fields/address.js b/client/src/views/fields/address.js index 66ab6d2649..4393a1593f 100644 --- a/client/src/views/fields/address.js +++ b/client/src/views/fields/address.js @@ -61,6 +61,14 @@ Espo.define('views/fields/address', 'views/fields/base', function (Dep) { data.formattedAddress = this.getFormattedAddress(); } + if (this.isEditMode()) { + data.stateMaxLength = this.stateMaxLength; + data.streetMaxLength = this.streetMaxLength; + data.postalCodeMaxLength = this.postalCodeMaxLength; + data.cityMaxLength = this.cityMaxLength; + data.countryMaxLength = this.countryMaxLength; + } + var isNotEmpty = false; return data; @@ -330,7 +338,6 @@ Espo.define('views/fields/address', 'views/fields/base', function (Dep) { this.once('remove', function () { this.$country.autocomplete('dispose'); }, this); - this.$country.attr('autocomplete', 'espo-country'); } @@ -369,7 +376,6 @@ Espo.define('views/fields/address', 'views/fields/base', function (Dep) { this.once('remove', function () { this.$city.autocomplete('dispose'); }, this); - this.$city.attr('autocomplete', 'espo-city'); } @@ -377,6 +383,44 @@ Espo.define('views/fields/address', 'views/fields/base', function (Dep) { this.$street.on('input', function (e) { this.controlStreetTextareaHeight(); }.bind(this)); + + var stateList = this.getConfig().get('addressStateList') || []; + if (stateList.length) { + this.$state.autocomplete({ + minChars: 0, + lookup: stateList, + maxHeight: 200, + formatResult: function (suggestion) { + return suggestion.value; + }, + lookupFilter: function (suggestion, query, queryLowerCase) { + if (suggestion.value.toLowerCase().indexOf(queryLowerCase) === 0) { + if (suggestion.value.length === queryLowerCase.length) return false; + return true; + } + return false; + }, + onSelect: function () { + this.trigger('change'); + }.bind(this) + }); + this.$state.on('focus', function () { + if (this.$state.val()) return; + this.$state.autocomplete('onValueChange'); + }.bind(this)); + this.once('render', function () { + this.$state.autocomplete('dispose'); + }, this); + this.once('remove', function () { + this.$state.autocomplete('dispose'); + }, this); + this.$state.attr('autocomplete', 'espo-state'); + } + + this.controlStreetTextareaHeight(); + this.$street.on('input', function (e) { + this.controlStreetTextareaHeight(); + }.bind(this)); } }, @@ -412,6 +456,8 @@ Espo.define('views/fields/address', 'views/fields/base', function (Dep) { this.addressAttributeList.push(attribute); this.addressPartList.push(item); this[item + 'Field'] = attribute; + + this[item + 'MaxLength'] = this.getMetadata().get(['entityDefs', this.model.name, 'fields', attribute, 'maxLength']); }, this); },