u
This commit is contained in:
@@ -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({
|
||||
|
||||
@@ -284,6 +284,17 @@ export function getManifestDirtyDetails(current, baseline) {
|
||||
|
||||
if (curLines.length !== baseLines.length) {
|
||||
fields.lines = true;
|
||||
} else {
|
||||
for (let i = 0; i < curLines.length; i++) {
|
||||
const cl = curLines[i];
|
||||
const bl = baseLines[i];
|
||||
const clIdentifier = cl?.key ?? (cl?.id != null ? `id-${cl.id}` : null);
|
||||
const blIdentifier = bl?.key ?? (bl?.id != null ? `id-${bl.id}` : null);
|
||||
if (clIdentifier && blIdentifier && clIdentifier !== blIdentifier) {
|
||||
fields.lines = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (let i = 0; i < curLines.length; i++) {
|
||||
|
||||
Reference in New Issue
Block a user