stash
This commit is contained in:
parent
6b11cb8393
commit
1ede9b0930
2 changed files with 22 additions and 2 deletions
|
@ -444,6 +444,12 @@ const store = createStore({
|
|||
commit('setMessageTemplateVariables', data);
|
||||
}
|
||||
},
|
||||
async createMessageTemplate({commit, state}, template_name) {
|
||||
const {data, success} = await http.post('/2/message_templates/', {name: template_name}, state.user.token);
|
||||
if (data && success) {
|
||||
commit('setMessageTemplates', data);
|
||||
}
|
||||
}
|
||||
},
|
||||
plugins: [
|
||||
persistentStatePlugin({ // TODO change remember to some kind of enable field
|
||||
|
|
|
@ -15,10 +15,17 @@
|
|||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card bg-dark">
|
||||
<div class="card-body">
|
||||
<input type="text" class="form-control" v-model="newTemplateName" placeholder="New Template Name">
|
||||
<button class="btn btn-success" @click="createMessageTemplateAndReset()" ref="createButton">Create</button>
|
||||
</div>
|
||||
</div>
|
||||
</ul>
|
||||
<h3 class="text-center">Message Template Variables</h3>
|
||||
<p>
|
||||
<span v-for="(variable, key) in messageTemplateVariables" :key="key" class="badge badge-primary" style="margin: 5px;">
|
||||
<span v-for="(variable, key) in messageTemplateVariables" :key="key" class="badge badge-primary"
|
||||
style="margin: 5px;">
|
||||
{{ variable }}
|
||||
</span>
|
||||
</p>
|
||||
|
@ -35,11 +42,12 @@ export default {
|
|||
data() {
|
||||
return {
|
||||
messageTemplatesIntermediate: [],
|
||||
newTemplateName: '',
|
||||
};
|
||||
},
|
||||
computed: mapState(['messageTemplates', 'messageTemplateVariables']),
|
||||
methods: {
|
||||
...mapActions(['fetchMessageTemplates', 'fetchMessageTemplateVariables', 'updateMessageTemplate']),
|
||||
...mapActions(['fetchMessageTemplates', 'fetchMessageTemplateVariables', 'updateMessageTemplate', 'createMessageTemplate']),
|
||||
formatText(value) {
|
||||
return value.replace(/{{(.+?)}}/g, (match, key) => {
|
||||
return `<span class="text-primary">{{${key}}}</span>`;
|
||||
|
@ -60,6 +68,12 @@ export default {
|
|||
this.messageTemplatesIntermediate.find(template => template.id === id).message =
|
||||
this.messageTemplates.find(template => template.id === id).message;
|
||||
},
|
||||
async createMessageTemplateAndReset() {
|
||||
this.$refs.createButton.disabled = true;
|
||||
await this.createMessageTemplate(this.newTemplateName);
|
||||
this.newTemplateName = '';
|
||||
this.$refs.createButton.disabled = false;
|
||||
},
|
||||
},
|
||||
mounted() {
|
||||
this.fetchMessageTemplates().then(() => {
|
||||
|
|
Loading…
Reference in a new issue