[FIX] web: ViewButton supports styling set on anchors tags

Part-of: odoo/odoo#92475
This commit is contained in:
luvi
2022-06-30 09:29:46 +02:00
committed by Aaron Bohy
parent b1f072cba4
commit 8e32e1dace
3 changed files with 35 additions and 0 deletions
@@ -124,6 +124,7 @@ ViewButton.props = [
"size?",
"tabindex?",
"title?",
"style?",
"string?",
"slots?",
];
@@ -8,6 +8,7 @@
t-att-name="props.clickParams.name"
t-att-special="props.clickParams.special"
t-att-href="props.tag === 'a' and '#'"
t-att-style="props.style"
t-att-type="clickParams.type"
t-att-data-tooltip-template="hasBigTooltip ? 'views.ViewButtonTooltip' : false"
t-att-data-tooltip-info="hasBigTooltip ? tooltip : false"
@@ -6386,6 +6386,39 @@ QUnit.module("Views", (hooks) => {
assert.containsN(target, ".o_btn_test_2", 3, "kanban should have three buttons of type 2");
});
QUnit.test("support styling of anchor tags with action type", async function (assert) {
assert.expect(3);
const actionService = {
start() {
return {
doActionButton: (action) => assert.strictEqual(action.name, "42"),
};
},
};
registry.category("services").add("action", actionService, { force: true });
await makeView({
type: "form",
resModel: "partner",
serverData,
arch: `
<kanban>
<templates>
<div t-name="kanban-box">
<field name="foo"/>
<a type="action" name="42" class="btn-primary" style="margin-left: 10px"><i class="fa fa-arrow-right"/> Click me !</a>
</div>
</templates>
</kanban>`,
resId: 1,
});
await click(target.querySelector("a[type='action']"));
assert.hasClass(target.querySelector("a[type='action']"), "btn-primary");
assert.strictEqual(target.querySelector("a[type='action']").style.marginLeft, "10px");
});
QUnit.test("button executes action and reloads", async (assert) => {
const kanban = await makeView({
type: "kanban",