From f3bc4dbccfac11041441dd4a3a52d7a4342c7b15 Mon Sep 17 00:00:00 2001 From: yuri Date: Mon, 30 Mar 2015 13:39:14 +0300 Subject: [PATCH] import dev --- application/Espo/Modules/Crm/Repositories/Lead.php | 7 +++++++ .../Modules/Crm/Resources/i18n/en_US/Lead.json | 3 ++- .../Crm/Resources/metadata/entityDefs/Lead.json | 9 +++++++++ application/Espo/Modules/Crm/Services/Lead.php | 3 --- .../Espo/Resources/metadata/fields/currency.json | 1 - frontend/client/src/views/import/step2.js | 14 ++++++++++++-- 6 files changed, 30 insertions(+), 7 deletions(-) diff --git a/application/Espo/Modules/Crm/Repositories/Lead.php b/application/Espo/Modules/Crm/Repositories/Lead.php index 8240543c9d..0f030dda06 100644 --- a/application/Espo/Modules/Crm/Repositories/Lead.php +++ b/application/Espo/Modules/Crm/Repositories/Lead.php @@ -26,6 +26,13 @@ use Espo\ORM\Entity; class Lead extends \Espo\Core\ORM\Repositories\RDB { + public function afterSave(Entity $entity, array $options) + { + parent::afterSave($entity, $options); + if ($entity->has('targetListId') && $entity->isNew()) { + $this->relate($entity, 'targetLists', $entity->get('targetListId')); + } + } } 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 e69af589f2..7dffd715a2 100644 --- a/application/Espo/Modules/Crm/Resources/i18n/en_US/Lead.json +++ b/application/Espo/Modules/Crm/Resources/i18n/en_US/Lead.json @@ -22,7 +22,8 @@ "createdContact": "Contact", "createdOpportunity": "Opportunity", "campaign": "Campaign", - "targetLists": "Target Lists" + "targetLists": "Target Lists", + "targetList": "Target List" }, "links": { "targetLists": "Target Lists", diff --git a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Lead.json b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Lead.json index e2ca65b62b..787b74b78a 100644 --- a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Lead.json +++ b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Lead.json @@ -142,6 +142,15 @@ "layoutMassUpdateDisabled": true, "noLoad": true, "noSave": true + }, + "targetList": { + "type": "link", + "notStorable": true, + "layoutDetailDisabled": true, + "layoutListDisabled": true, + "layoutMassUpdateDisabled": true, + "layoutSearchDisabled": true, + "entity": "TargetList" } }, "links": { diff --git a/application/Espo/Modules/Crm/Services/Lead.php b/application/Espo/Modules/Crm/Services/Lead.php index aa6283dd87..12d833d56e 100644 --- a/application/Espo/Modules/Crm/Services/Lead.php +++ b/application/Espo/Modules/Crm/Services/Lead.php @@ -68,9 +68,6 @@ class Lead extends \Espo\Services\Record $this->getEntityManager()->saveEntity($email); } } - if (!empty($data['targetListId'])) { - $this->getEntityManager()->getRepository('Lead')->relate($entity, 'targetLists', $data['targetListId']); - } if ($entity->get('campaignId')) { $campaign = $this->getEntityManager()->getEntity('Campaign', $entity->get('campaignId')); if ($campaign) { diff --git a/application/Espo/Resources/metadata/fields/currency.json b/application/Espo/Resources/metadata/fields/currency.json index 92581559d4..c083ad3e8c 100644 --- a/application/Espo/Resources/metadata/fields/currency.json +++ b/application/Espo/Resources/metadata/fields/currency.json @@ -16,7 +16,6 @@ ], "actualFields":[ "currency", - "converted", "" ], "fields":{ diff --git a/frontend/client/src/views/import/step2.js b/frontend/client/src/views/import/step2.js index 628e15ba6e..0ef40546ea 100644 --- a/frontend/client/src/views/import/step2.js +++ b/frontend/client/src/views/import/step2.js @@ -135,6 +135,10 @@ Espo.define('Views.Import.Step2', 'View', function (Dep) { var fieldList = []; for (var field in defs) { + var d = defs[field]; + if (d.readOnly) { + continue; + } fieldList.push(field); } @@ -152,7 +156,11 @@ Espo.define('Views.Import.Step2', 'View', function (Dep) { for (var field in fields) { var d = fields[field]; - if (['modifiedBy', 'createdBy', 'modifiedAt', 'createdAt'].indexOf(field) !== -1) { + if (d.readOnly) { + continue; + } + + if (~['modifiedBy', 'createdBy', 'modifiedAt', 'createdAt'].indexOf(field)) { continue; } @@ -161,7 +169,7 @@ Espo.define('Views.Import.Step2', 'View', function (Dep) { fieldList.push(field + 'Id'); } - if (['linkMultiple', 'foreign'].indexOf(d.type) !== -1) { + if (~['linkMultiple', 'foreign'].indexOf(d.type)) { continue; } @@ -178,6 +186,8 @@ Espo.define('Views.Import.Step2', 'View', function (Dep) { }, this); } + console.log(fieldList); + $select = $('