Browse Source

fix: template editor

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/863/head
Pranav C 3 years ago
parent
commit
cda9014a08
  1. 8
      packages/nc-gui/components/templates/detailed.vue
  2. 13
      packages/nc-gui/components/templates/editor.vue
  3. 5
      packages/nc-gui/components/templates/list.vue
  4. 2
      packages/nc-gui/components/templates/templatesModal.vue

8
packages/nc-gui/components/templates/detailed.vue

@ -39,7 +39,8 @@
x-large x-large
v-on="on" v-on="on"
> >
Use template <v-icon>mdi-menu-down</v-icon> Use template
<v-icon>mdi-menu-down</v-icon>
</v-btn> </v-btn>
</template> </template>
<v-list> <v-list>
@ -78,8 +79,9 @@
<templat-editor <templat-editor
:id="templateId" :id="templateId"
ref="editor"
:view-mode="$store.state.templateE < 4 && viewMode" :view-mode="$store.state.templateE < 4 && viewMode"
:template-data.sync="templateData" :project-template.sync="templateData"
@saved="onSaved" @saved="onSaved"
/> />
</template> </template>
@ -120,6 +122,8 @@ export default {
const res = await this.$axios.get(`${process.env.NC_API_URL}/api/v1/nc/templates/${this.templateId}`) const res = await this.$axios.get(`${process.env.NC_API_URL}/api/v1/nc/templates/${this.templateId}`)
const data = res.data const data = res.data
this.templateData = JSON.parse(data.template) this.templateData = JSON.parse(data.template)
await this.$nextTick()
if (this.$refs.editor) { this.$refs.editor.parseAndLoadTemplate() }
} catch (e) { } catch (e) {
console.log(e) console.log(e)
} }

13
packages/nc-gui/components/templates/editor.vue

@ -709,7 +709,7 @@ export default {
return table return table
}) })
} }
debugger
this.$emit('update:projectTemplate', template) this.$emit('update:projectTemplate', template)
} }
} }
@ -722,10 +722,7 @@ export default {
document.removeEventListener('keydown', this.handleKeyDown) document.removeEventListener('keydown', this.handleKeyDown)
}, },
mounted() { mounted() {
if (this.projectTemplate) { this.parseAndLoadTemplate()
this.parseTemplate(this.projectTemplate)
this.expansionPanel = Array.from({ length: this.project.tables.length }, (_, i) => i)
}
const input = this.$refs.projec && this.$refs.project.$el.querySelector('input') const input = this.$refs.projec && this.$refs.project.$el.querySelector('input')
if (input) { if (input) {
input.focus() input.focus()
@ -733,6 +730,12 @@ export default {
} }
}, },
methods: { methods: {
parseAndLoadTemplate() {
if (this.projectTemplate) {
this.parseTemplate(this.projectTemplate)
this.expansionPanel = Array.from({ length: this.project.tables.length }, (_, i) => i)
}
},
getIcon(type) { getIcon(type) {
return getUIDTIcon(type) return getUIDTIcon(type)
}, },

5
packages/nc-gui/components/templates/list.vue

@ -10,7 +10,7 @@
@showTemplateEditor="newEditor = true" @showTemplateEditor="newEditor = true"
/> />
</v-navigation-drawer> </v-navigation-drawer>
<template-editor v-if="newEditor" style="width:100%; height: 100%; " @saved="onSaved" /> <template-editor v-if="newEditor" :project-template.sync="projectTemplate" style="width:100%; height: 100%; " @saved="onSaved" />
<v-container v-else fluid style="height: 100%; overflow: auto"> <v-container v-else fluid style="height: 100%; overflow: auto">
<v-row v-if="templatesLoading"> <v-row v-if="templatesLoading">
<v-col <v-col
@ -108,7 +108,8 @@ export default {
selectedId: null, selectedId: null,
templateListLoc: [], templateListLoc: [],
counter: 0, counter: 0,
newEditor: false newEditor: false,
projectTemplate: null
}), }),
computed: { computed: {
templateList() { templateList() {

2
packages/nc-gui/components/templates/templatesModal.vue

@ -13,6 +13,7 @@
style="height:90vh" style="height:90vh"
modal modal
:loading="loading" :loading="loading"
:project-template.sync="templateData"
@import="importTemplate" @import="importTemplate"
/> />
</v-card> </v-card>
@ -39,6 +40,7 @@ export default {
createProject: Boolean createProject: Boolean
}, },
data: () => ({ data: () => ({
templateData: null,
loading: false, loading: false,
projectCreation: false, projectCreation: false,
loaderMessagesIndex: 0, loaderMessagesIndex: 0,

Loading…
Cancel
Save