@geode/opengeodeweb-front 10.14.0-rc.5 → 10.14.0-rc.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -16,7 +16,7 @@ const { itemProps } = defineProps({
|
|
|
16
16
|
|
|
17
17
|
const modelId = computed(() => itemProps.meta_data.modelId || itemProps.id);
|
|
18
18
|
const componentId = computed(() => itemProps.meta_data.pickedComponentId);
|
|
19
|
-
const selection = dataStyleStore.visibleMeshComponents(modelId);
|
|
19
|
+
const selection = dataStyleStore.visibleMeshComponents(modelId.value);
|
|
20
20
|
const componentType = ref(undefined);
|
|
21
21
|
|
|
22
22
|
watchEffect(async () => {
|
package/app/stores/treeview.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { defineStore } from "pinia";
|
|
2
2
|
|
|
3
3
|
import { ref, toRaw, watch } from "vue";
|
|
4
|
+
import { compareSelections } from "@ogw_front/utils/treeview";
|
|
4
5
|
import { database } from "@ogw_internal/database/database";
|
|
5
6
|
const PANEL_WIDTH = 300;
|
|
6
7
|
|
|
@@ -55,9 +56,21 @@ export const useTreeviewStore = defineStore("treeview", () => {
|
|
|
55
56
|
{ deep: true },
|
|
56
57
|
);
|
|
57
58
|
|
|
59
|
+
watch(selection, (current, previous) => {
|
|
60
|
+
const { removed } = compareSelections(current, previous);
|
|
61
|
+
for (const id of removed) {
|
|
62
|
+
const index = opened_views.value.findIndex(
|
|
63
|
+
(view) => view.type === "component" && view.id === id,
|
|
64
|
+
);
|
|
65
|
+
if (index !== -1) {
|
|
66
|
+
closeView(index);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
|
|
58
71
|
function closeView(index) {
|
|
59
72
|
if (index > 0) {
|
|
60
|
-
opened_views.value.
|
|
73
|
+
opened_views.value = opened_views.value.filter((view, view_index) => view_index !== index);
|
|
61
74
|
}
|
|
62
75
|
}
|
|
63
76
|
|
|
@@ -67,9 +80,9 @@ export const useTreeviewStore = defineStore("treeview", () => {
|
|
|
67
80
|
for (const item of items.value) {
|
|
68
81
|
if (item.title === geodeObjectType) {
|
|
69
82
|
item.children.push(child);
|
|
70
|
-
const
|
|
83
|
+
const options = { numeric: true, sensitivity: "base" };
|
|
71
84
|
item.children.sort((childA, childB) =>
|
|
72
|
-
childA.title.localeCompare(childB.title, undefined,
|
|
85
|
+
childA.title.localeCompare(childB.title, undefined, options),
|
|
73
86
|
);
|
|
74
87
|
found = true;
|
|
75
88
|
break;
|
|
@@ -77,12 +90,12 @@ export const useTreeviewStore = defineStore("treeview", () => {
|
|
|
77
90
|
}
|
|
78
91
|
if (!found) {
|
|
79
92
|
items.value.push({ id: geodeObjectType, title: geodeObjectType, children: [child] });
|
|
80
|
-
const
|
|
93
|
+
const sort_options = { numeric: true, sensitivity: "base" };
|
|
81
94
|
items.value.sort((groupA, groupB) =>
|
|
82
|
-
groupA.title.localeCompare(groupB.title, undefined,
|
|
95
|
+
groupA.title.localeCompare(groupB.title, undefined, sort_options),
|
|
83
96
|
);
|
|
84
97
|
}
|
|
85
|
-
selection.value.
|
|
98
|
+
selection.value = [...selection.value, id];
|
|
86
99
|
}
|
|
87
100
|
|
|
88
101
|
function removeItem(id) {
|
|
@@ -94,10 +107,7 @@ export const useTreeviewStore = defineStore("treeview", () => {
|
|
|
94
107
|
if (group.children.length === 0) {
|
|
95
108
|
items.value.splice(index, 1);
|
|
96
109
|
}
|
|
97
|
-
|
|
98
|
-
if (selectionIndex !== -1) {
|
|
99
|
-
selection.value.splice(selectionIndex, 1);
|
|
100
|
-
}
|
|
110
|
+
selection.value = selection.value.filter((selection_id) => selection_id !== id);
|
|
101
111
|
return;
|
|
102
112
|
}
|
|
103
113
|
}
|
|
@@ -119,10 +129,10 @@ export const useTreeviewStore = defineStore("treeview", () => {
|
|
|
119
129
|
});
|
|
120
130
|
}
|
|
121
131
|
|
|
122
|
-
function moveView(
|
|
123
|
-
if (
|
|
124
|
-
const [element] = opened_views.value.splice(
|
|
125
|
-
opened_views.value.splice(
|
|
132
|
+
function moveView(from_index, to_index) {
|
|
133
|
+
if (from_index !== 0 && to_index !== 0) {
|
|
134
|
+
const [element] = opened_views.value.splice(from_index, 1);
|
|
135
|
+
opened_views.value.splice(to_index, 0, element);
|
|
126
136
|
}
|
|
127
137
|
}
|
|
128
138
|
|
|
@@ -31,8 +31,8 @@ function useModelStyle() {
|
|
|
31
31
|
const modelColorStyle = useModelColorStyle(componentStyleFunctions);
|
|
32
32
|
const modelVisibilityStyle = useModelVisibilityStyle(componentStyleFunctions);
|
|
33
33
|
|
|
34
|
-
function visibleMeshComponents(
|
|
35
|
-
return useModelSelection(
|
|
34
|
+
function visibleMeshComponents(modelId) {
|
|
35
|
+
return useModelSelection(modelId, dataStyleState);
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
function applyModelStyle(modelId) {
|
|
@@ -44,6 +44,9 @@ function buildSelection(modelId, components, stylesMap, typeStylesMap, dataStyle
|
|
|
44
44
|
function useModelSelection(modelId, dataStyleState) {
|
|
45
45
|
return useObservable(
|
|
46
46
|
liveQuery(async () => {
|
|
47
|
+
if (!modelId) {
|
|
48
|
+
return [];
|
|
49
|
+
}
|
|
47
50
|
const [allComponents, componentStyles, typeStyles] = await Promise.all([
|
|
48
51
|
database.model_components.where("id").equals(modelId).toArray(),
|
|
49
52
|
database.model_component_datastyle.where("id_model").equals(modelId).toArray(),
|
|
@@ -55,9 +58,10 @@ function useModelSelection(modelId, dataStyleState) {
|
|
|
55
58
|
const stylesMap = Object.fromEntries(
|
|
56
59
|
componentStyles.map((style) => [style.id_component, style]),
|
|
57
60
|
);
|
|
58
|
-
const
|
|
59
|
-
return buildSelection(modelId, allComponents, stylesMap,
|
|
61
|
+
const stylesByTypeMap = Object.fromEntries(typeStyles.map((style) => [style.type, style]));
|
|
62
|
+
return buildSelection(modelId, allComponents, stylesMap, stylesByTypeMap, dataStyleState);
|
|
60
63
|
}),
|
|
64
|
+
{ initialValue: [] },
|
|
61
65
|
);
|
|
62
66
|
}
|
|
63
67
|
|
package/package.json
CHANGED