@stonecrop/desktop 0.13.7 → 0.13.8
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/dist/desktop.js +1044 -1025
- package/dist/desktop.js.map +1 -1
- package/package.json +6 -6
- package/src/components/Desktop.vue +53 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stonecrop/desktop",
|
|
3
|
-
"version": "0.13.
|
|
3
|
+
"version": "0.13.8",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": {
|
|
@@ -32,11 +32,11 @@
|
|
|
32
32
|
"**/*.css"
|
|
33
33
|
],
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@stonecrop/aform": "0.13.
|
|
36
|
-
"@stonecrop/atable": "0.13.
|
|
37
|
-
"@stonecrop/
|
|
38
|
-
"@stonecrop/
|
|
39
|
-
"@stonecrop/
|
|
35
|
+
"@stonecrop/aform": "0.13.8",
|
|
36
|
+
"@stonecrop/atable": "0.13.8",
|
|
37
|
+
"@stonecrop/stonecrop": "0.13.8",
|
|
38
|
+
"@stonecrop/themes": "0.13.8",
|
|
39
|
+
"@stonecrop/schema": "0.13.8"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
42
42
|
"vue": "^3.5.33"
|
|
@@ -120,7 +120,29 @@ const currentViewData = computed<Record<string, any>>({
|
|
|
120
120
|
// Return a plain shallow copy so AForm mutations don't propagate directly into
|
|
121
121
|
// the HST reactive object, which would bypass field-trigger diffing and cause
|
|
122
122
|
// setupDeepReactivity to fire triggers for all fields on every keystroke.
|
|
123
|
-
|
|
123
|
+
const flat: Record<string, any> = { ...record?.get('') }
|
|
124
|
+
|
|
125
|
+
// AFieldset receives data[fieldsetFieldname] as its data prop, so the fieldset's
|
|
126
|
+
// children must be grouped under the fieldset key. The server returns flat SQL rows,
|
|
127
|
+
// so we nest fieldset children here before AForm renders them.
|
|
128
|
+
const doctype = stonecrop.value.registry.registry[currentDoctype.value]
|
|
129
|
+
if (doctype) {
|
|
130
|
+
for (const field of doctype.getSchemaArray()) {
|
|
131
|
+
if (
|
|
132
|
+
'fieldtype' in field &&
|
|
133
|
+
field.fieldtype === 'Fieldset' &&
|
|
134
|
+
'schema' in field &&
|
|
135
|
+
Array.isArray(field.schema)
|
|
136
|
+
) {
|
|
137
|
+
const nested: Record<string, any> = {}
|
|
138
|
+
for (const child of field.schema as any[]) {
|
|
139
|
+
if (child.fieldname) nested[child.fieldname] = flat[child.fieldname]
|
|
140
|
+
}
|
|
141
|
+
flat[field.fieldname] = nested
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
return flat
|
|
124
146
|
} catch {
|
|
125
147
|
return {}
|
|
126
148
|
}
|
|
@@ -131,9 +153,38 @@ const currentViewData = computed<Record<string, any>>({
|
|
|
131
153
|
}
|
|
132
154
|
|
|
133
155
|
try {
|
|
156
|
+
// AForm emits nested data for fieldsets: { fieldsetKey: { childA: val } }.
|
|
157
|
+
// HST and the server both expect flat rows, so flatten fieldset values back before writing.
|
|
158
|
+
const doctype = stonecrop.value.registry.registry[currentDoctype.value]
|
|
159
|
+
const fieldsetNames = new Set<string>()
|
|
160
|
+
if (doctype) {
|
|
161
|
+
for (const field of doctype.getSchemaArray()) {
|
|
162
|
+
if ('fieldtype' in field && field.fieldtype === 'Fieldset') {
|
|
163
|
+
fieldsetNames.add(field.fieldname)
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
// Two-pass flatten: non-fieldset keys first, then fieldset children.
|
|
169
|
+
// Fieldset children must be applied last — AForm may emit stale flat copies
|
|
170
|
+
// of fieldset children alongside the updated nested value, and the nested
|
|
171
|
+
// value must win regardless of key insertion order.
|
|
172
|
+
const flatData: Record<string, any> = {}
|
|
173
|
+
const fieldsetValues: Record<string, any>[] = []
|
|
174
|
+
for (const [key, value] of Object.entries(newData)) {
|
|
175
|
+
if (fieldsetNames.has(key) && value && typeof value === 'object' && !Array.isArray(value)) {
|
|
176
|
+
fieldsetValues.push(value)
|
|
177
|
+
} else {
|
|
178
|
+
flatData[key] = value
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
for (const nestedValue of fieldsetValues) {
|
|
182
|
+
Object.assign(flatData, nestedValue)
|
|
183
|
+
}
|
|
184
|
+
|
|
134
185
|
// Only update fields that actually changed to avoid triggering actions for unchanged fields
|
|
135
186
|
const hstStore = stonecrop.value.getStore()
|
|
136
|
-
for (const [fieldname, value] of Object.entries(
|
|
187
|
+
for (const [fieldname, value] of Object.entries(flatData)) {
|
|
137
188
|
const fieldPath = `${currentDoctype.value}.${currentRecordId.value}.${fieldname}`
|
|
138
189
|
const currentValue = hstStore.has(fieldPath) ? hstStore.get(fieldPath) : undefined
|
|
139
190
|
if (currentValue !== value) {
|