fix entity manager labels
This commit is contained in:
@@ -245,7 +245,9 @@ class EntityManager extends \Espo\Core\Controllers\Base
|
||||
|
||||
$params = array();
|
||||
foreach ($paramList as $item) {
|
||||
$params[$item] = filter_var($data[$item], \FILTER_SANITIZE_STRING);
|
||||
if (array_key_exists($item, $data)) {
|
||||
$params[$item] = filter_var($data[$item], \FILTER_SANITIZE_STRING);
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($additionalParamList as $item) {
|
||||
|
||||
@@ -743,9 +743,6 @@ class EntityManager
|
||||
$entityForeign = $params['entityForeign'];
|
||||
$linkForeign = $params['linkForeign'];
|
||||
|
||||
$label = $params['label'];
|
||||
$labelForeign = $params['labelForeign'];
|
||||
|
||||
if (empty($entity) || empty($entityForeign)) {
|
||||
throw new Error();
|
||||
}
|
||||
@@ -839,24 +836,41 @@ class EntityManager
|
||||
}
|
||||
}
|
||||
|
||||
$this->getLanguage()->set($entity, 'fields', $link, $label);
|
||||
$this->getLanguage()->set($entity, 'links', $link, $label);
|
||||
$this->getLanguage()->set($entityForeign, 'fields', $linkForeign, $labelForeign);
|
||||
$this->getLanguage()->set($entityForeign, 'links', $linkForeign, $labelForeign);
|
||||
$label = null;
|
||||
if (isset($params['label'])) {
|
||||
$label = $params['label'];
|
||||
}
|
||||
$labelForeign = null;
|
||||
if (isset($params['labelForeign'])) {
|
||||
$labelForeign = $params['labelForeign'];
|
||||
}
|
||||
|
||||
if ($label) {
|
||||
$this->getLanguage()->set($entity, 'fields', $link, $label);
|
||||
$this->getLanguage()->set($entity, 'links', $link, $label);
|
||||
}
|
||||
|
||||
if ($labelForeign) {
|
||||
$this->getLanguage()->set($entityForeign, 'fields', $linkForeign, $labelForeign);
|
||||
$this->getLanguage()->set($entityForeign, 'links', $linkForeign, $labelForeign);
|
||||
}
|
||||
|
||||
$this->getLanguage()->save();
|
||||
|
||||
if ($isCustom) {
|
||||
if ($this->getBaseLanguage()->getLanguage() !== $this->getBaseLanguage()->getLanguage()) {
|
||||
$this->getBaseLanguage()->set($entity, 'fields', $link, $label);
|
||||
$this->getBaseLanguage()->set($entity, 'links', $link, $label);
|
||||
$this->getBaseLanguage()->set($entityForeign, 'fields', $linkForeign, $labelForeign);
|
||||
$this->getBaseLanguage()->set($entityForeign, 'links', $linkForeign, $labelForeign);
|
||||
if ($label) {
|
||||
$this->getBaseLanguage()->set($entity, 'fields', $link, $label);
|
||||
$this->getBaseLanguage()->set($entity, 'links', $link, $label);
|
||||
}
|
||||
if ($labelForeign) {
|
||||
$this->getBaseLanguage()->set($entityForeign, 'fields', $linkForeign, $labelForeign);
|
||||
$this->getBaseLanguage()->set($entityForeign, 'links', $linkForeign, $labelForeign);
|
||||
}
|
||||
$this->getBaseLanguage()->save();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -276,6 +276,7 @@ Espo.define('views/admin/entity-manager/modals/edit-entity', ['views/modal', 'mo
|
||||
});
|
||||
}
|
||||
}
|
||||
this.model.fetchedAttributes = this.model.getClonedAttributes();
|
||||
},
|
||||
|
||||
hideField: function (name) {
|
||||
@@ -365,7 +366,7 @@ Espo.define('views/admin/entity-manager/modals/edit-entity', ['views/modal', 'mo
|
||||
return;
|
||||
}
|
||||
|
||||
this.$el.find('button[data-name="save"]').addClass('disabled');
|
||||
this.$el.find('button[data-name="save"]').addClass('disabled').attr('disabled');
|
||||
|
||||
var url = 'EntityManager/action/createEntity';
|
||||
if (this.scope) {
|
||||
@@ -394,14 +395,25 @@ Espo.define('views/admin/entity-manager/modals/edit-entity', ['views/modal', 'mo
|
||||
data.sortDirection = this.model.get('sortDirection');
|
||||
}
|
||||
|
||||
if (!this.isNew) {
|
||||
if (this.model.fetchedAttributes.labelPlural === data.labelPlural) {
|
||||
delete data.labelPlural;
|
||||
}
|
||||
if (this.model.fetchedAttributes.labelSingular === data.labelSingular) {
|
||||
delete data.labelSingular;
|
||||
}
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
url: url,
|
||||
type: 'POST',
|
||||
data: JSON.stringify(data),
|
||||
error: function () {
|
||||
this.$el.find('button[data-name="save"]').removeClass('disabled');
|
||||
this.$el.find('button[data-name="save"]').removeClass('disabled').removeAttr('disabled');
|
||||
}.bind(this)
|
||||
}).done(function () {
|
||||
this.model.fetchedAttributes = this.model.getClonedAttributes();
|
||||
|
||||
if (this.scope) {
|
||||
Espo.Ui.success(this.translate('Saved'));
|
||||
} else {
|
||||
|
||||
@@ -283,6 +283,9 @@ Espo.define('views/admin/link-manager/modals/edit', ['views/modal', 'views/admin
|
||||
tooltip: true,
|
||||
tooltipText: this.translate('linkAudited', 'tooltips', 'EntityManager')
|
||||
});
|
||||
|
||||
|
||||
this.model.fetchedAttributes = this.model.getClonedAttributes();
|
||||
},
|
||||
|
||||
toPlural: function (string) {
|
||||
@@ -487,7 +490,7 @@ Espo.define('views/admin/link-manager/modals/edit', ['views/modal', 'views/admin
|
||||
return;
|
||||
}
|
||||
|
||||
this.$el.find('button[data-name="save"]').addClass('disabled');
|
||||
this.$el.find('button[data-name="save"]').addClass('disabled').attr('disabled');
|
||||
|
||||
var url = 'EntityManager/action/createLink';
|
||||
if (!this.isNew) {
|
||||
@@ -508,29 +511,40 @@ Espo.define('views/admin/link-manager/modals/edit', ['views/modal', 'views/admin
|
||||
var audited = this.model.get('audited');
|
||||
var auditedForeign = this.model.get('auditedForeign');
|
||||
|
||||
var attributes = {
|
||||
entity: entity,
|
||||
entityForeign: entityForeign,
|
||||
link: link,
|
||||
linkForeign: linkForeign,
|
||||
label: label,
|
||||
labelForeign: labelForeign,
|
||||
linkType: this.model.get('linkType'),
|
||||
relationName: relationName,
|
||||
linkMultipleField: linkMultipleField,
|
||||
linkMultipleFieldForeign: linkMultipleFieldForeign,
|
||||
audited: audited,
|
||||
auditedForeign: auditedForeign
|
||||
};
|
||||
|
||||
if (!this.isNew) {
|
||||
if (attributes.label === this.model.fetchedAttributes.label) {
|
||||
delete attributes.label;
|
||||
}
|
||||
if (attributes.labelForeign === this.model.fetchedAttributes.labelForeign) {
|
||||
delete attributes.labelForeign;
|
||||
}
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
url: url,
|
||||
type: 'POST',
|
||||
data: JSON.stringify({
|
||||
entity: entity,
|
||||
entityForeign: entityForeign,
|
||||
link: link,
|
||||
linkForeign: linkForeign,
|
||||
label: label,
|
||||
labelForeign: labelForeign,
|
||||
linkType: this.model.get('linkType'),
|
||||
relationName: relationName,
|
||||
linkMultipleField: linkMultipleField,
|
||||
linkMultipleFieldForeign: linkMultipleFieldForeign,
|
||||
audited: audited,
|
||||
auditedForeign: auditedForeign
|
||||
}),
|
||||
data: JSON.stringify(attributes),
|
||||
error: function (x) {
|
||||
if (x.status == 409) {
|
||||
Espo.Ui.error(this.translate('linkConflict', 'messages', 'EntityManager'));
|
||||
x.errorIsHandled = true;
|
||||
}
|
||||
this.$el.find('button[data-name="save"]').removeClass('disabled');
|
||||
this.$el.find('button[data-name="save"]').removeClass('disabled').removeAttr('disabled');
|
||||
}.bind(this)
|
||||
}).done(function () {
|
||||
if (!this.isNew) {
|
||||
@@ -539,6 +553,8 @@ Espo.define('views/admin/link-manager/modals/edit', ['views/modal', 'views/admin
|
||||
Espo.Ui.success(this.translate('Created'));
|
||||
}
|
||||
|
||||
this.model.fetchedAttributes = this.model.getClonedAttributes();
|
||||
|
||||
var data;
|
||||
|
||||
data = ((this.getLanguage().data || {}) || {})[entity] || {};
|
||||
|
||||
Reference in New Issue
Block a user