stash
This commit is contained in:
parent
e9f192f92e
commit
be6717ac34
2 changed files with 13 additions and 11 deletions
|
@ -448,6 +448,14 @@ const store = createStore({
|
||||||
commit('setMessageTemplates', data);
|
commit('setMessageTemplates', data);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
async updateMessageTemplate({commit, state}, template) {
|
||||||
|
const {data, success} = await http.patch(`/2/message_templates/${template.id}/`,
|
||||||
|
{'message': template.message}, state.user.token);
|
||||||
|
const {data: newTemplates, success: newSuccess} = await http.get('/2/message_templates/', state.user.token);
|
||||||
|
if (data && success) {
|
||||||
|
commit('setMessageTemplates', data);
|
||||||
|
}
|
||||||
|
},
|
||||||
async fetchMessageTemplateVariables({commit, state}) {
|
async fetchMessageTemplateVariables({commit, state}) {
|
||||||
const {data, success} = await http.get('/2/message_template_variables/', state.user.token);
|
const {data, success} = await http.get('/2/message_template_variables/', state.user.token);
|
||||||
if (data && success) {
|
if (data && success) {
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
<div v-for="template in messageTemplatesIntermediate" :key="template.id" class="card bg-dark">
|
<div v-for="template in messageTemplatesIntermediate" :key="template.id" class="card bg-dark">
|
||||||
<div class="card-header">{{ template.name }}</div>
|
<div class="card-header">{{ template.name }}</div>
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<FormatedText :value="template.message" :format="formatText" class="template-message"
|
<FormatedText :value="template.message" :format="formatText"
|
||||||
@input="changeMessageTemplate(template.id, $event)"/>
|
@input="changeMessageTemplate(template.id, $event)"/>
|
||||||
<br>
|
<br>
|
||||||
<button class="btn btn-primary" @click="resetMessageTemplate(template.id)"
|
<button class="btn btn-primary" @click="resetMessageTemplate(template.id)"
|
||||||
|
@ -43,7 +43,7 @@ export default {
|
||||||
},
|
},
|
||||||
computed: mapState(['messageTemplates', 'messageTemplateVariables']),
|
computed: mapState(['messageTemplates', 'messageTemplateVariables']),
|
||||||
methods: {
|
methods: {
|
||||||
...mapActions(['fetchMessageTemplates', 'fetchMessageTemplateVariables']),
|
...mapActions(['fetchMessageTemplates', 'fetchMessageTemplateVariables', 'updateMessageTemplate']),
|
||||||
formatText(value) {
|
formatText(value) {
|
||||||
return value.replace(/{{(.+?)}}/g, (match, key) => {
|
return value.replace(/{{(.+?)}}/g, (match, key) => {
|
||||||
return `<span class="text-primary">{{${key}}}</span>`;
|
return `<span class="text-primary">{{${key}}}</span>`;
|
||||||
|
@ -58,10 +58,11 @@ export default {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
saveMessageTemplate(id) {
|
saveMessageTemplate(id) {
|
||||||
console.log(id);
|
this.updateMessageTemplate(this.messageTemplatesIntermediate.find(template => template.id === id));
|
||||||
},
|
},
|
||||||
resetMessageTemplate(id) {
|
resetMessageTemplate(id) {
|
||||||
console.log(id);
|
this.messageTemplatesIntermediate.find(template => template.id === id).message =
|
||||||
|
this.messageTemplates.find(template => template.id === id).message;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
|
@ -79,11 +80,4 @@ pre {
|
||||||
word-wrap: break-word;
|
word-wrap: break-word;
|
||||||
color: inherit;
|
color: inherit;
|
||||||
}
|
}
|
||||||
|
|
||||||
.template-message {
|
|
||||||
border: none;
|
|
||||||
margin-left: 4em;
|
|
||||||
white-space: pre-wrap;
|
|
||||||
word-wrap: break-word;
|
|
||||||
}
|
|
||||||
</style>
|
</style>
|
Loading…
Reference in a new issue