@live-change/frontend-auto-form 0.8.123 → 0.8.124

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.
@@ -29,6 +29,7 @@ export default function editorData(options) {
29
29
  onDraftSaved = () => {},
30
30
  onDraftDiscarded = () => {},
31
31
  onSaveError = () => {},
32
+ onCreated = (createResult) => {},
32
33
 
33
34
  toast = useToast(),
34
35
  path = usePath(),
@@ -65,7 +66,7 @@ export default function editorData(options) {
65
66
  }
66
67
  }
67
68
  const draftId = idKey ? identifiers[idKey]
68
- : identifiersNames.map(identifier => draftIdParts.map(key => JSON.stringify(identifier[key])).join('_'))
69
+ : draftIdParts.map(key => JSON.stringify(identifiers[key])).join('_')
69
70
 
70
71
  const draftIdentifiers = {
71
72
  actionType: serviceName, action: crudMethods.read, targetType: modelName, target: draftId
@@ -103,7 +104,9 @@ export default function editorData(options) {
103
104
  if(savedData.value) {
104
105
  return updateAction(data)
105
106
  } else {
106
- return createAction(data)
107
+ const createResult = await createAction(data)
108
+ await onCreated(createResult)
109
+ return createResult
107
110
  }
108
111
  } finally {
109
112
  saving.value = false
@@ -149,6 +152,7 @@ export default function editorData(options) {
149
152
  await saveData()
150
153
  if(draftData.value) await removeDraftAction(draftIdentifiers)
151
154
  onSaved()
155
+ if(toast && savedToast) toast.add({ severity: 'success', summary: savedToast, life: 1500 })
152
156
  }
153
157
 
154
158
  async function discardDraft() {
@@ -183,7 +187,7 @@ export default function editorData(options) {
183
187
  debounce,
184
188
  onSave: () => {
185
189
  onSaved()
186
- if(toast && savedDraftToast) toast.add({ severity: 'info', summary: savedDraftToast, life: 1500 })
190
+ if(toast && savedToast) toast.add({ severity: 'success', summary: savedToast, life: 1500 })
187
191
  },
188
192
  onSaveError(e) {
189
193
  console.error("SAVE ERROR", e)
@@ -0,0 +1,85 @@
1
+ <template>
2
+ <div class="w-full lg:w-8 md:w-11">
3
+ <div class="surface-card p-3 shadow-1 border-round">
4
+ <div class="text-xl mb-2">
5
+ Service <strong>{{ serviceName }} model {{ modelName }}</strong>
6
+ </div>
7
+
8
+ <h4>identifiers as object</h4>
9
+ <pre>{{ identifiersObject }}</pre>
10
+
11
+ <h4>definition</h4>
12
+ <pre>{{ modelDefinition }}</pre>
13
+
14
+ </div>
15
+ </div>
16
+ </template>
17
+
18
+ <script setup>
19
+
20
+ import { ref, computed, onMounted, defineProps, toRefs } from 'vue'
21
+
22
+ const props = defineProps({
23
+ serviceName: {
24
+ type: String,
25
+ required: true,
26
+ },
27
+ modelName: {
28
+ type: String,
29
+ required: true,
30
+ },
31
+ identifiers: {
32
+ type: Array,
33
+ default: []
34
+ }
35
+ })
36
+ const { serviceName, modelName, identifiers } = toRefs(props)
37
+
38
+ import { useApi, usePath, live } from '@live-change/vue3-ssr'
39
+ const api = useApi()
40
+ const path = usePath()
41
+
42
+ const modelDefinition = computed(() => {
43
+ const service = api.services[serviceName.value]
44
+ if(!service) return null
45
+ const model = service.models[modelName.value]
46
+ if(!model) return null
47
+ return model
48
+ })
49
+
50
+ const identifiersObject = computed(() => {
51
+ const result = {}
52
+ for(const [i, identifier] of Object.entries(identifiers.value)) {
53
+ const identifierDefinition = modelDefinition.value.identifiers[i]
54
+ if(typeof identifierDefinition === 'string') {
55
+ result[identifierDefinition] = identifier
56
+ } else {
57
+ result[Object.keys(identifierDefinition)[0]] = identifier
58
+ }
59
+ }
60
+ return result
61
+ })
62
+
63
+
64
+ import { editorData } from "@live-change/frontend-auto-form"
65
+
66
+ /*const treeSettings = computedAsync(async () => {
67
+ const ed = await editorData({
68
+ service: serviceName,
69
+ model: modelName,
70
+ identifiers: { file: tree.value },
71
+ draft: true,
72
+ onCreated() {
73
+ console.log("CREATED")
74
+ // TODO: change route - add identifiers
75
+ },
76
+ })
77
+ console.log("ED", ed)
78
+ return ed
79
+ })*/
80
+
81
+ </script>
82
+
83
+ <style scoped>
84
+
85
+ </style>
@@ -0,0 +1,40 @@
1
+ <template>
2
+ <div class="w-full lg:w-8 md:w-11">
3
+ <div class="surface-card p-3 shadow-1 border-round">
4
+ List
5
+ </div>
6
+ </div>
7
+ </template>
8
+
9
+ <script setup>
10
+
11
+ import { ref, computed, onMounted, defineProps, toRefs } from 'vue'
12
+
13
+ const props = defineProps({
14
+ serviceName: {
15
+ type: String,
16
+ required: true,
17
+ },
18
+ modelName: {
19
+ type: String,
20
+ required: true,
21
+ },
22
+ identifiers: {
23
+ type: Array,
24
+ default: []
25
+ }
26
+ })
27
+ const { serviceName } = toRefs(props)
28
+
29
+ import { useApi, usePath, live } from '@live-change/vue3-ssr'
30
+ const api = useApi()
31
+ const path = usePath()
32
+
33
+
34
+
35
+
36
+ </script>
37
+
38
+ <style scoped>
39
+
40
+ </style>
@@ -18,13 +18,13 @@
18
18
  </div>
19
19
  <div>
20
20
  <Button icon="pi pi-list" severity="primary" label="List" class="mr-2" />
21
- <Button icon="pi pi-plus" severity="warning" :label="'Create new '+model.name" />
21
+ <router-link :to="createRoute(serviceWithModels.name, model)" class="no-underline">
22
+ <Button icon="pi pi-plus" severity="warning" :label="'Create new '+model.name" />
23
+ </router-link>
22
24
  </div>
23
25
  </div>
24
26
  </div>
25
27
  </div>
26
-
27
-
28
28
  </div>
29
29
  </template>
30
30
 
@@ -69,6 +69,16 @@
69
69
  return results
70
70
  })
71
71
 
72
+ function createRoute(serviceName, model) {
73
+ return {
74
+ name: 'auto-form:editor',
75
+ params: {
76
+ serviceName,
77
+ modelName: model.name
78
+ }
79
+ }
80
+ }
81
+
72
82
  </script>
73
83
 
74
84
  <style scoped>
@@ -8,6 +8,12 @@ export function autoFormRoutes(config = {}) {
8
8
  props: true
9
9
  }),
10
10
 
11
+ route({
12
+ name: 'auto-form:editor', path: prefix + '/editor/:serviceName/:modelName/:identifiers*', meta: { },
13
+ component: () => import("./pages/Editor.vue"),
14
+ props: true
15
+ }),
16
+
11
17
  ]
12
18
  }
13
19
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@live-change/frontend-auto-form",
3
- "version": "0.8.123",
3
+ "version": "0.8.124",
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.5.2",
25
- "@live-change/cli": "^0.8.123",
26
- "@live-change/dao": "^0.8.123",
27
- "@live-change/dao-vue3": "^0.8.123",
28
- "@live-change/dao-websocket": "^0.8.123",
29
- "@live-change/framework": "^0.8.123",
30
- "@live-change/image-frontend": "^0.8.123",
31
- "@live-change/image-service": "^0.8.123",
32
- "@live-change/session-service": "^0.8.123",
33
- "@live-change/vue3-components": "^0.8.123",
34
- "@live-change/vue3-ssr": "^0.8.123",
25
+ "@live-change/cli": "^0.8.124",
26
+ "@live-change/dao": "^0.8.124",
27
+ "@live-change/dao-vue3": "^0.8.124",
28
+ "@live-change/dao-websocket": "^0.8.124",
29
+ "@live-change/framework": "^0.8.124",
30
+ "@live-change/image-frontend": "^0.8.124",
31
+ "@live-change/image-service": "^0.8.124",
32
+ "@live-change/session-service": "^0.8.124",
33
+ "@live-change/vue3-components": "^0.8.124",
34
+ "@live-change/vue3-ssr": "^0.8.124",
35
35
  "@vueuse/core": "^10.11.0",
36
36
  "codeceptjs-assert": "^0.0.5",
37
37
  "compression": "^1.7.4",
@@ -52,7 +52,7 @@
52
52
  "vue3-scroll-border": "0.1.6"
53
53
  },
54
54
  "devDependencies": {
55
- "@live-change/codeceptjs-helper": "^0.8.123",
55
+ "@live-change/codeceptjs-helper": "^0.8.124",
56
56
  "codeceptjs": "^3.6.5",
57
57
  "generate-password": "1.7.1",
58
58
  "playwright": "^1.41.2",
@@ -63,5 +63,5 @@
63
63
  "author": "Michał Łaszczewski <michal@laszczewski.pl>",
64
64
  "license": "ISC",
65
65
  "description": "",
66
- "gitHead": "42148742342a5ac004deb122042ead1d977cb8f8"
66
+ "gitHead": "837e7729f4cbd909d6c7ae32189c562b39cc3122"
67
67
  }