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.
139 lines
3.8 KiB
139 lines
3.8 KiB
3 years ago
|
<template>
|
||
2 years ago
|
<v-container v-if="newEditor || !modal || selectedId === null" class="py-0">
|
||
3 years ago
|
<div class="d-flex h-100">
|
||
|
<v-navigation-drawer permanent height="100% ">
|
||
3 years ago
|
<categories
|
||
|
ref="cat"
|
||
|
v-model="category"
|
||
|
:counter.sync="counter"
|
||
2 years ago
|
@input="newEditor = false"
|
||
3 years ago
|
@showTemplateEditor="newEditor = true"
|
||
|
/>
|
||
3 years ago
|
</v-navigation-drawer>
|
||
2 years ago
|
<template-editor
|
||
|
v-if="newEditor"
|
||
|
:project-template.sync="projectTemplate"
|
||
|
style="width: 100%; height: 100%"
|
||
|
@saved="onSaved"
|
||
|
/>
|
||
3 years ago
|
<v-container v-else fluid style="height: 100%; overflow: auto">
|
||
3 years ago
|
<v-row v-if="templatesLoading">
|
||
2 years ago
|
<v-col v-for="i in 10" :key="i" sm="8" offset-sm="2" offset-md="0" md="6" lg="4" xl="3">
|
||
3 years ago
|
<v-skeleton-loader type="card" />
|
||
|
</v-col>
|
||
|
</v-row>
|
||
|
|
||
2 years ago
|
<v-row v-else-if="templateList && templateList.length" class="align-stretch">
|
||
|
<v-col v-for="(template, i) in templateList" :key="i" sm="8" offset-sm="2" offset-md="0" md="6" lg="4" xl="3">
|
||
|
<v-card height="100%" class="mx-auto" @click="openTemplate(template.id)">
|
||
|
<v-img :src="template.image_url" height="50px" :style="{ background: template.image_url }" />
|
||
3 years ago
|
|
||
|
<v-card-title>
|
||
|
{{ template.title }}
|
||
|
</v-card-title>
|
||
|
|
||
|
<v-card-subtitle>
|
||
|
<span class="caption">
|
||
|
{{ getShortDescription(template.description) }}
|
||
|
</span>
|
||
|
</v-card-subtitle>
|
||
|
</v-card>
|
||
|
</v-col>
|
||
|
</v-row>
|
||
2 years ago
|
<div v-else class="d-flex justify-center mt-10">
|
||
|
<v-alert class="flex-shrink-1" type="info" outlined dense> No templates found </v-alert>
|
||
3 years ago
|
</div>
|
||
|
</v-container>
|
||
|
</div>
|
||
|
</v-container>
|
||
3 years ago
|
<project-template-detailed
|
||
|
v-else
|
||
|
:id="selectedId"
|
||
3 years ago
|
:create-project="createProject"
|
||
3 years ago
|
:loading="loading"
|
||
3 years ago
|
:counter="counter"
|
||
|
:modal="modal"
|
||
|
:view-mode="counter < 5"
|
||
|
@saved="onSaved"
|
||
2 years ago
|
@load-category="
|
||
|
v => {
|
||
|
category = v;
|
||
|
selectedId = null;
|
||
|
}
|
||
|
"
|
||
3 years ago
|
v-on="$listeners"
|
||
3 years ago
|
@showTemplateEditor="newEditor = true"
|
||
3 years ago
|
/>
|
||
3 years ago
|
</template>
|
||
|
|
||
|
<script>
|
||
3 years ago
|
// import templateList from './templates.list'
|
||
2 years ago
|
import ProjectTemplateDetailed from '~/components/templates/Detailed';
|
||
|
import Categories from '~/components/templates/Categories';
|
||
|
import TemplateEditor from '~/components/templates/Editor';
|
||
3 years ago
|
|
||
|
export default {
|
||
|
name: 'ProjectTemplates',
|
||
3 years ago
|
components: { TemplateEditor, Categories, ProjectTemplateDetailed },
|
||
3 years ago
|
props: {
|
||
3 years ago
|
modal: Boolean,
|
||
3 years ago
|
loading: Boolean,
|
||
2 years ago
|
createProject: Boolean,
|
||
3 years ago
|
},
|
||
|
data: () => ({
|
||
3 years ago
|
templatesLoading: false,
|
||
3 years ago
|
category: null,
|
||
3 years ago
|
selectedId: null,
|
||
|
templateListLoc: [],
|
||
|
counter: 0,
|
||
3 years ago
|
newEditor: false,
|
||
2 years ago
|
projectTemplate: null,
|
||
3 years ago
|
}),
|
||
|
computed: {
|
||
|
templateList() {
|
||
2 years ago
|
return this.templateListLoc.filter(t => !this.category || t.category === this.category);
|
||
|
},
|
||
3 years ago
|
},
|
||
3 years ago
|
created() {
|
||
2 years ago
|
this.loadTemplates();
|
||
3 years ago
|
},
|
||
3 years ago
|
methods: {
|
||
3 years ago
|
async loadTemplates() {
|
||
2 years ago
|
this.templatesLoading = true;
|
||
3 years ago
|
try {
|
||
2 years ago
|
const res = await this.$axios.get(`${process.env.NC_API_URL}/api/v1/nc/templates`);
|
||
|
this.templateListLoc = res.data.data;
|
||
3 years ago
|
} catch (e) {
|
||
2 years ago
|
console.log(e);
|
||
3 years ago
|
}
|
||
2 years ago
|
this.templatesLoading = false;
|
||
3 years ago
|
},
|
||
3 years ago
|
getShortDescription(str) {
|
||
3 years ago
|
if (!str || str.length < 200) {
|
||
2 years ago
|
return str;
|
||
3 years ago
|
}
|
||
2 years ago
|
return `${str.slice(0, 200)}...`;
|
||
3 years ago
|
},
|
||
|
openTemplate(id) {
|
||
|
if (this.modal) {
|
||
2 years ago
|
this.selectedId = id;
|
||
3 years ago
|
} else {
|
||
2 years ago
|
this.$router.push(`/project/templates/${id}`);
|
||
3 years ago
|
}
|
||
3 years ago
|
},
|
||
|
async onSaved() {
|
||
2 years ago
|
await this.loadTemplates();
|
||
3 years ago
|
if (this.$refs.cat) {
|
||
2 years ago
|
await this.$refs.cat.loadCategories();
|
||
3 years ago
|
}
|
||
2 years ago
|
},
|
||
|
},
|
||
|
};
|
||
3 years ago
|
</script>
|
||
|
|
||
|
<style scoped>
|
||
3 years ago
|
/deep/ .v-list-item {
|
||
3 years ago
|
min-height: 30px;
|
||
|
}
|
||
|
</style>
|