Record edit view dropdown actions

This commit is contained in:
Yurii
2026-06-11 20:00:39 +03:00
parent d1bffffbab
commit eb5d667109
4 changed files with 77 additions and 3 deletions

View File

@@ -97,6 +97,10 @@ class Builder
['recordDefs', self::ANY_KEY, 'beforeUnlinkHookClassNameList'],
['recordDefs', self::ANY_KEY, 'afterLinkHookClassNameList'],
['recordDefs', self::ANY_KEY, 'afterUnlinkHookClassNameList'],
['clientDefs', self::ANY_KEY, 'detailActionList'],
['clientDefs', self::ANY_KEY, 'editActionList'],
['clientDefs', self::ANY_KEY, 'modalDetailActionList'],
];
private const ANY_KEY = '__ANY__';

View File

@@ -31,6 +31,7 @@
import ModalView from 'views/modal';
import Backbone from 'backbone';
import DefaultsPopulator from 'helpers/model/defaults-populator';
import ActionItemSetup from 'helpers/action-item-setup';
/**
* A quick edit modal.
@@ -234,6 +235,7 @@ class EditModalView extends ModalView {
this.headerHtml = this.composeHeaderHtml();
}
this.setupActionItems();
this.createRecordView(model);
return;
@@ -257,6 +259,7 @@ class EditModalView extends ModalView {
this.headerHtml = this.composeHeaderHtml();
}
this.setupActionItems();
this.createRecordView(model);
});
@@ -539,6 +542,23 @@ class EditModalView extends ModalView {
this.getRouter().removeWindowLeaveOutObject(this);
}
/**
* @private
*/
setupActionItems() {
const actionItemSetup = new ActionItemSetup();
actionItemSetup.setup(
this,
'modalEdit',
promise => this.wait(promise),
item => this.addDropdownItem(item),
name => this.showActionItem(name),
name => this.hideActionItem(name),
{listenToViewModelSync: true}
);
}
}
export default EditModalView;

View File

@@ -1023,6 +1023,10 @@ class DetailRecordView<S extends DetailRecordViewSchema = DetailRecordViewSchema
});
}
if (this.buttonsDisabled) {
return;
}
if (this.type === this.TYPE_DETAIL) {
const actionItemSetup = new ActionItemSetup();
@@ -1044,6 +1048,25 @@ class DetailRecordView<S extends DetailRecordViewSchema = DetailRecordViewSchema
});
}
}
if (this.type === this.TYPE_EDIT || this.type === this.TYPE_DETAIL) {
const actionItemSetup = new ActionItemSetup();
actionItemSetup.setup(
this,
'edit',
promise => this.wait(promise),
item => {
if (this.type === this.TYPE_EDIT) {
this.addDropdownItem(item);
} else {
this.dropdownEditItemList.push(item);
}
},
name => this.showActionItem(name),
name => this.hideActionItem(name)
);
}
}
/**
@@ -1808,10 +1831,13 @@ class DetailRecordView<S extends DetailRecordViewSchema = DetailRecordViewSchema
};
}
private getDropdownItemDataList(): (DropdownItem | false)[] {
private getDropdownItemDataList(type: 'detail' | 'edit' = 'detail'): (DropdownItem | false)[] {
const dropdownGroups: DropdownItem[][] = [];
this.dropdownItemList.forEach(item => {
const list = type === 'edit' ?
this.dropdownEditItemList : this.dropdownItemList;
list.forEach(item => {
// For bc.
if ((item as any) === false) {
return;
@@ -3816,7 +3842,7 @@ class DetailRecordView<S extends DetailRecordViewSchema = DetailRecordViewSchema
dataProvider: () => {
return {
buttonList: this.buttonEditList,
dropdownItemList: this.dropdownEditItemList,
dropdownItemList: this.getDropdownItemDataList('edit'),
allDisabled: this.allActionItemsDisabled,
};
},

View File

@@ -726,6 +726,18 @@
]
}
},
"editActionList": {
"description": "Edit view actions (available from the dropdown next to the Save button). As of v10.0.",
"type": "array",
"items": {
"anyOf": [
{"const": "__APPEND__"},
{
"$ref": "#/definitions/actionDefs"
}
]
}
},
"modalDetailActionList": {
"description": "Modal detail view actions.",
"type": "array",
@@ -738,6 +750,18 @@
]
}
},
"modalEditActionList": {
"description": "Modal edit view actions. As of v10.0.",
"type": "array",
"items": {
"anyOf": [
{"const": "__APPEND__"},
{
"$ref": "#/definitions/actionDefs"
}
]
}
},
"iconClass": {
"description": "A scope icon CSS class.",
"type": "string"