Skip to content
This repository has been archived by the owner on Apr 18, 2024. It is now read-only.

Commit

Permalink
feat: LOPS-155: [FE] Select and export CandidateTasks to a new Project (
Browse files Browse the repository at this point in the history
  • Loading branch information
yyassi-heartex committed Jun 6, 2023
1 parent d989b82 commit 6c32e37
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/components/CandidateTaskView/CandidateTaskView.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export const CandidateTaskView = observer(({ item, columns }) => {
setModified(metadata.updated ? format(new Date(metadata.updated), dateDisplayFormat) : "");
setSize(`${new Intl.NumberFormat().format(parseInt(metadata.size))} bytes`);
setBucket(metadata.bucket);
setDimensions(Object.values(imgRef.current).map(ref => `${ref.naturalWidth} x ${ref.naturalHeight} px`));
setDimensions(Object.values(imgRef.current).map(ref => `${ref?.naturalWidth ?? 0} x ${ref?.naturalHeight ?? 0} px`));
}
};

Expand Down
2 changes: 0 additions & 2 deletions src/components/MainView/DataView/DataView.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,10 @@ export const DataView = injector(
);

const onSelectAll = useCallback(() => {
console.log('selected all');
view.selectAll();
}, [view]);

const onRowSelect = useCallback((id) => {
console.log('selected row');
view.toggleSelected(id);
}, [view]);

Expand Down
4 changes: 3 additions & 1 deletion src/stores/DataStores/tasks.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { DataStore, DataStoreItem } from "../../mixins/DataStore";
import { getAnnotationSnapshot } from "../../sdk/lsf-utils";
import { isDefined } from "../../utils/utils";
import { Assignee } from "../Assignee";
import { DynamicModel } from "../DynamicModel";
import { DynamicModel, registerModel } from "../DynamicModel";
import { CustomJSON } from "../types";
import { FF_DEV_2536, FF_LOPS_E_3, isFF } from "../../utils/feature-flags";

Expand Down Expand Up @@ -102,6 +102,8 @@ export const create = (columns) => {

const TaskModel = types.compose("TaskModel", TaskModelBase, DataStoreItem);

registerModel("TaskModel", TaskModel);

return DataStore("TasksStore", {
apiMethod: "tasks",
listItemType: TaskModel,
Expand Down
24 changes: 22 additions & 2 deletions src/stores/Tabs/tab_selected_items.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
import { getRoot, types } from "mobx-state-tree";
import { DynamicModel } from "../DynamicModel";

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")),
)
, []),
})
.views((self) => ({
get snapshot() {
return {
all: self.all,
[self.listName]: Array.from(self.list),
listObject: Array.from(self.listObject),
};
},

Expand Down Expand Up @@ -62,37 +69,50 @@ 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();
},

Expand All @@ -101,8 +121,8 @@ export const TabSelectedItems = types
},
}))
.preProcessSnapshot((sn) => {
const { included, excluded, all } = sn ?? {};
const result = { all, list: sn.list ?? (all ? excluded : included) };
const { included, excluded, all, listObject } = sn ?? {};
const result = { all, list: sn.list ?? (all ? excluded : included), listObject };

return result;
});
5 changes: 5 additions & 0 deletions src/utils/api-proxy/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,11 @@ export class APIProxy {
json() {
return Promise.resolve(response);
},
text() {
return JSON.stringify(response);
},
headers: {},
status: 200,
});
}, this.mockDelay);
});
Expand Down

0 comments on commit 6c32e37

Please sign in to comment.