This commit is contained in:
@@ -122,7 +122,7 @@ export default {
|
|||||||
vm.appBar.menuItems.push({ divider: true, inset: false });
|
vm.appBar.menuItems.push({ divider: true, inset: false });
|
||||||
|
|
||||||
//SEARCH
|
//SEARCH
|
||||||
//all forms except the search form
|
//all forms except the search form
|
||||||
if (ctx.icon != "fa-search") {
|
if (ctx.icon != "fa-search") {
|
||||||
//For all forms but not on the search form itself; if this is necessary for others then make a nosearch or something flag controlled by incoming ctx but if not then this should suffice
|
//For all forms but not on the search form itself; if this is necessary for others then make a nosearch or something flag controlled by incoming ctx but if not then this should suffice
|
||||||
vm.appBar.menuItems.push({
|
vm.appBar.menuItems.push({
|
||||||
|
|||||||
@@ -1,21 +1,154 @@
|
|||||||
<template>
|
<template>
|
||||||
<UnderConstruction />
|
<v-row row v-if="this.formState.ready">
|
||||||
|
<gz-error :errorBoxMessage="formState.errorBoxMessage"></gz-error>
|
||||||
|
History here
|
||||||
|
</v-row>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import UnderConstruction from "../components/underconstruction.vue";
|
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
//THIS IS THE RECORD HISTORY FEATURE SCREEN FOR AN INDIVIDUAL ITEMS RECORD HISTORY
|
/* Xeslint-disable */
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
const FORM_KEY = "ay-history";
|
||||||
|
const API_BASE_URL = "EventLog/";
|
||||||
export default {
|
export default {
|
||||||
components: {
|
created() {
|
||||||
UnderConstruction
|
let vm = this;
|
||||||
|
|
||||||
|
initForm(vm)
|
||||||
|
.then(() => {
|
||||||
|
vm.formState.ready = true;
|
||||||
|
vm.readOnly = !vm.rights.change;
|
||||||
|
window.$gz.eventBus.$on("menu-click", clickHandler);
|
||||||
|
vm.getDataFromApi(vm.$route.params.recordid);
|
||||||
|
generateMenu(vm, false);
|
||||||
|
})
|
||||||
|
.catch(err => {
|
||||||
|
vm.formState.ready = true;
|
||||||
|
window.$gz.errorHandler.handleFormError(err, vm);
|
||||||
|
});
|
||||||
},
|
},
|
||||||
beforeCreate() {
|
data() {
|
||||||
window.$gz.eventBus.$emit("menu-change", {
|
return {
|
||||||
isMain: true,
|
formState: {
|
||||||
icon: "fa-history",
|
ready: false,
|
||||||
title: this.$ay.t("History"),
|
loading: true,
|
||||||
helpUrl: "form-ay-history"
|
errorBoxMessage: null,
|
||||||
});
|
appError: null,
|
||||||
|
serverError: {}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
getDataFromApi(recordId) {
|
||||||
|
let vm = this;
|
||||||
|
vm.formState.loading = true;
|
||||||
|
if (!recordId) {
|
||||||
|
throw FORM_KEY + "::getDataFromApi -> Missing recordID!";
|
||||||
|
}
|
||||||
|
let url = API_BASE_URL + recordId;
|
||||||
|
window.$gz.form.deleteAllErrorBoxErrors(vm);
|
||||||
|
window.$gz.api
|
||||||
|
.get(url)
|
||||||
|
.then(res => {
|
||||||
|
if (res.error) {
|
||||||
|
//Not found?
|
||||||
|
if (res.error.code == "2010") {
|
||||||
|
//notify not found error then navigate backwards
|
||||||
|
window.$gz.eventBus.$emit(
|
||||||
|
"notify-error",
|
||||||
|
vm.$ay.t("ErrorAPI2010")
|
||||||
|
);
|
||||||
|
// navigate backwards
|
||||||
|
window.$gz._.delay(function() {
|
||||||
|
vm.$router.go(-1);
|
||||||
|
}, 2000);
|
||||||
|
}
|
||||||
|
vm.formState.serverError = res.error;
|
||||||
|
window.$gz.form.setErrorBoxErrors(vm);
|
||||||
|
} else {
|
||||||
|
vm.obj = res.data;
|
||||||
|
//Update the form status
|
||||||
|
window.$gz.form.setFormState({
|
||||||
|
vm: vm,
|
||||||
|
dirty: false,
|
||||||
|
valid: true,
|
||||||
|
loading: false,
|
||||||
|
readOnly: res.readOnly ? true : false
|
||||||
|
});
|
||||||
|
//modify the menu as necessary
|
||||||
|
generateMenu(vm);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(function handleGetDataFromAPIError(error) {
|
||||||
|
//Update the form status
|
||||||
|
window.$gz.form.setFormState({
|
||||||
|
vm: vm,
|
||||||
|
loading: false
|
||||||
|
});
|
||||||
|
window.$gz.errorHandler.handleFormError(error, vm);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
/////////////////////////////
|
||||||
|
//
|
||||||
|
//
|
||||||
|
function clickHandler(menuItem) {
|
||||||
|
if (!menuItem) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
let m = window.$gz.menu.parseMenuItem(menuItem);
|
||||||
|
if (m.owner == FORM_KEY && !m.disabled) {
|
||||||
|
switch (m.key) {
|
||||||
|
default:
|
||||||
|
window.$gz.eventBus.$emit(
|
||||||
|
"notify-warning",
|
||||||
|
FORM_KEY + "::context click: [" + m.key + "]"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//////////////////////
|
||||||
|
//
|
||||||
|
//
|
||||||
|
function generateMenu(vm) {
|
||||||
|
let menuOptions = {
|
||||||
|
isMain: false,
|
||||||
|
icon: "fa-history",
|
||||||
|
title: vm.$ay.t("History"),
|
||||||
|
helpUrl: "form-ay-history",
|
||||||
|
menuItems: []
|
||||||
|
};
|
||||||
|
}
|
||||||
|
/////////////////////////////////
|
||||||
|
//
|
||||||
|
//
|
||||||
|
function initForm(vm) {
|
||||||
|
return new Promise(function(resolve, reject) {
|
||||||
|
(async function() {
|
||||||
|
try {
|
||||||
|
await fetchTranslatedText(vm);
|
||||||
|
} catch (err) {
|
||||||
|
reject(err);
|
||||||
|
}
|
||||||
|
resolve();
|
||||||
|
})();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Ensures UI translated text is available
|
||||||
|
//
|
||||||
|
function fetchTranslatedText(vm) {
|
||||||
|
return window.$gz.translation.fetch(["History?"]);
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user