Frontend: Remove original states tracking from chip-selector and update batch component logic

This commit is contained in:
Ömer Duran
2025-09-17 15:48:43 +03:00
parent 1342b1d1a2
commit 7664ee7556
3 changed files with 4 additions and 47 deletions

View File

@@ -99,7 +99,6 @@ export default {
data() {
return {
newItemTitle: null,
originalStates: new Map(),
};
},
computed: {
@@ -122,23 +121,6 @@ export default {
return this.processedItems.length > 0 || !this.showInput;
},
},
watch: {
items: {
handler(newItems) {
newItems.forEach((item) => {
const itemKey = item.value || item.title;
if (!item.isNew && !this.originalStates.has(itemKey)) {
this.originalStates.set(itemKey, {
mixed: item.mixed,
action: item.action || "none",
});
}
});
},
immediate: true,
deep: true,
},
},
methods: {
getChipClasses(item) {
const baseClass = "chip";

View File

@@ -1110,10 +1110,10 @@ export default {
this.formData[fieldName].action = this.actions.none;
this.formData[fieldName].value = this.previousFormData[fieldName]?.value || "";
// TODO: add this if it is necessary to change the mixed value
// if (this.formData[fieldName].mixed !== this.previousFormData[fieldName].mixed) {
// this.formData[fieldName].mixed = true;
// }
// Restore the original mixed state when undoing changes
if (this.previousFormData[fieldName]?.mixed !== undefined) {
this.formData[fieldName].mixed = this.previousFormData[fieldName].mixed;
}
} else if (classList.contains("mdi-delete")) {
this.deletedFields[fieldName] = true;

View File

@@ -259,29 +259,4 @@ describe("component/file/chip-selector", () => {
expect(wrapper.vm.shouldRenderChips).toBe(false);
});
});
describe("Original States Tracking", () => {
it("should track original states of items", async () => {
const newItems = [
{ value: "test1", title: "Test 1", mixed: true, action: "none" },
{ value: "test2", title: "Test 2", mixed: false, action: "add" },
];
await wrapper.setProps({ items: newItems });
expect(wrapper.vm.originalStates.has("test1")).toBe(true);
expect(wrapper.vm.originalStates.get("test1")).toEqual({
mixed: true,
action: "none",
});
});
it("should not track original states for new items", async () => {
const newItems = [{ value: "new1", title: "New 1", mixed: false, action: "add", isNew: true }];
await wrapper.setProps({ items: newItems });
expect(wrapper.vm.originalStates.has("new1")).toBe(false);
});
});
});