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

@@ -96,6 +96,7 @@ class ManifestForm extends PureComponent {
this.handleCloseArticleSearch = this.handleCloseArticleSearch.bind(this);
this.handleAssignArticleForLine = this.handleAssignArticleForLine.bind(this);
this.handleRemoveLine = this.handleRemoveLine.bind(this);
this.handleMoveLine = this.handleMoveLine.bind(this);
this.handleRemoveAllLines = this.handleRemoveAllLines.bind(this);
this.handleSave = this.handleSave.bind(this);
this.handlePdfUpload = this.handlePdfUpload.bind(this);
@@ -701,6 +702,19 @@ class ManifestForm extends PureComponent {
});
}
handleMoveLine(key, delta) {
this.setState((prev) => {
const fromIndex = prev.lines.findIndex((l) => l.key === key);
if (fromIndex < 0) return null;
const toIndex = fromIndex + delta;
if (toIndex < 0 || toIndex >= prev.lines.length) return null;
const next = [...prev.lines];
const [item] = next.splice(fromIndex, 1);
next.splice(toIndex, 0, item);
return { lines: next, isDirty: true };
});
}
handleRemoveAllLines() {
this.setState({ lines: [] });
}
@@ -998,6 +1012,7 @@ class ManifestForm extends PureComponent {
onAddArticleLine={this.handleAddArticleLine}
onSearchArticle={this.handleOpenArticleSearchForLine}
onRemoveLine={this.handleRemoveLine}
onMoveLine={this.handleMoveLine}
onRemoveAllLines={this.handleRemoveAllLines}
onSave={() => void this.handleSave()}
/>