mirror of
https://github.com/photoprism/photoprism.git
synced 2025-09-26 21:01:58 +08:00
Frontend: Remove original states tracking from chip-selector and update batch component logic
This commit is contained in:
@@ -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";
|
||||
|
@@ -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;
|
||||
|
||||
|
@@ -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);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user