@live-change/frontend-auto-form 0.9.105 → 0.9.107
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.
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
}
|
|
40
40
|
})
|
|
41
41
|
|
|
42
|
-
const { value, definition, propName, rootValue, visibleProperties } = toRefs(props)
|
|
42
|
+
const { value, definition, propName, rootValue, visibleProperties, i18n } = toRefs(props)
|
|
43
43
|
|
|
44
44
|
const definitionIf = computed(() => {
|
|
45
45
|
if(definition.value?.if) {
|
|
@@ -43,7 +43,7 @@ export default function editorData(options) {
|
|
|
43
43
|
toast = useToast(options.appContext || getCurrentInstance().appContext),
|
|
44
44
|
path = usePath(options.appContext || getCurrentInstance().appContext),
|
|
45
45
|
api = useApi(options.appContext || getCurrentInstance().appContext),
|
|
46
|
-
workingZone = inject('workingZone'
|
|
46
|
+
workingZone = inject('workingZone'),
|
|
47
47
|
|
|
48
48
|
} = options
|
|
49
49
|
|
|
@@ -72,7 +72,6 @@ export default function editorData(options) {
|
|
|
72
72
|
draftIdParts.push(identifier)
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
|
-
const isNew = (idKey ? (!identifiers[idKey]) : (!draftIdParts.every(key => identifiers[key])))
|
|
76
75
|
let draftId = (idKey ? identifiers[idKey]
|
|
77
76
|
: draftIdParts.map(key => JSON.stringify(identifiers[key])).join('_')) ?? 'new'
|
|
78
77
|
if(draftId.length > 16) {
|
|
@@ -82,7 +81,7 @@ export default function editorData(options) {
|
|
|
82
81
|
actionType: serviceName, action: crudMethods.read, targetType: modelName, target: draftId
|
|
83
82
|
}
|
|
84
83
|
|
|
85
|
-
const savedDataPath =
|
|
84
|
+
const savedDataPath = Object.keys(identifiers).length > 0 ? path[serviceName][crudMethods.read](identifiers) : null
|
|
86
85
|
const draftDataPath = (draft && path.draft.myDraft(draftIdentifiers)) || null
|
|
87
86
|
|
|
88
87
|
const updateAction = api.actions[serviceName][crudMethods.update]
|
|
@@ -90,8 +89,6 @@ export default function editorData(options) {
|
|
|
90
89
|
if(!updateAction && !createOrUpdateAction)
|
|
91
90
|
throw new Error('update or createOrUpdate action must be defined in model or options')
|
|
92
91
|
const createAction = api.actions[serviceName][crudMethods.create]
|
|
93
|
-
if(isNew && !createAction && !createOrUpdateAction)
|
|
94
|
-
throw new Error('create action must be defined in model or options')
|
|
95
92
|
const createOrUpdateDraftAction = draft && api.actions.draft.setOrUpdateMyDraft
|
|
96
93
|
const removeDraftAction = draft && api.actions.draft.resetMyDraft
|
|
97
94
|
|
|
@@ -99,6 +96,13 @@ export default function editorData(options) {
|
|
|
99
96
|
live(savedDataPath), live(draftDataPath)
|
|
100
97
|
]).then(([savedData, draftData]) => {
|
|
101
98
|
|
|
99
|
+
const isNew = computed(() => !savedData.value)
|
|
100
|
+
watch(isNew, (newVal) => {
|
|
101
|
+
console.log("IS NEW", newVal)
|
|
102
|
+
if(newVal && !createAction && !createOrUpdateAction)
|
|
103
|
+
console.error('create action must be defined in model or options')
|
|
104
|
+
})
|
|
105
|
+
|
|
102
106
|
const editableSavedData = computed(() => savedData.value && Object.fromEntries(
|
|
103
107
|
editableProperties.map(prop => [prop, savedData.value[prop]])
|
|
104
108
|
.concat([[timeField, savedData.value[timeField]]])
|
|
@@ -177,11 +181,11 @@ export default function editorData(options) {
|
|
|
177
181
|
}
|
|
178
182
|
})
|
|
179
183
|
const changed = computed(() =>
|
|
180
|
-
JSON.stringify(editableSavedData.value ?? {})
|
|
184
|
+
JSON.stringify({ ...(editableSavedData.value ?? {}), [timeField]: undefined })
|
|
181
185
|
!== JSON.stringify({ ...synchronizedData.value.value, [timeField]: undefined })
|
|
182
186
|
)
|
|
183
187
|
const sourceChanged = computed(() =>
|
|
184
|
-
JSON.stringify(draftData.value.from)
|
|
188
|
+
JSON.stringify({ ...(draftData.value.from ?? {}), [timeField]: undefined })
|
|
185
189
|
!== JSON.stringify({ ...synchronizedData.value.value, [timeField]: undefined })
|
|
186
190
|
)
|
|
187
191
|
|
|
@@ -226,11 +230,13 @@ export default function editorData(options) {
|
|
|
226
230
|
model,
|
|
227
231
|
isNew,
|
|
228
232
|
propertiesErrors,
|
|
233
|
+
source,
|
|
229
234
|
draftChanged: synchronizedData.changed,
|
|
230
235
|
saveDraft: synchronizedData.save,
|
|
231
236
|
savingDraft: synchronizedData.saving,
|
|
232
237
|
saved: savedData,
|
|
233
238
|
savedPath: savedDataPath,
|
|
239
|
+
editableSavedData,
|
|
234
240
|
draft: draftData,
|
|
235
241
|
sourceChanged /// needed for draft discard on concurrent save
|
|
236
242
|
}
|
|
@@ -273,6 +279,7 @@ export default function editorData(options) {
|
|
|
273
279
|
saving: synchronizedData.saving,
|
|
274
280
|
saved: savedData,
|
|
275
281
|
savedPath: savedDataPath,
|
|
282
|
+
isNew,
|
|
276
283
|
propertiesErrors,
|
|
277
284
|
reset,
|
|
278
285
|
model,
|
|
@@ -26,6 +26,7 @@ function addSchema(schemas, schema) {
|
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
export function schemaFromDefinition(definition, data, type, appContext = getCurrentInstance().appContext) {
|
|
29
|
+
if(!definition) throw new Error("Definition is required")
|
|
29
30
|
if(!type) type = definition.type
|
|
30
31
|
if(type === 'Object') {
|
|
31
32
|
const properties = Object.fromEntries(
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@live-change/frontend-auto-form",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.107",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"memDev": "node server/start.js memDev --enableSessions --initScript ./init.js --dbAccess",
|
|
6
6
|
"localDevInit": "rm tmp.db; lcli localDev --enableSessions --initScript ./init.js",
|
|
@@ -22,16 +22,16 @@
|
|
|
22
22
|
"type": "module",
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"@fortawesome/fontawesome-free": "^6.7.2",
|
|
25
|
-
"@live-change/cli": "^0.9.
|
|
26
|
-
"@live-change/dao": "^0.9.
|
|
27
|
-
"@live-change/dao-vue3": "^0.9.
|
|
28
|
-
"@live-change/dao-websocket": "^0.9.
|
|
29
|
-
"@live-change/framework": "^0.9.
|
|
30
|
-
"@live-change/image-frontend": "^0.9.
|
|
31
|
-
"@live-change/image-service": "^0.9.
|
|
32
|
-
"@live-change/session-service": "^0.9.
|
|
33
|
-
"@live-change/vue3-components": "^0.9.
|
|
34
|
-
"@live-change/vue3-ssr": "^0.9.
|
|
25
|
+
"@live-change/cli": "^0.9.107",
|
|
26
|
+
"@live-change/dao": "^0.9.107",
|
|
27
|
+
"@live-change/dao-vue3": "^0.9.107",
|
|
28
|
+
"@live-change/dao-websocket": "^0.9.107",
|
|
29
|
+
"@live-change/framework": "^0.9.107",
|
|
30
|
+
"@live-change/image-frontend": "^0.9.107",
|
|
31
|
+
"@live-change/image-service": "^0.9.107",
|
|
32
|
+
"@live-change/session-service": "^0.9.107",
|
|
33
|
+
"@live-change/vue3-components": "^0.9.107",
|
|
34
|
+
"@live-change/vue3-ssr": "^0.9.107",
|
|
35
35
|
"@vueuse/core": "^12.3.0",
|
|
36
36
|
"codeceptjs-assert": "^0.0.5",
|
|
37
37
|
"compression": "^1.7.5",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"vue3-scroll-border": "0.1.7"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
|
-
"@live-change/codeceptjs-helper": "^0.9.
|
|
55
|
+
"@live-change/codeceptjs-helper": "^0.9.107",
|
|
56
56
|
"codeceptjs": "^3.6.10",
|
|
57
57
|
"generate-password": "1.7.1",
|
|
58
58
|
"playwright": "1.49.1",
|
|
@@ -63,5 +63,5 @@
|
|
|
63
63
|
"author": "Michał Łaszczewski <michal@laszczewski.pl>",
|
|
64
64
|
"license": "ISC",
|
|
65
65
|
"description": "",
|
|
66
|
-
"gitHead": "
|
|
66
|
+
"gitHead": "c546be0c12841aa8eca060d4c53d6d89bac2d088"
|
|
67
67
|
}
|