This commit is contained in:
@@ -49,7 +49,7 @@ CURRENT TODOs
|
|||||||
|
|
||||||
@@@@@@@@@@@ ROADMAP STAGE 2:
|
@@@@@@@@@@@ ROADMAP STAGE 2:
|
||||||
|
|
||||||
|
todo: template editor - rights!
|
||||||
todo: mkhelp docs, what to do with random pages that don't need to be in navigation because they are accessed from links only
|
todo: mkhelp docs, what to do with random pages that don't need to be in navigation because they are accessed from links only
|
||||||
todo: picklist template editor UI at client end
|
todo: picklist template editor UI at client end
|
||||||
todo: document how to use picklist in user docs (own page)
|
todo: document how to use picklist in user docs (own page)
|
||||||
|
|||||||
@@ -111,6 +111,15 @@ export default {
|
|||||||
title: tKeyTitle ? window.$gz.translation.get(tKeyTitle) : "",
|
title: tKeyTitle ? window.$gz.translation.get(tKeyTitle) : "",
|
||||||
yesButtonText: window.$gz.translation.get("OK")
|
yesButtonText: window.$gz.translation.get("OK")
|
||||||
});
|
});
|
||||||
|
}, /////////////////////////////////////
|
||||||
|
// Custom confirmation
|
||||||
|
//
|
||||||
|
confirmByKey() {
|
||||||
|
return VM_LOCAL.$root.$gzconfirm({
|
||||||
|
message: window.$gz.translation.get("DeletePrompt"),
|
||||||
|
yesButtonText: window.$gz.translation.get("OK"),
|
||||||
|
noButtonText: window.$gz.translation.get("Cancel")
|
||||||
|
});
|
||||||
}
|
}
|
||||||
//TODO: Implement the following as it's own re-usable component instead of here
|
//TODO: Implement the following as it's own re-usable component instead of here
|
||||||
/////////////////////////////////////
|
/////////////////////////////////////
|
||||||
|
|||||||
@@ -121,6 +121,7 @@ export default {
|
|||||||
generateMenu(vm, false); //default is never read only and passing in this vm
|
generateMenu(vm, false); //default is never read only and passing in this vm
|
||||||
//init disable save button so it can be enabled only on edit to show dirty form
|
//init disable save button so it can be enabled only on edit to show dirty form
|
||||||
window.$gz.eventBus.$emit("menu-disable-item", FORM_KEY + ":save");
|
window.$gz.eventBus.$emit("menu-disable-item", FORM_KEY + ":save");
|
||||||
|
window.$gz.eventBus.$emit("menu-disable-item", FORM_KEY + ":delete");
|
||||||
vm.formState.loading = false;
|
vm.formState.loading = false;
|
||||||
})
|
})
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
@@ -172,6 +173,13 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
deep: true
|
deep: true
|
||||||
|
},
|
||||||
|
templateId(val) {
|
||||||
|
if (val) {
|
||||||
|
window.$gz.eventBus.$emit("menu-enable-item", FORM_KEY + ":delete");
|
||||||
|
} else {
|
||||||
|
window.$gz.eventBus.$emit("menu-disable-item", FORM_KEY + ":delete");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
@@ -329,6 +337,40 @@ export default {
|
|||||||
vm.formState.loading = false;
|
vm.formState.loading = false;
|
||||||
window.$gz.errorHandler.handleFormError(error, vm);
|
window.$gz.errorHandler.handleFormError(error, vm);
|
||||||
});
|
});
|
||||||
|
},
|
||||||
|
remove() {
|
||||||
|
var vm = this;
|
||||||
|
window.$gz.dialog.confirmDelete().then(dialogResult => {
|
||||||
|
if (dialogResult == true) {
|
||||||
|
//do the delete
|
||||||
|
vm.formState.loading = true;
|
||||||
|
//No need to delete a new record, just abandon it...
|
||||||
|
if (vm.templateId && vm.templateId != 0) {
|
||||||
|
var url = API_BASE_URL + vm.templateId;
|
||||||
|
|
||||||
|
window.$gz.form.deleteAllErrorBoxErrors(vm);
|
||||||
|
window.$gz.api
|
||||||
|
.remove(url)
|
||||||
|
.then(res => {
|
||||||
|
if (res.error != undefined) {
|
||||||
|
vm.formState.serverError = res.error;
|
||||||
|
window.$gz.form.setErrorBoxErrors(vm);
|
||||||
|
} else {
|
||||||
|
//trigger reload of form
|
||||||
|
this.getDataFromApi();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(function handleGetDataFromAPIError(error) {
|
||||||
|
//Update the form status
|
||||||
|
window.$gz.form.setFormState({
|
||||||
|
vm: vm,
|
||||||
|
loading: false
|
||||||
|
});
|
||||||
|
window.$gz.errorHandler.handleFormError(error, vm);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -346,7 +388,9 @@ function clickHandler(menuItem) {
|
|||||||
case "save":
|
case "save":
|
||||||
m.vm.submit();
|
m.vm.submit();
|
||||||
break;
|
break;
|
||||||
|
case "delete":
|
||||||
|
m.vm.remove();
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
window.$gz.eventBus.$emit(
|
window.$gz.eventBus.$emit(
|
||||||
"notify-warning",
|
"notify-warning",
|
||||||
@@ -380,6 +424,16 @@ function generateMenu(vm) {
|
|||||||
key: FORM_KEY + ":save",
|
key: FORM_KEY + ":save",
|
||||||
vm: vm
|
vm: vm
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (vm.rights.delete) {
|
||||||
|
menuOptions.menuItems.push({
|
||||||
|
title: window.$gz.translation.get("ResetToDefault"),
|
||||||
|
icon: "undo",
|
||||||
|
surface: false,
|
||||||
|
key: FORM_KEY + ":delete",
|
||||||
|
vm: vm
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
window.$gz.eventBus.$emit("menu-change", menuOptions);
|
window.$gz.eventBus.$emit("menu-change", menuOptions);
|
||||||
@@ -407,7 +461,7 @@ function initForm(vm) {
|
|||||||
// Ensures UI translated text is available
|
// Ensures UI translated text is available
|
||||||
//
|
//
|
||||||
function fetchTranslatedText(vm) {
|
function fetchTranslatedText(vm) {
|
||||||
var tKeysRequired = ["Include"];
|
var tKeysRequired = ["Include", "ResetToDefault"];
|
||||||
|
|
||||||
return window.$gz.translation.fetch(tKeysRequired);
|
return window.$gz.translation.fetch(tKeysRequired);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user