diff --git a/package-lock.json b/package-lock.json index a6168d5c..c9b147ea 100644 --- a/package-lock.json +++ b/package-lock.json @@ -31,6 +31,7 @@ "http-errors": "^2.0.0", "http-link-header": "^1.1.0", "json-schema-defaults": "^0.4.0", + "json-schema-ref-parser": "^9.0.9", "marked": "^4.3.0", "memoizee": "^0.4.15", "mime-types": "^2.1.35", @@ -117,6 +118,33 @@ "node": ">=6.0.0" } }, + "node_modules/@apidevtools/json-schema-ref-parser": { + "version": "9.0.9", + "resolved": "https://registry.npmjs.org/@apidevtools/json-schema-ref-parser/-/json-schema-ref-parser-9.0.9.tgz", + "integrity": "sha512-GBD2Le9w2+lVFoc4vswGI/TjkNIZSVp7+9xPf+X3uidBfWnAeUWmquteSyt0+VCrhNMWj/FTABISQrD3Z/YA+w==", + "dependencies": { + "@jsdevtools/ono": "^7.1.3", + "@types/json-schema": "^7.0.6", + "call-me-maybe": "^1.0.1", + "js-yaml": "^4.1.0" + } + }, + "node_modules/@apidevtools/json-schema-ref-parser/node_modules/argparse": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", + "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==" + }, + "node_modules/@apidevtools/json-schema-ref-parser/node_modules/js-yaml": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", + "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", + "dependencies": { + "argparse": "^2.0.1" + }, + "bin": { + "js-yaml": "bin/js-yaml.js" + } + }, "node_modules/@aws-crypto/ie11-detection": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/@aws-crypto/ie11-detection/-/ie11-detection-3.0.0.tgz", @@ -4229,6 +4257,11 @@ "@jridgewell/sourcemap-codec": "1.4.14" } }, + "node_modules/@jsdevtools/ono": { + "version": "7.1.3", + "resolved": "https://registry.npmjs.org/@jsdevtools/ono/-/ono-7.1.3.tgz", + "integrity": "sha512-4JQNk+3mVzK3xh2rqd6RB4J46qUR19azEHBneZyTZM+c456qOrbbM/5xcR8huNCCcbVt7+UmizG6GuUvPvKUYg==" + }, "node_modules/@koumoul/nuxt-config-inject": { "version": "0.4.12", "resolved": "https://registry.npmjs.org/@koumoul/nuxt-config-inject/-/nuxt-config-inject-0.4.12.tgz", @@ -7567,8 +7600,7 @@ "node_modules/@types/json-schema": { "version": "7.0.9", "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.9.tgz", - "integrity": "sha512-qcUXuemtEu+E5wZSJHNxUXeCZhAfXKQ41D+duX+VYPde7xyEVZci+/oXKJL13tnRs9lR2pr4fod59GT6/X1/yQ==", - "dev": true + "integrity": "sha512-qcUXuemtEu+E5wZSJHNxUXeCZhAfXKQ41D+duX+VYPde7xyEVZci+/oXKJL13tnRs9lR2pr4fod59GT6/X1/yQ==" }, "node_modules/@types/json5": { "version": "0.0.29", @@ -9510,6 +9542,11 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/call-me-maybe": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/call-me-maybe/-/call-me-maybe-1.0.2.tgz", + "integrity": "sha512-HpX65o1Hnr9HH25ojC1YGs7HCQLq0GCOibSaWER0eNpgJ/Z1MZv2mTc7+xh6WOPxbRVcmgbv4hGU+uSQ/2xFZQ==" + }, "node_modules/callsite": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/callsite/-/callsite-1.0.0.tgz", @@ -15235,6 +15272,18 @@ "json-schema-defaults": "bin/defaults.js" } }, + "node_modules/json-schema-ref-parser": { + "version": "9.0.9", + "resolved": "https://registry.npmjs.org/json-schema-ref-parser/-/json-schema-ref-parser-9.0.9.tgz", + "integrity": "sha512-qcP2lmGy+JUoQJ4DOQeLaZDqH9qSkeGCK3suKWxJXS82dg728Mn3j97azDMaOUmJAN4uCq91LdPx4K7E8F1a7Q==", + "deprecated": "Please switch to @apidevtools/json-schema-ref-parser", + "dependencies": { + "@apidevtools/json-schema-ref-parser": "9.0.9" + }, + "engines": { + "node": ">=10" + } + }, "node_modules/json-schema-traverse": { "version": "0.4.1", "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", @@ -24476,6 +24525,32 @@ } } }, + "@apidevtools/json-schema-ref-parser": { + "version": "9.0.9", + "resolved": "https://registry.npmjs.org/@apidevtools/json-schema-ref-parser/-/json-schema-ref-parser-9.0.9.tgz", + "integrity": "sha512-GBD2Le9w2+lVFoc4vswGI/TjkNIZSVp7+9xPf+X3uidBfWnAeUWmquteSyt0+VCrhNMWj/FTABISQrD3Z/YA+w==", + "requires": { + "@jsdevtools/ono": "^7.1.3", + "@types/json-schema": "^7.0.6", + "call-me-maybe": "^1.0.1", + "js-yaml": "^4.1.0" + }, + "dependencies": { + "argparse": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", + "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==" + }, + "js-yaml": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", + "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", + "requires": { + "argparse": "^2.0.1" + } + } + } + }, "@aws-crypto/ie11-detection": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/@aws-crypto/ie11-detection/-/ie11-detection-3.0.0.tgz", @@ -27746,6 +27821,11 @@ "@jridgewell/sourcemap-codec": "1.4.14" } }, + "@jsdevtools/ono": { + "version": "7.1.3", + "resolved": "https://registry.npmjs.org/@jsdevtools/ono/-/ono-7.1.3.tgz", + "integrity": "sha512-4JQNk+3mVzK3xh2rqd6RB4J46qUR19azEHBneZyTZM+c456qOrbbM/5xcR8huNCCcbVt7+UmizG6GuUvPvKUYg==" + }, "@koumoul/nuxt-config-inject": { "version": "0.4.12", "resolved": "https://registry.npmjs.org/@koumoul/nuxt-config-inject/-/nuxt-config-inject-0.4.12.tgz", @@ -30047,8 +30127,7 @@ "@types/json-schema": { "version": "7.0.9", "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.9.tgz", - "integrity": "sha512-qcUXuemtEu+E5wZSJHNxUXeCZhAfXKQ41D+duX+VYPde7xyEVZci+/oXKJL13tnRs9lR2pr4fod59GT6/X1/yQ==", - "dev": true + "integrity": "sha512-qcUXuemtEu+E5wZSJHNxUXeCZhAfXKQ41D+duX+VYPde7xyEVZci+/oXKJL13tnRs9lR2pr4fod59GT6/X1/yQ==" }, "@types/json5": { "version": "0.0.29", @@ -31652,6 +31731,11 @@ "get-intrinsic": "^1.0.2" } }, + "call-me-maybe": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/call-me-maybe/-/call-me-maybe-1.0.2.tgz", + "integrity": "sha512-HpX65o1Hnr9HH25ojC1YGs7HCQLq0GCOibSaWER0eNpgJ/Z1MZv2mTc7+xh6WOPxbRVcmgbv4hGU+uSQ/2xFZQ==" + }, "callsite": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/callsite/-/callsite-1.0.0.tgz", @@ -36110,6 +36194,14 @@ "argparse": "^1.0.9" } }, + "json-schema-ref-parser": { + "version": "9.0.9", + "resolved": "https://registry.npmjs.org/json-schema-ref-parser/-/json-schema-ref-parser-9.0.9.tgz", + "integrity": "sha512-qcP2lmGy+JUoQJ4DOQeLaZDqH9qSkeGCK3suKWxJXS82dg728Mn3j97azDMaOUmJAN4uCq91LdPx4K7E8F1a7Q==", + "requires": { + "@apidevtools/json-schema-ref-parser": "9.0.9" + } + }, "json-schema-traverse": { "version": "0.4.1", "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", diff --git a/package.json b/package.json index 4a64f4b1..d3effe26 100644 --- a/package.json +++ b/package.json @@ -73,6 +73,7 @@ "http-errors": "^2.0.0", "http-link-header": "^1.1.0", "json-schema-defaults": "^0.4.0", + "json-schema-ref-parser": "^9.0.9", "marked": "^4.3.0", "memoizee": "^0.4.15", "mime-types": "^2.1.35", diff --git a/public/assets/templates/news.json b/public/assets/templates/news.json index 321179da..0cbd2715 100644 --- a/public/assets/templates/news.json +++ b/public/assets/templates/news.json @@ -77,9 +77,6 @@ "description": { "$ref": "#/definitions/description" }, - "alert": { - "$ref": "#/definitions/alert" - }, "application": { "$ref": "#/definitions/application" }, diff --git a/public/assets/templates/thematic.json b/public/assets/templates/thematic.json index 716fb146..004da7d1 100644 --- a/public/assets/templates/thematic.json +++ b/public/assets/templates/thematic.json @@ -7,39 +7,45 @@ "$ref": "#/definitions/title" }, "banner": { - "title": "URL de l'image de bannière", - "description": "Utile pour pointer vers une image sur un autre serveur Web. Si vous disposez de l'image en fichier sur votre poste vous pouvez la charger ci-dessous.", - "type": "string" - }, - "localBanner": { "type": "object", - "x-display": "custom-df-image", + "title": "Bannière", "properties": { - "assetId": { - "readOnly": true - }, - "assetTitle": { - "readOnly": true - }, - "pageId": { - "type": "string", - "readOnly": true - }, - "pageTitle": { - "type": "string", - "readOnly": true + "url": { + "title": "URL vers l'image", + "description": "Utile pour pointer vers une image sur un autre serveur Web. Si vous disposez de l'image en fichier sur votre poste vous pouvez la charger ci-dessous.", + "type": "string" }, - "_updatedAt": { - "type": "string", - "readOnly": true - }, - "_id": { - "type": "string", - "readOnly": true - }, - "attachmentPath": { - "type": "string", - "readOnly": true + "local": { + "type": "object", + "x-display": "custom-df-image", + "properties": { + "assetId": { + "readOnly": true + }, + "assetTitle": { + "readOnly": true + }, + "pageId": { + "type": "string", + "readOnly": true + }, + "pageTitle": { + "type": "string", + "readOnly": true + }, + "_updatedAt": { + "type": "string", + "readOnly": true + }, + "_id": { + "type": "string", + "readOnly": true + }, + "attachmentPath": { + "type": "string", + "readOnly": true + } + } } } }, diff --git a/public/components/pages/blank.vue b/public/components/pages/blank.vue index 7409a623..bf6ad8a9 100644 --- a/public/components/pages/blank.vue +++ b/public/components/pages/blank.vue @@ -1,71 +1,276 @@ @@ -71,7 +60,6 @@ import Thematic from '~/components/pages/thematic.vue' import News from '~/components/pages/news.vue' const { mapState } = require('vuex') -const context = require.context('../../../../../../assets/templates', true, /\.json$/) const pageSchema = require('~/../contract/page.json') Object.keys(pageSchema.properties).forEach(p => { if (pageSchema.properties[p].readOnly) delete pageSchema.properties[p] @@ -88,9 +76,6 @@ export default { }), computed: { ...mapState(['config', 'portal']), - template () { - return this.page.template && context(`./${this.page.template}.json`) - }, dataFairUrl () { return this.$store.getters.dataFairUrl }, @@ -137,14 +122,23 @@ export default { this.pageConfig = this.page.config || {} delete this.page.config if (this.config.owner) this.owner = this.config.owner.type + ':' + this.config.owner.id - this.htmlPage = await this.$axios.$get(this.$store.state.publicUrl + `/api/v1/portals/${this.portal._id}/pages/${this.$route.params.id}`, { params: { html: true } }) + this.htmlPage.config = this.htmlPage.config || {} }, methods: { - async update (patch) { + async updatePage (patch) { + try { + this.page = await this.$axios.$patch(this.$store.state.publicUrl + `/api/v1/portals/${this.portal._id}/pages/${this.$route.params.id}`, patch) + delete this.page.config + delete this.page.id + } catch (error) { + console.error(error) + } + }, + async updateConfig (config) { + this.pageConfig = { ...this.pageConfig, ...config } try { - this.htmlPage = await this.$axios.$patch(this.$store.state.publicUrl + `/api/v1/portals/${this.portal._id}/pages/${this.$route.params.id}`, patch, { params: { html: true } }) - // this.$router.push({ name: 'pages' }) + this.htmlPage = await this.$axios.$patch(this.$store.state.publicUrl + `/api/v1/portals/${this.portal._id}/pages/${this.$route.params.id}`, { config: this.pageConfig }, { params: { html: true } }) } catch (error) { console.error(error) } diff --git a/public/pages/pages/_id.vue b/public/pages/pages/_id.vue index d5157704..9dcfe6dc 100644 --- a/public/pages/pages/_id.vue +++ b/public/pages/pages/_id.vue @@ -7,12 +7,12 @@