This commit is contained in:
2019-05-01 19:41:10 +00:00
parent 3ebf647d53
commit 1c4f9ffee6
2 changed files with 60 additions and 147 deletions

View File

@@ -41,10 +41,10 @@ All platforms and browsers
- DONE Make about contextual and insert a menu item to view log
- DONE WIRE up save menu item and add code to disable save on broken rules (and make red, disabled etc)
- DONE Move wire up event code from app.vue to gzmenu and call it from app.vue
### UPDATE VUETIFY, SB 0.5.0, not 0.4.6
### - RIGHTS in form state so can easily enable / disable etc
- INFO - SERVER will return on request of an object one of these:
- DONE INFO - SERVER will return on request of an object one of these:
- DONE Not authenticated at all 401
- DONE Redirect to login
- DONE Not authorized for this object 403 (could be due to not own or whatever, we don't care, server handles that shit, client just knows not to show it)
@@ -74,7 +74,7 @@ All platforms and browsers
- Wire up delete menu item
- api code is stubbed out for delete, need to write that as well
- DONE TODO navigating through menu doesn't "back" properly when clicking back on browser controls
= TODO: widget form now not localized title at menu top
- DONE widget form now not localized title at menu top
- Widget list, refresh page causes items per page to reset back to 5 from custom setting, it should cache that shit at least for a session anyway

View File

@@ -168,9 +168,11 @@
</template>
<script>
/* eslint-disable */
//import ayatype from "../api/ayatype";
/* xeslint-disable */
/////////////////////////////
//
//
function clickHandler(menuItem) {
if (!menuItem) {
return;
@@ -193,35 +195,53 @@ function clickHandler(menuItem) {
}
}
export default {
//https://router.vuejs.org/guide/advanced/navigation-guards.html#in-component-guards
// /*eslint-disable-next-line*/
// beforeRouteEnter(to, from, next) {
// //check rights here!!!
// /*eslint-disable-next-line*/
// var v = { t: to, f: from, n: next };
//////////////////////
//
//
function generateMenu(vm, readOnly) {
var menuOptions = {
isMain: false,
icon: "fa-splotch",
title: vm.$gzlocale.get("Widget"),
helpUrl: "intro/#searching",
menuItems: []
};
// // called before the route that renders this component is confirmed.
// // does NOT have access to `this` component instance,
// // because it has not been created yet when this guard is called!
// },
// /*eslint-disable-next-line*/
// beforeRouteUpdate(to, from, next) {
// // called when the route that renders this component has changed,
// // but this component is reused in the new route.
// // For example, for a route with dynamic params `/foo/:id`, when we
// // navigate between `/foo/1` and `/foo/2`, the same `Foo` component instance
// // will be reused, and this hook will be called when that happens.
// // has access to `this` component instance.
// },
// /*eslint-disable-next-line*/
// beforeRouteLeave(to, from, next) {
// // called when the route that renders this component is about to
// // be navigated away from.
// // has access to `this` component instance.
// },
//eslint-disable-next-line
console.log(readOnly);
if (readOnly != true) {
menuOptions.menuItems = [
{
title: vm.$gzlocale.get("Save"),
icon: "save",
surface: true,
key: "inventory-widget-edit:save",
vm: vm
},
{
title: vm.$gzlocale.get("Delete"),
icon: "trash-alt",
surface: true,
key: "inventory-widget-edit:delete",
vm: vm
},
{ divider: true, inset: false },
{
title: vm.$gzlocale.get("Duplicate"),
icon: "clone",
key: "inventory-widget-edit:duplicate",
vm: vm
}
];
}
//eslint-disable-next-line
console.log(menuOptions);
vm.$gzevent.$emit("menu-change", menuOptions);
}
export default {
beforeCreate() {
console.log("BEFORE CREATE CALLED");
//Cache all required lt keys
var ltKeysRequired = [
"Widget",
@@ -251,42 +271,11 @@ export default {
"WidgetCustom16"
];
var vm = this;
//console.log("B4CREATE FETCHING KEYS NOW");
this.$gzlocale
.fetch(ltKeysRequired)
//.then(() => console.log("KEYS FETCHED"))
.then(function() {
vm.$gzevent.$emit("menu-change", {
isMain: false,
icon: "fa-splotch",
title: vm.$gzlocale.get("Widget"),
helpUrl: "intro/#searching",
menuItems: [
{
title: vm.$gzlocale.get("Save"),
icon: "save",
surface: true,
key: "inventory-widget-edit:save",
vm: vm
},
{
title: vm.$gzlocale.get("Delete"),
icon: "trash-alt",
surface: true,
key: "inventory-widget-edit:delete",
vm: vm
},
{ divider: true, inset: false },
{
title: vm.$gzlocale.get("Duplicate"),
icon: "clone",
key: "inventory-widget-edit:duplicate",
vm: vm
}
]
});
})
// .then(function() {
// generateMenu(vm, );
// })
.then(() => (vm.formState.ready = true))
.catch(err => {
vm.formState.ready = true;
@@ -294,38 +283,6 @@ export default {
});
},
created() {
//console.log("CREATED CALLED");
// this.$gzevent.$emit("menu-change", {
// isMain: false,
// icon: "fa-splotch",
// title: this.$gzlocale.get("Widget"),
// helpUrl: "intro/#searching",
// menuItems: [
// {
// title: this.$gzlocale.get("Save"),
// icon: "save",
// surface: true,
// key: "inventory-widget-edit:save",
// vm: this
// },
// {
// title: this.$gzlocale.get("Delete"),
// icon: "trash-alt",
// surface: true,
// key: "inventory-widget-edit:delete",
// vm: this
// },
// { divider: true, inset: false },
// {
// title: this.$gzlocale.get("Duplicate"),
// icon: "clone",
// key: "inventory-widget-edit:duplicate",
// vm: this
// }
// ]
// });
this.$gzevent.$on("menu-click", clickHandler);
this.getDataFromApi();
},
@@ -356,7 +313,8 @@ export default {
if (this.formState.loading) {
return;
}
var canSave = val.dirty && val.valid;
var canSave = val.dirty && val.valid && !val.readOnly;
if (canSave) {
this.$gzevent.$emit("menu-enable-item", "inventory-widget-edit:save");
} else {
@@ -401,6 +359,9 @@ export default {
loading: false,
readOnly: res.readOnly ? true : false
});
//modify the menu as necessary
generateMenu(vm, res.readOnly);
}
})
.catch(function handleGetDataFromAPIError(error) {
@@ -487,51 +448,3 @@ export default {
</script>
<style></style>
/*
Sample widget record api v8
{
"data": {
"id": 100,
"concurrencyToken": 2675248,
"ownerId": 1,
"name": "Fantastic Wooden Chips 122",
"serial": 100,
"dollarAmount": 584.83,
"active": true,
"roles": 8212,
"startDate": "2019-02-12T10:12:39.594206",
"endDate": "2019-02-12T13:40:59.986405",
"notes": "Eum optio incidunt blanditiis laboriosam. Sed ipsam occaecati minus corrupti repudiandae delectus. Culpa nostrum est ullam assumenda animi ut. Velit sunt ex ipsum. Temporibus cum quaerat at omnis at quas. Commodi dolor molestiae beatae.",
"count": 0,
"customFields": null,
"tags": [
"brown",
"red"
]
}
}
IN JS FORMAT
{
data: {
id: 100,
concurrencyToken: 2675248,
ownerId: 1,
name: 'Fantastic Wooden Chips 122',
serial: 100,
dollarAmount: 584.83,
active: true,
roles: 8212,
startDate: '2019-02-12T10:12:39.594206',
endDate: '2019-02-12T13:40:59.986405',
notes: 'Eum optio incidunt blanditiis laboriosam. Sed ipsam occaecati minus corrupti repudiandae delectus. Culpa nostrum est ullam assumenda animi ut. Velit sunt ex ipsum. Temporibus cum quaerat at omnis at quas. Commodi dolor molestiae beatae.',
count: 0,
customFields: null,
tags: [
'brown',
'red'
]
}
}
*/