@geode/opengeodeweb-front 10.14.0-rc.5 → 10.14.0-rc.6
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.
- package/app/stores/treeview.js +24 -14
- package/package.json +1 -1
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
|
|
package/package.json
CHANGED