[FIX] web: kanban: "muted" already in progress bar colors
Problem: In a kanban view with progress bars, have - a record with a false value for the progress bar field - "muted" be the color of a progress bar field value different from false a crash occurs. This happens because no fallback is found for value = false in findProgressValueFromRecord. Solution: Always add a bar for the value false (as it was the case before). closes odoo/odoo#95215 Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
This commit is contained in:
@@ -305,11 +305,7 @@ class KanbanGroup extends Group {
|
||||
/** @type {[string | typeof FALSE, string][]} */
|
||||
const colorEntries = Object.entries(colors);
|
||||
const selection = fieldSelection && Object.fromEntries(fieldSelection);
|
||||
|
||||
if (!colorEntries.some((v) => v[1] === "muted")) {
|
||||
colorEntries.push([FALSE, "muted"]);
|
||||
}
|
||||
|
||||
colorEntries.push([FALSE, "muted"]);
|
||||
return colorEntries.map(([value, color]) => {
|
||||
let string;
|
||||
if (value === FALSE) {
|
||||
|
||||
@@ -57,7 +57,7 @@
|
||||
</div>
|
||||
<div t-if="(env.isSmall or !group.isFolded) and group.progressBars.length" class="o_kanban_counter">
|
||||
<div class="o_kanban_counter_progress progress">
|
||||
<t t-foreach="group.progressBars" t-as="progressBar" t-key="progressBar.color">
|
||||
<t t-foreach="group.progressBars" t-as="progressBar" t-key="progressBar.value">
|
||||
<div t-if="progressBar.count"
|
||||
role="progressbar"
|
||||
class="progress-bar o_bar_has_records"
|
||||
|
||||
@@ -10149,4 +10149,75 @@ QUnit.module("Views", (hooks) => {
|
||||
|
||||
assert.strictEqual(getCardTexts()[0], "yop\nTOGGLER\nMENU");
|
||||
});
|
||||
|
||||
QUnit.test("'muted' already in progress bar colors", async (assert) => {
|
||||
serverData.models.partner.records.push({ id: 5, bar: true }, { id: 6, bar: false });
|
||||
await makeView({
|
||||
type: "kanban",
|
||||
resModel: "partner",
|
||||
serverData,
|
||||
arch: `
|
||||
<kanban>
|
||||
<field name="bar"/>
|
||||
<field name="foo"/>
|
||||
<progressbar field="foo" colors='{"yop": "muted", "gnap": "warning", "blip": "danger"}'/>
|
||||
<templates>
|
||||
<t t-name="kanban-box">
|
||||
<div>
|
||||
<field name="state"/>
|
||||
</div>
|
||||
</t>
|
||||
</templates>
|
||||
</kanban>
|
||||
`,
|
||||
groupBy: ["bar"],
|
||||
});
|
||||
|
||||
assert.containsN(target, ".o_kanban_group:nth-child(1) .progress-bar", 2);
|
||||
assert.deepEqual(
|
||||
[...target.querySelectorAll(".o_kanban_group:nth-child(1) .progress-bar")].map(
|
||||
(el) => el.dataset.tooltip
|
||||
),
|
||||
["1 blip", "1 Other"]
|
||||
);
|
||||
assert.containsN(target, ".o_kanban_group:nth-child(2) .progress-bar", 4);
|
||||
assert.deepEqual(
|
||||
[...target.querySelectorAll(".o_kanban_group:nth-child(2) .progress-bar")].map(
|
||||
(el) => el.dataset.tooltip
|
||||
),
|
||||
["1 yop", "1 gnap", "1 blip", "1 Other"]
|
||||
);
|
||||
assert.deepEqual(getCounters(), ["2", "4"]);
|
||||
|
||||
await click(target.querySelector(".o_kanban_group:nth-child(2) .progress-bar"));
|
||||
|
||||
assert.deepEqual(getCounters(), ["2", "1"]);
|
||||
assert.strictEqual(
|
||||
target.querySelector(".o_kanban_group:nth-child(2) .o_kanban_record").innerText,
|
||||
"ABC"
|
||||
);
|
||||
assert.containsNone(target, ".o_kanban_group:nth-child(2) .o_kanban_load_more");
|
||||
|
||||
await click(
|
||||
target.querySelector(".o_kanban_group:nth-child(2) .progress-bar:nth-child(2)")
|
||||
);
|
||||
|
||||
assert.deepEqual(getCounters(), ["2", "1"]);
|
||||
assert.strictEqual(
|
||||
target.querySelector(".o_kanban_group:nth-child(2) .o_kanban_record").innerText,
|
||||
"GHI"
|
||||
);
|
||||
assert.containsNone(target, ".o_kanban_group:nth-child(2) .o_kanban_load_more");
|
||||
|
||||
await click(
|
||||
target.querySelector(".o_kanban_group:nth-child(2) .progress-bar:nth-child(4)")
|
||||
);
|
||||
|
||||
assert.deepEqual(getCounters(), ["2", "1"]);
|
||||
assert.strictEqual(
|
||||
target.querySelector(".o_kanban_group:nth-child(2) .o_kanban_record").innerText,
|
||||
""
|
||||
);
|
||||
assert.containsNone(target, ".o_kanban_group:nth-child(2) .o_kanban_load_more");
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user