From 1135573af68d43ebe35d3f46cf7ccb7af887dc4e Mon Sep 17 00:00:00 2001 From: Taras Machyshyn Date: Tue, 28 Apr 2015 11:59:05 +0300 Subject: [PATCH 01/22] Metadata changes: generated fields now added to metadata --- .../Core/Utils/Database/Orm/Converter.php | 61 ++----------------- application/Espo/Core/Utils/Metadata.php | 43 +++++++++++++ .../Espo/Core/Utils/Metadata/Utils.php | 54 +++++++++++++++- .../Resources/metadata/fields/address.json | 5 +- .../Resources/metadata/fields/personName.json | 2 +- 5 files changed, 104 insertions(+), 61 deletions(-) diff --git a/application/Espo/Core/Utils/Database/Orm/Converter.php b/application/Espo/Core/Utils/Database/Orm/Converter.php index 580837462d..e83e7cb872 100644 --- a/application/Espo/Core/Utils/Database/Orm/Converter.php +++ b/application/Espo/Core/Utils/Database/Orm/Converter.php @@ -82,7 +82,6 @@ class Converter 'len' => '24', ); - public function __construct(\Espo\Core\Utils\Metadata $metadata, \Espo\Core\Utils\File\Manager $fileManager) { $this->metadata = $metadata; @@ -93,7 +92,6 @@ class Converter $this->metadataUtils = new \Espo\Core\Utils\Metadata\Utils($this->metadata); } - protected function getMetadata() { return $this->metadata; @@ -227,24 +225,9 @@ class Converter /** check if "fields" option exists in $fieldMeta */ $fieldTypeMeta = $this->getMetadataUtils()->getFieldDefsByType($fieldParams); - if (isset($fieldTypeMeta['fields']) && is_array($fieldTypeMeta['fields'])) { - - foreach($fieldTypeMeta['actualFields'] as $subFieldName) { - - $subField = $this->convertActualFields($entityName, $fieldName, $fieldParams, $subFieldName, $fieldTypeMeta); - - if (!isset($outputMeta[ $subField['naming'] ])) { - $subFieldDefs = $this->convertField($entityName, $subField['name'], $subField['params']); - if ($subFieldDefs !== false) { - $outputMeta[ $subField['naming'] ] = $subFieldDefs; //push fieldDefs to the main array - } - } - } - } else { - $fieldDefs = $this->convertField($entityName, $fieldName, $fieldParams, $fieldTypeMeta); - if ($fieldDefs !== false) { - $outputMeta[$fieldName] = $fieldDefs; //push fieldDefs to the main array - } + $fieldDefs = $this->convertField($entityName, $fieldName, $fieldParams, $fieldTypeMeta); + if ($fieldDefs !== false) { + $outputMeta[$fieldName] = $fieldDefs; //push fieldDefs to the main array } /** check and set the linkDefs from 'fields' metadata */ @@ -310,17 +293,12 @@ class Converter if (isset($scopeDefs['stream']) && $scopeDefs['stream']) { if (!isset($entityMeta['fields']['isFollowed'])) { $ormMeta[$entityName]['fields']['isFollowed'] = array( - 'type' => 'bool', + 'type' => 'varchar', 'notStorable' => true, ); } } //END: add a field 'isFollowed' for stream => true - $ormMeta[$entityName]['fields']['isEditable'] = array( - 'type' => 'bool', - 'notStorable' => true - ); - return $ormMeta; } @@ -366,37 +344,6 @@ class Converter return $fieldDefs; } - protected function convertActualFields($entityName, $fieldName, $fieldParams, $subFieldName, $fieldTypeMeta) - { - $subField = array(); - - $subField['params'] = $this->getInitValues($fieldParams); - - if (isset($fieldTypeMeta['fieldDefs'])) { - $subField['params'] = Util::merge($subField['params'], $fieldTypeMeta['fieldDefs']); - } - - //if empty field name, then use the main field - if (trim($subFieldName) == '') { - - $subField['name'] = $fieldName; - $subField['naming'] = $fieldName; - - } else { - - $namingType = isset($fieldTypeMeta['naming']) ? $fieldTypeMeta['naming'] : $this->defaultNaming; - - $subField['name'] = $subFieldName; - $subField['naming'] = Util::getNaming($fieldName, $subFieldName, $namingType); - if (isset($fieldTypeMeta['fields'][$subFieldName])) { - $subField['params'] = Util::merge($subField['params'], $fieldTypeMeta['fields'][$subFieldName]); - } - - } - - return $subField; - } - protected function convertLinks($entityName, $entityMeta, $ormMeta) { if (!isset($entityMeta['links'])) { diff --git a/application/Espo/Core/Utils/Metadata.php b/application/Espo/Core/Utils/Metadata.php index 58a16ba517..236c2da4ca 100644 --- a/application/Espo/Core/Utils/Metadata.php +++ b/application/Espo/Core/Utils/Metadata.php @@ -35,6 +35,7 @@ class Metadata private $fileManager; private $converter; private $moduleConfig; + private $metadataUtils; /** * @var string - uses for loading default values @@ -109,6 +110,15 @@ class Metadata return $this->moduleConfig; } + protected function getMetadataUtils() + { + if (!isset($this->metadataUtils)) { + $this->metadataUtils = new Metadata\Utils($this); + } + + return $this->metadataUtils; + } + public function isCached() { if (!$this->getConfig()->get('useCache')) { @@ -139,6 +149,7 @@ class Metadata } else { $this->meta = $this->getUnifier()->unify($this->name, $this->paths, true); $this->meta = $this->setLanguageFromConfig($this->meta); + $this->meta = $this->addAdditionalFields($this->meta); if ($this->getConfig()->get('useCache')) { $isSaved = $this->getFileManager()->putPhpContents($this->cacheFile, $this->meta); @@ -197,6 +208,7 @@ class Metadata } /** + * todo: move to a separate file * Set language list and default for Settings, Preferences metadata * * @param array $data Meta @@ -222,6 +234,37 @@ class Metadata return $data; } + /** + * todo: move to a separate file + * Add additional fields defined from metadata -> fields + * + * @param array $meta + */ + protected function addAdditionalFields(array $meta) + { + $metaCopy = $meta; + $definitionList = $meta['fields']; + + foreach ($metaCopy['entityDefs'] as $entityName => $entityParams) { + foreach ($entityParams['fields'] as $fieldName => $fieldParams) { + + $additionalFields = $this->getMetadataUtils()->getAdditionalFieldList($fieldName, $fieldParams, $definitionList); + if (!empty($additionalFields)) { + //merge or add to the end of meta array + foreach ($additionalFields as $subFieldName => $subFieldParams) { + if (isset($entityParams['fields'][$subFieldName])) { + $meta['entityDefs'][$entityName]['fields'][$subFieldName] = Util::merge($subFieldParams, $entityParams['fields'][$subFieldName]); + } else { + $meta['entityDefs'][$entityName]['fields'][$subFieldName] = $subFieldParams; + } + } + } + } + } + + return $meta; + } + /** * Set Metadata data * Ex. $key1 = menu, $key2 = Account then will be created a file metadataFolder/menu/Account.json diff --git a/application/Espo/Core/Utils/Metadata/Utils.php b/application/Espo/Core/Utils/Metadata/Utils.php index 56adc7f72d..bc463b66e8 100644 --- a/application/Espo/Core/Utils/Metadata/Utils.php +++ b/application/Espo/Core/Utils/Metadata/Utils.php @@ -22,10 +22,26 @@ namespace Espo\Core\Utils\Metadata; +use Espo\Core\Utils\Util; + class Utils { private $metadata; + protected $defaultNaming = 'postfix'; + + /** + * List of copied params for metadata -> 'fields' from parent items + */ + protected $copiedDefParams = array( + 'readOnly', + 'notStorable', + 'layoutListDisabled', + 'layoutDetailDisabled', + 'layoutMassUpdateDisabled', + 'layoutFiltersDisabled', + ); + public function __construct(\Espo\Core\Utils\Metadata $metadata) { $this->metadata = $metadata; @@ -102,7 +118,41 @@ class Utils return $linkFieldDefsByType; } -} + /** + * Get additional field list based on field definition in metadata 'fields' + * + * @param string $fieldName + * @param array $fieldParams + * @param array|null $definitionList + * + * @return array + */ + public function getAdditionalFieldList($fieldName, array $fieldParams, array $definitionList = null) + { + if (empty($fieldParams['type'])) { + return; + } + $fieldType = $fieldParams['type']; + $fieldDefinition = isset($definitionList[$fieldType]) ? $definitionList[$fieldType] : $this->getMetadata()->get('fields.'.$fieldType); -?> + if (!empty($fieldDefinition['fields']) && is_array($fieldDefinition['fields'])) { + + $copiedParams = array_intersect_key($fieldParams, array_flip($this->copiedDefParams)); + + $additionalFields = array(); + + //add additional fields + foreach ($fieldDefinition['fields'] as $subFieldName => $subFieldParams) { + $namingType = isset($fieldDefinition['naming']) ? $fieldDefinition['naming'] : $this->defaultNaming; + + $subFieldNaming = Util::getNaming($fieldName, $subFieldName, $namingType); + $additionalFields[$subFieldNaming] = array_merge($copiedParams, $subFieldParams); + } + + return $additionalFields; + } + + } + +} \ No newline at end of file diff --git a/application/Espo/Resources/metadata/fields/address.json b/application/Espo/Resources/metadata/fields/address.json index 832b8f3146..b34c546459 100644 --- a/application/Espo/Resources/metadata/fields/address.json +++ b/application/Espo/Resources/metadata/fields/address.json @@ -27,5 +27,8 @@ }, "mergable":false, "notCreatable": false, - "filter": true + "filter": true, + "fieldDefs":{ + "skip":true + } } diff --git a/application/Espo/Resources/metadata/fields/personName.json b/application/Espo/Resources/metadata/fields/personName.json index 1b5d713851..d09f8421f3 100644 --- a/application/Espo/Resources/metadata/fields/personName.json +++ b/application/Espo/Resources/metadata/fields/personName.json @@ -20,6 +20,6 @@ "notCreatable": true, "filter": true, "fieldDefs":{ - "default":"" + "notStorable":true } } From 59a564cc1bacd6a4d49e78fce4e8c19011b38ab6 Mon Sep 17 00:00:00 2001 From: Taras Machyshyn Date: Tue, 28 Apr 2015 14:40:50 +0300 Subject: [PATCH 02/22] FieldManager fixes --- application/Espo/Core/Utils/FieldManager.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/application/Espo/Core/Utils/FieldManager.php b/application/Espo/Core/Utils/FieldManager.php index 4c544f7927..23b9544197 100644 --- a/application/Espo/Core/Utils/FieldManager.php +++ b/application/Espo/Core/Utils/FieldManager.php @@ -187,11 +187,6 @@ class FieldManager } } - if (isset($fieldDef['linkDefs'])) { - $linkDefs = $fieldDef['linkDefs']; - unset($fieldDef['linkDefs']); - } - $currentOptionList = array_keys((array) $this->getFieldDef($name, $scope)); foreach ($fieldDef as $defName => $defValue) { if ( (!isset($defValue) || $defValue === '') && !in_array($defName, $currentOptionList) ) { @@ -219,6 +214,11 @@ class FieldManager $fieldDef = Util::merge($metaFieldDef, $fieldDef); } + if (isset($fieldDef['linkDefs'])) { + $linkDefs = $fieldDef['linkDefs']; + unset($fieldDef['linkDefs']); + } + $defs = array( 'fields' => array( $fieldName => $fieldDef, From 8ce806d41f60a63bfa60d61160f8849451c6b3dd Mon Sep 17 00:00:00 2001 From: Taras Machyshyn Date: Tue, 28 Apr 2015 14:54:43 +0300 Subject: [PATCH 03/22] Metadata: renamed option 'skip' to 'skipOrmDefs' --- application/Espo/Core/Utils/Database/Orm/Converter.php | 4 ++-- application/Espo/Resources/metadata/fields/address.json | 2 +- .../Espo/Resources/metadata/fields/currencyConverted.json | 2 +- application/Espo/Resources/metadata/fields/file.json | 2 +- application/Espo/Resources/metadata/fields/foreign.json | 5 +---- application/Espo/Resources/metadata/fields/image.json | 2 +- 6 files changed, 7 insertions(+), 10 deletions(-) diff --git a/application/Espo/Core/Utils/Database/Orm/Converter.php b/application/Espo/Core/Utils/Database/Orm/Converter.php index e83e7cb872..e8401ef972 100644 --- a/application/Espo/Core/Utils/Database/Orm/Converter.php +++ b/application/Espo/Core/Utils/Database/Orm/Converter.php @@ -319,8 +319,8 @@ class Converter $fieldParams = Util::merge($fieldParams, $fieldTypeMeta['fieldDefs']); } - /** check if need to skip this field in ORM metadata */ - if (isset($fieldParams['skip']) && $fieldParams['skip'] === true) { + /** check if need to skipOrmDefs this field in ORM metadata */ + if (isset($fieldParams['skipOrmDefs']) && $fieldParams['skipOrmDefs'] === true) { return false; } diff --git a/application/Espo/Resources/metadata/fields/address.json b/application/Espo/Resources/metadata/fields/address.json index b34c546459..209eb47c75 100644 --- a/application/Espo/Resources/metadata/fields/address.json +++ b/application/Espo/Resources/metadata/fields/address.json @@ -29,6 +29,6 @@ "notCreatable": false, "filter": true, "fieldDefs":{ - "skip":true + "skipOrmDefs":true } } diff --git a/application/Espo/Resources/metadata/fields/currencyConverted.json b/application/Espo/Resources/metadata/fields/currencyConverted.json index 124118157c..401c1d5000 100644 --- a/application/Espo/Resources/metadata/fields/currencyConverted.json +++ b/application/Espo/Resources/metadata/fields/currencyConverted.json @@ -4,6 +4,6 @@ "filter": true, "notCreatable": true, "fieldDefs":{ - "skip": true + "skipOrmDefs": true } } diff --git a/application/Espo/Resources/metadata/fields/file.json b/application/Espo/Resources/metadata/fields/file.json index 5d83e0d2ea..7cc88347d2 100644 --- a/application/Espo/Resources/metadata/fields/file.json +++ b/application/Espo/Resources/metadata/fields/file.json @@ -18,6 +18,6 @@ "entity": "Attachment" }, "fieldDefs":{ - "skip": true + "skipOrmDefs": true } } diff --git a/application/Espo/Resources/metadata/fields/foreign.json b/application/Espo/Resources/metadata/fields/foreign.json index 8cc033630d..7042a3a38b 100644 --- a/application/Espo/Resources/metadata/fields/foreign.json +++ b/application/Espo/Resources/metadata/fields/foreign.json @@ -10,8 +10,5 @@ } ], "filter": true, - "notCreatable": true, - "fieldDefs":{ - "skip": false - } + "notCreatable": true } diff --git a/application/Espo/Resources/metadata/fields/image.json b/application/Espo/Resources/metadata/fields/image.json index 00effca389..80620fe860 100644 --- a/application/Espo/Resources/metadata/fields/image.json +++ b/application/Espo/Resources/metadata/fields/image.json @@ -24,6 +24,6 @@ "entity": "Attachment" }, "fieldDefs":{ - "skip": true + "skipOrmDefs": true } } From 0f62d7da1319fc87f8445fbde893908fadf4a1b2 Mon Sep 17 00:00:00 2001 From: Taras Machyshyn Date: Tue, 28 Apr 2015 15:28:26 +0300 Subject: [PATCH 04/22] Metadata: code improvements --- .../Espo/Core/Utils/Database/Orm/Converter.php | 14 +++++++------- application/Espo/Core/Utils/EntityManager.php | 8 ++++---- application/Espo/Core/Utils/FieldManager.php | 12 ++++++------ application/Espo/Core/Utils/Metadata.php | 12 ++++++------ .../Core/Utils/Metadata/{Utils.php => Helper.php} | 2 +- 5 files changed, 24 insertions(+), 24 deletions(-) rename application/Espo/Core/Utils/Metadata/{Utils.php => Helper.php} (99%) diff --git a/application/Espo/Core/Utils/Database/Orm/Converter.php b/application/Espo/Core/Utils/Database/Orm/Converter.php index e8401ef972..3287ac60fa 100644 --- a/application/Espo/Core/Utils/Database/Orm/Converter.php +++ b/application/Espo/Core/Utils/Database/Orm/Converter.php @@ -29,7 +29,7 @@ class Converter { private $metadata; private $fileManager; - private $metadataUtils; + private $metadataHelper; private $relationManager; @@ -89,7 +89,7 @@ class Converter $this->relationManager = new RelationManager($this->metadata); - $this->metadataUtils = new \Espo\Core\Utils\Metadata\Utils($this->metadata); + $this->metadataHelper = new \Espo\Core\Utils\Metadata\Helper($this->metadata); } protected function getMetadata() @@ -116,9 +116,9 @@ class Converter return $this->relationManager; } - protected function getMetadataUtils() + protected function getMetadataHelper() { - return $this->metadataUtils; + return $this->metadataHelper; } public function process() @@ -223,7 +223,7 @@ class Converter foreach($entityMeta['fields'] as $fieldName => $fieldParams) { /** check if "fields" option exists in $fieldMeta */ - $fieldTypeMeta = $this->getMetadataUtils()->getFieldDefsByType($fieldParams); + $fieldTypeMeta = $this->getMetadataHelper()->getFieldDefsByType($fieldParams); $fieldDefs = $this->convertField($entityName, $fieldName, $fieldParams, $fieldTypeMeta); if ($fieldDefs !== false) { @@ -232,7 +232,7 @@ class Converter /** check and set the linkDefs from 'fields' metadata */ if (isset($fieldTypeMeta['linkDefs'])) { - $linkDefs = $this->getMetadataUtils()->getLinkDefsInFieldMeta($entityName, $fieldParams, $fieldTypeMeta['linkDefs']); + $linkDefs = $this->getMetadataHelper()->getLinkDefsInFieldMeta($entityName, $fieldParams, $fieldTypeMeta['linkDefs']); if (isset($linkDefs)) { if (!isset($entityMeta['links'])) { $entityMeta['links'] = array(); @@ -312,7 +312,7 @@ class Converter /** merge fieldDefs option from field definition */ if (!isset($fieldTypeMeta)) { - $fieldTypeMeta = $this->getMetadataUtils()->getFieldDefsByType($fieldParams); + $fieldTypeMeta = $this->getMetadataHelper()->getFieldDefsByType($fieldParams); } if (isset($fieldTypeMeta['fieldDefs'])) { diff --git a/application/Espo/Core/Utils/EntityManager.php b/application/Espo/Core/Utils/EntityManager.php index 3644937126..3eb3a791c0 100644 --- a/application/Espo/Core/Utils/EntityManager.php +++ b/application/Espo/Core/Utils/EntityManager.php @@ -35,7 +35,7 @@ class EntityManager private $fileManager; - private $metadataUtils; + private $metadataHelper; public function __construct(Metadata $metadata, Language $language, File\Manager $fileManager) { @@ -43,7 +43,7 @@ class EntityManager $this->language = $language; $this->fileManager = $fileManager; - $this->metadataUtils = new \Espo\Core\Utils\Metadata\Utils($this->metadata); + $this->metadataHelper = new \Espo\Core\Utils\Metadata\Helper($this->metadata); } protected function getMetadata() @@ -61,9 +61,9 @@ class EntityManager return $this->fileManager; } - protected function getMetadataUtils() + protected function getMetadataHelper() { - return $this->metadataUtils; + return $this->metadataHelper; } public function create($name, $type, $params = array()) diff --git a/application/Espo/Core/Utils/FieldManager.php b/application/Espo/Core/Utils/FieldManager.php index 23b9544197..3a5c3469a1 100644 --- a/application/Espo/Core/Utils/FieldManager.php +++ b/application/Espo/Core/Utils/FieldManager.php @@ -31,7 +31,7 @@ class FieldManager private $language; - private $metadataUtils; + private $metadataHelper; protected $isChanged = null; @@ -44,7 +44,7 @@ class FieldManager $this->metadata = $metadata; $this->language = $language; - $this->metadataUtils = new \Espo\Core\Utils\Metadata\Utils($this->metadata); + $this->metadataHelper = new \Espo\Core\Utils\Metadata\Helper($this->metadata); } protected function getMetadata() @@ -57,9 +57,9 @@ class FieldManager return $this->language; } - protected function getMetadataUtils() + protected function getMetadataHelper() { - return $this->metadataUtils; + return $this->metadataHelper; } public function read($name, $scope) @@ -209,7 +209,7 @@ class FieldManager { $fieldDef = $this->prepareFieldDef($fieldName, $fieldDef, $scope); - $metaFieldDef = $this->getMetadataUtils()->getFieldDefsInFieldMeta($fieldDef); + $metaFieldDef = $this->getMetadataHelper()->getFieldDefsInFieldMeta($fieldDef); if (isset($metaFieldDef)) { $fieldDef = Util::merge($metaFieldDef, $fieldDef); } @@ -226,7 +226,7 @@ class FieldManager ); /** Save links for a field. */ - $metaLinkDef = $this->getMetadataUtils()->getLinkDefsInFieldMeta($scope, $fieldDef); + $metaLinkDef = $this->getMetadataHelper()->getLinkDefsInFieldMeta($scope, $fieldDef); if (isset($linkDefs) || isset($metaLinkDef)) { $linkDefs = Util::merge((array) $metaLinkDef, (array) $linkDefs); $defs['links'] = array( diff --git a/application/Espo/Core/Utils/Metadata.php b/application/Espo/Core/Utils/Metadata.php index 236c2da4ca..5fe4ea1b49 100644 --- a/application/Espo/Core/Utils/Metadata.php +++ b/application/Espo/Core/Utils/Metadata.php @@ -35,7 +35,7 @@ class Metadata private $fileManager; private $converter; private $moduleConfig; - private $metadataUtils; + private $metadataHelper; /** * @var string - uses for loading default values @@ -110,13 +110,13 @@ class Metadata return $this->moduleConfig; } - protected function getMetadataUtils() + protected function getMetadataHelper() { - if (!isset($this->metadataUtils)) { - $this->metadataUtils = new Metadata\Utils($this); + if (!isset($this->metadataHelper)) { + $this->metadataHelper = new Metadata\Helper($this); } - return $this->metadataUtils; + return $this->metadataHelper; } public function isCached() @@ -248,7 +248,7 @@ class Metadata foreach ($metaCopy['entityDefs'] as $entityName => $entityParams) { foreach ($entityParams['fields'] as $fieldName => $fieldParams) { - $additionalFields = $this->getMetadataUtils()->getAdditionalFieldList($fieldName, $fieldParams, $definitionList); + $additionalFields = $this->getMetadataHelper()->getAdditionalFieldList($fieldName, $fieldParams, $definitionList); if (!empty($additionalFields)) { //merge or add to the end of meta array foreach ($additionalFields as $subFieldName => $subFieldParams) { diff --git a/application/Espo/Core/Utils/Metadata/Utils.php b/application/Espo/Core/Utils/Metadata/Helper.php similarity index 99% rename from application/Espo/Core/Utils/Metadata/Utils.php rename to application/Espo/Core/Utils/Metadata/Helper.php index bc463b66e8..3e0475d3c6 100644 --- a/application/Espo/Core/Utils/Metadata/Utils.php +++ b/application/Espo/Core/Utils/Metadata/Helper.php @@ -24,7 +24,7 @@ namespace Espo\Core\Utils\Metadata; use Espo\Core\Utils\Util; -class Utils +class Helper { private $metadata; From 08cf333c0c34399c771a011dfc4240fdfc397995 Mon Sep 17 00:00:00 2001 From: Taras Machyshyn Date: Tue, 28 Apr 2015 15:38:45 +0300 Subject: [PATCH 05/22] Metadata: optimization --- application/Espo/Core/Utils/Metadata.php | 28 ++++++++++++++---------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/application/Espo/Core/Utils/Metadata.php b/application/Espo/Core/Utils/Metadata.php index 5fe4ea1b49..217c8e362c 100644 --- a/application/Espo/Core/Utils/Metadata.php +++ b/application/Espo/Core/Utils/Metadata.php @@ -77,12 +77,6 @@ class Metadata { $this->config = $config; $this->fileManager = $fileManager; - - $this->unifier = new \Espo\Core\Utils\File\Unifier($this->fileManager); - - $this->converter = new \Espo\Core\Utils\Database\Converter($this, $this->fileManager); - - $this->moduleConfig = new \Espo\Core\Utils\Module($this->config, $this->fileManager); } protected function getConfig() @@ -90,23 +84,35 @@ class Metadata return $this->config; } - protected function getUnifier() - { - return $this->unifier; - } - protected function getFileManager() { return $this->fileManager; } + protected function getUnifier() + { + if (!isset($this->unifier)) { + $this->unifier = new \Espo\Core\Utils\File\Unifier($this->fileManager); + } + + return $this->unifier; + } + protected function getConverter() { + if (!isset($this->converter)) { + $this->converter = new \Espo\Core\Utils\Database\Converter($this, $this->fileManager); + } + return $this->converter; } protected function getModuleConfig() { + if (!isset($this->moduleConfig)) { + $this->moduleConfig = new \Espo\Core\Utils\Module($this->config, $this->fileManager); + } + return $this->moduleConfig; } From 898a7d89c772c3ff599a3c306394163779fe4cc1 Mon Sep 17 00:00:00 2001 From: Taras Machyshyn Date: Wed, 29 Apr 2015 17:17:00 +0300 Subject: [PATCH 06/22] Fixed ScheduledJobLog clean-up --- application/Espo/Jobs/Cleanup.php | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/application/Espo/Jobs/Cleanup.php b/application/Espo/Jobs/Cleanup.php index 9343a0ebb0..93973d10ec 100644 --- a/application/Espo/Jobs/Cleanup.php +++ b/application/Espo/Jobs/Cleanup.php @@ -49,21 +49,26 @@ class Cleanup extends \Espo\Core\Jobs\Base protected function cleanupScheduledJobLog() { - $lastTenRecords = "SELECT c.id FROM ( - SELECT i1.id - FROM scheduled_job_log_record i1 - CROSS JOIN scheduled_job_log_record i2 ON ( i1.scheduled_job_id = i2.scheduled_job_id - AND i1.id < i2.id ) - GROUP BY i1.id - HAVING COUNT( * ) <10 - ORDER BY i1.created_at DESC - ) AS c"; - - $query = "DELETE FROM `scheduled_job_log_record` WHERE DATE(created_at) < '".$this->getDate()."' AND id NOT IN (".$lastTenRecords.") "; - $pdo = $this->getEntityManager()->getPDO(); - $sth = $pdo->prepare($query); + + $sql = "SELECT id FROM scheduled_job"; + $sth = $pdo->prepare($sql); $sth->execute(); + while ($row = $sth->fetch(\PDO::FETCH_ASSOC)) { + $id = $row['id']; + + $lastRowsSql = "SELECT id FROM scheduled_job_log_record WHERE scheduled_job_id = '".$id."' ORDER BY created_at DESC LIMIT 0,10"; + $lastRowsSth = $pdo->prepare($lastRowsSql); + $lastRowsSth->execute(); + $lastRowIds = $lastRowsSth->fetchAll(\PDO::FETCH_COLUMN, 0); + + $delSql = "DELETE FROM `scheduled_job_log_record` + WHERE scheduled_job_id = '".$id."' + AND DATE(created_at) < '".$this->getDate()."' + AND id NOT IN ('".implode("', '", $lastRowIds)."') + "; + $pdo->query($delSql); + } } protected function getDate($format = 'Y-m-d') From 461bffbf02374641d8f17dae8f83c9c276b0ee89 Mon Sep 17 00:00:00 2001 From: Taras Machyshyn Date: Thu, 30 Apr 2015 13:07:54 +0300 Subject: [PATCH 07/22] Jobs: improved scheduledJobLog --- application/Espo/Core/Utils/Cron/Job.php | 27 ++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/application/Espo/Core/Utils/Cron/Job.php b/application/Espo/Core/Utils/Cron/Job.php index 5b185f7abb..789c69ede0 100644 --- a/application/Espo/Core/Utils/Cron/Job.php +++ b/application/Espo/Core/Utils/Cron/Job.php @@ -33,10 +33,14 @@ class Job private $entityManager; + private $cronScheduledJob; + public function __construct(Config $config, EntityManager $entityManager) { $this->config = $config; $this->entityManager = $entityManager; + + $this->cronScheduledJob = new ScheduledJob($this->config, $this->entityManager); } protected function getConfig() @@ -49,6 +53,11 @@ class Job return $this->entityManager; } + protected function getCronScheduledJob() + { + return $this->cronScheduledJob; + } + /** * Get Pending Jobs * @@ -145,13 +154,27 @@ class Job $currentTime = time(); $periodTime = $currentTime - intval($jobConfigs['jobPeriod']); - $update = "UPDATE job SET `status` = '" . CronManager::FAILED ."' WHERE + $pdo = $this->getEntityManager()->getPDO(); + + $select = "SELECT id, scheduled_job_id FROM `job` WHERE (`status` = '" . CronManager::RUNNING ."') AND execute_time < '".date('Y-m-d H:i:s', $periodTime)."' "; + $sth = $pdo->prepare($select); + $sth->execute(); + $jobData = $sth->fetchAll(PDO::FETCH_COLUMN|PDO::FETCH_GROUP); - $pdo = $this->getEntityManager()->getPDO(); + $update = "UPDATE job SET `status` = '". CronManager::FAILED ."' WHERE id IN ('".implode("', '", array_keys($jobData))."')"; $sth = $pdo->prepare($update); $sth->execute(); + + //add status 'Failed' to SchediledJobLog + $cronScheduledJob = $this->getCronScheduledJob(); + foreach ($jobData as $jobId => $jobRowData) { + $scheduledJobId = $jobRowData[0]; + if (!empty($scheduledJobId)) { + $cronScheduledJob->addLogRecord($scheduledJobId, CronManager::FAILED); + } + } } /** From b60e65379ea071a39c8e8d91a8d909b10baa3466 Mon Sep 17 00:00:00 2001 From: Taras Machyshyn Date: Fri, 1 May 2015 12:03:17 +0300 Subject: [PATCH 08/22] Improved ScheduledJobLog --- application/Espo/Core/Utils/Cron/Job.php | 15 +++++++++------ application/Espo/Core/Utils/Cron/ScheduledJob.php | 10 ++++++---- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/application/Espo/Core/Utils/Cron/Job.php b/application/Espo/Core/Utils/Cron/Job.php index 789c69ede0..48487cb22c 100644 --- a/application/Espo/Core/Utils/Cron/Job.php +++ b/application/Espo/Core/Utils/Cron/Job.php @@ -156,12 +156,16 @@ class Job $pdo = $this->getEntityManager()->getPDO(); - $select = "SELECT id, scheduled_job_id FROM `job` WHERE + $select = "SELECT id, scheduled_job_id, execute_time FROM `job` WHERE (`status` = '" . CronManager::RUNNING ."') AND execute_time < '".date('Y-m-d H:i:s', $periodTime)."' "; $sth = $pdo->prepare($select); $sth->execute(); - $jobData = $sth->fetchAll(PDO::FETCH_COLUMN|PDO::FETCH_GROUP); + + $jobData = array(); + while ($row = $sth->fetch(PDO::FETCH_ASSOC)){ + $jobData[$row['id']] = $row; + } $update = "UPDATE job SET `status` = '". CronManager::FAILED ."' WHERE id IN ('".implode("', '", array_keys($jobData))."')"; $sth = $pdo->prepare($update); @@ -169,10 +173,9 @@ class Job //add status 'Failed' to SchediledJobLog $cronScheduledJob = $this->getCronScheduledJob(); - foreach ($jobData as $jobId => $jobRowData) { - $scheduledJobId = $jobRowData[0]; - if (!empty($scheduledJobId)) { - $cronScheduledJob->addLogRecord($scheduledJobId, CronManager::FAILED); + foreach ($jobData as $jobId => $job) { + if (!empty($job['scheduled_job_id'])) { + $cronScheduledJob->addLogRecord($job['scheduled_job_id'], CronManager::FAILED, $job['execute_time']); } } } diff --git a/application/Espo/Core/Utils/Cron/ScheduledJob.php b/application/Espo/Core/Utils/Cron/ScheduledJob.php index 84fdfaad41..2338268d0e 100644 --- a/application/Espo/Core/Utils/Cron/ScheduledJob.php +++ b/application/Espo/Core/Utils/Cron/ScheduledJob.php @@ -81,14 +81,16 @@ class ScheduledJob * * @return string ID of created ScheduledJobLogRecord */ - public function addLogRecord($scheduledJobId, $status) + public function addLogRecord($scheduledJobId, $status, $runTime = null) { - $lastRun = date('Y-m-d H:i:s'); + if (!isset($runTime)) { + $runTime = date('Y-m-d H:i:s'); + } $entityManager = $this->getEntityManager(); $scheduledJob = $entityManager->getEntity('ScheduledJob', $scheduledJobId); - $scheduledJob->set('lastRun', $lastRun); + $scheduledJob->set('lastRun', $runTime); $entityManager->saveEntity($scheduledJob); $scheduledJobLog = $entityManager->getEntity('ScheduledJobLogRecord'); @@ -96,7 +98,7 @@ class ScheduledJob 'scheduledJobId' => $scheduledJobId, 'name' => $scheduledJob->get('name'), 'status' => $status, - 'executionTime' => $lastRun, + 'executionTime' => $runTime, )); $scheduledJobLogId = $entityManager->saveEntity($scheduledJobLog); From 4a1237cdcc62aa26dbad7448bbc54aaf1fc52bdf Mon Sep 17 00:00:00 2001 From: Taras Machyshyn Date: Fri, 1 May 2015 12:51:40 +0300 Subject: [PATCH 09/22] Translation corrections --- application/Espo/Resources/i18n/ru_RU/EmailTemplate.json | 2 +- install/core/i18n/ru_RU/install.json | 4 ++-- install/core/i18n/uk_UA/install.json | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/application/Espo/Resources/i18n/ru_RU/EmailTemplate.json b/application/Espo/Resources/i18n/ru_RU/EmailTemplate.json index b7d0e0ecc7..d003dfdf34 100644 --- a/application/Espo/Resources/i18n/ru_RU/EmailTemplate.json +++ b/application/Espo/Resources/i18n/ru_RU/EmailTemplate.json @@ -6,7 +6,7 @@ "body": "Тело", "subject": "Тема", "attachments": "Вложения", - "insertField": "Project-Id-Version: Russian Translation\nPOT-Creation-Date: \nPO-Revision-Date: \nLast-Translator: \nLanguage-Team: EspoCRM \nMIME-Version: 1.0\nContent-Type: text/plain; charset=UTF-8\nContent-Transfer-Encoding: 8bit\nLanguage: ru_RU\nX-Generator: Poedit 1.6.5\n" + "insertField": "" }, "links": { }, diff --git a/install/core/i18n/ru_RU/install.json b/install/core/i18n/ru_RU/install.json index 4baad7e77f..0fdb61a091 100644 --- a/install/core/i18n/ru_RU/install.json +++ b/install/core/i18n/ru_RU/install.json @@ -1,7 +1,7 @@ { "labels": { "Main page title": "Welcome to EspoCRM", - "Main page header": "Project-Id-Version: Russian Translation\nPOT-Creation-Date: \nPO-Revision-Date: \nLast-Translator: \nLanguage-Team: EspoCRM \nMIME-Version: 1.0\nContent-Type: text/plain; charset=UTF-8\nContent-Transfer-Encoding: 8bit\nLanguage: ru_RU\nX-Generator: Poedit 1.6.5\n", + "Main page header": "", "Start page title": "License Agreement", "Step1 page title": "License Agreement", "License Agreement": "License Agreement", @@ -120,7 +120,7 @@ "windows": "
1. Find the httpd.conf file (usually you will find it in a folder called conf, config or something along those lines)
\n2. Inside the httpd.conf file uncomment the line LoadModule rewrite_module modules/mod_rewrite.so (remove the pound '#' sign from in front of the line)
\n3. Also find the line ClearModuleList is uncommented then find and make sure that the line AddModule mod_rewrite.c is not commented out.\n
" }, "microsoft-iis": { - "windows": "Project-Id-Version: Russian Translation\nPOT-Creation-Date: \nPO-Revision-Date: \nLast-Translator: \nLanguage-Team: EspoCRM \nMIME-Version: 1.0\nContent-Type: text/plain; charset=UTF-8\nContent-Transfer-Encoding: 8bit\nLanguage: ru_RU\nX-Generator: Poedit 1.6.5\n" + "windows": "" } }, "modRewriteHelp": { diff --git a/install/core/i18n/uk_UA/install.json b/install/core/i18n/uk_UA/install.json index f3342469c8..e454436ccd 100644 --- a/install/core/i18n/uk_UA/install.json +++ b/install/core/i18n/uk_UA/install.json @@ -1,7 +1,7 @@ { "labels": { "Main page title": "Ласкаво просимо EspoCRM", - "Main page header": "Project-Id-Version: \nPOT-Creation-Date: \nPO-Revision-Date: 2015-04-09 15:16+0300\nLast-Translator: alihor \nLanguage-Team: EspoCRM \nLanguage: uk\nMIME-Version: 1.0\nContent-Type: text/plain; charset=UTF-8\nContent-Transfer-Encoding: 8bit\nPlural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);\nX-Generator: Virtaal 0.7.1\n", + "Main page header": "", "Start page title": "Ліцензійна Угода", "Step1 page title": "Ліцензійна Угода", "License Agreement": "Ліцензійна Угода", From f678253b056169deb61b449dcb0a754c56df1698 Mon Sep 17 00:00:00 2001 From: yuri Date: Mon, 4 May 2015 11:11:08 +0300 Subject: [PATCH 10/22] fix outbound email encoding --- application/Espo/Core/Mail/Sender.php | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/application/Espo/Core/Mail/Sender.php b/application/Espo/Core/Mail/Sender.php index 9f5186cad9..23752b613a 100644 --- a/application/Espo/Core/Mail/Sender.php +++ b/application/Espo/Core/Mail/Sender.php @@ -284,11 +284,18 @@ class Sender $message->setBody($body); - if (!$message->getHeaders()->has('content-type')) { - $contentTypeHeader = new \Zend\Mail\Header\ContentType(); - $message->getHeaders()->addHeader($contentTypeHeader); + if ($messageType == 'text/plain') { + if ($message->getHeaders()->has('content-type')) { + $message->getHeaders()->removeHeader('content-type'); + } + $message->getHeaders()->addHeaderLine('Content-Type', 'text/plain; charset=UTF-8'); + } else { + if (!$message->getHeaders()->has('content-type')) { + $contentTypeHeader = new \Zend\Mail\Header\ContentType(); + $message->getHeaders()->addHeader($contentTypeHeader); + } + $message->getHeaders()->get('content-type')->setType($messageType); } - $message->getHeaders()->get('content-type')->setType($messageType); $message->setEncoding('UTF-8'); From 951d68724b869a8e17e337ba0e636751ab96131c Mon Sep 17 00:00:00 2001 From: yuri Date: Mon, 4 May 2015 12:24:32 +0300 Subject: [PATCH 11/22] acl imporvements --- application/Espo/Acl/Email.php | 2 +- application/Espo/Core/Acl/Base.php | 25 ++++++++++++++ application/Espo/Core/Acl/Table.php | 33 +++++++++++++++++-- application/Espo/Core/AclManager.php | 4 +-- .../Espo/Resources/metadata/app/acl.json | 5 +++ frontend/client/src/acl.js | 20 ++++++----- 6 files changed, 75 insertions(+), 14 deletions(-) diff --git a/application/Espo/Acl/Email.php b/application/Espo/Acl/Email.php index 6dfa850d99..4be53b79db 100644 --- a/application/Espo/Acl/Email.php +++ b/application/Espo/Acl/Email.php @@ -28,7 +28,7 @@ use \Espo\ORM\Entity; class Email extends \Espo\Core\Acl\Base { - public function checkRead(User $user, Entity $entity, $data) + public function checkEntityRead(User $user, Entity $entity, $data) { if ($this->checkEntity($user, $entity, $data, 'read')) { return true; diff --git a/application/Espo/Core/Acl/Base.php b/application/Espo/Core/Acl/Base.php index feab20f736..a5ca7609ce 100644 --- a/application/Espo/Core/Acl/Base.php +++ b/application/Espo/Core/Acl/Base.php @@ -194,5 +194,30 @@ class Base implements Injectable } return false; } + + public function checkEntityDelete(User $user, Entity $entity, $data) + { + $result = $this->checkEntity($user, $entity, $data, 'delete'); + if (!$result) { + if (is_array($data)) { + if ($data['edit'] != 'no') { + if ($entity->has('createdById') && $entity->get('createdById') == $user->id) { + if (!$entity->has('assignedUserId')) { + return true; + } else { + if (!$entity->get('assignedUserId')) { + return true; + } + if ($entity->get('assignedUserId') == $entity->get('createdById')) { + return true; + } + } + } + } + } + } + + return $result; + } } diff --git a/application/Espo/Core/Acl/Table.php b/application/Espo/Core/Acl/Table.php index c12e593bac..bde8317ba4 100644 --- a/application/Espo/Core/Acl/Table.php +++ b/application/Espo/Core/Acl/Table.php @@ -166,11 +166,30 @@ class Table return $result; } + private function getScopeList() + { + $scopeList = []; + $scopes = $this->metadata->get('scopes'); + foreach ($scopes as $scope => $d) { + if (!empty($d['acl'])) { + $scopeList[] = $scope; + } + } + return $scopeList; + } + private function merge($tables) { $data = array(); + $scopeList = $this->getScopeList(); + foreach ($tables as $table) { - foreach ($table as $scope => $row) { + foreach ($scopeList as $scope) { + if (!isset($table->$scope)) { + continue; + } + $row = $table->$scope; + if ($row == false) { if (!isset($data[$scope])) { $data[$scope] = false; @@ -184,7 +203,8 @@ class Table if ($data[$scope] == false) { $data[$scope] = array(); } - if (is_array($row)) { + + if (is_array($row) || $row instanceof \stdClass) { foreach ($row as $action => $level) { if (!isset($data[$scope][$action])) { $data[$scope][$action] = $level; @@ -198,6 +218,15 @@ class Table } } } + + foreach ($scopeList as $scope) { + if (!array_key_exists($scope, $data)) { + $aclType = $this->metadata->get('scopes.' . $scope . '.acl'); + if (!empty($aclType) && ($aclType === true || $aclType === 'record')) { + $data[$scope] = $this->metadata->get('app.acl.recordDefault'); + } + } + } return $data; } diff --git a/application/Espo/Core/AclManager.php b/application/Espo/Core/AclManager.php index 1abe81b2ac..86b40f6e3d 100644 --- a/application/Espo/Core/AclManager.php +++ b/application/Espo/Core/AclManager.php @@ -149,13 +149,13 @@ class AclManager $entityType = $entity->getEntityType(); $impl = $this->getImplementation($entityType); - $methodName = 'check' . ucfirst($action); + $methodName = 'checkEntity' . ucfirst($action); if (method_exists($impl, $methodName)) { $data = $this->getTable($user)->getScopeData($entityType); return $impl->$methodName($user, $entity, $data); } - return $this->checkEntity($user, $entity, $action, $isOwner, $inTeam, $entity); + return $this->checkEntity($user, $entity, $action); } } } diff --git a/application/Espo/Resources/metadata/app/acl.json b/application/Espo/Resources/metadata/app/acl.json index 1a5b1f9f23..3d61a0d2dd 100644 --- a/application/Espo/Resources/metadata/app/acl.json +++ b/application/Espo/Resources/metadata/app/acl.json @@ -31,5 +31,10 @@ "delete": "own" }, "Role": false + }, + "recordDefault": { + "read": "all", + "edit": "all", + "delete": "no" } } diff --git a/frontend/client/src/acl.js b/frontend/client/src/acl.js index b481f24bd0..0a3387a0dc 100644 --- a/frontend/client/src/acl.js +++ b/frontend/client/src/acl.js @@ -75,25 +75,27 @@ _.extend(Espo.Acl.prototype, { return true; } - if (!value || value === 'no') { - return false; - } - if (typeof isOwner === 'undefined') { return true; } + if (isOwner && action == 'delete' && value === 'no') { + return this.check(controller, 'edit', isOwner); + } + + if (!value || value === 'no') { + return false; + } + if (isOwner) { if (value === 'own' || value === 'team') { return true; } } - //if (inTeam) { - if (value === 'team') { - return true; - } - //} + if (value === 'team') { + return true; + } return false; } From 0e2f8d9bf9fb70c7432f59b3fc3db579f233b96d Mon Sep 17 00:00:00 2001 From: yuri Date: Mon, 4 May 2015 15:15:39 +0300 Subject: [PATCH 12/22] fix email link --- .../Espo/Modules/Crm/Resources/metadata/entityDefs/Contact.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Contact.json b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Contact.json index 8bdcfe69e0..eaf8d88978 100644 --- a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Contact.json +++ b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Contact.json @@ -209,7 +209,7 @@ }, "emails": { "type": "hasChildren", - "entity": "Task", + "entity": "Email", "foreign": "parent", "layoutRelationshipsDisabled": true }, From 15b329580c01b05ebd3d785af4a1990b365b6fee Mon Sep 17 00:00:00 2001 From: yuri Date: Mon, 4 May 2015 15:19:41 +0300 Subject: [PATCH 13/22] fix layout --- .../res/templates/admin/layouts/rows.tpl | 2 +- .../client/src/views/admin/layouts/rows.js | 36 +++++++++---------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/frontend/client/res/templates/admin/layouts/rows.tpl b/frontend/client/res/templates/admin/layouts/rows.tpl index ed82c2c676..581669e233 100644 --- a/frontend/client/res/templates/admin/layouts/rows.tpl +++ b/frontend/client/res/templates/admin/layouts/rows.tpl @@ -92,7 +92,7 @@ {{#if ../editable}} -
+
{{/if}} {{/each}} diff --git a/frontend/client/src/views/admin/layouts/rows.js b/frontend/client/src/views/admin/layouts/rows.js index 2b3c7dd158..c1c3011719 100644 --- a/frontend/client/src/views/admin/layouts/rows.js +++ b/frontend/client/src/views/admin/layouts/rows.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('Views.Admin.Layouts.Rows', 'Views.Admin.Layouts.Base', function (Dep) { + ************************************************************************/ + +Espo.define('Views.Admin.Layouts.Rows', 'Views.Admin.Layouts.Base', function (Dep) { + + return Dep.extend({ - return Dep.extend({ - template: 'admin.layouts.rows', - + events: _.extend({ - 'click #layout a[data-action="editField"]': function (e) { + 'click #layout a[data-action="editField"]': function (e) { var data = {}; this.dataAttributes.forEach(function (attr) { data[attr] = $(e.target).closest('li').data(Espo.Utils.toDom(attr)) - }); + }); this.openEditDialog(data); }, }, Dep.prototype.events), - + dataAttributes: null, - + dataAttributesDefs: {}, - + editable: false, - + data: function () { return { scope: this.scope, @@ -54,14 +54,14 @@ Espo.define('Views.Admin.Layouts.Rows', 'Views.Admin.Layouts.Base', function (De dataAttributesDefs: this.dataAttributesDefs, editable: this.editable, }; - }, - + }, + afterRender: function () { $('#layout ul.enabled, #layout ul.disabled').sortable({ connectWith: '#layout ul.connected' }); }, - + fetch: function () { var layout = []; $("#layout ul.enabled > li").each(function (i, el) { @@ -71,19 +71,19 @@ Espo.define('Views.Admin.Layouts.Rows', 'Views.Admin.Layouts.Base', function (De if (value) { o[attr] = value; } - }); + }); layout.push(o); }.bind(this)); return layout; }, - + validate: function (layout) { if (layout.length == 0) { this.notify('Layout cannot be empty', 'error'); return false; } return true; - }, + } }); }); From 8d3da43dcac4971682afd759830617395f2f1a34 Mon Sep 17 00:00:00 2001 From: yuri Date: Mon, 4 May 2015 15:23:25 +0300 Subject: [PATCH 14/22] list buttonDisabled --- frontend/client/src/views/modals/select-records.js | 2 +- frontend/client/src/views/record/list.js | 9 +++++++-- frontend/client/src/views/record/panels/relationship.js | 2 +- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/frontend/client/src/views/modals/select-records.js b/frontend/client/src/views/modals/select-records.js index 905af5545a..8530c72a37 100644 --- a/frontend/client/src/views/modals/select-records.js +++ b/frontend/client/src/views/modals/select-records.js @@ -148,7 +148,7 @@ Espo.define('Views.Modals.SelectRecords', 'Views.Modal', function (Dep) { type: 'listSmall', searchManager: searchManager, checkAllResultDisabled: !this.massRelateEnabled, - disableButtons: true + buttonsDisabled: true }, function (list) { list.once('select', function (model) { this.trigger('select', model); diff --git a/frontend/client/src/views/record/list.js b/frontend/client/src/views/record/list.js index cf552a5cc3..0cf04d4285 100644 --- a/frontend/client/src/views/record/list.js +++ b/frontend/client/src/views/record/list.js @@ -199,6 +199,8 @@ Espo.define('Views.Record.List', 'View', function (Dep) { checkAllResultDisabled: false, + buttonsDisabled: false, + allResultIsChecked: false, data: function () { @@ -218,7 +220,7 @@ Espo.define('Views.Record.List', 'View', function (Dep) { checkboxes: this.checkboxes, massActionList: this.massActionList, rows: this.rows, - topBar: paginationTop || this.checkboxes || (this.buttonList.length && !this.disableButtons), + topBar: paginationTop || this.checkboxes || (this.buttonList.length && !this.buttonsDisabled), bottomBar: paginationBottom, checkAllResultDisabled: this.checkAllResultDisabled, buttonList: this.buttonList @@ -235,7 +237,10 @@ Espo.define('Views.Record.List', 'View', function (Dep) { this.rowActionsView = _.isUndefined(this.options.rowActionsView) ? this.rowActionsView : this.options.rowActionsView; this.showMore = _.isUndefined(this.options.showMore) ? this.showMore : this.options.showMore; - this.disableButtons = this.options.disableButtons || false; + + if ('buttonsDisabled' in this.options) { + this.buttonsDisabled = this.options.buttonsDisabled; + } if ('checkAllResultDisabled' in this.options) { this.checkAllResultDisabled = this.options.checkAllResultDisabled; diff --git a/frontend/client/src/views/record/panels/relationship.js b/frontend/client/src/views/record/panels/relationship.js index de623acdb6..41b097d07d 100644 --- a/frontend/client/src/views/record/panels/relationship.js +++ b/frontend/client/src/views/record/panels/relationship.js @@ -113,7 +113,7 @@ Espo.define('Views.Record.Panels.Relationship', ['Views.Record.Panels.Bottom', ' listLayout: listLayout, checkboxes: false, rowActionsView: this.defs.readOnly ? false : (this.defs.rowActionsView || this.rowActionsView), - disableButtons: true, + buttonsDisabled: true, el: this.options.el + ' .list-container', }, function (view) { view.render(); From bc7d4f214fb71e321fcf956ed91d5e76f4e13394 Mon Sep 17 00:00:00 2001 From: yuri Date: Mon, 4 May 2015 15:34:03 +0300 Subject: [PATCH 15/22] fix email preview --- frontend/client/src/views/email/modals/detail.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/frontend/client/src/views/email/modals/detail.js b/frontend/client/src/views/email/modals/detail.js index 48a25e6f1d..9b22bbbaad 100644 --- a/frontend/client/src/views/email/modals/detail.js +++ b/frontend/client/src/views/email/modals/detail.js @@ -31,11 +31,13 @@ Espo.define('Views.Email.Modals.Detail', ['Views.Modals.Detail', 'Views.Email.De 'label': 'Reply', 'style': 'danger' }); - this.listenToOnce(this.model, 'sync', function () { - setTimeout(function () { - this.model.set('isRead', true); - }.bind(this), 50); - }, this); + if (this.model) { + this.listenToOnce(this.model, 'sync', function () { + setTimeout(function () { + this.model.set('isRead', true); + }.bind(this), 50); + }, this); + } }, From d22ce60f7b5808a7a6a58b292705b16275b8c771 Mon Sep 17 00:00:00 2001 From: yuri Date: Mon, 4 May 2015 15:48:58 +0300 Subject: [PATCH 16/22] fix link manager --- frontend/client/src/views/admin/link-manager/index.js | 2 +- frontend/client/src/views/admin/link-manager/modals/edit.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/client/src/views/admin/link-manager/index.js b/frontend/client/src/views/admin/link-manager/index.js index da01e6e838..2b3b6dadec 100644 --- a/frontend/client/src/views/admin/link-manager/index.js +++ b/frontend/client/src/views/admin/link-manager/index.js @@ -167,7 +167,7 @@ Espo.define('Views.Admin.LinkManager.Index', 'View', function (Dep) { this.getMetadata().load(function () { this.setupLinkData(); this.render(); - }.bind(this)); + }.bind(this), true); }.bind(this)); }, diff --git a/frontend/client/src/views/admin/link-manager/modals/edit.js b/frontend/client/src/views/admin/link-manager/modals/edit.js index a43cd25f3b..1d95257bce 100644 --- a/frontend/client/src/views/admin/link-manager/modals/edit.js +++ b/frontend/client/src/views/admin/link-manager/modals/edit.js @@ -343,7 +343,7 @@ Espo.define('Views.Admin.LinkManager.Modals.Edit', ['Views.Modal', 'Views.Admin. this.getMetadata().load(function () { this.trigger('after:save'); this.close(); - }.bind(this)); + }.bind(this), true); }.bind(this)); }, From 6d8017f1dc78749f29b3ce39183d18996c1dd590 Mon Sep 17 00:00:00 2001 From: yuri Date: Mon, 4 May 2015 16:00:03 +0300 Subject: [PATCH 17/22] fix link manager --- application/Espo/Core/Utils/EntityManager.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/application/Espo/Core/Utils/EntityManager.php b/application/Espo/Core/Utils/EntityManager.php index 3eb3a791c0..66563e8765 100644 --- a/application/Espo/Core/Utils/EntityManager.php +++ b/application/Espo/Core/Utils/EntityManager.php @@ -343,6 +343,10 @@ class EntityManager ) ) ); + if ($entityForeign == $entity) { + $dataLeft['links'][$link]['midKeys'] = ['leftId', 'rightId']; + $dataRight['links'][$linkForeign]['midKeys'] = ['rightId', 'leftId']; + } break; } From e36ee5aafffd89c2f087c4aaaea5156b43ccba85 Mon Sep 17 00:00:00 2001 From: yuri Date: Tue, 5 May 2015 10:14:03 +0300 Subject: [PATCH 18/22] link multiple
--- frontend/client/src/views/fields/link-multiple.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/client/src/views/fields/link-multiple.js b/frontend/client/src/views/fields/link-multiple.js index 6d778c477d..f48b3a1e98 100644 --- a/frontend/client/src/views/fields/link-multiple.js +++ b/frontend/client/src/views/fields/link-multiple.js @@ -220,7 +220,7 @@ Espo.define('Views.Fields.LinkMultiple', 'Views.Fields.Base', function (Dep) { this.ids.forEach(function (id) { names.push(this.getDetailLinkHtml(id)); }, this); - return names.join(', '); + return '
' + names.join('
') + '
'; } }, From 50f9f24887cd23eeeb5d8188990e5607d58f3e20 Mon Sep 17 00:00:00 2001 From: Taras Machyshyn Date: Tue, 5 May 2015 10:29:52 +0300 Subject: [PATCH 19/22] OrmMetadata: fixed 'midKeys' merging priority --- .../Espo/Core/Utils/Database/Orm/Relations/Base.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/application/Espo/Core/Utils/Database/Orm/Relations/Base.php b/application/Espo/Core/Utils/Database/Orm/Relations/Base.php index 5af5cbc822..fb79d2d3de 100644 --- a/application/Espo/Core/Utils/Database/Orm/Relations/Base.php +++ b/application/Espo/Core/Utils/Database/Orm/Relations/Base.php @@ -22,6 +22,8 @@ namespace Espo\Core\Utils\Database\Orm\Relations; +use Espo\Core\Utils\Util; + class Base extends \Espo\Core\Utils\Database\Orm\Base { private $params; @@ -119,8 +121,11 @@ class Base extends \Espo\Core\Utils\Database\Orm\Base $additionalParrams = $this->getAllowedAdditionalParams($name); - if (isset($additionalParrams) && !isset($linkParams[$name])) { + if (isset($additionalParrams)) { $linkParams[$name] = $additionalParrams; + if (isset($linkParams[$name]) && is_array($linkParams[$name])) { + $linkParams[$name] = Util::merge($linkParams[$name], $additionalParrams); + } } } } From 4037ffa295fa05d56a22c1a8b0d37ae3b83f1704 Mon Sep 17 00:00:00 2001 From: Taras Machyshyn Date: Tue, 5 May 2015 10:49:44 +0300 Subject: [PATCH 20/22] Changed 'relationName' to camelCase --- .../Crm/Resources/metadata/entityDefs/Account.json | 2 +- .../Crm/Resources/metadata/entityDefs/Call.json | 2 +- .../Crm/Resources/metadata/entityDefs/Campaign.json | 2 +- .../Crm/Resources/metadata/entityDefs/Case.json | 2 +- .../Crm/Resources/metadata/entityDefs/Contact.json | 2 +- .../Crm/Resources/metadata/entityDefs/Document.json | 2 +- .../Crm/Resources/metadata/entityDefs/Lead.json | 2 +- .../Crm/Resources/metadata/entityDefs/Meeting.json | 2 +- .../Crm/Resources/metadata/entityDefs/Opportunity.json | 2 +- .../Crm/Resources/metadata/entityDefs/Target.json | 2 +- .../Crm/Resources/metadata/entityDefs/TargetList.json | 2 +- .../Crm/Resources/metadata/entityDefs/Task.json | 2 +- .../Espo/Resources/metadata/entityDefs/Email.json | 10 +++++----- .../Resources/metadata/entityDefs/EmailTemplate.json | 2 +- .../Espo/Resources/metadata/entityDefs/Note.json | 2 +- 15 files changed, 19 insertions(+), 19 deletions(-) diff --git a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Account.json b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Account.json index 0eb4be02e9..c485c81b2b 100644 --- a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Account.json +++ b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Account.json @@ -147,7 +147,7 @@ "teams": { "type": "hasMany", "entity": "Team", - "relationName": "EntityTeam", + "relationName": "entityTeam", "layoutRelationshipsDisabled": true }, "contacts": { diff --git a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Call.json b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Call.json index 0a265e749e..90a4e23df7 100644 --- a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Call.json +++ b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Call.json @@ -127,7 +127,7 @@ "teams": { "type": "hasMany", "entity": "Team", - "relationName": "EntityTeam", + "relationName": "entityTeam", "layoutRelationshipsDisabled": true }, "users": { diff --git a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Campaign.json b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Campaign.json index c1e74a3f9c..c22b9c1977 100644 --- a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Campaign.json +++ b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Campaign.json @@ -137,7 +137,7 @@ "teams": { "type": "hasMany", "entity": "Team", - "relationName": "EntityTeam", + "relationName": "entityTeam", "layoutRelationshipsDisabled": true }, "targetLists": { diff --git a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Case.json b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Case.json index 61b80cade9..b9b5f21453 100644 --- a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Case.json +++ b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Case.json @@ -84,7 +84,7 @@ "teams": { "type": "hasMany", "entity": "Team", - "relationName": "EntityTeam", + "relationName": "entityTeam", "layoutRelationshipsDisabled": true }, "inboundEmail": { diff --git a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Contact.json b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Contact.json index eaf8d88978..e453109d00 100644 --- a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Contact.json +++ b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Contact.json @@ -160,7 +160,7 @@ "teams": { "type": "hasMany", "entity": "Team", - "relationName": "EntityTeam", + "relationName": "entityTeam", "layoutRelationshipsDisabled": true }, "account": { diff --git a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Document.json b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Document.json index 1ad451894b..af7117e22a 100644 --- a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Document.json +++ b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Document.json @@ -90,7 +90,7 @@ "teams": { "type": "hasMany", "entity": "Team", - "relationName": "EntityTeam", + "relationName": "entityTeam", "layoutRelationshipsDisabled": true } }, diff --git a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Lead.json b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Lead.json index fb7b1782c6..d08793c78e 100644 --- a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Lead.json +++ b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Lead.json @@ -169,7 +169,7 @@ "teams": { "type": "hasMany", "entity": "Team", - "relationName": "EntityTeam", + "relationName": "entityTeam", "layoutRelationshipsDisabled": true }, "opportunities": { diff --git a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Meeting.json b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Meeting.json index 02c68c1132..1b4a690921 100644 --- a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Meeting.json +++ b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Meeting.json @@ -122,7 +122,7 @@ "teams": { "type": "hasMany", "entity": "Team", - "relationName": "EntityTeam", + "relationName": "entityTeam", "layoutRelationshipsDisabled": true }, "users": { diff --git a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Opportunity.json b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Opportunity.json index f747c9d063..a040914f20 100644 --- a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Opportunity.json +++ b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Opportunity.json @@ -106,7 +106,7 @@ "teams": { "type": "hasMany", "entity": "Team", - "relationName": "EntityTeam", + "relationName": "entityTeam", "layoutRelationshipsDisabled": true }, "account": { diff --git a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Target.json b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Target.json index 16cf261612..81cb7b0046 100644 --- a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Target.json +++ b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Target.json @@ -103,7 +103,7 @@ "teams": { "type": "hasMany", "entity": "Team", - "relationName": "EntityTeam", + "relationName": "entityTeam", "layoutRelationshipsDisabled": true } }, diff --git a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/TargetList.json b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/TargetList.json index 43bb241021..463b37343b 100644 --- a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/TargetList.json +++ b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/TargetList.json @@ -55,7 +55,7 @@ "teams": { "type": "hasMany", "entity": "Team", - "relationName": "EntityTeam", + "relationName": "entityTeam", "layoutRelationshipsDisabled": true }, "campaigns": { diff --git a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Task.json b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Task.json index 0390e02be7..0ac1b27d69 100644 --- a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Task.json +++ b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Task.json @@ -97,7 +97,7 @@ "teams": { "type": "hasMany", "entity": "Team", - "relationName": "EntityTeam", + "relationName": "entityTeam", "layoutRelationshipsDisabled": true }, "parent": { diff --git a/application/Espo/Resources/metadata/entityDefs/Email.json b/application/Espo/Resources/metadata/entityDefs/Email.json index ed56cd3168..8b0c9ef6b8 100644 --- a/application/Espo/Resources/metadata/entityDefs/Email.json +++ b/application/Espo/Resources/metadata/entityDefs/Email.json @@ -174,7 +174,7 @@ "teams": { "type": "hasMany", "entity": "Team", - "relationName": "EntityTeam" + "relationName": "entityTeam" }, "users": { "type": "hasMany", @@ -191,7 +191,7 @@ "type": "hasChildren", "entity": "Attachment", "foreign": "parent", - "relationName": "Attachments" + "relationName": "attachments" }, "parent": { "type": "belongsToParent", @@ -205,7 +205,7 @@ "toEmailAddresses": { "type": "hasMany", "entity": "EmailAddress", - "relationName": "EmailEmailAddress", + "relationName": "emailEmailAddress", "conditions": { "addressType": "to" }, @@ -219,7 +219,7 @@ "ccEmailAddresses": { "type": "hasMany", "entity": "EmailAddress", - "relationName": "EmailEmailAddress", + "relationName": "emailEmailAddress", "conditions": { "addressType": "cc" }, @@ -233,7 +233,7 @@ "bccEmailAddresses": { "type": "hasMany", "entity": "EmailAddress", - "relationName": "EmailEmailAddress", + "relationName": "emailEmailAddress", "conditions": { "addressType": "bcc" }, diff --git a/application/Espo/Resources/metadata/entityDefs/EmailTemplate.json b/application/Espo/Resources/metadata/entityDefs/EmailTemplate.json index 9bada69af1..574bcae10b 100644 --- a/application/Espo/Resources/metadata/entityDefs/EmailTemplate.json +++ b/application/Espo/Resources/metadata/entityDefs/EmailTemplate.json @@ -52,7 +52,7 @@ "teams": { "type": "hasMany", "entity": "Team", - "relationName": "EntityTeam" + "relationName": "entityTeam" }, "assignedUser": { "type": "belongsTo", diff --git a/application/Espo/Resources/metadata/entityDefs/Note.json b/application/Espo/Resources/metadata/entityDefs/Note.json index 8abb61dc77..f059ed0190 100644 --- a/application/Espo/Resources/metadata/entityDefs/Note.json +++ b/application/Espo/Resources/metadata/entityDefs/Note.json @@ -49,7 +49,7 @@ "attachments": { "type": "hasChildren", "entity": "Attachment", - "relationName": "Attachments", + "relationName": "attachments", "foreign": "parent" }, "parent": { From c0c77e6e6b0eb9bc6e8883ccd5598ec9712b4249 Mon Sep 17 00:00:00 2001 From: yuri Date: Tue, 5 May 2015 11:23:35 +0300 Subject: [PATCH 21/22] task attachments --- .../Espo/Modules/Crm/Resources/i18n/en_US/Task.json | 4 +++- .../Modules/Crm/Resources/layouts/Task/detail.json | 3 ++- .../Crm/Resources/metadata/entityDefs/Task.json | 11 +++++++++++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/application/Espo/Modules/Crm/Resources/i18n/en_US/Task.json b/application/Espo/Modules/Crm/Resources/i18n/en_US/Task.json index b2717ea7ba..3b833dc12e 100644 --- a/application/Espo/Modules/Crm/Resources/i18n/en_US/Task.json +++ b/application/Espo/Modules/Crm/Resources/i18n/en_US/Task.json @@ -11,9 +11,11 @@ "description": "Description", "isOverdue": "Is Overdue", "account": "Account", - "dateCompleted": "Date Completed" + "dateCompleted": "Date Completed", + "attachments": "Attachments" }, "links": { + "attachments": "Attachments" }, "options": { "status": { diff --git a/application/Espo/Modules/Crm/Resources/layouts/Task/detail.json b/application/Espo/Modules/Crm/Resources/layouts/Task/detail.json index 8ff25afd2b..77ebe31c17 100644 --- a/application/Espo/Modules/Crm/Resources/layouts/Task/detail.json +++ b/application/Espo/Modules/Crm/Resources/layouts/Task/detail.json @@ -7,7 +7,8 @@ {"name":"priority"}], [{"name":"dateStart"},{"name":"dateCompleted"}], [{"name":"dateEnd"},false], - [{"name":"description", "fullWidth": true}] + [{"name":"description", "fullWidth": true}], + [{"name":"attachments"},false] ] } ] \ No newline at end of file diff --git a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Task.json b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Task.json index 0390e02be7..1956fbe2d2 100644 --- a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Task.json +++ b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Task.json @@ -79,6 +79,10 @@ }, "teams": { "type": "linkMultiple" + }, + "attachments": { + "type": "linkMultiple", + "view": "Fields.AttachmentMultiple" } }, "links": { @@ -108,6 +112,13 @@ "account": { "type": "belongsTo", "entity": "Account" + }, + "attachments": { + "type": "hasChildren", + "entity": "Attachment", + "foreign": "parent", + "relationName": "attachments", + "layoutRelationshipsDisabled": true } }, "collection": { From 3067abcac2f642e8558d7439fa67d4019a319ffa Mon Sep 17 00:00:00 2001 From: yuri Date: Tue, 5 May 2015 11:30:29 +0300 Subject: [PATCH 22/22] save calendar view --- .../modules/crm/src/views/calendar/calendar-page.js | 11 +++++++++-- .../client/modules/crm/src/views/calendar/calendar.js | 1 + 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/frontend/client/modules/crm/src/views/calendar/calendar-page.js b/frontend/client/modules/crm/src/views/calendar/calendar-page.js index e57de5a456..624b673c69 100644 --- a/frontend/client/modules/crm/src/views/calendar/calendar-page.js +++ b/frontend/client/modules/crm/src/views/calendar/calendar-page.js @@ -28,9 +28,13 @@ Espo.define('Crm:Views.Calendar.CalendarPage', 'View', function (Dep) { el: '#main', setup: function () { + var mode = this.options.mode || null; + if (!mode) { + var mode = this.getStorage().get('state', 'calendarMode') || null; + } this.createView('calendar', 'Crm:Calendar.Calendar', { date: this.options.date, - mode: this.options.mode, + mode: mode, el: '#main > .calendar-container', }, function (view) { var first = true; @@ -39,7 +43,10 @@ Espo.define('Crm:Views.Calendar.CalendarPage', 'View', function (Dep) { this.getRouter().navigate('#Calendar/show/date=' + date + '&mode=' + mode); } first = false; - }.bind(this)); + }, this); + this.listenTo(view, 'change:mode', function (mode) { + this.getStorage().set('state', 'calendarMode', mode); + }, this); }.bind(this)); }, diff --git a/frontend/client/modules/crm/src/views/calendar/calendar.js b/frontend/client/modules/crm/src/views/calendar/calendar.js index fe8e183f7a..700ce10cb9 100644 --- a/frontend/client/modules/crm/src/views/calendar/calendar.js +++ b/frontend/client/modules/crm/src/views/calendar/calendar.js @@ -80,6 +80,7 @@ Espo.define('Crm:Views.Calendar.Calendar', ['View', 'lib!FullCalendar'], functio this.$el.find('button[data-mode="' + mode + '"]').addClass('active'); this.$calendar.fullCalendar('changeView', mode); this.updateDate(); + this.trigger('change:mode', mode); }, 'click [data-action="refresh"]': function (e) { this.$calendar.fullCalendar('refetchEvents');