165 lines
4.7 KiB
JavaScript
Raw Normal View History

2019-11-16 10:21:14 +03:00
/**
* First we will load all of this project's JavaScript dependencies which
* includes Vue and other libraries. It is a great starting point when
* building robust, powerful web applications using Vue and Laravel.
*/
require('./../../bootstrap');
import Vue from 'vue';
2020-01-03 12:10:07 +03:00
import DashboardPlugin from './../../plugins/dashboard-plugin';
2019-11-16 10:21:14 +03:00
import Global from './../../mixins/global';
import Form from './../../plugins/form';
import BulkAction from './../../plugins/bulk-action';
2020-01-03 12:10:07 +03:00
// plugin setup
Vue.use(DashboardPlugin);
2020-01-03 12:10:07 +03:00
2019-11-16 10:21:14 +03:00
const app = new Vue({
el: '#app',
2019-11-22 15:16:57 +03:00
2019-11-16 10:21:14 +03:00
mixins: [
Global
],
2019-11-22 15:16:57 +03:00
2019-11-16 10:21:14 +03:00
data: function () {
return {
form: new Form('setting'),
2019-12-20 20:12:43 +03:00
bulk_action: new BulkAction('settings'),
email: {
2019-12-20 20:12:43 +03:00
sendmailPath:true,
smtpHost:true,
smtpPort:true,
smtpUsername:true,
smtpPassword:true,
smtpEncryption:true,
2019-12-25 19:09:04 +03:00
},
2022-06-01 10:15:55 +03:00
tags: null,
template_title: '',
2020-01-08 17:17:37 +03:00
2019-12-25 19:09:04 +03:00
invoice_form: new Form('template'),
template: {
modal: false,
title: '',
message: '',
html: '',
errors: new Error()
2020-01-08 17:17:37 +03:00
},
2022-06-01 10:15:55 +03:00
item_name_input: false,
price_name_input: false,
quantity_name_input: false
2020-01-08 17:17:37 +03:00
}
2019-12-20 20:12:43 +03:00
},
methods:{
2020-01-08 17:17:37 +03:00
onChangeProtocol(protocol) {
switch(protocol) {
2019-12-20 20:12:43 +03:00
case "smtp":
this.email.sendmailPath = true;
this.email.smtpHost = false;
this.email.smtpPort = false;
this.email.smtpUsername = false;
this.email.smtpPassword = false;
this.email.smtpEncryption = false;
break;
2020-01-08 17:17:37 +03:00
2019-12-20 20:12:43 +03:00
case "sendmail":
this.email.sendmailPath = false;
this.email.smtpHost = true;
this.email.smtpPort = true;
this.email.smtpUsername = true;
this.email.smtpPassword = true;
this.email.smtpEncryption = true;
break;
2020-01-08 17:17:37 +03:00
2019-12-20 20:12:43 +03:00
default:
this.email.sendmailPath = true;
this.email.smtpHost = true;
this.email.smtpPort = true;
this.email.smtpUsername = true;
this.email.smtpPassword = true;
this.email.smtpEncryption = true;
break;
2019-12-05 18:47:42 +08:00
}
2019-12-25 19:09:04 +03:00
},
onTemplate() {
this.template.modal = true;
this.invoice_form = new Form('template');
let skips = [
'_method', '_prefix', '_token', 'action', 'errors', 'loading', 'method', 'response'
];
for (const [key, value] of Object.entries(this.form)) {
if (!skips.includes(key)) {
this.invoice_form[key] = value;
}
}
2019-12-25 19:09:04 +03:00
this.invoice_form.template = this.invoice_form._template;
},
addTemplate() {
if (this.invoice_form.template != 1) {
2020-01-08 17:17:37 +03:00
2019-12-25 19:09:04 +03:00
this.invoice_form.submit();
this.template.errors = this.invoice_form.errors;
}
2020-02-03 15:57:15 +03:00
this.form.loading = true;
this.$emit("confirm");
2019-12-25 19:09:04 +03:00
},
closeTemplate() {
this.template = {
modal: false,
title: '',
message: '',
errors: this.invoice_form.errors
};
},
2020-01-08 17:17:37 +03:00
2022-06-01 10:15:55 +03:00
onEditEmailTemplate(template_id) {
axios.get(url + '/settings/email-templates/get', {
params: {
id: template_id
}
})
.then(response => {
this.template_title = response.data.data.title;
this.form.subject = response.data.data.subject;
this.form.body = response.data.data.body;
this.form.id = response.data.data.id;
this.tags = response.data.data.tags;
});
2020-01-08 17:17:37 +03:00
},
2022-06-01 10:15:55 +03:00
settingsInvoice() {
if (this.form.item_name == 'custom') {
this.item_name_input = true;
} else {
this.item_name_input = false;
}
if (this.form.price_name == 'custom') {
this.price_name_input = true;
} else {
this.price_name_input = false;
}
if (this.form.quantity_name == 'custom') {
this.quantity_name_input = true;
} else {
this.quantity_name_input = false;
}
2020-01-08 17:17:37 +03:00
}
2019-11-16 10:21:14 +03:00
}
});