link create button changes

This commit is contained in:
Yuri Kuznetsov
2023-11-09 15:39:04 +02:00
parent 0a7005edaa
commit bb4a93418e
3 changed files with 23 additions and 2 deletions
@@ -16,6 +16,10 @@
{
"name": "readOnlyAfterCreate",
"type": "bool"
},
{
"name": "createButton",
"type": "bool"
}
],
"actualFields": [
+1 -1
View File
@@ -12,7 +12,7 @@
{{#if createButton}}
<button
data-action="createLink"
class="btn btn-default btn-icon"
class="btn btn-default btn-icon{{#if idValue}} hidden{{/if}}"
type="button"
title="{{translate 'Create'}}"
><i class="fas fa-plus"></i></button>
+18 -1
View File
@@ -376,6 +376,8 @@ class LinkFieldView extends BaseFieldView {
this.trigger('change');
this.controlCreateButtonVisibility();
this.getSelectFieldHandler().then(handler => {
handler.getAttributes(model)
.then(attributes => {
@@ -393,14 +395,29 @@ class LinkFieldView extends BaseFieldView {
this.trigger('change');
this.controlCreateButtonVisibility();
this.getSelectFieldHandler().then(handler => {
handler.getClearAttributes()
.then(attributes => {
this.model.set(attributes)
this.model.set(attributes);
});
});
}
/** @private */
controlCreateButtonVisibility() {
if (!this.createButton) {
return;
}
const $btn = this.$el.find('[data-action="createLink"]');
this.model.get(this.idName) ?
$btn.addClass('hidden') :
$btn.removeClass('hidden');
}
/**
* @private
* @return {Promise<{