From 9c37bb5003a7f00dfe9516a809d8ef6c3ae62dae Mon Sep 17 00:00:00 2001 From: Yousif Yassi Date: Fri, 16 Jun 2023 09:11:47 -0400 Subject: [PATCH] fix: LOPS-185: [FE] resolve issue affecting semantic search when selecting items then changing text in semantic search --- src/stores/Tabs/tab_selected_items.js | 27 ++++----------------------- 1 file changed, 4 insertions(+), 23 deletions(-) diff --git a/src/stores/Tabs/tab_selected_items.js b/src/stores/Tabs/tab_selected_items.js index 47aab24c..fca3d0af 100644 --- a/src/stores/Tabs/tab_selected_items.js +++ b/src/stores/Tabs/tab_selected_items.js @@ -1,22 +1,16 @@ import { getRoot, types } from "mobx-state-tree"; -import { DynamicModel } from "../DynamicModel"; +import { StringOrNumber } from "../types"; export const TabSelectedItems = types .model("TabSelectedItems", { all: false, - list: types.optional(types.array(types.number), []), - listObject: types.optional( - types.array( - types.late(() => DynamicModel.get("TaskModel")), - ) - , []), + list: types.optional(types.array(StringOrNumber), []), }) .views((self) => ({ get snapshot() { return { all: self.all, [self.listName]: Array.from(self.list), - listObject: Array.from(self.listObject), }; }, @@ -69,50 +63,37 @@ export const TabSelectedItems = types } self.list = []; - self.listObject = []; self._invokeChangeEvent(); }, addItem(id) { - const item = getRoot(self).taskStore.list.find(rec => rec.id === id); - self.list.push(id); - self.listObject = [...self.listObject, item.toJSON()]; self._invokeChangeEvent(); }, removeItem(id) { self.list.splice(self.list.indexOf(id), 1); - self.listObject = self.listObject.filter(rec => rec.id !== id); self._invokeChangeEvent(); }, toggleItem(id) { - const item = getRoot(self).taskStore.list.find(rec => rec.id === id); - if (self.list.includes(id)) { self.list.splice(self.list.indexOf(id), 1); - self.listObject = self.listObject.filter(rec => rec.id !== id); } else { self.list.push(id); - self.listObject = [...self.listObject, item.toJSON()]; } self._invokeChangeEvent(); }, update(data) { - const taskStoreList = getRoot(self).taskStore.list; - self.all = data?.all ?? self.all; self.list = data?.[self.listName] ?? self.list; - self.listObject = data?.[self.listName] ? data?.[self.listName]?.map(id => taskStoreList.find(rec => rec.id === id)) : self.listObject; self._invokeChangeEvent(); }, clear() { self.all = false; self.list = []; - self.listObject = []; self._invokeChangeEvent(); }, @@ -121,8 +102,8 @@ export const TabSelectedItems = types }, })) .preProcessSnapshot((sn) => { - const { included, excluded, all, listObject } = sn ?? {}; - const result = { all, list: sn.list ?? (all ? excluded : included), listObject }; + const { included, excluded, all } = sn ?? {}; + const result = { all, list: sn.list ?? (all ? excluded : included) }; return result; });