@live-change/content-frontend 0.2.6 → 0.2.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.
@@ -1,13 +1,17 @@
1
1
  <template>
2
- <auto-input v-model="editable.title" :definition="properties.title" />
3
-
2
+ <pre style="white-space: pre-wrap; word-wrap: break-word;">{{ JSON.stringify(editable, null, ' ') }}</pre>
3
+ <auto-editor :definition="editableDefinition" v-model="editable" :rootValue="editable" />
4
+ <Button label="Save metadata" icon="pi pi-save" :disabled="!changed || error" @click="save" />
5
+ <small v-if="error" class="p-error">Fix errors above to save</small>
4
6
  </template>
5
7
 
6
8
  <script setup>
9
+ import Button from 'primevue/button'
10
+ import { AutoInput, AutoField, AutoEditor } from '@live-change/frontend-auto-form'
7
11
 
8
- import AutoInput from '@live-change/frontend-auto-form/AutoInput.vue'
12
+ import "@live-change/image-frontend"
9
13
 
10
- import { computed, watch, ref, onMounted, inject } from 'vue'
14
+ import { computed, watch, ref, onMounted, onUnmounted, inject } from 'vue'
11
15
  import { toRefs } from "@vueuse/core"
12
16
 
13
17
  const isMounted = ref(false)
@@ -31,11 +35,25 @@
31
35
  const p = path()
32
36
 
33
37
  const definition = api.getServiceDefinition('content').models.Metadata
34
- const properties = definition.properties
35
-
36
- import { synchronized } from "@live-change/vue3-components"
37
-
38
- const metadata = await live(p.content.objectOwnedMetadata({ objectType, object }))
38
+ const editableDefinition = {
39
+ ...definition,
40
+ properties: { ...{
41
+ ...definition.properties,
42
+ objectType: undefined,
43
+ object: undefined,
44
+ lastUpdate: undefined
45
+ } }
46
+ }
47
+
48
+ import { useToast } from 'primevue/usetoast'
49
+ const toast = useToast()
50
+ import { useConfirm } from 'primevue/useconfirm'
51
+ const confirm = useConfirm()
52
+
53
+ import { synchronized, defaultData, validateData } from "@live-change/vue3-components"
54
+
55
+ const serverMetadata = await live(p.content.objectOwnedMetadata({ objectType, object }))
56
+ const metadata = computed(() => serverMetadata.value || defaultData(editableDefinition))
39
57
 
40
58
  const synchronizedMetadata = synchronized({
41
59
  source: metadata,
@@ -43,13 +61,22 @@
43
61
  identifiers: { object, objectType },
44
62
  recursive: true,
45
63
  autoSave: false,
46
- onSave: () => toast.add({ severity: 'info', summary: 'Public access saved', life: 1500 })
47
- }).value
64
+ onSave: () => toast.add({ severity: 'info', summary: 'Metadata saved', life: 1500 })
65
+ })
48
66
 
49
67
  const editable = synchronizedMetadata.value
50
68
  const save = synchronizedMetadata.save
51
69
  const changed = synchronizedMetadata.changed
52
70
 
71
+ const error = computed(() => validateData(editableDefinition, editable.value))
72
+
73
+
74
+ function beforeUnload(ev) {
75
+ if(changed.value) return ev.returnValue = "You have some unsaved changes!"
76
+ }
77
+ onMounted(() => window.addEventListener('beforeunload', beforeUnload))
78
+ onUnmounted(() => window.removeEventListener('beforeunload', beforeUnload))
79
+
53
80
  </script>
54
81
 
55
82
  <style scoped>
@@ -21,7 +21,7 @@
21
21
  </AccordionTab>
22
22
  </Accordion>
23
23
 
24
- <DocumentEditor v-if="pageData" targetType="content_Page" :target="pageId"
24
+ <DocumentEditor v-if="pageData" targetType="content_Page" :target="pageId" purpose="page"
25
25
  :config="contentConfig" type="content" v-model:saveState="saveState" v-model:version="version">
26
26
  <template #menuEnd="{}">
27
27
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@live-change/content-frontend",
3
- "version": "0.2.6",
3
+ "version": "0.2.8",
4
4
  "scripts": {
5
5
  "memDev": "lcli memDev --enableSessions --initScript ./init.js --dbAccess",
6
6
  "localDevInit": "rm tmp.db; lcli localDev --enableSessions --initScript ./init.js",
@@ -28,8 +28,8 @@
28
28
  "@live-change/framework": "0.7.4",
29
29
  "@live-change/image-service": "0.3.2",
30
30
  "@live-change/session-service": "0.3.2",
31
- "@live-change/vue3-components": "0.2.15",
32
- "@live-change/vue3-ssr": "0.2.15",
31
+ "@live-change/vue3-components": "0.2.16",
32
+ "@live-change/vue3-ssr": "0.2.16",
33
33
  "@tiptap/extension-highlight": "^2.0.0-beta.33",
34
34
  "@tiptap/extension-underline": "2.0.0-beta.23",
35
35
  "@tiptap/starter-kit": "^2.0.0-beta.185",
@@ -66,5 +66,5 @@
66
66
  "author": "",
67
67
  "license": "ISC",
68
68
  "description": "",
69
- "gitHead": "323185f6d910912093b3c92df102d0f938cef367"
69
+ "gitHead": "72bd46680370e7804b168fec5dde28de205487e0"
70
70
  }