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
v-on="on"
>
Use template <v-icon>mdi-menu-down</v-icon>
Use template
<v-icon>mdi-menu-down</v-icon>
</v-btn>
</template>
<v-list>
@ -78,8 +79,9 @@
<templat-editor
:id="templateId"
ref="editor"
:view-mode="$store.state.templateE < 4 && viewMode"
:template-data.sync="templateData"
:project-template.sync="templateData"
@saved="onSaved"
/>
</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 data = res.data
this.templateData = JSON.parse(data.template)
await this.$nextTick()
if (this.$refs.editor) { this.$refs.editor.parseAndLoadTemplate() }
} catch (e) {
console.log(e)
}

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

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

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

@ -10,7 +10,7 @@
@showTemplateEditor="newEditor = true"
/>
</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-row v-if="templatesLoading">
<v-col
@ -108,7 +108,8 @@ export default {
selectedId: null,
templateListLoc: [],
counter: 0,
newEditor: false
newEditor: false,
projectTemplate: null
}),
computed: {
templateList() {

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

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

Loading…
Cancel
Save