This commit is contained in:
seb
2026-10-15 00:20:54 +02:00
parent 7ce2e3216f
commit 39aa898324
6 changed files with 126 additions and 10 deletions

View File

@@ -375,6 +375,24 @@ export function createDeliveryEditorAutomat(options = {}) {
automat.actions.removeLineitem(payload);
},
/**
* Moves a lineitem from one index to another.
* @param {number} fromIndex Source index.
* @param {number} toIndex Target index.
* @returns {void}
*/
moveLineitem(fromIndex, toIndex) {
const currentLines = automat.state.lines ?? [];
if (fromIndex < 0 || fromIndex >= currentLines.length || toIndex < 0 || toIndex >= currentLines.length) return;
const nextLines = [...currentLines];
const [item] = nextLines.splice(fromIndex, 1);
nextLines.splice(toIndex, 0, item);
automat.setState({
lines: nextLines,
lineitems: nextLines,
});
},
/** Clears all lines from the editor. @returns {void} */
clearLineitems() {
automat.setState({