@live-change/frontend-auto-form 0.9.201 → 0.9.204

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.
@@ -1,8 +1,8 @@
1
1
  <template>
2
2
  <router-link v-if="link" :to="viewRoute">
3
- <ObjectIdentification :objectType="objectType" :object="object" :data="data" />
3
+ <ObjectIdentification :objectType="objectType" :object="object" :data="data" v-bind="$attrs" />
4
4
  </router-link>
5
- <ObjectIdentification v-else :objectType="objectType" :object="object" :data="data" />
5
+ <ObjectIdentification v-else :objectType="objectType" :object="object" :data="data" v-bind="$attrs" />
6
6
  </template>
7
7
 
8
8
  <script setup>
@@ -25,7 +25,7 @@
25
25
  link: {
26
26
  type: Boolean,
27
27
  default: false
28
- }
28
+ }
29
29
  })
30
30
  const { objectType, object, data, link } = toRefs(props)
31
31
 
@@ -10,11 +10,6 @@
10
10
  const model = defineModel({
11
11
  })
12
12
 
13
- const convertedDate = computed({ // convert from iso to Date
14
- get: () => model.value ? new Date(model.value) : null,
15
- set: val => model.value = val ? new Date(val) : null
16
- })
17
-
18
13
  const props = defineProps({
19
14
  selectionMode: {
20
15
  type: String,
@@ -256,6 +251,11 @@
256
251
  })
257
252
 
258
253
 
254
+ const convertedDate = computed({ // convert from iso to Date
255
+ get: () => model.value ? new Date(model.value) : null,
256
+ set: val => model.value = val ? (props.showTime ? new Date(val).toISOString() : `${val.getFullYear()}-${(val.getMonth()+1).toString().padStart(2, '0')}-${val.getDate().toString().padStart(2, '0')}`) : null
257
+ })
258
+
259
259
  </script>
260
260
 
261
261
  <style scoped>
@@ -24,6 +24,7 @@ types.Array = inputs.list = inputConfig(() => import('./ArrayInput.vue'), {
24
24
  })
25
25
 
26
26
  types.Date = inputs.datetime = inputConfig(() => import('./Calendar.vue'), { attributes: { showTime: true } })
27
+ inputs.date = inputConfig(() => import('./Calendar.vue'), { attributes: { showTime: false } })
27
28
 
28
29
  inputs.select = inputConfig(() => import('primevue/dropdown'), {
29
30
  attributes: (config) => {
@@ -5,7 +5,7 @@ import { synchronized, defaultData } from '@live-change/vue3-components'
5
5
 
6
6
  import { propertiesValidationErrors } from './validation.js'
7
7
 
8
- import { cyrb128 } from './utils.js'
8
+ import { cyrb128, deepUnref } from './utils.js'
9
9
  import deepmerge from 'deepmerge'
10
10
 
11
11
  export default async function actionData(options) {
@@ -97,7 +97,7 @@ export default async function actionData(options) {
97
97
  let commandPromise = null
98
98
  const submitting = ref(false)
99
99
  async function submitData(data){
100
- const requestData = JSON.parse(JSON.stringify({ ...data, ...parameters }))
100
+ const requestData = JSON.parse(JSON.stringify({ ...data, ...deepUnref(parameters) }))
101
101
  if(commandPromise) await commandPromise // wait for previous save
102
102
  submitting.value = true
103
103
  commandPromise = (async () => {
@@ -1,13 +1,13 @@
1
1
  import { useToast } from 'primevue/usetoast'
2
2
  import { usePath, live, useApi } from '@live-change/vue3-ssr'
3
- import { ref, computed, inject, watch, getCurrentInstance } from 'vue'
3
+ import { ref, computed, inject, watch, getCurrentInstance, unref } from 'vue'
4
4
  import { synchronized, defaultData } from '@live-change/vue3-components'
5
5
 
6
6
  import deepmerge from 'deepmerge';
7
7
 
8
8
  import { propertiesValidationErrors } from './validation.js'
9
9
 
10
- import { cyrb128 } from './utils.js'
10
+ import { cyrb128, deepUnref } from './utils.js'
11
11
 
12
12
  export default function editorData(options) {
13
13
  if(!options) throw new Error('options must be provided')
@@ -141,7 +141,7 @@ export default function editorData(options) {
141
141
  ...(updateDataProperty ? { [updateDataProperty]: data } : data),
142
142
  ...savedIdentifiers,
143
143
  ...identifiers,
144
- ...parameters,
144
+ ...deepUnref(parameters),
145
145
  }
146
146
  if(savePromise) await savePromise // wait for previous save
147
147
  saving.value = true
@@ -18,3 +18,28 @@ export function cyrb128(str) {
18
18
  const data8 = new Uint8Array(data.buffer, data.byteOffset, data.byteLength)
19
19
  return btoa(String.fromCharCode(...data8))
20
20
  }
21
+
22
+ import {
23
+ unref,
24
+ isRef,
25
+ isReactive,
26
+ isProxy,
27
+ } from 'vue'
28
+
29
+ export function deepUnref(sourceObj) {
30
+ const objectIterator = (input) => {
31
+ if (Array.isArray(input)) {
32
+ return input.map((item) => objectIterator(item));
33
+ } if (isRef(input) || isReactive(input) || isProxy(input)) {
34
+ return objectIterator(unref(input));
35
+ } if (input && typeof input === 'object') {
36
+ return Object.keys(input).reduce((acc, key) => {
37
+ acc[key] = objectIterator(input[key]);
38
+ return acc;
39
+ }, {});
40
+ }
41
+ return input;
42
+ };
43
+
44
+ return objectIterator(sourceObj);
45
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@live-change/frontend-auto-form",
3
- "version": "0.9.201",
3
+ "version": "0.9.204",
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.201",
26
- "@live-change/dao": "^0.9.201",
27
- "@live-change/dao-vue3": "^0.9.201",
28
- "@live-change/dao-websocket": "^0.9.201",
29
- "@live-change/framework": "^0.9.201",
30
- "@live-change/image-frontend": "^0.9.201",
31
- "@live-change/image-service": "^0.9.201",
32
- "@live-change/session-service": "^0.9.201",
33
- "@live-change/vue3-components": "^0.9.201",
34
- "@live-change/vue3-ssr": "^0.9.201",
25
+ "@live-change/cli": "^0.9.204",
26
+ "@live-change/dao": "^0.9.204",
27
+ "@live-change/dao-vue3": "^0.9.204",
28
+ "@live-change/dao-websocket": "^0.9.204",
29
+ "@live-change/framework": "^0.9.204",
30
+ "@live-change/image-frontend": "^0.9.204",
31
+ "@live-change/image-service": "^0.9.204",
32
+ "@live-change/session-service": "^0.9.204",
33
+ "@live-change/vue3-components": "^0.9.204",
34
+ "@live-change/vue3-ssr": "^0.9.204",
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.201",
55
+ "@live-change/codeceptjs-helper": "^0.9.204",
56
56
  "codeceptjs": "^3.7.6",
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": "c9d7d6987de61d4f4cfa04e583b94150ade7c7bf"
66
+ "gitHead": "6ac17ccf3c184ca4d7ef920f63827dbfd8749f96"
67
67
  }