From 2babd51bf065fe182219cab03451d5b980686029 Mon Sep 17 00:00:00 2001 From: Burak Civan Date: Thu, 20 May 2021 16:03:57 +0300 Subject: [PATCH] 'Delete and success function development and styling edited' --- resources/assets/js/mixins/spa-global.js | 93 +++++----- resources/assets/js/views/Wizard.vue | 8 + .../assets/js/views/wizard/Currencies.vue | 175 +++++++++--------- resources/assets/js/views/wizard/Taxes.vue | 129 ++++++------- 4 files changed, 213 insertions(+), 192 deletions(-) diff --git a/resources/assets/js/mixins/spa-global.js b/resources/assets/js/mixins/spa-global.js index 986262692..0a9cbae15 100644 --- a/resources/assets/js/mixins/spa-global.js +++ b/resources/assets/js/mixins/spa-global.js @@ -32,7 +32,51 @@ export default { this.model.select = item.code ? item.code : ''; } }, + dataHandleEvent() { + this.newDatas = false; + this.currentTab = undefined; + this.model.name = ''; + this.model.rate = ''; + this.model.select = ''; + this.model.enabled = 1; + }, + onSuccessEvent(response) { + let type = response.data.success ? 'success' : 'error'; + let timeout = 1000; + + if (response.data.important) { + timeout = 0; + } + + this.$notify({ + message: response.data.message, + timeout: timeout, + icon: "fas fa-bell", + type, + }); + + this.dataHandleEvent(); + + }, + onSuccessDelete(event) { + let type = event.success ? 'success' : 'error'; + let timeout = 1000; + + if (event.important) { + timeout = 0; + } + + this.$notify({ + message: event.message, + timeout: timeout, + icon: "fas fa-bell", + type, + }); + + this.dataHandleEvent(); + }, onEditEvent(form_method, form_url, plus_data, form_list, form_id) { + let self = this; const formData = new FormData(this.$refs["form"]); const data = {}; @@ -46,7 +90,7 @@ export default { if (!plus_data || plus_data == undefined) { delete data.type; } - + window.axios({ method: form_method, url: form_url, @@ -62,27 +106,8 @@ export default { } }); - let type = response.data.success ? 'success' : 'error'; - let timeout = 1000; - - if (response.data.important) { - timeout = 0; - } - - this.$notify({ - message: response.data.message, - timeout: timeout, - icon: "fas fa-bell", - type, - }); - - this.newDatas = false; - this.currentTab = undefined; - this.model.name = ''; - this.model.rate = ''; - this.model.select = ''; - this.model.enabled = 1; - }) + this.onSuccessEvent(response); + }, this) .catch(error => { this.success = false; }); @@ -116,28 +141,8 @@ export default { "enabled": response.data.data.enabled != undefined ? response.data.data.enabled : 'true' }); - let type = response.data.success ? 'success' : 'error'; - let timeout = 1000; - - if (response.data.important) { - timeout = 0; - } - - this.$notify({ - message: response.data.message, - timeout: timeout, - icon: "fas fa-bell", - type, - }); - - - this.newDatas = false; - this.currentTab = undefined; - this.model.name = ''; - this.model.rate = ''; - this.model.select = ''; - this.model.enabled = 1; - }) + this.onSuccessEvent(response); + }, this) .catch(error => { this.success = false; }); diff --git a/resources/assets/js/views/Wizard.vue b/resources/assets/js/views/Wizard.vue index c6ada01db..84370d7fb 100644 --- a/resources/assets/js/views/Wizard.vue +++ b/resources/assets/js/views/Wizard.vue @@ -82,5 +82,13 @@ export default { .current-tab-btn { padding: 0 15px; } + + .form-container { + flex-direction: column; + } + + .form-container .form-group { + width: 100%; + } } diff --git a/resources/assets/js/views/wizard/Currencies.vue b/resources/assets/js/views/wizard/Currencies.vue index 4e8b616c0..c6ca90858 100644 --- a/resources/assets/js/views/wizard/Currencies.vue +++ b/resources/assets/js/views/wizard/Currencies.vue @@ -21,7 +21,8 @@ native-type="button" class="btn-sm" @click="addItem()" - >{{ translations.currencies.add_new }} + >{{ translations.currencies.add_new }}
@@ -171,77 +172,80 @@
+ + +
+
+ + + + + + + +
+
+ + +
+
+
+ {{ translations.currencies.save }} +
+
+
+ + - -
-
-
- - - - - - - -
-
- - -
-
-
- {{ translations.currencies.save }} -
-
-
-
@@ -353,7 +357,7 @@ export default { decimal_mark: "", thousands_separator: "", }; - + for (let [key, val] of formData.entries()) { Object.assign(data, { [key]: val, @@ -380,11 +384,22 @@ export default { }, onEditSave(item) { - this.onEditEvent("PATCH", url + "/wizard/currencies/" + item.id, '', this.currencies, item.id); + this.onEditEvent( + "PATCH", + url + "/wizard/currencies/" + item.id, + "", + this.currencies, + item.id + ); }, onSubmitForm() { - this.onSubmitEvent("POST", url + "/wizard/currencies", '', this.currencies); + this.onSubmitEvent( + "POST", + url + "/wizard/currencies", + "", + this.currencies + ); }, deleteCurrency(event) { @@ -397,19 +412,7 @@ export default { this.component = ""; - let type = event.success ? 'success' : 'error'; - let timeout = 1000; - - if (event.important) { - timeout = 0; - } - - this.$notify({ - message: event.message, - timeout: timeout, - icon: "fas fa-bell", - type, - }); + this.onSuccessDelete(event); }, }, }; diff --git a/resources/assets/js/views/wizard/Taxes.vue b/resources/assets/js/views/wizard/Taxes.vue index 4cb7fec95..46bfbecdf 100644 --- a/resources/assets/js/views/wizard/Taxes.vue +++ b/resources/assets/js/views/wizard/Taxes.vue @@ -134,58 +134,63 @@ + + +
+
+ + +
+
+ + +
+
+
+ {{ translations.taxes.save }} +
+
+
+ + -
-
-
- - -
-
- - -
-
-
- {{ translations.taxes.save }} -
-
-
-
- +