This commit is contained in:
2020-06-21 14:06:56 +00:00
parent 0481a674c5
commit 15b37daeab
5 changed files with 120 additions and 119 deletions

View File

@@ -24,6 +24,10 @@ todo: need a role collection control of some kind for things like case 3417.
ideally it binds to a single value and can extract back out of that value bitwise all the correct items in the list checked
This way can bind it to a single bit field value and be efficient FTW$!
todo: user options form put color picker last it's pushing down the entire last row
also, can it be shorter, there's probably a setting for that
todo: need to test a license downgrade of techs once have User creation stuff done
todo: Administration - translation

View File

@@ -112,7 +112,8 @@ export default {
let userRole = window.$gz.store.state.roles;
//calculate the effective rights
//a non zero result of the bitwise calculation means true and zero means false so using !! to force it into a boolean value (contrary to some style guides that say !! is obscure but I say it saves a lot of typing)
//a non zero result of the bitwise calculation means true and zero means false so using !! to force it into a boolean value
//(contrary to some style guides that say !! is obscure but I say it saves a lot of typing)
let canChange = !!(userRole & objectRoleRights.Change);
let canReadFullRecord = !!(userRole & objectRoleRights.ReadFullRecord);

View File

@@ -0,0 +1,76 @@
<template>
<v-select
:items="availableRoles"
item-text="name"
item-value="id"
multiple
chips
hint="select roles"
persistent-hint
:value="rolevalue()"
@input="handleInput"
:readonly="readonly"
:disabled="disabled"
:label="label"
:rules="rules"
:error-messages="allErrors()"
:data-cy="!!$ay.dev ? 'roleinput:' + testId : false"
></v-select>
</template>
<script>
/* Xeslint-disable */
export default {
async created() {
//get the available roles
//first make sure it's cached
await window.$gz.enums.fetchEnumList("AuthorizationRoles");
this.availableRoles = window.$gz.enums.getSelectionList(
"AuthorizationRoles"
);
//window.$gz.form.addNoSelectionItem(vm.selectLists.objectTypes);
},
data() {
return {
internalValue: null,
availableRoles: []
};
},
watch: {
value(val) {
this.internalValue = val;
}
},
props: {
label: String,
rules: Array,
"error-messages": { type: Array, default: null },
value: { type: Number, default: 0 },
readonly: { type: Boolean, default: false },
disabled: { type: Boolean, default: false },
error: {
type: String,
required: false
},
testId: String
},
methods: {
allErrors() {
let ret = "";
if (this.error != null) {
ret = this.error;
}
if (this.errorMessages != null && this.errorMessages.length > 0) {
ret += this.errorMessages.toString();
}
return ret;
},
rolevalue() {
//turn ineternalValue numeric bitfield role value into list of selected roles
},
handleInput(value) {
//turn list of selected roles into single bitfield value
//and emit it
}
}
};
</script>

View File

@@ -44,6 +44,7 @@ import dataTable from "./components/gz-data-table.vue";
import customFieldsControl from "./components/custom-fields-control.vue";
import currencyControl from "./components/currency-control.vue";
import decimalControl from "./components/decimal-control.vue";
import roleControl from "./components/role-control.vue";
import errorControl from "./components/error-control.vue";
import reportSelectorControl from "./components/report-selector-control.vue";
import reportViewerControl from "./components/report-viewer-control.vue";
@@ -183,6 +184,7 @@ Vue.component("gz-data-table", dataTable);
Vue.component("gz-custom-fields", customFieldsControl);
Vue.component("gz-currency", currencyControl);
Vue.component("gz-decimal", decimalControl);
Vue.component("gz-role-picker", roleControl);
Vue.component("gz-error", errorControl);
Vue.component("gz-report-selector", reportSelectorControl);
Vue.component("gz-report-viewer", reportViewerControl);

View File

@@ -4,6 +4,7 @@
<v-row v-if="formState.ready">
<v-col>
<v-form ref="form">
todo: set password, maybe set user options?
<v-row>
<gz-error :errorBoxMessage="formState.errorBoxMessage"></gz-error>
<v-col cols="12" sm="6" lg="4" xl="3">
@@ -14,7 +15,7 @@
:clearable="!formState.readOnly"
@click:clear="fieldValueChanged('name')"
:counter="255"
:label="$ay.t('UserName')"
:label="$ay.t('Name')"
:rules="[
form().max255(this, 'name'),
form().required(this, 'name')
@@ -25,94 +26,39 @@
@input="fieldValueChanged('name')"
></v-text-field>
</v-col>
<v-col
v-if="form().showMe(this, 'Serial')"
cols="12"
sm="6"
lg="4"
xl="3"
>
<v-col cols="12" sm="6" lg="4" xl="3">
<v-text-field
v-model="obj.serial"
:readonly="true"
:disabled="formState.readOnly"
:label="$ay.t('UserSerial')"
:data-cy="!!$ay.dev ? 'serial' : false"
></v-text-field>
</v-col>
<v-col
v-if="form().showMe(this, 'Count')"
cols="12"
sm="6"
lg="4"
xl="3"
>
<v-text-field
v-model="obj.count"
v-model="obj.employeeNumber"
:readonly="formState.readOnly"
:disabled="formState.readOnly"
:clearable="!formState.readOnly"
@click:clear="fieldValueChanged('count')"
:counter="10"
:label="$ay.t('UserCount')"
ref="count"
:data-cy="!!$ay.dev ? 'count' : false"
:rules="[form().integerValid(this, 'count')]"
:error-messages="form().serverErrors(this, 'count')"
@input="fieldValueChanged('count')"
type="number"
@click:clear="fieldValueChanged('employeeNumber')"
:counter="255"
:label="$ay.t('UserEmployeeNumber')"
:rules="[
form().max255(this, 'employeeNumber'),
form().required(this, 'employeeNumber')
]"
:error-messages="form().serverErrors(this, 'employeeNumber')"
ref="employeeNumber"
:data-cy="!!$ay.dev ? 'employeeNumber' : false"
@input="fieldValueChanged('employeeNumber')"
></v-text-field>
</v-col>
<v-col
v-if="form().showMe(this, 'DollarAmount')"
cols="12"
sm="6"
lg="4"
xl="3"
>
<gz-currency
v-model="obj.dollarAmount"
<v-col cols="12" sm="6" lg="4" xl="3">
<gz-role-picker
:label="$ay.t('AuthorizationRoles')"
v-model="obj.roles"
:readonly="formState.readOnly"
:disabled="formState.readOnly"
:label="$ay.t('UserDollarAmount')"
ref="dollarAmount"
:data-cy="!!$ay.dev ? 'dollarAmount' : false"
:rules="[
form().decimalValid(this, 'dollarAmount'),
form().required(this, 'dollarAmount')
]"
:error-messages="form().serverErrors(this, 'dollarAmount')"
@input="fieldValueChanged('dollarAmount')"
></gz-currency>
ref="roles"
testId="roles"
:error-messages="form().serverErrors(this, 'roles')"
@input="fieldValueChanged('roles')"
></gz-role-picker>
</v-col>
<v-col cols="12" sm="6" lg="4" xl="3">
<gz-date-time-picker
:label="$ay.t('UserStartDate')"
v-model="obj.startDate"
:readonly="formState.readOnly"
:disabled="formState.readOnly"
ref="startDate"
testId="startDate"
:error-messages="form().serverErrors(this, 'startDate')"
@input="fieldValueChanged('startDate')"
></gz-date-time-picker>
</v-col>
<v-col cols="12" sm="6" lg="4" xl="3">
<gz-date-time-picker
:label="$ay.t('UserEndDate')"
:rules="[form().datePrecedence(this, 'startDate', 'endDate')]"
:error-messages="form().serverErrors(this, 'endDate')"
v-model="obj.endDate"
:readonly="formState.readOnly"
:disabled="formState.readOnly"
ref="endDate"
testId="endDate"
@input="fieldValueChanged('endDate')"
></gz-date-time-picker>
</v-col>
<v-col
v-if="form().showMe(this, 'Active')"
cols="12"
@@ -132,27 +78,6 @@
></v-checkbox>
</v-col>
<v-col
v-if="form().showMe(this, 'UserId')"
cols="12"
sm="6"
lg="4"
xl="3"
>
<gz-pick-list
:ayaType="ayaTypes().User"
:showEditIcon="true"
v-model="obj.userId"
:readonly="formState.readOnly"
:disabled="formState.readOnly"
:label="$ay.t('User')"
ref="userid"
:data-cy="!!$ay.dev ? 'userid' : false"
:error-messages="form().serverErrors(this, 'userid')"
@input="fieldValueChanged('userid')"
></gz-pick-list>
</v-col>
<v-col
v-if="form().showMe(this, 'UserType')"
cols="12"
@@ -326,23 +251,21 @@ export default {
usertypes: []
},
obj: {
//IMPORTANT NOTE: Fields that are NON NULLABLE in the schema for the table but *are* hideable **MUST** have a default value set here or else there will be no way to save the record
//I.E. Serial, usertype fields
id: 0,
concurrency: 0,
name: null,
serial: 0,
dollarAmount: null,
active: null,
name: null,
roles: null,
userType: 0,
startDate: null,
endDate: null,
employeeNumber: null,
notes: null,
count: null,
customerId: null,
headOfficeId: null,
subVendorId: null,
wiki: null,
customFields: "{}",
tags: [],
userId: null
lastLogin: null
},
formState: {
ready: false,
@@ -729,15 +652,12 @@ async function initForm(vm) {
async function fetchTranslatedText(vm) {
await window.$gz.translation.cacheTranslations([
"User",
"UserName",
"UserSerial",
"UserDollarAmount",
"UserCount",
"User",
"UserType",
"UserStartDate",
"UserEndDate",
"Name",
"UserEmployeeNumber",
"AuthorizationRoles",
"UserNotes",
"UserType",
"Active",
"UserCustom1",
"UserCustom2",
"UserCustom3",
@@ -766,5 +686,3 @@ async function populateSelectionLists(vm) {
vm.selectLists.usertypes = window.$gz.enums.getSelectionList("usertype");
}
</script>
<style></style>