Keep calculator parent value after saving child entries
All checks were successful
Deploy Sokko G / deploy (push) Successful in 6s
All checks were successful
Deploy Sokko G / deploy (push) Successful in 6s
This commit is contained in:
parent
5dd47b3234
commit
5d7bd7888f
2 changed files with 13 additions and 3 deletions
|
|
@ -189,6 +189,8 @@ test("toolbox module registry and modules expose expected behavior", async () =>
|
||||||
assert.match(calculatorModule, /tool-split-entry-label/);
|
assert.match(calculatorModule, /tool-split-entry-label/);
|
||||||
assert.match(calculatorModule, /copyChecklistImport/);
|
assert.match(calculatorModule, /copyChecklistImport/);
|
||||||
assert.match(calculatorModule, /resetCalculator/);
|
assert.match(calculatorModule, /resetCalculator/);
|
||||||
|
assert.match(calculatorModule, /returnToRoot/);
|
||||||
|
assert.match(calculatorModule, /setExpression\(activeParent \? formatResult\(activeParent\.value\) : ""\)/);
|
||||||
assert.match(calculatorModule, /Quantité non modifiable/);
|
assert.match(calculatorModule, /Quantité non modifiable/);
|
||||||
assert.match(calculatorModule, /entry\.label \|\| formatResult\(entry\.value\)/);
|
assert.match(calculatorModule, /entry\.label \|\| formatResult\(entry\.value\)/);
|
||||||
assert.match(calculatorModule, /ResizeObserver/);
|
assert.match(calculatorModule, /ResizeObserver/);
|
||||||
|
|
|
||||||
|
|
@ -93,7 +93,7 @@ export function CalculatorModule({ toolboxId, moduleId, context }) {
|
||||||
value: result
|
value: result
|
||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
setExpression("");
|
setExpression(activeParent ? formatResult(activeParent.value) : "");
|
||||||
setLabel("");
|
setLabel("");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -104,7 +104,10 @@ export function CalculatorModule({ toolboxId, moduleId, context }) {
|
||||||
|
|
||||||
function deleteEntry(entryId) {
|
function deleteEntry(entryId) {
|
||||||
const deletedIds = new Set([entryId, ...getDescendantIds(data.entries, entryId)]);
|
const deletedIds = new Set([entryId, ...getDescendantIds(data.entries, entryId)]);
|
||||||
if (deletedIds.has(activeParentId)) setActiveParentId("");
|
if (deletedIds.has(activeParentId)) {
|
||||||
|
setActiveParentId("");
|
||||||
|
setExpression("");
|
||||||
|
}
|
||||||
save(data.entries.filter((entry) => !deletedIds.has(entry.id)));
|
save(data.entries.filter((entry) => !deletedIds.has(entry.id)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -119,6 +122,11 @@ export function CalculatorModule({ toolboxId, moduleId, context }) {
|
||||||
setActiveParentId("");
|
setActiveParentId("");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function returnToRoot() {
|
||||||
|
setActiveParentId("");
|
||||||
|
setExpression("");
|
||||||
|
}
|
||||||
|
|
||||||
async function copyChecklistImport() {
|
async function copyChecklistImport() {
|
||||||
const text = getEntriesInTreeOrder(data.entries)
|
const text = getEntriesInTreeOrder(data.entries)
|
||||||
.map((entry) => `${entry.label || formatResult(entry.value)}:${formatResult(entry.value)}`)
|
.map((entry) => `${entry.label || formatResult(entry.value)}:${formatResult(entry.value)}`)
|
||||||
|
|
@ -154,7 +162,7 @@ export function CalculatorModule({ toolboxId, moduleId, context }) {
|
||||||
>
|
>
|
||||||
<div className="tool-split-actions">
|
<div className="tool-split-actions">
|
||||||
{activeParent && (
|
{activeParent && (
|
||||||
<button className="tool-split-root-button" type="button" onClick={() => setActiveParentId("")}>
|
<button className="tool-split-root-button" type="button" onClick={returnToRoot}>
|
||||||
{textContent.rootButton || "Revenir à la racine"}
|
{textContent.rootButton || "Revenir à la racine"}
|
||||||
</button>
|
</button>
|
||||||
)}
|
)}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue