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
|
|
@ -93,7 +93,7 @@ export function CalculatorModule({ toolboxId, moduleId, context }) {
|
|||
value: result
|
||||
}
|
||||
]);
|
||||
setExpression("");
|
||||
setExpression(activeParent ? formatResult(activeParent.value) : "");
|
||||
setLabel("");
|
||||
}
|
||||
|
||||
|
|
@ -104,7 +104,10 @@ export function CalculatorModule({ toolboxId, moduleId, context }) {
|
|||
|
||||
function deleteEntry(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)));
|
||||
}
|
||||
|
||||
|
|
@ -119,6 +122,11 @@ export function CalculatorModule({ toolboxId, moduleId, context }) {
|
|||
setActiveParentId("");
|
||||
}
|
||||
|
||||
function returnToRoot() {
|
||||
setActiveParentId("");
|
||||
setExpression("");
|
||||
}
|
||||
|
||||
async function copyChecklistImport() {
|
||||
const text = getEntriesInTreeOrder(data.entries)
|
||||
.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">
|
||||
{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"}
|
||||
</button>
|
||||
)}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue