This commit is contained in:
2019-06-05 21:02:51 +00:00
parent 65967d4992
commit a6dabfe3ea
5 changed files with 71 additions and 23 deletions

View File

@@ -45,8 +45,19 @@ export default {
}
return (store.state.roles & desiredRole) != 0;
},
/////////////////////////////////
///////////////////////////////////////////////////////////////////////
// Get a default empty rights object so that it can be present when a
// form first loads
//
defaultRightsObject() {
return {
change: false,
read: false,
delete: false
};
},
/////////////////////////////////
// oType is the name of the object type as defined in ayatype.js
//
getRights(vm, oType) {
//from bizroles.cs:
@@ -58,11 +69,7 @@ export default {
//DELETE = SAME AS CHANGE FOR NOW (There is no specific delete right for now though it's checked for by routes in Authorized.cs in case we want to add it in future as a separate right from create.)
//NOTE: biz rules can supersede this, this is just for general rights purposes, if an object has restrictive business rules they will take precedence every time.
var ret = {
change: false,
read: false,
delete: false
};
var ret = this.defaultRightsObject();
//Get the type name from the type enum value
var typeName = _.findKey(vm.$gztype, function(o) {

View File

@@ -13,7 +13,6 @@ import Vue from "vue";
import errorHandler from "./errorhandler";
import store from "../store";
var triggeringChange = false;
function isEmpty(o) {

View File

@@ -27,6 +27,8 @@ export default function initialize() {
//Everyone has a home
addNavItem(locale.get("Home"), "home", "/");
//NOTE: If a user has read full record or better then they should have access to that area
if (
roles.hasRole(roles.AUTHORIZATION_ROLES.TechLimited) ||
roles.hasRole(roles.AUTHORIZATION_ROLES.TechFull) ||
@@ -45,7 +47,9 @@ export default function initialize() {
if (
roles.hasRole(roles.AUTHORIZATION_ROLES.InventoryLimited) ||
roles.hasRole(roles.AUTHORIZATION_ROLES.InventoryFull)
roles.hasRole(roles.AUTHORIZATION_ROLES.InventoryFull) ||
roles.hasRole(roles.AUTHORIZATION_ROLES.BizAdminLimited) ||
roles.hasRole(roles.AUTHORIZATION_ROLES.BizAdminFull)
) {
addNavItem(locale.get("Inventory"), "dolly", "/inventory");
}

View File

@@ -23,10 +23,10 @@
}}</span>
</v-toolbar-title>
<v-spacer></v-spacer>
<v-btn icon @click="newItem()">
<v-btn v-if="this.rights.change" icon @click="newItem()">
<v-icon>fa-plus-circle</v-icon>
</v-btn>
<v-btn icon>
<v-btn icon @click="filterMe()">
<v-icon>fa-filter</v-icon>
</v-btn>
<v-btn icon @click="getDataFromApi()">
@@ -47,21 +47,36 @@
:rows-per-page-items="rowsPerPageItems"
:rows-per-page-text="this.$gzlocale.get('RowsPerPage')"
class="elevation-1"
select-all
>
<template slot="items" slot-scope="props">
<td class="text-xs-left">{{ props.item.name | capitalize }}</td>
<td class="text-xs-left">{{ props.item.serial }}</td>
<td class="text-xs-left">
<td>
<v-checkbox
v-model="props.selected"
primary
hide-details
></v-checkbox>
</td>
<td class="text-xs-left" @click="editItem(props.item)">
{{ props.item.name | capitalize }}
</td>
<td class="text-xs-left" @click="editItem(props.item)">
{{ props.item.serial }}
</td>
<td class="text-xs-left" @click="editItem(props.item)">
{{ props.item.dollarAmount | currency }}
</td>
<td class="text-xs-left">{{ props.item.active | boolastext }}</td>
<td class="text-xs-left">{{ props.item.roles }}</td>
<td class="text-xs-left">{{ props.item.startDate | shortdate }}</td>
<td class="text-xs-left">{{ props.item.endDate | shortdate }}</td>
<td class="justify-center layout px-0">
<v-icon class="mr-3" @click="editItem(props.item)"
>fa-pencil-alt</v-icon
>
<td class="text-xs-left" @click="editItem(props.item)">
{{ props.item.active | boolastext }}
</td>
<td class="text-xs-left" @click="editItem(props.item)">
{{ props.item.roles }}
</td>
<td class="text-xs-left" @click="editItem(props.item)">
{{ props.item.startDate | shortdate }}
</td>
<td class="text-xs-left" @click="editItem(props.item)">
{{ props.item.endDate | shortdate }}
</td>
</template>
</v-data-table>
@@ -71,12 +86,13 @@
</template>
<script>
/* Xeslint-disable */
/* eslint-disable */
const FORM_KEY = "inventorywidgetlist";
export default {
beforeCreate() {
var that = this;
this.$gzlocale
.fetch([
"Widget",
@@ -97,6 +113,8 @@ export default {
});
})
.then(() => {
//don't have access to local data object until here
that.rights = this.$gzrole.getRights(this, this.$gztype.Widget);
var formSettings = that.$gzform.getFormSettings(FORM_KEY);
/**
* {
@@ -140,6 +158,7 @@ export default {
appError: null,
serverError: {}
},
rights: this.$gzrole.defaultRightsObject(),
totalItems: 0,
Items: [],
loading: true,
@@ -149,6 +168,7 @@ export default {
selected: [],
rowsPerPageItems: [5, 10, 25, 99],
rowsPerPageText: "blah per blah",
selected: [],
headers: [
{
text: "WidgetName",
@@ -181,6 +201,9 @@ export default {
params: { id: 0 }
});
},
filterMe() {
console.log(this.selected);
},
getDataFromApi() {
var that = this;
var listOptions = {

View File

@@ -201,6 +201,7 @@ function generateMenu(vm, readOnly) {
};
if (readOnly != true) {
//TODO: Handle new record here
menuOptions.menuItems = [
{
title: vm.$gzlocale.get("Save"),
@@ -276,6 +277,19 @@ export default {
//id 0 means create a new record don't load one
if (this.$route.params.id != 0) {
this.getDataFromApi();
} else {
//setup for new record
//first get rights, are they allowed here at all?
//Update the form status
// this.$gzform.setFormState({
// vm: this,
// dirty: false,
// valid: true,
// loading: false,
// readOnly: res.readOnly ? true : false
// });
// //modify the menu as necessary
// generateMenu(this, res.readOnly);
}
},
beforeRouteLeave(to, from, next) {
@@ -354,8 +368,9 @@ export default {
.get(url)
.then(res => {
if (res.error) {
//Not found?
if (res.error.code == "2010") {
//notify error then navigate backwards
//notify not found error then navigate backwards
vm.$gzdialog
.displayLTErrorMessage(vm, "ErrorAPI2010")
.then(() => {