Add 'clone template' feature to the templates UI

This commit is contained in:
Kailash Nadh 2020-08-01 13:28:12 +05:30
parent 2587d67765
commit 818da1bb4d
2 changed files with 22 additions and 2 deletions

View File

@ -153,7 +153,7 @@
</b-tooltip>
</a>
<a href="" @click.prevent="$utils.prompt(`Clone campaign`,
{ placeholder: 'Campaign name', value: `Copy of ${props.row.name}`},
{ placeholder: 'Name', value: `Copy of ${props.row.name}`},
(name) => cloneCampaign(name, props.row))">
<b-tooltip label="Clone" type="is-dark">
<b-icon icon="file-multiple-outline" size="is-small" />

View File

@ -40,6 +40,13 @@
<b-icon icon="pencil-outline" size="is-small" />
</b-tooltip>
</a>
<a href="" @click.prevent="$utils.prompt(`Clone template`,
{ placeholder: 'Name', value: `Copy of ${props.row.name}`},
(name) => cloneTemplate(name, props.row))">
<b-tooltip label="Clone" type="is-dark">
<b-icon icon="file-multiple-outline" size="is-small" />
</b-tooltip>
</a>
<a v-if="!props.row.isDefault" href="#"
@click.prevent="$utils.confirm(null, () => makeTemplateDefault(props.row))">
<b-tooltip label="Make default" type="is-dark">
@ -126,6 +133,19 @@ export default Vue.extend({
this.previewItem = null;
},
cloneTemplate(name, t) {
const data = { name, body: t.body };
this.$api.createTemplate(data).then((d) => {
this.$api.getTemplates();
this.$emit('finished');
this.$buefy.toast.open({
message: `'${d.name}' created`,
type: 'is-success',
queue: false,
});
});
},
makeTemplateDefault(tpl) {
this.$api.makeTemplateDefault(tpl.id).then(() => {
this.$api.getTemplates();