mirror of https://github.com/nocodb/nocodb
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
153 lines
4.5 KiB
153 lines
4.5 KiB
3 years ago
|
<template>
|
||
|
<v-container class="py-0">
|
||
3 years ago
|
<div class="d-flex h-100">
|
||
|
<v-navigation-drawer permanent height="100%">
|
||
3 years ago
|
<categories
|
||
|
ref="cat"
|
||
|
:counter.sync="counter"
|
||
|
@showTemplateEditor="$emit('showTemplateEditor')"
|
||
|
@input="v => $emit('load-category', v)"
|
||
|
/>
|
||
3 years ago
|
</v-navigation-drawer>
|
||
3 years ago
|
<v-container fluid style="height: 100%; overflow: auto">
|
||
|
<template v-if="loadingTemplate">
|
||
|
<v-skeleton-loader type="image" />
|
||
|
<div class="d-flex mt-2 align-center">
|
||
|
<v-skeleton-loader style="width:200px; " type="card-heading" />
|
||
|
<v-spacer />
|
||
|
<v-skeleton-loader type="button" />
|
||
|
</div>
|
||
|
<v-skeleton-loader type="paragraph" class="mt-2" />
|
||
|
<v-skeleton-loader type="table" class="mt-2" />
|
||
|
</template>
|
||
|
<template v-else-if="templateData">
|
||
|
<v-img
|
||
|
:src="templateData.image_url"
|
||
|
height="200px"
|
||
|
:style="{ background: templateData.image_url }"
|
||
|
/>
|
||
|
<div class="d-flex align-center mt-10">
|
||
|
<h2 class="display-2 font-weight-bold my-0 flex-grow-1">
|
||
|
{{ templateData.title }}
|
||
|
</h2>
|
||
|
<v-menu v-if="createProject" bottom offset-y>
|
||
|
<template #activator="{on}">
|
||
|
<v-btn
|
||
|
:loading="loading"
|
||
|
:disabled="loading"
|
||
|
class="primary"
|
||
|
x-large
|
||
|
v-on="on"
|
||
|
>
|
||
3 years ago
|
Use template
|
||
|
<v-icon>mdi-menu-down</v-icon>
|
||
3 years ago
|
</v-btn>
|
||
|
</template>
|
||
|
<v-list>
|
||
|
<v-list-item dense class="py-2" @click="useTemplate('rest')">
|
||
|
<v-list-item-title>
|
||
|
<v-icon class="mr-1" :color="textColors[7]">
|
||
|
mdi-code-json
|
||
|
</v-icon>
|
||
|
Create REST Project
|
||
|
</v-list-item-title>
|
||
|
</v-list-item>
|
||
|
<v-list-item dense class="py-2" @click="useTemplate('graphql')">
|
||
|
<v-list-item-title>
|
||
|
<v-icon class="mr-1" :color="textColors[3]">
|
||
|
mdi-graphql
|
||
|
</v-icon>
|
||
|
Create GQL Project
|
||
|
</v-list-item-title>
|
||
|
</v-list-item>
|
||
|
</v-list>
|
||
|
</v-menu>
|
||
|
<v-btn
|
||
|
v-else
|
||
|
:loading="loading"
|
||
|
:disabled="loading"
|
||
|
class="primary"
|
||
|
x-large
|
||
|
@click="useTemplate"
|
||
|
>
|
||
|
Use template
|
||
|
</v-btn>
|
||
|
</div>
|
||
|
<p class="caption mt-10">
|
||
|
{{ templateData.description }}
|
||
|
</p>
|
||
3 years ago
|
|
||
3 years ago
|
<templat-editor
|
||
|
:id="templateId"
|
||
3 years ago
|
ref="editor"
|
||
3 years ago
|
:view-mode="$store.state.templateE < 4 && viewMode"
|
||
3 years ago
|
:project-template.sync="templateData"
|
||
3 years ago
|
@saved="onSaved"
|
||
|
/>
|
||
|
</template>
|
||
3 years ago
|
</v-container>
|
||
|
</div>
|
||
|
</v-container>
|
||
|
</template>
|
||
|
|
||
|
<script>
|
||
3 years ago
|
import TemplatEditor from '~/components/templates/Editor'
|
||
|
import Categories from '~/components/templates/Categories'
|
||
3 years ago
|
import colors from '~/mixins/colors'
|
||
3 years ago
|
|
||
|
export default {
|
||
|
name: 'ProjectTemplateDetailed',
|
||
3 years ago
|
components: { Categories, TemplatEditor },
|
||
3 years ago
|
mixins: [colors],
|
||
3 years ago
|
props: {
|
||
3 years ago
|
loading: Boolean,
|
||
3 years ago
|
modal: Boolean,
|
||
|
viewMode: Boolean,
|
||
3 years ago
|
id: [String, Number],
|
||
|
createProject: Boolean
|
||
3 years ago
|
},
|
||
3 years ago
|
data: () => ({ templateData: null, counter: 0, loadingTemplate: false }),
|
||
3 years ago
|
computed: {
|
||
|
templateId() {
|
||
|
return this.modal ? this.id : this.$route.params.id
|
||
|
}
|
||
|
},
|
||
|
mounted() {
|
||
|
this.loadTemplateData()
|
||
3 years ago
|
},
|
||
3 years ago
|
methods: {
|
||
|
async loadTemplateData() {
|
||
3 years ago
|
this.loadingTemplate = true
|
||
3 years ago
|
try {
|
||
|
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)
|
||
3 years ago
|
await this.$nextTick()
|
||
|
if (this.$refs.editor) { this.$refs.editor.parseAndLoadTemplate() }
|
||
3 years ago
|
} catch (e) {
|
||
|
console.log(e)
|
||
|
}
|
||
3 years ago
|
this.loadingTemplate = false
|
||
3 years ago
|
},
|
||
3 years ago
|
useTemplate(apiType) {
|
||
3 years ago
|
if (this.modal) {
|
||
3 years ago
|
this.$emit('import', this.templateData, apiType)
|
||
3 years ago
|
}
|
||
3 years ago
|
},
|
||
|
async onSaved() {
|
||
|
await this.loadTemplateData()
|
||
|
if (this.$refs.cat) {
|
||
|
await this.$refs.cat.loadCategories()
|
||
|
}
|
||
|
this.$emit('saved')
|
||
3 years ago
|
}
|
||
|
}
|
||
|
}
|
||
|
</script>
|
||
|
|
||
|
<style scoped>
|
||
|
/deep/ .v-list-item {
|
||
|
min-height: 30px;
|
||
|
}
|
||
|
</style>
|