mirror of
https://github.com/espocrm/espocrm.git
synced 2026-06-28 06:56:05 +00:00
entity manager: text filter fields
This commit is contained in:
@@ -78,6 +78,9 @@ class EntityManager extends \Espo\Core\Controllers\Base
|
||||
if (!empty($data['sortDirection'])) {
|
||||
$params['asc'] = $data['sortDirection'] === 'asc';
|
||||
}
|
||||
if (isset($data['textFilterFields']) && is_array($data['textFilterFields'])) {
|
||||
$params['textFilterFields'] = $data['textFilterFields'];
|
||||
}
|
||||
|
||||
$result = $this->getContainer()->get('entityManagerUtil')->create($name, $type, $params);
|
||||
|
||||
|
||||
@@ -219,6 +219,15 @@ class EntityManager
|
||||
$this->getMetadata()->set('entityDefs', $name, $entityDefsData);
|
||||
}
|
||||
|
||||
if (isset($data['textFilterFields'])) {
|
||||
$entityDefsData = array(
|
||||
'collection' => array(
|
||||
'textFilterFields' => $data['textFilterFields']
|
||||
)
|
||||
);
|
||||
$this->getMetadata()->set('entityDefs', $name, $entityDefsData);
|
||||
}
|
||||
|
||||
$this->getMetadata()->save();
|
||||
$this->getLanguage()->save();
|
||||
|
||||
|
||||
@@ -20,7 +20,8 @@
|
||||
"relationName": "Middle Table Name",
|
||||
"linkMultipleField": "Link Multiple Field",
|
||||
"linkMultipleFieldForeign": "Foreign Link Multiple Field",
|
||||
"disabled": "Disabled"
|
||||
"disabled": "Disabled",
|
||||
"textFilterFields": "Text Filter Fields"
|
||||
},
|
||||
"options": {
|
||||
"type": {
|
||||
|
||||
@@ -59,4 +59,14 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="row">
|
||||
<div class="cell form-group col-md-6" data-name="textFilterFields">
|
||||
<label class="control-label" data-name="textFilterFields">{{translate 'textFilterFields' category='fields' scope='EntityManager'}}</label>
|
||||
<div class="field" data-name="textFilterFields">
|
||||
{{{textFilterFields}}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{/if}}
|
||||
|
||||
@@ -77,6 +77,8 @@ Espo.define('views/admin/entity-manager/modals/edit-entity', ['views/modal', 'mo
|
||||
|
||||
this.model.set('sortBy', this.getMetadata().get('entityDefs.' + scope + '.collection.sortBy'));
|
||||
this.model.set('sortDirection', this.getMetadata().get('entityDefs.' + scope + '.collection.asc') ? 'asc' : 'desc');
|
||||
|
||||
this.model.set('textFilterFields', this.getMetadata().get('entityDefs.' + scope + '.collection.textFilterFields') || ['name']);
|
||||
}
|
||||
|
||||
this.createView('type', 'views/fields/enum', {
|
||||
@@ -159,7 +161,7 @@ Espo.define('views/admin/entity-manager/modals/edit-entity', ['views/modal', 'mo
|
||||
}
|
||||
return true;
|
||||
}, this).sort(function (v1, v2) {
|
||||
return this.translate(v1, 'fields', scope).localeCompare(this.translate(v2, 'fields', scope));
|
||||
return this.translate(v1, 'fields', scope).localeCompare(this.translate(v2, 'fields', scope));
|
||||
}.bind(this));
|
||||
|
||||
var translatedOptions = {};
|
||||
@@ -174,10 +176,10 @@ Espo.define('views/admin/entity-manager/modals/edit-entity', ['views/modal', 'mo
|
||||
defs: {
|
||||
name: 'sortBy',
|
||||
params: {
|
||||
options: orderableFieldList,
|
||||
translatedOptions: translatedOptions
|
||||
options: orderableFieldList
|
||||
}
|
||||
}
|
||||
},
|
||||
translatedOptions: translatedOptions
|
||||
});
|
||||
|
||||
this.createView('sortDirection', 'views/fields/enum', {
|
||||
@@ -191,6 +193,32 @@ Espo.define('views/admin/entity-manager/modals/edit-entity', ['views/modal', 'mo
|
||||
}
|
||||
}
|
||||
});
|
||||
var fieldDefs = this.getMetadata().get(['entityDefs', scope, 'fields']) || {};
|
||||
|
||||
var optionList = Object.keys(fieldDefs).filter(function (item) {
|
||||
if (!~['varchar', 'text', 'phoneNumber', 'email', 'personName'].indexOf(this.getMetadata().get(['entityDefs', scope, 'fields', item, 'type']))) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}, this);
|
||||
|
||||
var textFilterFieldsTranslation = {};
|
||||
optionList.forEach(function (item) {
|
||||
textFilterFieldsTranslation[item] = this.translate(item, 'fields', scope);
|
||||
}, this);
|
||||
|
||||
this.createView('textFilterFields', 'views/fields/multi-enum', {
|
||||
model: model,
|
||||
mode: 'edit',
|
||||
el: this.options.el + ' .field[data-name="textFilterFields"]',
|
||||
defs: {
|
||||
name: 'textFilterFields',
|
||||
params: {
|
||||
options: optionList
|
||||
}
|
||||
},
|
||||
translatedOptions: textFilterFieldsTranslation
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
@@ -262,7 +290,8 @@ Espo.define('views/admin/entity-manager/modals/edit-entity', ['views/modal', 'mo
|
||||
labelPlural: this.model.get('labelPlural'),
|
||||
type: this.model.get('type'),
|
||||
stream: this.model.get('stream'),
|
||||
disabled: this.model.get('disabled')
|
||||
disabled: this.model.get('disabled'),
|
||||
textFilterFields: this.model.get('textFilterFields')
|
||||
};
|
||||
|
||||
if (this.scope) {
|
||||
|
||||
Reference in New Issue
Block a user