@edgedev/create-edge-app 1.1.29 → 1.2.30
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/agents.md +2 -0
- package/bin/cli.js +13 -5
- package/deploy-services.sh +237 -0
- package/deploy.sh +88 -1
- package/edge/components/cms/blockEditor.vue +748 -7
- package/{pages/app/dashboard/blocks/index.vue → edge/components/cms/blocksManager.vue} +9 -24
- package/edge/components/cms/menu.vue +100 -15
- package/edge/components/cms/site.vue +83 -3
- package/edge/components/cms/sitesManager.vue +110 -0
- package/edge/components/cms/themeEditor.vue +9 -3
- package/edge/components/dashboard.vue +22 -3
- package/edge/components/editor.vue +100 -35
- package/edge/components/organizationMembers.vue +294 -221
- package/edge/components/shad/combobox.vue +2 -2
- package/edge/composables/global.ts +1 -1
- package/edge/routes/cms/dashboard/blocks/index.vue +21 -0
- package/edge/routes/cms/dashboard/sites/index.vue +13 -0
- package/edge/routes/cms/nuxtHooks.js +52 -0
- package/edge/routes/cms/routes.js +56 -0
- package/firebase_init.sh +63 -2
- package/nuxt.config.ts +19 -2
- package/package.json +1 -1
- package/services/.deploy.shared.env.example +12 -0
- package/pages/app/dashboard/sites/index.vue +0 -114
- /package/{pages/app → edge/routes/cms}/dashboard/blocks/[block].vue +0 -0
- /package/{pages/app → edge/routes/cms}/dashboard/media/index.vue +0 -0
- /package/{pages/app → edge/routes/cms}/dashboard/sites/[site]/[[page]].vue +0 -0
- /package/{pages/app → edge/routes/cms}/dashboard/sites/[site].vue +0 -0
- /package/{pages/app → edge/routes/cms}/dashboard/templates/[page].vue +0 -0
- /package/{pages/app/dashboard/templates.vue → edge/routes/cms/dashboard/templates/index.vue} +0 -0
- /package/{pages/app → edge/routes/cms}/dashboard/themes/[theme].vue +0 -0
- /package/{pages/app → edge/routes/cms}/dashboard/themes/index.vue +0 -0
|
@@ -96,6 +96,46 @@ const state = reactive({
|
|
|
96
96
|
const edgeFirebase = inject('edgeFirebase')
|
|
97
97
|
// const edgeGlobal = inject('edgeGlobal')
|
|
98
98
|
|
|
99
|
+
const normalizeObject = (value) => {
|
|
100
|
+
if (Array.isArray(value)) {
|
|
101
|
+
return value.map(item => normalizeObject(item))
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
if (value && typeof value === 'object') {
|
|
105
|
+
return Object.keys(value)
|
|
106
|
+
.sort()
|
|
107
|
+
.reduce((acc, key) => {
|
|
108
|
+
acc[key] = normalizeObject(value[key])
|
|
109
|
+
return acc
|
|
110
|
+
}, {})
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
return value
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
const withSchemaDefaults = (doc = {}) => {
|
|
117
|
+
const normalizedDoc = edgeGlobal.dupObject(doc || {})
|
|
118
|
+
Object.keys(newDoc.value).forEach((field) => {
|
|
119
|
+
if (!edgeGlobal.objHas(normalizedDoc, field)) {
|
|
120
|
+
normalizedDoc[field] = newDoc.value[field]
|
|
121
|
+
}
|
|
122
|
+
})
|
|
123
|
+
return normalizedDoc
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
const comparableDoc = (doc = {}) => {
|
|
127
|
+
const sourceDoc = (doc && typeof doc === 'object') ? doc : {}
|
|
128
|
+
const comparable = {}
|
|
129
|
+
Object.keys(props.newDocSchema || {}).forEach((field) => {
|
|
130
|
+
if (edgeGlobal.objHas(sourceDoc, field)) {
|
|
131
|
+
comparable[field] = sourceDoc[field]
|
|
132
|
+
return
|
|
133
|
+
}
|
|
134
|
+
comparable[field] = newDoc.value[field]
|
|
135
|
+
})
|
|
136
|
+
return normalizeObject(comparable)
|
|
137
|
+
}
|
|
138
|
+
|
|
99
139
|
const unsavedChanges = computed(() => {
|
|
100
140
|
if (props.docId === 'new') {
|
|
101
141
|
return false
|
|
@@ -107,9 +147,9 @@ const unsavedChanges = computed(() => {
|
|
|
107
147
|
return false
|
|
108
148
|
}
|
|
109
149
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
return JSON.stringify(
|
|
150
|
+
const workingComparable = comparableDoc(state.workingDoc)
|
|
151
|
+
const baselineComparable = comparableDoc(baselineDoc)
|
|
152
|
+
return JSON.stringify(workingComparable) !== JSON.stringify(baselineComparable)
|
|
113
153
|
})
|
|
114
154
|
|
|
115
155
|
onBeforeRouteLeave((to, from, next) => {
|
|
@@ -164,7 +204,7 @@ const discardChanges = async () => {
|
|
|
164
204
|
}
|
|
165
205
|
return
|
|
166
206
|
}
|
|
167
|
-
state.workingDoc =
|
|
207
|
+
state.workingDoc = withSchemaDefaults(state.collectionData[props.docId])
|
|
168
208
|
state.bypassUnsavedChanges = true
|
|
169
209
|
state.dialog = false
|
|
170
210
|
edgeGlobal.edgeState.changeTracker = {}
|
|
@@ -328,44 +368,63 @@ const initData = (newVal) => {
|
|
|
328
368
|
if (edgeGlobal.objHas(newVal, props.docId) === false) {
|
|
329
369
|
return
|
|
330
370
|
}
|
|
331
|
-
state.workingDoc =
|
|
332
|
-
Object.keys(newDoc.value).forEach((field) => {
|
|
333
|
-
if (!edgeGlobal.objHas(state.workingDoc, field)) {
|
|
334
|
-
state.workingDoc[field] = newDoc.value[field]
|
|
335
|
-
}
|
|
336
|
-
})
|
|
371
|
+
state.workingDoc = withSchemaDefaults(newVal[props.docId])
|
|
337
372
|
state.afterMount = true
|
|
338
373
|
}
|
|
339
374
|
else {
|
|
340
375
|
if (!state.afterMount) {
|
|
341
|
-
state.workingDoc =
|
|
376
|
+
state.workingDoc = withSchemaDefaults(newDoc.value)
|
|
342
377
|
}
|
|
343
378
|
state.afterMount = true
|
|
344
379
|
}
|
|
345
380
|
}
|
|
346
381
|
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
edgeGlobal.edgeState.changeTracker = {}
|
|
350
|
-
for (const field of Object.keys(props.newDocSchema)) {
|
|
382
|
+
const startCollectionSnapshots = async () => {
|
|
383
|
+
for (const field of Object.keys(props.newDocSchema || {})) {
|
|
351
384
|
if (props.newDocSchema[field].type === 'collection') {
|
|
352
385
|
await edgeFirebase.startSnapshot(`${edgeGlobal.edgeState.organizationDocPath}/${field}`)
|
|
353
386
|
}
|
|
354
387
|
}
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
if (!edgeFirebase.data?.[
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
state.collectionData
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
const setCollectionData = async () => {
|
|
391
|
+
const collectionPath = `${edgeGlobal.edgeState.organizationDocPath}/${props.collection}`
|
|
392
|
+
if (!edgeFirebase.data?.[collectionPath]) {
|
|
393
|
+
if (props.docId !== 'new') {
|
|
394
|
+
const docData = await edgeFirebase.getDocData(collectionPath, props.docId)
|
|
395
|
+
state.collectionData = {
|
|
396
|
+
...(state.collectionData || {}),
|
|
397
|
+
[props.docId]: docData,
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
else if (!state.collectionData || typeof state.collectionData !== 'object') {
|
|
401
|
+
state.collectionData = {}
|
|
402
|
+
}
|
|
403
|
+
return
|
|
368
404
|
}
|
|
405
|
+
state.collectionData = edgeFirebase.data[collectionPath]
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
const resetEditorState = () => {
|
|
409
|
+
state.bypassUnsavedChanges = false
|
|
410
|
+
state.bypassRoute = ''
|
|
411
|
+
state.afterMount = false
|
|
412
|
+
state.dialog = false
|
|
413
|
+
state.successMessage = ''
|
|
414
|
+
state.skipNextValidation = props.docId === 'new'
|
|
415
|
+
edgeGlobal.edgeState.changeTracker = {}
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
const refreshEditorData = async () => {
|
|
419
|
+
resetEditorState()
|
|
420
|
+
await startCollectionSnapshots()
|
|
421
|
+
await setCollectionData()
|
|
422
|
+
initData(state.collectionData)
|
|
423
|
+
emit('unsavedChanges', unsavedChanges.value)
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
onBeforeMount(async () => {
|
|
427
|
+
await refreshEditorData()
|
|
369
428
|
if (props.noCloseAfterSave) {
|
|
370
429
|
state.overrideClose = true
|
|
371
430
|
}
|
|
@@ -374,6 +433,17 @@ onBeforeMount(async () => {
|
|
|
374
433
|
watch(() => state.collectionData, (newVal) => {
|
|
375
434
|
initData(newVal)
|
|
376
435
|
})
|
|
436
|
+
|
|
437
|
+
watch(() => [props.collection, props.docId], async (newVal, oldVal) => {
|
|
438
|
+
if (!oldVal) {
|
|
439
|
+
return
|
|
440
|
+
}
|
|
441
|
+
if (newVal[0] === oldVal[0] && newVal[1] === oldVal[1]) {
|
|
442
|
+
return
|
|
443
|
+
}
|
|
444
|
+
await refreshEditorData()
|
|
445
|
+
})
|
|
446
|
+
|
|
377
447
|
onActivated(() => {
|
|
378
448
|
// console.log('activated')
|
|
379
449
|
state.bypassUnsavedChanges = false
|
|
@@ -384,17 +454,12 @@ onActivated(() => {
|
|
|
384
454
|
if (edgeGlobal.objHas(state.collectionData, props.docId) === false) {
|
|
385
455
|
return
|
|
386
456
|
}
|
|
387
|
-
state.workingDoc =
|
|
388
|
-
Object.keys(newDoc.value).forEach((field) => {
|
|
389
|
-
if (!edgeGlobal.objHas(state.workingDoc, field)) {
|
|
390
|
-
state.workingDoc[field] = newDoc.value[field]
|
|
391
|
-
}
|
|
392
|
-
})
|
|
457
|
+
state.workingDoc = withSchemaDefaults(state.collectionData[props.docId])
|
|
393
458
|
|
|
394
459
|
// console.log('state.workingDoc', state.workingDoc)
|
|
395
460
|
}
|
|
396
461
|
else {
|
|
397
|
-
state.workingDoc =
|
|
462
|
+
state.workingDoc = withSchemaDefaults(newDoc.value)
|
|
398
463
|
Object.entries(route.query).forEach(([key, value]) => {
|
|
399
464
|
// Check if the key exists in state.workingDoc, and if so, set the value
|
|
400
465
|
if (key in state.workingDoc) {
|