HUGE REFACTOR / CLEANUP

if there is a issue it's probably something in here that was changed
This commit is contained in:
2021-09-28 20:19:44 +00:00
parent 51eddfede9
commit d0afdd9855
238 changed files with 3127 additions and 8614 deletions

View File

@@ -71,13 +71,11 @@
<script>
const FORM_KEY = "home-dashboard";
import DashRegistry from "../api/dash-registry";
//---------- DASH ITEMS ----------
import GzDashTestListWidgetsPriciest from "../components/dash-test-list-widgets-priciest.vue";
import GzDashTestBarWidgetCountByUserType from "../components/dash-test-bar-widget-count-by-usertype.vue";
import GzDashTestLineWidgetMonthlyTotalPrice from "../components/dash-test-line-widget-monthly-total-price.vue";
import GzDashTestDayCalendarWidget from "../components/dash-test-day-calendar-widget.vue";
export default {
components: {
GzDashTestListWidgetsPriciest,
@@ -94,7 +92,7 @@ export default {
});
},
async created() {
let vm = this;
const vm = this;
//------------------
//Test ui feedback mechanisms here:
//this.formState.errorBoxMessage = "This is a test crlf\r\nOnly a test lf\nEot";
@@ -151,7 +149,7 @@ export default {
this.move("end", id);
},
dashRemove: function(id) {
let index = this.getEffectiveViewItemIndexById(id);
const index = this.getEffectiveViewItemIndexById(id);
if (index == -1) {
return;
}
@@ -159,12 +157,12 @@ export default {
this.saveView();
},
move: function(direction, id) {
let index = this.getEffectiveViewItemIndexById(id);
const index = this.getEffectiveViewItemIndexById(id);
if (index == -1) {
return;
}
let totalItems = this.effectiveView.length;
const totalItems = this.effectiveView.length;
let newIndex = 0;
//calculate new index
switch (direction) {
@@ -204,14 +202,14 @@ export default {
this.saveView();
},
availableItems: function() {
let allItems = DashRegistry.availableItems();
let newItems = allItems.filter(
const allItems = DashRegistry.availableItems();
const newItems = allItems.filter(
z => !this.effectiveView.find(m => m.id == z.id)
);
return newItems;
},
async getDataFromApi() {
let vm = this;
const vm = this;
window.$gz.form.setFormState({
vm: vm,
loading: true
@@ -219,27 +217,21 @@ export default {
try {
window.$gz.form.deleteAllErrorBoxErrors(vm);
let res = await window.$gz.api.get("dashboard-view");
const res = await window.$gz.api.get("dashboard-view");
if (res.error) {
//Not found?
if (res.error.code == "2010") {
window.$gz.form.handleObjectNotFound(vm);
}
vm.formState.serverError = res.error;
window.$gz.form.setErrorBoxErrors(vm);
} else {
let savedView = JSON.parse(res.data.view);
let availableItems = DashRegistry.availableItems();
let allowedView = savedView.filter(z =>
const savedView = JSON.parse(res.data.view);
const availableItems = DashRegistry.availableItems();
const allowedView = savedView.filter(z =>
availableItems.find(m => m.id == z.id)
);
vm.effectiveView = allowedView;
//modify the menu as necessary
generateMenu(vm);
//Update the form status
window.$gz.form.setFormState({
vm: vm,
dirty: false,
@@ -257,21 +249,17 @@ export default {
}
},
async saveView() {
let vm = this;
const vm = this;
if (vm.canSave == false) {
return;
}
try {
window.$gz.form.setFormState({
vm: vm,
loading: true
});
//clear any errors vm might be around from previous submit
window.$gz.form.deleteAllErrorBoxErrors(vm);
let res = await window.$gz.api.put(
const res = await window.$gz.api.put(
"dashboard-view",
JSON.stringify(vm.effectiveView)
);
@@ -280,7 +268,6 @@ export default {
vm.formState.serverError = res.error;
window.$gz.form.setErrorBoxErrors(vm);
} else {
//Update the form status
window.$gz.form.setFormState({
vm: vm,
dirty: false,
@@ -322,7 +309,7 @@ async function clickHandler(menuItem) {
if (!menuItem) {
return;
}
let m = window.$gz.menu.parseMenuItem(menuItem);
const m = window.$gz.menu.parseMenuItem(menuItem);
if (m.owner == FORM_KEY && !m.disabled) {
switch (m.key) {
case "add-dash":
@@ -365,7 +352,7 @@ async function clickHandler(menuItem) {
//
//
function generateMenu(vm) {
let menuOptions = {
const menuOptions = {
isMain: true,
icon: "$ayiTachometer",
title: "Dashboard",
@@ -396,21 +383,4 @@ function generateMenu(vm) {
}
window.$gz.eventBus.$emit("menu-change", menuOptions);
}
// /////////////////////////////////
// //
// //
// async function initForm(vm) {
// await fetchTranslatedText(vm);
// await window.$gz.formCustomTemplate.get(FORM_CUSTOM_TEMPLATE_KEY, vm);
// await populateSelectionLists(vm);
// }
// //////////////////////////////////////////////////////////
// //
// // Ensures UI translated text is available
// //
// async function fetchTranslatedText(vm) {
// await window.$gz.translation.cacheTranslations(["Widget", "WidgetName"]);
// }
</script>