This commit is contained in:
2020-04-10 14:51:28 +00:00
parent d201bfcd3c
commit 70302d0261
2 changed files with 146 additions and 13 deletions

View File

@@ -122,7 +122,7 @@ export default {
vm.appBar.menuItems.push({ divider: true, inset: false });
//SEARCH
//all forms except the search form
//all forms except the search form
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
vm.appBar.menuItems.push({

View File

@@ -1,21 +1,154 @@
<template>
<UnderConstruction />
<v-row row v-if="this.formState.ready">
<gz-error :errorBoxMessage="formState.errorBoxMessage"></gz-error>
History here
</v-row>
</template>
<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 {
components: {
UnderConstruction
created() {
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() {
window.$gz.eventBus.$emit("menu-change", {
isMain: true,
icon: "fa-history",
title: this.$ay.t("History"),
helpUrl: "form-ay-history"
});
data() {
return {
formState: {
ready: false,
loading: true,
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>