row actions dividers

This commit is contained in:
Yuri Kuznetsov
2024-04-09 20:35:36 +03:00
parent 9fd07d2fab
commit a8078c3fc6
30 changed files with 200 additions and 63 deletions
@@ -45,7 +45,8 @@ define('crm:views/meeting/record/row-actions/dashlet', ['views/record/row-action
data: {
id: this.model.id,
scope: this.model.entityType,
}
},
groupIndex: 1,
});
actionList.push({
@@ -54,7 +55,8 @@ define('crm:views/meeting/record/row-actions/dashlet', ['views/record/row-action
data: {
id: this.model.id,
scope: this.model.entityType,
}
},
groupIndex: 1,
});
}
@@ -65,7 +67,8 @@ define('crm:views/meeting/record/row-actions/dashlet', ['views/record/row-action
data: {
id: this.model.id,
scope: this.model.entityType,
}
},
groupIndex: 0,
});
}
@@ -45,7 +45,8 @@ define('crm:views/meeting/record/row-actions/default', ['views/record/row-action
data: {
id: this.model.id,
scope: this.model.entityType,
}
},
groupIndex: 1,
});
actionList.push({
@@ -54,7 +55,8 @@ define('crm:views/meeting/record/row-actions/default', ['views/record/row-action
data: {
id: this.model.id,
scope: this.model.entityType,
}
},
groupIndex: 1,
});
}
@@ -65,7 +67,8 @@ define('crm:views/meeting/record/row-actions/default', ['views/record/row-action
data: {
id: this.model.id,
scope: this.model.entityType,
}
},
groupIndex: 0,
});
}
@@ -47,7 +47,8 @@ define('crm:views/record/row-actions/activities-dashlet', ['views/record/row-act
label: 'Complete',
data: {
id: this.model.id
}
},
groupIndex: 1,
});
}
} else {
@@ -58,7 +59,8 @@ define('crm:views/record/row-actions/activities-dashlet', ['views/record/row-act
data: {
id: this.model.id,
scope: this.model.entityType
}
},
groupIndex: 1,
});
actionList.push({
action: 'setNotHeld',
@@ -66,7 +68,8 @@ define('crm:views/record/row-actions/activities-dashlet', ['views/record/row-act
data: {
id: this.model.id,
scope: this.model.entityType
}
},
groupIndex: 1,
});
}
}
@@ -78,7 +81,8 @@ define('crm:views/record/row-actions/activities-dashlet', ['views/record/row-act
data: {
id: this.model.id,
scope: this.model.entityType
}
},
groupIndex: 0,
});
}
@@ -38,6 +38,7 @@ define('crm:views/record/row-actions/activities', ['views/record/row-actions/rel
id: this.model.id,
},
link: '#' + this.model.entityType + '/view/' + this.model.id,
groupIndex: 0,
}];
if (this.options.acl.edit) {
@@ -48,6 +49,7 @@ define('crm:views/record/row-actions/activities', ['views/record/row-actions/rel
id: this.model.id,
},
link: '#' + this.model.entityType + '/edit/' + this.model.id,
groupIndex: 0,
});
if (this.model.entityType === 'Meeting' || this.model.entityType === 'Call') {
@@ -57,6 +59,7 @@ define('crm:views/record/row-actions/activities', ['views/record/row-actions/rel
data: {
id: this.model.id,
},
groupIndex: 1,
});
list.push({
@@ -65,6 +68,7 @@ define('crm:views/record/row-actions/activities', ['views/record/row-actions/rel
data: {
id: this.model.id,
},
groupIndex: 1,
});
}
}
@@ -75,7 +79,8 @@ define('crm:views/record/row-actions/activities', ['views/record/row-actions/rel
label: 'Remove',
data: {
id: this.model.id,
}
},
groupIndex: 0,
});
}
@@ -37,7 +37,8 @@ define('crm:views/record/row-actions/history', ['views/record/row-actions/relati
data: {
id: this.model.id
},
link: '#' + this.model.entityType + '/view/' + this.model.id
link: '#' + this.model.entityType + '/view/' + this.model.id,
groupIndex: 0,
}];
if (this.model.entityType === 'Email') {
@@ -46,7 +47,8 @@ define('crm:views/record/row-actions/history', ['views/record/row-actions/relati
text: this.translate('Reply', 'labels', 'Email'),
data: {
id: this.model.id
}
},
groupIndex: 1,
});
}
@@ -58,8 +60,9 @@ define('crm:views/record/row-actions/history', ['views/record/row-actions/relati
data: {
id: this.model.id
},
link: '#' + this.model.entityType + '/edit/' + this.model.id
}
link: '#' + this.model.entityType + '/edit/' + this.model.id,
groupIndex: 0,
},
]);
}
@@ -69,7 +72,8 @@ define('crm:views/record/row-actions/history', ['views/record/row-actions/relati
label: 'Remove',
data: {
id: this.model.id
}
},
groupIndex: 0,
});
}
@@ -40,7 +40,8 @@ define('crm:views/record/row-actions/relationship-target', ['views/record/row-ac
text: this.translate('Cancel Opt-Out', 'labels', 'TargetList'),
data: {
id: this.model.id
}
},
groupIndex: 1,
});
} else {
list.push({
@@ -48,7 +49,8 @@ define('crm:views/record/row-actions/relationship-target', ['views/record/row-ac
text: this.translate('Opt-Out', 'labels', 'TargetList'),
data: {
id: this.model.id
}
},
groupIndex: 1,
});
}
}
@@ -37,7 +37,8 @@ define('crm:views/record/row-actions/tasks', ['views/record/row-actions/relation
data: {
id: this.model.id
},
link: '#' + this.model.entityType + '/view/' + this.model.id
link: '#' + this.model.entityType + '/view/' + this.model.id,
groupIndex: 0,
}];
if (this.options.acl.edit) {
@@ -47,7 +48,8 @@ define('crm:views/record/row-actions/tasks', ['views/record/row-actions/relation
data: {
id: this.model.id
},
link: '#' + this.model.entityType + '/edit/' + this.model.id
link: '#' + this.model.entityType + '/edit/' + this.model.id,
groupIndex: 0,
});
if (!~['Completed', 'Canceled'].indexOf(this.model.get('status'))) {
@@ -56,7 +58,8 @@ define('crm:views/record/row-actions/tasks', ['views/record/row-actions/relation
text: this.translate('Complete', 'labels', 'Task'),
data: {
id: this.model.id
}
},
groupIndex: 1,
});
}
}
@@ -67,7 +70,8 @@ define('crm:views/record/row-actions/tasks', ['views/record/row-actions/relation
label: 'Remove',
data: {
id: this.model.id
}
},
groupIndex: 0,
});
}
@@ -39,7 +39,8 @@ define('crm:views/task/record/row-actions/dashlet', ['views/record/row-actions/v
label: 'Complete',
data: {
id: this.model.id
}
},
groupIndex: 1,
});
}
@@ -50,7 +51,8 @@ define('crm:views/task/record/row-actions/dashlet', ['views/record/row-actions/v
data: {
id: this.model.id,
scope: this.model.entityType
}
},
groupIndex: 0,
});
}
@@ -39,7 +39,8 @@ define('crm:views/task/record/row-actions/default', ['views/record/row-actions/v
label: 'Complete',
data: {
id: this.model.id
}
},
groupIndex: 1,
});
}
@@ -50,7 +51,8 @@ define('crm:views/task/record/row-actions/default', ['views/record/row-actions/v
data: {
id: this.model.id,
scope: this.model.entityType
}
},
groupIndex: 0,
});
}
@@ -7,18 +7,26 @@
><span class="caret"></span></button>
<ul class="dropdown-menu pull-right list-row-dropdown-menu" data-id="{{model.id}}">
{{#each actionList}}
<li>
<a
{{#if link}}href="{{link}}"{{else}}role="button"{{/if}}
tabindex="0"
class="action"
{{#if action}}data-action="{{action}}"{{/if}}
{{#each data}}
data-{{hyphen @key}}="{{./this}}"
{{/each}}
>{{#if html}}{{{html}}}{{else}}{{#if text}}{{text}}{{else}}{{translate label scope=../scope}}{{/if}}{{/if}}
</a>
</li>
{{#if this}}
<li>
<a
{{#if link}}href="{{link}}"{{else}}role="button"{{/if}}
tabindex="0"
class="action"
{{#if action}}data-action="{{action}}"{{/if}}
{{#each data}}
data-{{hyphen @key}}="{{./this}}"
{{/each}}
>{{#if html}}{{{html}}}{{else}}{{#if text}}{{text}}{{else}}{{translate label scope=../scope}}{{/if}}{{/if}}
</a>
</li>
{{else}}
{{#unless @first}}
{{#unless @last}}
<li class="divider"></li>
{{/unless}}
{{/unless}}
{{/if}}
{{/each}}
</ul>
</div>
@@ -46,7 +46,8 @@ define('views/email/record/row-actions/dashlet', ['views/record/row-actions/defa
label: 'View',
data: {
id: this.model.id
}
},
groupIndex: 0,
}];
if (this.options.acl.edit) {
@@ -56,7 +57,8 @@ define('views/email/record/row-actions/dashlet', ['views/record/row-actions/defa
label: 'Edit',
data: {
id: this.model.id
}
},
groupIndex: 0,
}
]);
}
@@ -68,7 +70,8 @@ define('views/email/record/row-actions/dashlet', ['views/record/row-actions/defa
label: 'Move to Trash',
data: {
id: this.model.id
}
},
groupIndex: 1,
});
} else {
list.push({
@@ -76,7 +79,8 @@ define('views/email/record/row-actions/dashlet', ['views/record/row-actions/defa
label: 'Retrieve from Trash',
data: {
id: this.model.id
}
},
groupIndex: 1,
});
}
}
@@ -87,7 +91,8 @@ define('views/email/record/row-actions/dashlet', ['views/record/row-actions/defa
label: 'Remove',
data: {
id: this.model.id
}
},
groupIndex: 0,
});
}
@@ -98,7 +103,8 @@ define('views/email/record/row-actions/dashlet', ['views/record/row-actions/defa
label: 'Mark as Important',
data: {
id: this.model.id
}
},
groupIndex: 1,
});
} else {
list.push({
@@ -106,7 +112,8 @@ define('views/email/record/row-actions/dashlet', ['views/record/row-actions/defa
label: 'Unmark Importance',
data: {
id: this.model.id
}
},
groupIndex: 1,
});
}
}
@@ -47,7 +47,8 @@ define('views/email/record/row-actions/default', ['views/record/row-actions/defa
label: 'View',
data: {
id: this.model.id
}
},
groupIndex: 0,
}];
if (
@@ -70,8 +71,9 @@ define('views/email/record/row-actions/default', ['views/record/row-actions/defa
label: 'Edit',
data: {
id: this.model.id
}
}
},
groupIndex: 0,
},
]);
}
@@ -82,7 +84,8 @@ define('views/email/record/row-actions/default', ['views/record/row-actions/defa
label: 'Move to Trash',
data: {
id: this.model.id
}
},
groupIndex: 1,
});
} else {
list.push({
@@ -90,7 +93,8 @@ define('views/email/record/row-actions/default', ['views/record/row-actions/defa
label: 'Retrieve from Trash',
data: {
id: this.model.id
}
},
groupIndex: 1,
});
}
}
@@ -103,7 +107,8 @@ define('views/email/record/row-actions/default', ['views/record/row-actions/defa
label: 'Mark as Important',
data: {
id: this.model.id
}
},
groupIndex: 1,
});
}
} else {
@@ -112,7 +117,8 @@ define('views/email/record/row-actions/default', ['views/record/row-actions/defa
label: 'Unmark Importance',
data: {
id: this.model.id
}
},
groupIndex: 1,
});
}
}
@@ -123,7 +129,8 @@ define('views/email/record/row-actions/default', ['views/record/row-actions/defa
label: 'Move to Folder',
data: {
id: this.model.id
}
},
groupIndex: 1,
});
}
@@ -133,12 +140,12 @@ define('views/email/record/row-actions/default', ['views/record/row-actions/defa
label: 'Remove',
data: {
id: this.model.id
}
},
groupIndex: 0,
});
}
return list;
},
});
});
+2 -1
View File
@@ -52,6 +52,7 @@ class ListRecordView extends View {
* @property {string} [link] A link.
* @property {string} [text] A text.
* @property {Object.<string, string|number|boolean>} [data] Data attributes.
* @property {number} [groupIndex] A group index.
*/
/**
@@ -3385,7 +3386,7 @@ class ListRecordView extends View {
const defs = this.getMetadata().get(`clientDefs.${this.scope}.rowActionDefs`) || {};
const promiseList = list.map(action => {
/** @type {{handler: string, label?: string, labelTranslation?: string}} */
/** @type {{handler: string, label?: string, labelTranslation?: string, groupIndex?: number}} */
const itemDefs = defs[action] || {};
if (!itemDefs.handler) {
@@ -38,6 +38,7 @@ class DefaultKanbanRowActionsView extends DefaultRowActionsView {
id: this.model.id,
},
link: '#' + this.model.entityType + '/view/' + this.model.id,
groupIndex: 0,
}];
if (this.options.statusFieldIsEditable) {
@@ -47,6 +48,7 @@ class DefaultKanbanRowActionsView extends DefaultRowActionsView {
data: {
id: this.model.id,
},
groupIndex: 1,
});
}
@@ -58,6 +60,7 @@ class DefaultKanbanRowActionsView extends DefaultRowActionsView {
id: this.model.id
},
link: '#' + this.model.entityType + '/edit/' + this.model.id,
groupIndex: 0,
});
}
@@ -70,6 +73,7 @@ class DefaultKanbanRowActionsView extends DefaultRowActionsView {
data: {
id: this.model.id,
},
groupIndex: 0,
});
}
+51 -3
View File
@@ -28,6 +28,21 @@
import View from 'view';
/**
* @module views/record/row-actions/actions
*/
/**
* @typedef {{
* label?: string,
* labelTranslation?: string,
* acl?: string,
* groupIndex?: number,
* name?: string,
* text?: string,
* }} module:views/record/row-actions/actions~item
*/
/**
* Row actions.
*/
@@ -42,7 +57,7 @@ class DefaultRowActionsView extends View {
/** @type {Object.<string, {isAvailable: function(module:model, string)}>} */
this.handlers = this.options.rowActionHandlers || {};
/** @type {{name: string, acl: string, text: string}[]} */
/** @type {module:views/record/row-actions/actions~item[]} */
this.additionalActionDataList = [];
this.setupAdditionalActions();
@@ -86,6 +101,7 @@ class DefaultRowActionsView extends View {
id: this.model.id
},
link: '#' + this.model.entityType + '/view/' + this.model.id,
groupIndex: 0,
}];
if (this.options.acl.edit) {
@@ -96,6 +112,7 @@ class DefaultRowActionsView extends View {
id: this.model.id
},
link: '#' + this.model.entityType + '/edit/' + this.model.id,
groupIndex: 0,
});
}
@@ -108,6 +125,7 @@ class DefaultRowActionsView extends View {
data: {
id: this.model.id,
},
groupIndex: 0,
});
}
@@ -135,6 +153,7 @@ class DefaultRowActionsView extends View {
id: this.model.id,
actualAction: item.name,
},
groupIndex: item.groupIndex,
});
});
@@ -142,9 +161,37 @@ class DefaultRowActionsView extends View {
}
data() {
/** @type {Array<module:views/record/row-actions/actions~item[]>} */
const dropdownGroups = [];
this.getActionList().forEach(item => {
// For bc.
if (item === false) {
return;
}
const index = item.groupIndex === undefined ? 9999 : item.groupIndex;
if (dropdownGroups[index] === undefined) {
dropdownGroups[index] = [];
}
dropdownGroups[index].push(item);
});
const dropdownItemList = [];
dropdownGroups.forEach(list => {
list.forEach(it => dropdownItemList.push(it));
dropdownItemList.push(false);
});
console.log(dropdownItemList);
return {
acl: this.options.acl,
actionList: this.getActionList(),
actionList: dropdownItemList,
scope: this.model.entityType,
};
}
@@ -160,7 +207,7 @@ class DefaultRowActionsView extends View {
const defs = this.getMetadata().get(`clientDefs.${this.scope}.rowActionDefs`) || {};
list.forEach(action => {
/** @type {{label?: string, labelTranslation?: string, acl?: string}} */
/** @type {{label?: string, labelTranslation?: string, acl?: string, groupIndex?: number}} */
const itemDefs = defs[action] || {};
const text = itemDefs.labelTranslation ?
@@ -171,6 +218,7 @@ class DefaultRowActionsView extends View {
name: action,
acl: itemDefs.acl,
text: text,
groupIndex: itemDefs.groupIndex,
});
});
}
@@ -40,7 +40,8 @@ class EditAndRemoveRowActionsView extends DefaultRowActionsView {
data: {
id: this.model.id
},
link: '#' + this.model.entityType + '/edit/' + this.model.id
link: '#' + this.model.entityType + '/edit/' + this.model.id,
groupIndex: 0,
});
}
@@ -51,6 +52,7 @@ class EditAndRemoveRowActionsView extends DefaultRowActionsView {
data: {
id: this.model.id,
},
groupIndex: 0,
});
}
@@ -40,6 +40,7 @@ class RelationshipEditAndRemoveActionsView extends RelationshipActionsView {
data: {
id: this.model.id,
},
groupIndex: 0,
});
}
@@ -50,6 +51,7 @@ class RelationshipEditAndRemoveActionsView extends RelationshipActionsView {
data: {
id: this.model.id,
},
groupIndex: 0,
});
}
@@ -37,7 +37,8 @@ define('views/record/row-actions/relationship-no-remove', ['views/record/row-act
data: {
id: this.model.id
},
link: '#' + this.model.entityType + '/view/' + this.model.id
link: '#' + this.model.entityType + '/view/' + this.model.id,
groupIndex: 0,
}];
if (this.options.acl.edit) {
@@ -47,15 +48,18 @@ define('views/record/row-actions/relationship-no-remove', ['views/record/row-act
data: {
id: this.model.id
},
link: '#' + this.model.entityType + '/edit/' + this.model.id
link: '#' + this.model.entityType + '/edit/' + this.model.id,
groupIndex: 0,
});
if (!this.options.unlinkDisabled) {
list.push({
action: 'unlinkRelated',
label: 'Unlink',
data: {
id: this.model.id
}
},
groupIndex: 0,
});
}
}
@@ -38,6 +38,7 @@ class RelationshipNoUnlinkActionsView extends RelationshipActionsView {
id: this.model.id,
},
link: '#' + this.model.entityType + '/view/' + this.model.id,
groupIndex: 0,
}];
if (this.options.acl.edit) {
@@ -49,6 +50,7 @@ class RelationshipNoUnlinkActionsView extends RelationshipActionsView {
id: this.model.id
},
link: '#' + this.model.entityType + '/edit/' + this.model.id,
groupIndex: 0,
}
]);
}
@@ -60,6 +62,7 @@ class RelationshipNoUnlinkActionsView extends RelationshipActionsView {
data: {
id: this.model.id,
},
groupIndex: 0,
});
}
@@ -39,6 +39,7 @@ class RelationshipRemoveOnlyActionsView extends RelationshipActionsView {
data: {
id: this.model.id,
},
groupIndex: 0,
},
];
}
@@ -39,6 +39,7 @@ class RelationshipUnlinkOnlyActionsView extends RelationshipActionsView {
data: {
id: this.model.id,
},
groupIndex: 0,
},
];
}
@@ -38,6 +38,7 @@ class RelationshipViewAndEditActionsView extends RelationshipActionsView {
id: this.model.id,
},
link: '#' + this.model.entityType + '/view/' + this.model.id,
groupIndex: 0,
}];
if (this.options.acl.edit) {
@@ -48,6 +49,7 @@ class RelationshipViewAndEditActionsView extends RelationshipActionsView {
id: this.model.id,
},
link: '#' + this.model.entityType + '/edit/' + this.model.id,
groupIndex: 0,
});
}
@@ -38,6 +38,7 @@ class RelationshipViewAndUnlinkActionsView extends RelationshipActionsView {
id: this.model.id,
},
link: '#' + this.model.entityType + '/view/' + this.model.id,
groupIndex: 0,
}];
if (this.options.acl.edit && !this.options.unlinkDisabled) {
@@ -47,6 +48,7 @@ class RelationshipViewAndUnlinkActionsView extends RelationshipActionsView {
data: {
id: this.model.id,
},
groupIndex: 0,
});
}
@@ -39,6 +39,7 @@ class RelationshipViewOnlyActionsView extends RelationshipActionsView {
id: this.model.id,
},
link: '#' + this.model.entityType + '/view/' + this.model.id,
groupIndex: 0,
}
];
}
@@ -38,6 +38,7 @@ class RelationshipActionsView extends DefaultRowActionsView {
id: this.model.id
},
link: '#' + this.model.entityType + '/view/' + this.model.id,
groupIndex: 0,
}];
if (this.options.acl.edit && !this.options.editDisabled) {
@@ -48,6 +49,7 @@ class RelationshipActionsView extends DefaultRowActionsView {
id: this.model.id,
},
link: '#' + this.model.entityType + '/edit/' + this.model.id,
groupIndex: 0,
});
}
@@ -58,6 +60,7 @@ class RelationshipActionsView extends DefaultRowActionsView {
data: {
id: this.model.id,
},
groupIndex: 0,
});
}
@@ -70,6 +73,7 @@ class RelationshipActionsView extends DefaultRowActionsView {
data: {
id: this.model.id,
},
groupIndex: 0,
});
}
@@ -39,6 +39,7 @@ class RemoveOnlyRowActionsView extends DefaultRowActionsView {
data: {
id: this.model.id,
},
groupIndex: 0,
}
];
}
@@ -38,6 +38,7 @@ class ViewAndEditRowActionsView extends DefaultRowActionsView {
id: this.model.id,
},
link: '#' + this.model.entityType + '/view/' + this.model.id,
groupIndex: 0,
}];
if (this.options.acl.edit) {
@@ -49,6 +50,7 @@ class ViewAndEditRowActionsView extends DefaultRowActionsView {
id: this.model.id,
},
link: '#' + this.model.entityType + '/edit/' + this.model.id,
groupIndex: 0,
}
]);
}
@@ -39,6 +39,7 @@ class ViewAndRemoveRowActionsView extends DefaultRowActionsView {
id: this.model.id,
},
link: '#' + this.model.entityType + '/view/' + this.model.id,
groupIndex: 0,
}];
if (this.options.acl.delete) {
@@ -48,6 +49,7 @@ class ViewAndRemoveRowActionsView extends DefaultRowActionsView {
data: {
id: this.model.id,
},
groupIndex: 0,
});
}
@@ -39,6 +39,7 @@ class ViewOnlyRowActionsView extends DefaultRowActionsView {
id: this.model.id,
},
link: '#' + this.model.entityType + '/view/' + this.model.id,
groupIndex: 0,
},
];
}
+5
View File
@@ -139,6 +139,11 @@
"handler": {
"type": "string",
"description": "A handler. Should extend handlers/row-action."
},
"groupIndex": {
"type": "integer",
"minimum": 0,
"description": "A group index."
}
}
}