'Delete and success function development and styling edited'

This commit is contained in:
Burak Civan 2021-05-20 16:03:57 +03:00
parent 79f91eab7f
commit 2babd51bf0
4 changed files with 213 additions and 192 deletions

View File

@ -32,7 +32,51 @@ export default {
this.model.select = item.code ? item.code : ''; 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) { onEditEvent(form_method, form_url, plus_data, form_list, form_id) {
let self = this;
const formData = new FormData(this.$refs["form"]); const formData = new FormData(this.$refs["form"]);
const data = {}; const data = {};
@ -62,27 +106,8 @@ export default {
} }
}); });
let type = response.data.success ? 'success' : 'error'; this.onSuccessEvent(response);
let timeout = 1000; }, this)
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;
})
.catch(error => { .catch(error => {
this.success = false; this.success = false;
}); });
@ -116,28 +141,8 @@ export default {
"enabled": response.data.data.enabled != undefined ? response.data.data.enabled : 'true' "enabled": response.data.data.enabled != undefined ? response.data.data.enabled : 'true'
}); });
let type = response.data.success ? 'success' : 'error'; this.onSuccessEvent(response);
let timeout = 1000; }, this)
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;
})
.catch(error => { .catch(error => {
this.success = false; this.success = false;
}); });

View File

@ -82,5 +82,13 @@ export default {
.current-tab-btn { .current-tab-btn {
padding: 0 15px; padding: 0 15px;
} }
.form-container {
flex-direction: column;
}
.form-container .form-group {
width: 100%;
}
} }
</style> </style>

View File

@ -21,7 +21,8 @@
native-type="button" native-type="button"
class="btn-sm" class="btn-sm"
@click="addItem()" @click="addItem()"
>{{ translations.currencies.add_new }}</base-button> >{{ translations.currencies.add_new }}</base-button
>
</div> </div>
<div class="row flex-column"> <div class="row flex-column">
@ -171,11 +172,9 @@
</div> </div>
</td> </td>
</tr> </tr>
</tbody> <tr v-if="newDatas">
</table> <td class="p-0">
<div class="row pt-3 pb-3">
<div class="mt-2" v-if="newDatas">
<div class="row p-3">
<div <div
class="form-container col-12 d-flex justify-content-between align-items-start" class="form-container col-12 d-flex justify-content-between align-items-start"
> >
@ -196,7 +195,9 @@
filterable filterable
> >
<template slot="prefix"> <template slot="prefix">
<span class="el-input__suffix-inner el-select-icon"> <span
class="el-input__suffix-inner el-select-icon"
>
<i <i
:class="'select-icon-position el-input__icon fa fa-code'" :class="'select-icon-position el-input__icon fa fa-code'"
></i> ></i>
@ -241,7 +242,10 @@
</div> </div>
</div> </div>
</div> </div>
</div> </td>
</tr>
</tbody>
</table>
</form> </form>
</div> </div>
@ -380,11 +384,22 @@ export default {
}, },
onEditSave(item) { 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() { onSubmitForm() {
this.onSubmitEvent("POST", url + "/wizard/currencies", '', this.currencies); this.onSubmitEvent(
"POST",
url + "/wizard/currencies",
"",
this.currencies
);
}, },
deleteCurrency(event) { deleteCurrency(event) {
@ -397,19 +412,7 @@ export default {
this.component = ""; this.component = "";
let type = event.success ? 'success' : 'error'; this.onSuccessDelete(event);
let timeout = 1000;
if (event.important) {
timeout = 0;
}
this.$notify({
message: event.message,
timeout: timeout,
icon: "fas fa-bell",
type,
});
}, },
}, },
}; };

View File

@ -134,10 +134,9 @@
</div> </div>
</td> </td>
</tr> </tr>
</tbody> <tr v-if="newDatas">
</table> <td class="p-0">
<div class="mt-2" v-if="newDatas"> <div class="row pt-3 pb-3">
<div class="row p-3">
<div <div
class="form-container col-12 d-flex justify-content-between align-items-start" class="form-container col-12 d-flex justify-content-between align-items-start"
> >
@ -180,12 +179,18 @@
</div> </div>
</div> </div>
</div> </div>
</div> </td>
</tr>
</tbody>
</table>
</form> </form>
</div> </div>
<notifications></notifications> <notifications></notifications>
<form id="form-dynamic-component" method="POST" action="#"></form> <form id="form-dynamic-component" method="POST" action="#"></form>
<component v-bind:is="component" @deleted="deleteCurrency($event)"></component> <component
v-bind:is="component"
@deleted="deleteCurrency($event)"
></component>
</div> </div>
<div class="card-footer"> <div class="card-footer">
<div class="row"> <div class="row">
@ -266,10 +271,16 @@ export default {
this.$router.push("/wizard/currencies"); this.$router.push("/wizard/currencies");
}, },
onEditSave(item) { onEditSave(item) {
this.onEditEvent("PATCH", url + "/wizard/taxes/" + item.id, 'type', this.taxes, item.id); this.onEditEvent(
"PATCH",
url + "/wizard/taxes/" + item.id,
"type",
this.taxes,
item.id
);
}, },
onSubmitForm() { onSubmitForm() {
this.onSubmitEvent("POST", url + "/wizard/taxes", 'type', this.taxes); this.onSubmitEvent("POST", url + "/wizard/taxes", "type", this.taxes);
}, },
deleteCurrency(event) { deleteCurrency(event) {
this.taxes.forEach(function (tax, index) { this.taxes.forEach(function (tax, index) {
@ -281,20 +292,14 @@ export default {
this.component = ""; this.component = "";
let type = event.success ? 'success' : 'error'; this.onSuccessDelete(event);
let timeout = 1000;
if (event.important) {
timeout = 0;
}
this.$notify({
message: event.message,
timeout: timeout,
icon: "fas fa-bell",
type,
});
}, },
}, },
}; };
</script> </script>
<style scoped>
.current-tab-btn {
padding: 0 80px;
}
</style>