diff --git a/resources/assets/js/views/wizard/Company.vue b/resources/assets/js/views/wizard/Company.vue index fa9f484ec..c57573992 100644 --- a/resources/assets/js/views/wizard/Company.vue +++ b/resources/assets/js/views/wizard/Company.vue @@ -115,129 +115,140 @@ import AkauntingDate from "./../../components/AkauntingDate"; import WizardAction from "./../../mixins/wizardAction"; export default { - name: "Company", - mixins: [WizardAction], - components: { - [Step.name]: Step, - [Steps.name]: Steps, - AkauntingDropzoneFileUpload, - AkauntingDate, - }, - props: { - company: { - type: [Object, Array], - }, - translations: { - type: [Object, Array], - }, - url: { - type: String, - default: "text", - }, - }, - data() { - return { - active: 0, - logo: [], - real_date: "", - }; - }, - mounted() { - let company_data = this.company; - this.onDataWatch(company_data); - }, - watch: { - company: function (company) { - this.onDataWatch(company); - }, - }, - methods: { - onDataWatch(company) { - if (Object.keys(company).length) { - let logo_arr = [ - { - id: company.logo.id, - name: company.logo.filename + "." + company.logo.extension, - path: company.logo.path, - type: company.logo.mime_type, - size: company.logo.size, - downloadPath: false, - }, - ]; - this.logo.push(logo_arr); - this.real_date = company.financial_start; - } + name: "Company", + + mixins: [WizardAction], + + components: { + [Step.name]: Step, + [Steps.name]: Steps, + AkauntingDropzoneFileUpload, + AkauntingDate, }, - onEditSave() { - FormData.prototype.appendRecursive = function (data, wrapper = null) { - for (var name in data) { - if (name == "previewElement" || name == "previewTemplate") { - continue; - } - if (wrapper) { - if ( - (typeof data[name] == "object" || Array.isArray(data[name])) && - data[name] instanceof File != true && - data[name] instanceof Blob != true - ) { - this.appendRecursive(data[name], wrapper + "[" + name + "]"); - } else { - this.append(wrapper + "[" + name + "]", data[name]); - } - } else { - if ( - (typeof data[name] == "object" || Array.isArray(data[name])) && - data[name] instanceof File != true && - data[name] instanceof Blob != true - ) { - this.appendRecursive(data[name], name); - } else { - this.append(name, data[name]); - } - } - } - }; + props: { + company: { + type: [Object, Array], + }, - const formData = new FormData(this.$refs["form"]); - let data_name = {}; + translations: { + type: [Object, Array], + }, + + url: { + type: String, + default: "text", + }, + }, + + data() { + return { + active: 0, + logo: [], + real_date: "", + }; + }, + + mounted() { + let company_data = this.company; + + this.onDataWatch(company_data); + }, + + methods: { + onDataWatch(company) { + if (Object.keys(company).length) { + let logo_arr = [{ + id: company.logo.id, + name: company.logo.filename + "." + company.logo.extension, + path: company.logo.path, + type: company.logo.mime_type, + size: company.logo.size, + downloadPath: false, + }]; + + this.logo.push(logo_arr); + this.real_date = company.financial_start; + } + }, + + onEditSave() { + FormData.prototype.appendRecursive = function (data, wrapper = null) { + for (var name in data) { + if (name == "previewElement" || name == "previewTemplate") { + continue; + } + + if (wrapper) { + if ( + (typeof data[name] == "object" || Array.isArray(data[name])) && + data[name] instanceof File != true && + data[name] instanceof Blob != true + ) { + this.appendRecursive(data[name], wrapper + "[" + name + "]"); + } else { + this.append(wrapper + "[" + name + "]", data[name]); + } + } else { + if ( + (typeof data[name] == "object" || Array.isArray(data[name])) && + data[name] instanceof File != true && + data[name] instanceof Blob != true + ) { + this.appendRecursive(data[name], name); + } else { + this.append(name, data[name]); + } + } + } + }; + + const formData = new FormData(this.$refs["form"]); + + let data_name = {}; - for (let [key, val] of formData.entries()) { - Object.assign(data_name, { - [key]: val, - ["logo"]: this.$refs.dropzoneWizard.files[1] - ? this.$refs.dropzoneWizard.files[1] - : this.$refs.dropzoneWizard.files[0], - ["_prefix"]: "company", - ["_token"]: window.Laravel.csrfToken, - ["_method"]: "POST", - }); - } + for (let [key, val] of formData.entries()) { + Object.assign(data_name, { + [key]: val, + ["logo"]: this.$refs.dropzoneWizard.files[1] + ? this.$refs.dropzoneWizard.files[1] + : this.$refs.dropzoneWizard.files[0], + ["_prefix"]: "company", + ["_token"]: window.Laravel.csrfToken, + ["_method"]: "POST", + }); + } - formData.appendRecursive(data_name); - window - .axios({ - method: "POST", - url: url + "/wizard/companies", - data: formData, - headers: { - "X-CSRF-TOKEN": window.Laravel.csrfToken, - "X-Requested-With": "XMLHttpRequest", - "Content-Type": "multipart/form-data", - }, - }) - .then((response) => { - this.onSuccessMessage(response); - this.$router.push("/wizard/currencies"); - }, this) - .catch((error) => { - }, this); + formData.appendRecursive(data_name); + + window.axios({ + method: "POST", + url: url + "/wizard/companies", + data: formData, + headers: { + "X-CSRF-TOKEN": window.Laravel.csrfToken, + "X-Requested-With": "XMLHttpRequest", + "Content-Type": "multipart/form-data", + }, + }) + .then((response) => { + this.onSuccessMessage(response); + this.$router.push("/wizard/currencies"); + }, this) + .catch((error) => { + }, this); + }, + + next() { + if (this.active++ > 2); + this.$router.push("/wizard/currencies"); + }, }, - next() { - if (this.active++ > 2); - this.$router.push("/wizard/currencies"); + watch: { + company: function (company) { + this.onDataWatch(company); + }, }, - }, }; \ No newline at end of file diff --git a/resources/assets/js/views/wizard/Currencies.vue b/resources/assets/js/views/wizard/Currencies.vue index 3323360c2..c99b49b85 100644 --- a/resources/assets/js/views/wizard/Currencies.vue +++ b/resources/assets/js/views/wizard/Currencies.vue @@ -299,124 +299,133 @@ import MixinsGlobal from "./../../mixins/global"; import WizardAction from "./../../mixins/wizardAction"; export default { - name: "Currencies", - mixins: [MixinsGlobal, WizardAction], - components: { - [Step.name]: Step, - [Steps.name]: Steps, - [Select.name]: Select, - [Option.name]: Option, - AkauntingRadioGroup, - }, - props: { - currencies: { - type: [Object, Array], - }, - currency_codes: { - type: [Object, Array], - }, - translations: { - type: [Object, Array], - }, - }, - data() { - return { - active: 1, - bulk_action: new BulkAction(url + "/settings/currencies"), - }; - }, - methods: { - onSwitchUpdate(item) { - this.onStatus(item.id, event); - this.onStatusControl(this.currencies, item.id, event); + name: "Currencies", + + mixins: [MixinsGlobal, WizardAction], + + components: { + [Step.name]: Step, + [Steps.name]: Steps, + [Select.name]: Select, + [Option.name]: Option, + AkauntingRadioGroup, }, - onClickDelete(item) { - this.confirmDelete( - `${ - new URL(url).protocol + - "//" + - location.host + - location.pathname + - "/" + - item.id - }`, - this.translations.currencies.title, - `Confirm Delete ${item.name} ${this.translations.currencies.title}?`, - this.translations.currencies.cancel, - this.translations.currencies.delete - ); + props: { + currencies: { + type: [Object, Array], + }, + + currency_codes: { + type: [Object, Array], + }, + + translations: { + type: [Object, Array], + }, }, - onDeleteCurrency(event) { - this.onEjetItem(event, this.currencies, event.currency_id); + data() { + return { + active: 1, + bulk_action: new BulkAction(url + "/settings/currencies"), + }; }, - onChangeCodeItem(code) { - const formData = new FormData(this.$refs["form"]); - const data = { - rate: "", - precision: "", - symbol: "", - symbol_first: "", - decimal_mark: "", - thousands_separator: "", - }; + methods: { + onSwitchUpdate(item) { + this.onStatus(item.id, event); - for (let [key, val] of formData.entries()) { - Object.assign(data, { - [key]: val, - }); - } + this.onStatusControl(this.currencies, item.id, event); + }, - window - .axios({ - method: "GET", - url: url + "/settings/currencies/config", - params: { - code: code, - }, - }) - .then((response) => { - data.rate = response.data.rate; - data.precision = response.data.precision; - data.symbol = response.data.symbol; - data.symbol_first = response.data.symbol_first; - data.decimal_mark = response.data.decimal_mark; - data.thousands_separator = response.data.thousands_separator; - this.model.rate = response.data.rate; - }, this); + onClickDelete(item) { + this.confirmDelete( + `${ + new URL(url).protocol + + "//" + + location.host + + location.pathname + + "/" + + item.id + }`, + this.translations.currencies.title, + `Confirm Delete ${item.name} ${this.translations.currencies.title}?`, + this.translations.currencies.cancel, + this.translations.currencies.delete + ); + }, + + onDeleteCurrency(event) { + this.onEjetItem(event, this.currencies, event.currency_id); + }, + + onChangeCodeItem(code) { + const formData = new FormData(this.$refs["form"]); + const data = { + rate: "", + precision: "", + symbol: "", + symbol_first: "", + decimal_mark: "", + thousands_separator: "", + }; + + for (let [key, val] of formData.entries()) { + Object.assign(data, { + [key]: val, + }); + } + + window.axios({ + method: "GET", + url: url + "/settings/currencies/config", + params: { + code: code, + }, + }) + .then((response) => { + data.rate = response.data.rate; + data.precision = response.data.precision; + data.symbol = response.data.symbol; + data.symbol_first = response.data.symbol_first; + data.decimal_mark = response.data.decimal_mark; + data.thousands_separator = response.data.thousands_separator; + + this.model.rate = response.data.rate; + }, this); + }, + + onEditForm(item) { + this.onSubmitEvent( + "PATCH", + url + "/wizard/currencies/" + item.id, + "", + this.currencies, + item.id + ); + }, + + onSubmitForm() { + this.onSubmitEvent( + "POST", + url + "/wizard/currencies", + "", + this.currencies + ); + }, + + prev() { + if (this.active-- > 2); + history.back() + + this.$router.push("/wizard/companies"); + }, + + next() { + if (this.active++ > 2); + this.$router.push("/wizard/taxes"); + }, }, - - onEditForm(item) { - this.onSubmitEvent( - "PATCH", - url + "/wizard/currencies/" + item.id, - "", - this.currencies, - item.id - ); - }, - - onSubmitForm() { - this.onSubmitEvent( - "POST", - url + "/wizard/currencies", - "", - this.currencies - ); - }, - - prev() { - if (this.active-- > 2); - history.back() - this.$router.push("/wizard/companies"); - }, - - next() { - if (this.active++ > 2); - this.$router.push("/wizard/taxes"); - }, - }, }; diff --git a/resources/assets/js/views/wizard/Finish.vue b/resources/assets/js/views/wizard/Finish.vue index beaeb4868..4e1ab1c8e 100644 --- a/resources/assets/js/views/wizard/Finish.vue +++ b/resources/assets/js/views/wizard/Finish.vue @@ -1,5 +1,5 @@