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.
134 lines
4.2 KiB
134 lines
4.2 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">
|
||
3 years ago
|
<v-skeleton-loader style="width: 200px" type="card-heading" />
|
||
3 years ago
|
<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">
|
||
3 years ago
|
<v-img :src="templateData.image_url" height="200px" :style="{ background: templateData.image_url }" />
|
||
3 years ago
|
<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>
|
||
3 years ago
|
<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>
|
||
3 years ago
|
<v-icon class="mr-1" :color="textColors[7]"> mdi-code-json </v-icon>
|
||
3 years ago
|
Create REST Project
|
||
|
</v-list-item-title>
|
||
|
</v-list-item>
|
||
|
<v-list-item dense class="py-2" @click="useTemplate('graphql')">
|
||
|
<v-list-item-title>
|
||
3 years ago
|
<v-icon class="mr-1" :color="textColors[3]"> mdi-graphql </v-icon>
|
||
3 years ago
|
Create GQL Project
|
||
|
</v-list-item-title>
|
||
|
</v-list-item>
|
||
|
</v-list>
|
||
|
</v-menu>
|
||
3 years ago
|
<v-btn v-else :loading="loading" :disabled="loading" class="primary" x-large @click="useTemplate">
|
||
3 years ago
|
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';
|
||
|
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],
|
||
3 years ago
|
createProject: Boolean,
|
||
3 years ago
|
},
|
||
3 years ago
|
data: () => ({ templateData: null, counter: 0, loadingTemplate: false }),
|
||
3 years ago
|
computed: {
|
||
|
templateId() {
|
||
3 years ago
|
return this.modal ? this.id : this.$route.params.id;
|
||
|
},
|
||
3 years ago
|
},
|
||
|
mounted() {
|
||
3 years ago
|
this.loadTemplateData();
|
||
3 years ago
|
},
|
||
3 years ago
|
methods: {
|
||
|
async loadTemplateData() {
|
||
3 years ago
|
this.loadingTemplate = true;
|
||
3 years ago
|
try {
|
||
3 years ago
|
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();
|
||
|
}
|
||
3 years ago
|
} catch (e) {
|
||
3 years ago
|
console.log(e);
|
||
3 years ago
|
}
|
||
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() {
|
||
3 years ago
|
await this.loadTemplateData();
|
||
3 years ago
|
if (this.$refs.cat) {
|
||
3 years ago
|
await this.$refs.cat.loadCategories();
|
||
3 years ago
|
}
|
||
3 years ago
|
this.$emit('saved');
|
||
|
},
|
||
|
},
|
||
|
};
|
||
3 years ago
|
</script>
|
||
|
|
||
|
<style scoped>
|
||
|
/deep/ .v-list-item {
|
||
|
min-height: 30px;
|
||
|
}
|
||
|
</style>
|