This commit is contained in:
2019-05-02 00:07:13 +00:00
parent 4a3980fd14
commit 60d1fb82fe
3 changed files with 56 additions and 38 deletions

View File

@@ -503,10 +503,26 @@ export default {
} }
}); });
}, },
confirm(vm) { ////////////////////////////
return vm.$dialog.confirm({ //
text: "GZFORM has a question: Do you really want to exit?", //
title: "Warning" confirmDelete(vm) {
//https://github.com/yariksav/vuetify-dialog#readme
return vm.$dialog.warning({
text: vm.$gzlocale.get("DeletePrompt"),
title: vm.$gzlocale.get("Delete"),
icon: "fa-exclamation-triangle",
actions: [
{
text: vm.$gzlocale.get("Cancel"),
key: false
},
{
text: vm.$gzlocale.get("Delete"),
color: "red",
key: true
}
]
}); });
} }
}; };

View File

@@ -91,7 +91,8 @@ export default {
"ErrorAPI2209", "ErrorAPI2209",
"ErrorServerUnresponsive", "ErrorServerUnresponsive",
"ErrorUserNotAuthenticated", "ErrorUserNotAuthenticated",
"ErrorUserNotAuthorized" "ErrorUserNotAuthorized",
"DeletePrompt"
], ],
decimalValidate(required) { decimalValidate(required) {
return { required: required, decimal: [2, this.formats.decimalSeparator] }; return { required: required, decimal: [2, this.formats.decimalSeparator] };

View File

@@ -401,40 +401,41 @@ export default {
} }
}, },
remove() { remove() {
//Prompt:
//do the delete
this.formState.loading = true;
var url = "Widget/" + this.$route.params.id;
//TODO: check if it's a new record (no ID) or one from server (has id)
var vm = this; var vm = this;
this.$gzform.deleteAllErrorBoxErrors(this); //Prompt:
this.$gzapi vm.$gzform.confirmDelete(vm).then(dialogResult => {
.remove(url) if (dialogResult == true) {
.then(res => { //do the delete
if (res.error) { vm.formState.loading = true;
vm.formState.serverError = res.error; var url = "Widget/" + vm.$route.params.id;
vm.$gzform.setErrorBoxErrors(vm); //TODO: check if it's a new record (no ID) or one from server (has id)
} else { vm.$gzform.deleteAllErrorBoxErrors(vm);
//success, navigate backwards vm.$gzapi
vm.$router.go(-1); .remove(url)
} .then(res => {
}) if (res.error) {
.catch(function handleGetDataFromAPIError(error) { vm.formState.serverError = res.error;
//Update the form status vm.$gzform.setErrorBoxErrors(vm);
vm.$gzform.setFormState({ } else {
vm: vm, //success, navigate backwards
loading: false vm.$router.go(-1);
}); }
vm.$gzHandleFormError(error, vm); })
}); .catch(function handleGetDataFromAPIError(error) {
//Update the form status
vm.$gzform.setFormState({
vm: vm,
loading: false
});
vm.$gzHandleFormError(error, vm);
});
}
});
}, },
duplicate() { duplicate() {
console.log("About to dialog"); // this.$gzform.confirmDelete(this).then(res => {
this.$gzform.confirm(this).then(res => { // console.log(res);
console.log("The dialog result is:"); // });
console.log(res);
});
// this.$dialog.confirm({ // this.$dialog.confirm({
// text: "Do you really want to exit?", // text: "Do you really want to exit?",
@@ -450,7 +451,7 @@ export default {
// text: "Cannot delete this item", // text: "Cannot delete this item",
// title: "Error" // title: "Error"
// }); // });
console.log("Done dialog"); // console.log("Done dialog");
// this.$dialog.notify.info("Test notification", { // this.$dialog.notify.info("Test notification", {
// position: "top-right", // position: "top-right",
@@ -468,7 +469,7 @@ export default {
//check rights //check rights
//duplicate //duplicate
//navigate to new record //navigate to new record
//alert("STUB: DUPLICATE"); alert("STUB: DUPLICATE");
}, },
stubTestClick() { stubTestClick() {
this.$gzevent.$emit("menu-replace-item", { this.$gzevent.$emit("menu-replace-item", {