Adding tge tags component

parent a0328ddb
<template> <template>
<el-form ref="form" :model="page" label-width="120px" label-position="top"> <el-form ref="form" :model="page" label-width="120px" label-position="top" @keydown="form.errors.clear($event.target.name);">
<div class="row"> <div class="row">
<div class="col-md-10"> <div class="col-md-10">
<div class="box box-primary"> <div class="box box-primary">
<div class="box-body"> <div class="box-body">
<el-tabs type="card"> <el-tabs type="card">
<el-tab-pane :label="localeArray.name" v-for="(localeArray, locale) in locales" :key="localeArray.name" class="asd" <el-tab-pane :label="localeArray.name" v-for="(localeArray, locale) in locales" :key="localeArray.name">
:class="{'has-error' : form.errors.has(locale)}"> <span slot="label" :class="{'error' : form.errors.has(locale)}">{{ localeArray.name }}</span>
<el-form-item :label="translate('page', 'title')" <el-form-item :label="translate('page', 'title')"
:class="{'el-form-item is-error': form.errors.has(locale + '.title') }"> :class="{'el-form-item is-error': form.errors.has(locale + '.title') }">
<el-input v-model="page[locale].title" @change="slugifyTitle($event, locale)"></el-input> <el-input v-model="page[locale].title" @change="slugifyTitle($event, locale)"></el-input>
...@@ -69,7 +69,6 @@ ...@@ -69,7 +69,6 @@
<el-option :label="translate('page', 'facebook-types.article')" value="article"></el-option> <el-option :label="translate('page', 'facebook-types.article')" value="article"></el-option>
</el-select> </el-select>
</el-form-item> </el-form-item>
<tags-input namespace="asgardcms/page"></tags-input>
</div> </div>
</div> </div>
</div> </div>
...@@ -97,6 +96,7 @@ ...@@ -97,6 +96,7 @@
</el-select> </el-select>
<div class="el-form-item__error" v-if="form.errors.has('template')" v-text="form.errors.first('template')"></div> <div class="el-form-item__error" v-if="form.errors.has('template')" v-text="form.errors.first('template')"></div>
</el-form-item> </el-form-item>
<tags-input namespace="asgardcms/page" @input="setTags"></tags-input>
</div> </div>
</div> </div>
</div> </div>
...@@ -139,16 +139,22 @@ ...@@ -139,16 +139,22 @@
}, },
form: new Form(), form: new Form(),
loading: false, loading: false,
tags: {},
} }
}, },
methods: { methods: {
onSubmit() { onSubmit() {
this.form = new Form(this.page); this.form = new Form(_.merge(this.page, {tags: this.tags}));
let vm = this; let vm = this;
this.loading = true; this.loading = true;
this.form.post(route('api.page.page.store')) this.form.post(route('api.page.page.store'))
.then(response => { .then(response => {
this.loading = false; this.loading = false;
vm.$message({
type: 'success',
message: response.data.message
});
window.location = route('admin.page.page.index');
}) })
.catch(error => { .catch(error => {
this.loading = false; this.loading = false;
...@@ -158,7 +164,7 @@ ...@@ -158,7 +164,7 @@
}); });
}); });
}, },
setPageTypes() { fetchTemplates() {
axios.get(route('api.page.page-templates.index')) axios.get(route('api.page.page-templates.index'))
.then(response => { .then(response => {
this.templates = response.data; this.templates = response.data;
...@@ -166,10 +172,13 @@ ...@@ -166,10 +172,13 @@
}, },
slugifyTitle(event, locale) { slugifyTitle(event, locale) {
this.page[locale].slug = this.slugify(event); this.page[locale].slug = this.slugify(event);
},
setTags(tags) {
this.tags = tags;
} }
}, },
mounted() { mounted() {
this.setPageTypes(); this.fetchTemplates();
} }
} }
</script> </script>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment