@geode/opengeodeweb-front 10.4.2-rc.1 → 10.5.0-rc.1
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/data.js
CHANGED
|
@@ -101,20 +101,70 @@ export const useDataStore = defineStore("data", () => {
|
|
|
101
101
|
await database.data.update(id, changes)
|
|
102
102
|
}
|
|
103
103
|
|
|
104
|
-
async function addModelComponents(values) {
|
|
104
|
+
async function addModelComponents(id, values) {
|
|
105
105
|
if (!values || values.length === 0) {
|
|
106
|
-
console.debug("[addModelComponents] No
|
|
106
|
+
console.debug("[addModelComponents] No components to add")
|
|
107
107
|
return
|
|
108
108
|
}
|
|
109
|
-
|
|
110
|
-
|
|
109
|
+
|
|
110
|
+
const { mesh_components, collection_components } = values
|
|
111
|
+
const allComponents = [
|
|
112
|
+
...(mesh_components || []),
|
|
113
|
+
...(collection_components || []),
|
|
114
|
+
]
|
|
115
|
+
|
|
116
|
+
const relations = []
|
|
117
|
+
for (const component of allComponents) {
|
|
118
|
+
component.id = id
|
|
119
|
+
component.created_at = new Date().toISOString()
|
|
120
|
+
|
|
121
|
+
if (component.boundaries) {
|
|
122
|
+
for (const boundary_id of component.boundaries) {
|
|
123
|
+
relations.push({
|
|
124
|
+
id,
|
|
125
|
+
parent: component.geode_id,
|
|
126
|
+
child: boundary_id,
|
|
127
|
+
type: "boundary",
|
|
128
|
+
})
|
|
129
|
+
}
|
|
130
|
+
delete component.boundaries
|
|
131
|
+
}
|
|
132
|
+
if (component.internals) {
|
|
133
|
+
for (const internal_id of component.internals) {
|
|
134
|
+
relations.push({
|
|
135
|
+
id,
|
|
136
|
+
parent: component.geode_id,
|
|
137
|
+
child: internal_id,
|
|
138
|
+
type: "internal",
|
|
139
|
+
})
|
|
140
|
+
}
|
|
141
|
+
delete component.internals
|
|
142
|
+
}
|
|
143
|
+
if (component.items) {
|
|
144
|
+
for (const item_id of component.items) {
|
|
145
|
+
relations.push({
|
|
146
|
+
id,
|
|
147
|
+
parent: component.geode_id,
|
|
148
|
+
child: item_id,
|
|
149
|
+
type: "collection",
|
|
150
|
+
})
|
|
151
|
+
}
|
|
152
|
+
delete component.items
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
const serializedComponents = structuredClone(allComponents)
|
|
157
|
+
const serializedRelations = structuredClone(relations)
|
|
158
|
+
|
|
159
|
+
await database.model_components.bulkAdd(serializedComponents)
|
|
160
|
+
if (serializedRelations.length > 0) {
|
|
161
|
+
await database.model_components_relation.bulkAdd(serializedRelations)
|
|
111
162
|
}
|
|
112
|
-
const serializedData = structuredClone(values)
|
|
113
|
-
await database.model_components.bulkAdd(serializedData)
|
|
114
163
|
}
|
|
115
164
|
|
|
116
165
|
async function deleteModelComponents(id) {
|
|
117
166
|
await database.model_components.where({ id }).delete()
|
|
167
|
+
await database.model_components_relation.where({ id }).delete()
|
|
118
168
|
}
|
|
119
169
|
|
|
120
170
|
async function fetchModelComponents(id) {
|
|
@@ -124,19 +174,7 @@ export const useDataStore = defineStore("data", () => {
|
|
|
124
174
|
{ id },
|
|
125
175
|
{
|
|
126
176
|
response_function: async (response) => {
|
|
127
|
-
|
|
128
|
-
...response.mesh_components.map(
|
|
129
|
-
({
|
|
130
|
-
boundaries: _boundaries,
|
|
131
|
-
internals: _internals,
|
|
132
|
-
...component
|
|
133
|
-
}) => component,
|
|
134
|
-
),
|
|
135
|
-
...response.collection_components.map(
|
|
136
|
-
({ items: _items, ...component }) => component,
|
|
137
|
-
),
|
|
138
|
-
].map((component) => Object.assign(component, { id }))
|
|
139
|
-
await addModelComponents(allComponents)
|
|
177
|
+
await addModelComponents(id, response)
|
|
140
178
|
},
|
|
141
179
|
},
|
|
142
180
|
)
|
|
@@ -2,6 +2,7 @@ import { Dexie } from "dexie"
|
|
|
2
2
|
import { ExtendedDatabase } from "./extended_database"
|
|
3
3
|
import { dataTable } from "./tables/data_table"
|
|
4
4
|
import { modelComponentsTable } from "./tables/model_components"
|
|
5
|
+
import { modelComponentsRelationTable } from "./tables/model_components_relation"
|
|
5
6
|
|
|
6
7
|
class Database extends Dexie {
|
|
7
8
|
constructor() {
|
|
@@ -10,6 +11,7 @@ class Database extends Dexie {
|
|
|
10
11
|
this.version(1).stores({
|
|
11
12
|
[dataTable.name]: dataTable.schema,
|
|
12
13
|
[modelComponentsTable.name]: modelComponentsTable.schema,
|
|
14
|
+
[modelComponentsRelationTable.name]: modelComponentsRelationTable.schema,
|
|
13
15
|
})
|
|
14
16
|
}
|
|
15
17
|
|
|
@@ -26,6 +28,8 @@ class Database extends Dexie {
|
|
|
26
28
|
|
|
27
29
|
currentStores[dataTable.name] = dataTable.schema
|
|
28
30
|
currentStores[modelComponentsTable.name] = modelComponentsTable.schema
|
|
31
|
+
currentStores[modelComponentsRelationTable.name] =
|
|
32
|
+
modelComponentsRelationTable.schema
|
|
29
33
|
|
|
30
34
|
for (const table of tempDb.tables) {
|
|
31
35
|
const keyPath = table.schema.primKey.src
|
|
@@ -49,6 +53,8 @@ class Database extends Dexie {
|
|
|
49
53
|
existingDb.version(1).stores({
|
|
50
54
|
[dataTable.name]: dataTable.schema,
|
|
51
55
|
[modelComponentsTable.name]: modelComponentsTable.schema,
|
|
56
|
+
[modelComponentsRelationTable.name]:
|
|
57
|
+
modelComponentsRelationTable.schema,
|
|
52
58
|
})
|
|
53
59
|
} else {
|
|
54
60
|
existingDb.version(version).stores(currentStores)
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Dexie } from "dexie"
|
|
2
2
|
import { dataTable } from "./tables/data_table"
|
|
3
3
|
import { modelComponentsTable } from "./tables/model_components"
|
|
4
|
+
import { modelComponentsRelationTable } from "./tables/model_components_relation"
|
|
4
5
|
|
|
5
6
|
export class ExtendedDatabase extends Dexie {
|
|
6
7
|
constructor(currentVersion, currentStores, newTables) {
|
|
@@ -11,6 +12,8 @@ export class ExtendedDatabase extends Dexie {
|
|
|
11
12
|
this.version(1).stores({
|
|
12
13
|
[dataTable.name]: dataTable.schema,
|
|
13
14
|
[modelComponentsTable.name]: modelComponentsTable.schema,
|
|
15
|
+
[modelComponentsRelationTable.name]:
|
|
16
|
+
modelComponentsRelationTable.schema,
|
|
14
17
|
})
|
|
15
18
|
} else {
|
|
16
19
|
this.version(version).stores(currentStores)
|
package/package.json
CHANGED