Skip to content
This repository has been archived by the owner on Nov 13, 2021. It is now read-only.

Commit

Permalink
1.8.1
Browse files Browse the repository at this point in the history
  • Loading branch information
r.ratsun committed Apr 6, 2018
1 parent ce42f73 commit b712a81
Show file tree
Hide file tree
Showing 38 changed files with 182 additions and 46 deletions.
38 changes: 31 additions & 7 deletions application/Espo/Modules/TreoCore/Metadata/Metadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,33 +88,35 @@ protected function prepareOwners(array $data): array
{
foreach ($data['entityDefs'] as $ent => $row) {
// unset ownerUser
if (isset($data['scopes'][$ent]['hasOwner']) && empty($data['scopes'][$ent]['hasOwner'])) {
if (empty($data['scopes'][$ent]['hasOwner'])) {
if (isset($data['entityDefs'][$ent]['fields']['ownerUser'])) {
unset($data['entityDefs'][$ent]['fields']['ownerUser']);
}
if (isset($data['entityDefs'][$ent]['links']['ownerUser'])) {
unset($data['entityDefs'][$ent]['links']['ownerUser']);
}
if (isset($data['entityDefs'][$ent]['indexes']['ownerUser'])) {
unset($data['entityDefs'][$ent]['indexes']['ownerUser']);
if (isset($data['entityDefs'][$ent]['indexes'])) {
$data['entityDefs'][$ent]['indexes'] = $this
->removeFieldFromIndex($data['entityDefs'][$ent]['indexes'], 'ownerUserId');
}
}

// unset assignedUser
if (isset($data['scopes'][$ent]['hasAssignedUser']) && empty($data['scopes'][$ent]['hasAssignedUser'])) {
if (empty($data['scopes'][$ent]['hasAssignedUser'])) {
if (isset($data['entityDefs'][$ent]['fields']['assignedUser'])) {
unset($data['entityDefs'][$ent]['fields']['assignedUser']);
}
if (isset($data['entityDefs'][$ent]['links']['assignedUser'])) {
unset($data['entityDefs'][$ent]['links']['assignedUser']);
}
if (isset($data['entityDefs'][$ent]['indexes']['assignedUser'])) {
unset($data['entityDefs'][$ent]['indexes']['assignedUser']);
if (isset($data['entityDefs'][$ent]['indexes'])) {
$data['entityDefs'][$ent]['indexes'] = $this
->removeFieldFromIndex($data['entityDefs'][$ent]['indexes'], 'assignedUserId');
}
}

// unset team
if (isset($data['scopes'][$ent]['hasTeam']) && empty($data['scopes'][$ent]['hasTeam'])) {
if (empty($data['scopes'][$ent]['hasTeam'])) {
if (isset($data['entityDefs'][$ent]['fields']['teams'])) {
unset($data['entityDefs'][$ent]['fields']['teams']);
}
Expand All @@ -127,6 +129,28 @@ protected function prepareOwners(array $data): array
return $data;
}

/**
* Remove field from index
*
* @param array $indexes
* @param string $fieldName
*
* @return array
*/
protected function removeFieldFromIndex(array $indexes, string $fieldName): array
{
foreach ($indexes as $indexName => $fields) {
// search field in index
$key = array_search($fieldName, $fields['columns']);
// remove field if exists
if ($key !== false) {
unset($indexes[$indexName]['columns'][$key]);
}
}

return $indexes;
}

/**
* Delete activities from CRM entity
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
"views/modal": [
"treo-core"
],
"views/modals/select-records": [
"treo-core"
],
"views/record/base": [
"treo-core"
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,8 @@ protected function loadModulesPackages(bool $droppingCache = false): void
if (is_array($versions)) {
$max = null;
foreach ($versions as $version => $data) {
if (!empty($treoId = $data['extra']['treoId'])) {
if (!empty($data['extra']['treoId'])) {
$treoId = $data['extra']['treoId'];
if (preg_match_all('/^v\d.\d.\d$/', $version, $matches)
|| preg_match_all('/^\d.\d.\d$/', $version, $matches)) {
// prepare version
Expand Down
17 changes: 12 additions & 5 deletions application/Espo/Modules/TreoCore/Services/RestApiDocs.php
Original file line number Diff line number Diff line change
Expand Up @@ -337,10 +337,12 @@ protected function getResponseBody(array $docs, int $counter, string $entity): s
if (isset($row['sample'])) {
// prepare route
$route = $docs['ApiRoute'][0]['name'];
// prepare method
$method = $docs['ApiMethod'][0]['type'];

$tr = [
'{{ elt_id }}' => $counter,
'{{ response }}' => $this->getEntityFields($row['sample'], $entity, $route)
'{{ response }}' => $this->getEntityFields($row['sample'], $entity, $route, $method)
];

// push data
Expand Down Expand Up @@ -441,10 +443,14 @@ protected function generateBodyTemplate($id, $docs, $entity): string
if (!empty($docs['ApiBody'])) {
// prepare route
$route = $docs['ApiRoute'][0]['name'];
// prepares sample
$sample = $docs['ApiBody'][0]['sample'];
// prepare method
$method = $docs["ApiMethod"][0]["type"];

$content = [
'{{ elt_id }}' => $id,
'{{ body }}' => $this->getEntityFields($docs['ApiBody'][0]['sample'], $entity, $route, true)
'{{ body }}' => $this->getEntityFields($sample, $entity, $route, $method, true)
];
$result = strtr($this->getTemplateContent('Parts/sample-post-body'), $content);
}
Expand Down Expand Up @@ -705,18 +711,19 @@ protected function prepareApiParams(array $docs, string $entity): array
* @param string $sample
* @param string $entity
* @param string $route
* @param bool $isBody
* @param string $method
* @param bool $isBody
*
* @return string
*/
protected function getEntityFields($sample, string $entity, string $route, bool $isBody = false)
protected function getEntityFields($sample, string $entity, string $route, string $method, bool $isBody = false)
{
// prepare sample
if (is_string($sample) && strpos($sample, '{entityDeff}') !== false) {
// get entity defs
$entityDeffs = $this->getResponseEntityData($entity);

if (!$isGet) {
if ($method !== 'GET') {
unset($entityDeffs['id']);
}

Expand Down
2 changes: 1 addition & 1 deletion application/Espo/Resources/metadata/scopes/Attachment.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"entity":true,"layouts":false,"tab":false,"acl":false,"customizable":false}
{"entity":true,"layouts":false,"tab":false,"acl":false,"customizable":false,"hasAssignedUser":true}
3 changes: 2 additions & 1 deletion application/Espo/Resources/metadata/scopes/AuthToken.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
"layouts": false,
"tab": false,
"acl": false,
"customizable":false
"customizable":false,
"hasAssignedUser":true
}
2 changes: 1 addition & 1 deletion application/Espo/Resources/metadata/scopes/Currency.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"entity":true,"layouts":false,"tab":false,"acl":false,"customizable":false}
{"entity":true,"layouts":false,"tab":false,"acl":false,"customizable":false,"hasAssignedUser":true}
3 changes: 2 additions & 1 deletion application/Espo/Resources/metadata/scopes/Dashboard.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
"layouts":false,
"tab":false,
"acl":false,
"customizable":false
"customizable":false,
"hasAssignedUser":true
}
3 changes: 2 additions & 1 deletion application/Espo/Resources/metadata/scopes/Email.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@
"customizable": true,
"activity": true,
"activityStatusList": ["Draft"],
"historyStatusList": ["Archived", "Sent"]
"historyStatusList": ["Archived", "Sent"],
"hasAssignedUser":true
}
3 changes: 2 additions & 1 deletion application/Espo/Resources/metadata/scopes/EmailAccount.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
"entity": true,
"layouts": false,
"tab": false,
"acl": false
"acl": false,
"hasAssignedUser":true
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
"entity": false,
"layouts": false,
"tab": false,
"acl": "boolean"
"acl": "boolean",
"hasAssignedUser":true
}
3 changes: 2 additions & 1 deletion application/Espo/Resources/metadata/scopes/EmailAddress.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
"layouts": false,
"tab": false,
"acl": false,
"customizable":false
"customizable":false,
"hasAssignedUser":true
}
3 changes: 2 additions & 1 deletion application/Espo/Resources/metadata/scopes/EmailFilter.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@
"acl": false,
"notifications": false,
"object": false,
"customizable": false
"customizable": false,
"hasAssignedUser":true
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
"layouts": false,
"tab": true,
"acl": true,
"customizable":false
"customizable":false,
"hasAssignedUser":true
}
3 changes: 2 additions & 1 deletion application/Espo/Resources/metadata/scopes/Extension.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
"layouts": false,
"tab": false,
"acl": false,
"customizable": false
"customizable": false,
"hasAssignedUser":true
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
"tab":false,
"acl": "boolean",
"aclPortal": false,
"customizable":false
"customizable":false,
"hasAssignedUser":true
}
3 changes: 2 additions & 1 deletion application/Espo/Resources/metadata/scopes/Import.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
"layouts": false,
"tab": false,
"acl": false,
"customizable": false
"customizable": false,
"hasAssignedUser":true
}
3 changes: 2 additions & 1 deletion application/Espo/Resources/metadata/scopes/InboundEmail.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
"entity": true,
"layouts": false,
"tab": false,
"acl": false
"acl": false,
"hasAssignedUser":true
}
3 changes: 2 additions & 1 deletion application/Espo/Resources/metadata/scopes/Integration.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
"layouts":false,
"tab":false,
"acl":false,
"customizable":false
"customizable":false,
"hasAssignedUser":true
}
3 changes: 2 additions & 1 deletion application/Espo/Resources/metadata/scopes/Job.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
"layouts": false,
"tab": false,
"acl": false,
"customizable":false
"customizable":false,
"hasAssignedUser":true
}
3 changes: 2 additions & 1 deletion application/Espo/Resources/metadata/scopes/LastViewed.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
"layouts": false,
"tab": false,
"acl": false,
"customizable": false
"customizable": false,
"hasAssignedUser":true
}
2 changes: 1 addition & 1 deletion application/Espo/Resources/metadata/scopes/Note.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"entity":true,"layouts":false,"tab":false,"acl":false,"customizable":false}
{"entity":true,"layouts":false,"tab":false,"acl":false,"customizable":false,"hasAssignedUser":true}
3 changes: 2 additions & 1 deletion application/Espo/Resources/metadata/scopes/Notification.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
"layouts":false,
"tab":false,
"acl":false,
"customizable":false
"customizable":false,
"hasAssignedUser":true
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
"layouts": false,
"tab": false,
"acl": false,
"customizable": false
"customizable": false,
"hasAssignedUser":true
}
3 changes: 2 additions & 1 deletion application/Espo/Resources/metadata/scopes/PhoneNumber.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
"layouts": false,
"tab": false,
"acl": false,
"customizable":false
"customizable":false,
"hasAssignedUser":true
}
3 changes: 2 additions & 1 deletion application/Espo/Resources/metadata/scopes/Portal.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
"layouts": false,
"tab": false,
"acl": false,
"customizable": false
"customizable": false,
"hasAssignedUser":true
}
3 changes: 2 additions & 1 deletion application/Espo/Resources/metadata/scopes/Preferences.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
"layouts": false,
"tab": false,
"acl": false,
"customizable": false
"customizable": false,
"hasAssignedUser":true
}
2 changes: 1 addition & 1 deletion application/Espo/Resources/metadata/scopes/Role.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"entity":true,"layouts":false,"tab":false,"acl":false,"customizable":false}
{"entity":true,"layouts":false,"tab":false,"acl":false,"customizable":false,"hasAssignedUser":true}
3 changes: 2 additions & 1 deletion application/Espo/Resources/metadata/scopes/ScheduledJob.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
"layouts": false,
"tab": false,
"acl": false,
"customizable":false
"customizable":false,
"hasAssignedUser":true
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
"layouts": false,
"tab": false,
"acl": false,
"customizable":false
"customizable":false,
"hasAssignedUser":true
}
3 changes: 2 additions & 1 deletion application/Espo/Resources/metadata/scopes/Stream.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
"layouts":false,
"tab":true,
"acl":false,
"customizable":false
"customizable":false,
"hasAssignedUser":true
}
3 changes: 2 additions & 1 deletion application/Espo/Resources/metadata/scopes/Team.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@
"acl": true,
"aclActionList": ["read"],
"aclLevelList": ["all", "team", "no"],
"customizable": false
"customizable": false,
"hasAssignedUser":true
}
3 changes: 2 additions & 1 deletion application/Espo/Resources/metadata/scopes/Template.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
"tab": false,
"acl": "recordAllTeamNo",
"customizable": true,
"disabled": false
"disabled": false,
"hasAssignedUser":true
}
3 changes: 2 additions & 1 deletion application/Espo/Resources/metadata/scopes/UniqueId.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
"layouts": false,
"tab": false,
"acl": false,
"customizable":false
"customizable":false,
"hasAssignedUser":true
}
3 changes: 2 additions & 1 deletion application/Espo/Resources/metadata/scopes/User.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@
"acl": true,
"aclActionList": ["read"],
"customizable": true,
"object": true
"object": true,
"hasAssignedUser":true
}
3 changes: 2 additions & 1 deletion client/modules/treo-core/src/search-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,9 @@ Espo.define('treo-core:search-manager', 'class-replace!treo-core:search-manager'
value = defs.value;
return {
isAttribute: defs.isAttribute,
isImport: defs.isImport,
type: type,
attribute: attribute,
attribute: defs.isImport ? undefined : attribute,
value: value
};
}
Expand Down
Loading

0 comments on commit b712a81

Please sign in to comment.