[IMP] web: adapt the kanban "Remove" button label
Remove button is shown when the view of our field is in kanban mode. When our field is one2many it will delete the record and when our field is many2one it will remove the record. So many times user get confuse that they are deleting the record or removing the record. So to clear out the confusion this commit changes the label of remove to to delete if the field is one2many. A test was added to ensure this ux change. Task-3185967 closes odoo/odoo#126112 X-original-commit: 008f3e792bd377499fdac5b16de356f9e03b230f Signed-off-by: Warnon Aurélien (awa) <awa@odoo.com>
This commit is contained in:
@@ -608,6 +608,7 @@ X2ManyFieldDialog.props = {
|
||||
save: Function,
|
||||
title: String,
|
||||
delete: { optional: true },
|
||||
deleteButtonLabel: {optional: true},
|
||||
config: Object,
|
||||
};
|
||||
X2ManyFieldDialog.template = "web.X2ManyFieldDialog";
|
||||
@@ -683,6 +684,7 @@ export function useOpenX2ManyRecord({
|
||||
const form = await getFormViewInfo({ list, activeField, viewService, userService, env });
|
||||
|
||||
let deleteRecord;
|
||||
let deleteButtonLabel = undefined;
|
||||
const isDuplicate = !!record;
|
||||
|
||||
if (record) {
|
||||
@@ -694,7 +696,8 @@ export function useOpenX2ManyRecord({
|
||||
views: { form },
|
||||
});
|
||||
const { delete: canDelete, onDelete } = activeActions;
|
||||
deleteRecord = viewMode === "kanban" && canDelete ? () => onDelete(_record) : null;
|
||||
deleteRecord = viewMode === "kanban" && canDelete ? () => onDelete(_record) : null;
|
||||
deleteButtonLabel = activeActions.type === 'one2many' ? env._t('Delete') : env._t('Remove');
|
||||
} else {
|
||||
const recordParams = {
|
||||
context: makeContext([list.context, context]),
|
||||
@@ -738,6 +741,7 @@ export function useOpenX2ManyRecord({
|
||||
},
|
||||
title,
|
||||
delete: deleteRecord,
|
||||
deleteButtonLabel: deleteButtonLabel,
|
||||
},
|
||||
{ onClose }
|
||||
);
|
||||
|
||||
@@ -20,7 +20,10 @@
|
||||
<button class="btn btn-secondary o_form_button_cancel" t-on-click="discard" data-hotkey="j">Discard</button>
|
||||
|
||||
<t t-if="props.delete">
|
||||
<button class="btn btn-secondary o_btn_remove" t-on-click="remove" data-hotkey="k">Remove</button>
|
||||
<button class="btn btn-secondary o_btn_remove" t-on-click="remove" data-hotkey="k">
|
||||
<t t-if="props.deleteButtonLabel" t-out="props.deleteButtonLabel"/>
|
||||
<t t-else="">Remove</t>
|
||||
</button>
|
||||
</t>
|
||||
</t>
|
||||
<t t-else="">
|
||||
|
||||
@@ -2518,6 +2518,42 @@ QUnit.module("Fields", (hooks) => {
|
||||
await clickSave(target);
|
||||
});
|
||||
|
||||
QUnit.test("When viewing one2many records in an embedded kanban, the delete button should say 'Delete' and not 'Remove'", async function (assert) {
|
||||
assert.expect(1);
|
||||
serverData.views = {
|
||||
"turtle,false,form": `
|
||||
<form>
|
||||
<h3>Data</h3>
|
||||
</form>`,
|
||||
};
|
||||
await makeView({
|
||||
type: "form",
|
||||
resModel: "partner",
|
||||
serverData,
|
||||
arch: `
|
||||
<form>
|
||||
<field name="turtles">
|
||||
<kanban>
|
||||
<field name="display_name"/>
|
||||
<templates>
|
||||
<t t-name="kanban-box">
|
||||
<div t-att-class="'oe_kanban_global_click'">
|
||||
<h3>Record 1</h3>
|
||||
</div>
|
||||
</t>
|
||||
</templates>
|
||||
</kanban>
|
||||
</field>
|
||||
</form>`,
|
||||
resId: 1,
|
||||
});
|
||||
|
||||
// Opening the record to see the footer buttons
|
||||
await click(target.querySelector(".o_kanban_record"));
|
||||
|
||||
assert.strictEqual(target.querySelector('.o_btn_remove').textContent, 'Delete');
|
||||
});
|
||||
|
||||
QUnit.test("open a record in a one2many kanban (mode 'readonly')", async function (assert) {
|
||||
serverData.views = {
|
||||
"turtle,false,form": `
|
||||
|
||||
Reference in New Issue
Block a user