Skip to content

Commit 29bb77b

Browse files
committed
add feedback
1 parent 76800f0 commit 29bb77b

3 files changed

Lines changed: 18 additions & 7 deletions

File tree

app/composables/project_manager.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { useAppStore } from "@ogw_front/stores/app";
88
import { useBackStore } from "@ogw_front/stores/back";
99
import { useDataStore } from "@ogw_front/stores/data";
1010
import { useDataStyleStore } from "@ogw_front/stores/data_style";
11+
import { useFeedbackStore } from "@ogw_front/stores/feedback";
1112
import { useHybridViewerStore } from "@ogw_front/stores/hybrid_viewer";
1213
import { useTreeviewStore } from "@ogw_front/stores/treeview";
1314
import { useViewerStore } from "@ogw_front/stores/viewer";
@@ -16,6 +17,7 @@ async function exportProject() {
1617
console.log("[export triggered]");
1718
const appStore = useAppStore();
1819
const backStore = useBackStore();
20+
const feedbackStore = useFeedbackStore();
1921
const snapshot = await appStore.exportStores();
2022
const schema = back_schemas.opengeodeweb_back.export_project;
2123
const defaultName = "project.vease";
@@ -26,6 +28,7 @@ async function exportProject() {
2628
body: { snapshot, filename: defaultName },
2729
});
2830
fileDownload(result, defaultName);
31+
feedbackStore.add_success("Project exported successfully");
2932
return { result };
3033
}
3134

@@ -74,7 +77,7 @@ async function importProject(file) {
7477
}
7578

7679
await treeviewStore.importStores(snapshot.treeview || {});
77-
await dataStore.importStores(snapshot.data || {});
80+
await dataStore.importStores(snapshot.data);
7881
await hybridViewerStore.initHybridViewer();
7982

8083
const items = snapshot?.data?.items || [];
@@ -85,6 +88,8 @@ async function importProject(file) {
8588

8689
treeviewStore.finalizeImportSelection();
8790
treeviewStore.isImporting = false;
91+
const feedbackStore = useFeedbackStore();
92+
feedbackStore.add_success("Project imported successfully");
8893
}
8994

9095
export { exportProject, importProject };

app/stores/data.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -198,12 +198,8 @@ export const useDataStore = defineStore("data", () => {
198198

199199
async function importStores(snapshot) {
200200
await clear();
201-
if (snapshot.modelComponents) {
202-
await model_components_db.bulkPut(snapshot.modelComponents);
203-
}
204-
if (snapshot.modelComponentsRelations) {
205-
await model_components_relation_db.bulkPut(snapshot.modelComponentsRelations);
206-
}
201+
await model_components_db.bulkPut(snapshot.modelComponents);
202+
await model_components_relation_db.bulkPut(snapshot.modelComponentsRelations);
207203
}
208204

209205
async function clear() {

tests/unit/composables/project_manager.nuxt.test.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,10 @@ const dataStyleStoreMock = {
112112
addDataStyle: vi.fn().mockResolvedValue(),
113113
applyDefaultStyle: vi.fn().mockResolvedValue(),
114114
};
115+
const feedbackStoreMock = {
116+
add_success: vi.fn(),
117+
add_error: vi.fn(),
118+
};
115119

116120
const viewer_call_mock_fn = vi.fn().mockResolvedValue();
117121

@@ -177,6 +181,9 @@ vi.mock(import("@ogw_front/stores/hybrid_viewer"), () => ({
177181
vi.mock(import("@ogw_front/stores/back"), () => ({
178182
useBackStore: () => backStoreMock,
179183
}));
184+
vi.mock(import("@ogw_front/stores/feedback"), () => ({
185+
useFeedbackStore: () => feedbackStoreMock,
186+
}));
180187
vi.mock(import("@ogw_front/stores/app"), () => ({
181188
useAppStore: () => ({
182189
exportStores: vi.fn(() => ({ projectName: "mockedProject" })),
@@ -222,6 +229,7 @@ function verifyRemaining() {
222229
expect(dataStyleStoreMock.addDataStyle).toHaveBeenCalledWith("abc123", "PointSet2D");
223230
expect(dataStyleStoreMock.applyDefaultStyle).toHaveBeenCalledWith("abc123");
224231
expect(hybridViewerStoreMock.remoteRender).toHaveBeenCalledWith();
232+
expect(feedbackStoreMock.add_success).toHaveBeenCalledWith("Project imported successfully");
225233
}
226234

227235
describe("projectManager composable (compact)", () => {
@@ -233,6 +241,7 @@ describe("projectManager composable (compact)", () => {
233241
dataStoreMock,
234242
dataStyleStoreMock,
235243
hybridViewerStoreMock,
244+
feedbackStoreMock,
236245
];
237246
for (const store of storesList) {
238247
const values = Object.values(store);
@@ -251,6 +260,7 @@ describe("projectManager composable (compact)", () => {
251260
await exportProject();
252261

253262
expect(fileDownload).toHaveBeenCalledWith({ snapshot: snapshotMock }, "project.vease");
263+
expect(feedbackStoreMock.add_success).toHaveBeenCalledWith("Project exported successfully");
254264
});
255265

256266
test("importProjectFile with snapshot - Viewer and Stores", async () => {

0 commit comments

Comments
 (0)