re-factor / cleanup

This commit is contained in:
2022-01-11 22:08:38 +00:00
parent e871708b20
commit e0be8a7cfe
251 changed files with 14680 additions and 15693 deletions

View File

@@ -164,10 +164,10 @@
<!-- ################################ WORK ORDER ITEMS TABLE ############################### -->
<v-col cols="12" class="mb-10">
<v-data-table
v-model="selectedRow"
:headers="headerList"
:items="itemList"
item-key="index"
v-model="selectedRow"
class="elevation-1"
disable-pagination
disable-filtering
@@ -176,9 +176,9 @@
data-cy="itemsTable"
dense
:item-class="itemRowClasses"
@click:row="handleRowClick"
:show-select="$vuetify.breakpoint.xs"
single-select
@click:row="handleRowClick"
>
<template v-slot:[`item.status`]="{ item }">
<template v-if="item.status.id != null">
@@ -209,8 +209,8 @@
<v-btn
v-if="canDelete && isDeleted"
large
@click="unDeleteItem"
color="primary"
@click="unDeleteItem"
>{{ $ay.t("Undelete")
}}<v-icon right large>$ayiTrashRestoreAlt</v-icon></v-btn
>
@@ -220,6 +220,7 @@
cols="12"
>
<v-textarea
:ref="`items[${activeItemIndex}].notes`"
v-model="value.items[activeItemIndex].notes"
:readonly="formState.readOnly || value.userIsRestrictedType"
:disabled="isDeleted"
@@ -227,11 +228,10 @@
:error-messages="
form().serverErrors(this, `items[${activeItemIndex}].notes`)
"
:ref="`items[${activeItemIndex}].notes`"
:rules="[form().required(this, `items[${activeItemIndex}].notes`)]"
data-cy="Items.Notes"
@input="fieldValueChanged(`items[${activeItemIndex}].notes`)"
auto-grow
@input="fieldValueChanged(`items[${activeItemIndex}].notes`)"
></v-textarea>
</v-col>
@@ -246,24 +246,25 @@
xl="3"
>
<v-text-field
:ref="`items[${activeItemIndex}].sequence`"
v-model="value.items[activeItemIndex].sequence"
:readonly="formState.readOnly || value.userIsRestrictedType"
:disabled="isDeleted"
:label="$ay.t('Sequence')"
:ref="`items[${activeItemIndex}].sequence`"
:rules="[
form().integerValid(this, `items[${activeItemIndex}].sequence`)
]"
:error-messages="
form().serverErrors(this, `items[${activeItemIndex}].sequence`)
"
@input="fieldValueChanged(`items[${activeItemIndex}].sequence`)"
type="number"
@input="fieldValueChanged(`items[${activeItemIndex}].sequence`)"
></v-text-field>
</v-col>
<v-col v-if="form().showMe(this, 'WorkOrderItemTechNotes')" cols="12">
<v-textarea
:ref="`items[${activeItemIndex}].techNotes`"
v-model="value.items[activeItemIndex].techNotes"
:readonly="formState.readOnly || value.userIsRestrictedType"
:disabled="isDeleted"
@@ -271,10 +272,9 @@
:error-messages="
form().serverErrors(this, `items[${activeItemIndex}].techNotes`)
"
:ref="`items[${activeItemIndex}].techNotes`"
data-cy="items.techNotes"
@input="fieldValueChanged(`items[${activeItemIndex}].techNotes`)"
auto-grow
@input="fieldValueChanged(`items[${activeItemIndex}].techNotes`)"
></v-textarea>
</v-col>
@@ -289,11 +289,11 @@
xl="3"
>
<gz-date-time-picker
:label="$ay.t('WorkOrderItemRequestDate')"
:ref="`items[${activeItemIndex}].requestDate`"
v-model="value.items[activeItemIndex].requestDate"
:label="$ay.t('WorkOrderItemRequestDate')"
:readonly="formState.readOnly"
:disabled="isDeleted"
:ref="`items[${activeItemIndex}].requestDate`"
data-cy="requestDate"
:error-messages="
form().serverErrors(this, `items[${activeItemIndex}].requestDate`)
@@ -313,10 +313,10 @@
xl="3"
>
<v-autocomplete
:ref="`items[${activeItemIndex}].workOrderItemStatusId`"
v-model="value.items[activeItemIndex].workOrderItemStatusId"
:readonly="formState.readOnly"
:disabled="isDeleted"
@input="fieldValueChanged('workOrderItemStatusId')"
:items="selectableStatusList"
item-text="name"
item-value="id"
@@ -327,9 +327,9 @@
`items[${activeItemIndex}].workOrderItemStatusId`
)
"
:ref="`items[${activeItemIndex}].workOrderItemStatusId`"
data-cy="workOrderItemStatusId"
prepend-icon="$ayiEdit"
@input="fieldValueChanged('workOrderItemStatusId')"
@click:prepend="handleEditItemStatusClick()"
>
<template v-slot:selection="{ item }">
@@ -369,10 +369,10 @@
xl="3"
>
<v-autocomplete
:ref="`items[${activeItemIndex}].workOrderItemPriorityId`"
v-model="value.items[activeItemIndex].workOrderItemPriorityId"
:readonly="formState.readOnly"
:disabled="isDeleted"
@input="fieldValueChanged('workOrderItemPriorityId')"
:items="selectablePriorityList"
item-text="name"
item-value="id"
@@ -383,9 +383,9 @@
`items[${activeItemIndex}].workOrderItemPriorityId`
)
"
:ref="`items[${activeItemIndex}].workOrderItemPriorityId`"
data-cy="workOrderItemPriorityId"
prepend-icon="$ayiEdit"
@input="fieldValueChanged('workOrderItemPriorityId')"
@click:prepend="handleEditItemPriorityClick()"
>
<template v-slot:selection="{ item }">
@@ -424,11 +424,11 @@
xl="3"
>
<v-checkbox
:ref="`items[${activeItemIndex}].warrantyService`"
v-model="value.items[activeItemIndex].warrantyService"
:readonly="formState.readOnly"
:disabled="isDeleted"
:label="$ay.t('WorkOrderItemWarrantyService')"
:ref="`items[${activeItemIndex}].warrantyService`"
data-cy="warrantyService"
:error-messages="
form().serverErrors(
@@ -448,9 +448,9 @@
cols="12"
>
<gz-tag-picker
:ref="`items[${activeItemIndex}].tags`"
v-model="value.items[activeItemIndex].tags"
:readonly="formState.readOnly"
:ref="`items[${activeItemIndex}].tags`"
data-cy="tags"
:error-messages="
form().serverErrors(this, `items[${activeItemIndex}].tags`)
@@ -461,12 +461,12 @@
<v-col v-if="!value.userIsRestrictedType" cols="12">
<gz-custom-fields
:ref="`items[${activeItemIndex}].customFields`"
v-model="value.items[activeItemIndex].customFields"
:form-key="formCustomTemplateKey"
:readonly="formState.readOnly"
:parent-v-m="this"
key-start-with="WorkOrderItemCustom"
:ref="`items[${activeItemIndex}].customFields`"
data-cy="customFields"
:error-messages="
form().serverErrors(
@@ -486,10 +486,10 @@
cols="12"
>
<gz-wiki
:aya-type="$ay.ayt().WorkOrderItem"
:aya-id="value.id"
:ref="`items[${activeItemIndex}].wiki`"
v-model="value.items[activeItemIndex].wiki"
:aya-type="$ay.ayt().WorkOrderItem"
:aya-id="value.id"
:readonly="formState.readOnly"
@input="fieldValueChanged('wiki')"
></gz-wiki
@@ -514,7 +514,7 @@
GRANDCHILDREN
############################################################################ -->
<v-col cols="12" v-show="showUnits">
<v-col v-show="showUnits" cols="12">
<GzQuoteItemUnits
v-model="value"
:pvm="pvm"
@@ -525,7 +525,7 @@
/>
</v-col>
<v-col cols="12" v-show="showScheduledUsers">
<v-col v-show="showScheduledUsers" cols="12">
<GzQuoteItemScheduledUsers
v-model="value"
:pvm="pvm"
@@ -535,7 +535,7 @@
@change="$emit('change')"
/>
</v-col>
<v-col cols="12" v-show="showTasks">
<v-col v-show="showTasks" cols="12">
<GzQuoteItemTasks
v-model="value"
:pvm="pvm"
@@ -546,7 +546,7 @@
/>
</v-col>
<v-col cols="12" v-show="showParts">
<v-col v-show="showParts" cols="12">
<GzQuoteItemParts
v-model="value"
:pvm="pvm"
@@ -557,7 +557,7 @@
/>
</v-col>
<v-col cols="12" v-show="showLabors">
<v-col v-show="showLabors" cols="12">
<GzQuoteItemLabors
v-model="value"
:pvm="pvm"
@@ -567,7 +567,7 @@
@change="$emit('change')"
/>
</v-col>
<v-col cols="12" v-show="showTravels">
<v-col v-show="showTravels" cols="12">
<GzQuoteItemTravels
v-model="value"
:pvm="pvm"
@@ -577,7 +577,7 @@
@change="$emit('change')"
/>
</v-col>
<v-col cols="12" v-show="showExpenses">
<v-col v-show="showExpenses" cols="12">
<GzQuoteItemExpenses
v-model="value"
:pvm="pvm"
@@ -588,7 +588,7 @@
/>
</v-col>
<v-col cols="12" v-show="showLoans">
<v-col v-show="showLoans" cols="12">
<GzQuoteItemLoans
v-model="value"
:pvm="pvm"
@@ -598,7 +598,7 @@
@change="$emit('change')"
/>
</v-col>
<v-col cols="12" v-show="showOutsideServices">
<v-col v-show="showOutsideServices" cols="12">
<GzQuoteItemOutsideServices
v-model="value"
:pvm="pvm"
@@ -635,8 +635,19 @@ export default {
GzQuoteItemLoans,
GzQuoteItemOutsideServices
},
created() {
this.setDefaultView();
props: {
value: {
default: null,
type: Object
},
pvm: {
default: null,
type: Object
},
goto: {
default: null,
type: Object
}
},
data() {
return {
@@ -653,308 +664,6 @@ export default {
gotoUnitIndex: null
};
},
props: {
value: {
default: null,
type: Object
},
pvm: {
default: null,
type: Object
},
goto: {
default: null,
type: Object
}
},
watch: {
goto(val, oldVal) {
if (val != oldVal) {
const navto = { woitemindex: null, childindex: null };
//find the item in question then trigger the nav
let keepgoing = true;
this.value.items.forEach((z, itemindex) => {
if (keepgoing) {
switch (val.type) {
case window.$gz.type.QuoteItem:
if (z.id == val.id) {
navto.woitemindex = itemindex;
keepgoing = false;
}
break;
case window.$gz.type.QuoteItemOutsideService:
z.outsideServices.forEach((x, childindex) => {
if (x.id == val.id) {
navto.woitemindex = itemindex;
navto.childindex = childindex;
keepgoing = false;
}
});
break;
case window.$gz.type.QuoteItemExpense:
z.expenses.forEach((x, childindex) => {
if (x.id == val.id) {
navto.woitemindex = itemindex;
navto.childindex = childindex;
keepgoing = false;
}
});
break;
case window.$gz.type.QuoteItemLabor:
z.labors.forEach((x, childindex) => {
if (x.id == val.id) {
navto.woitemindex = itemindex;
navto.childindex = childindex;
keepgoing = false;
}
});
break;
case window.$gz.type.QuoteItemLoan:
z.loans.forEach((x, childindex) => {
if (x.id == val.id) {
navto.woitemindex = itemindex;
navto.childindex = childindex;
keepgoing = false;
}
});
break;
case window.$gz.type.QuoteItemPart:
z.parts.forEach((x, childindex) => {
if (x.id == val.id) {
navto.woitemindex = itemindex;
navto.childindex = childindex;
keepgoing = false;
}
});
break;
case window.$gz.type.QuoteItemScheduledUser:
z.scheduledUsers.forEach((x, childindex) => {
if (x.id == val.id) {
navto.woitemindex = itemindex;
navto.childindex = childindex;
keepgoing = false;
}
});
break;
case window.$gz.type.QuoteItemTask:
z.tasks.forEach((x, childindex) => {
if (x.id == val.id) {
navto.woitemindex = itemindex;
navto.childindex = childindex;
keepgoing = false;
}
});
break;
case window.$gz.type.QuoteItemTravel:
z.travels.forEach((x, childindex) => {
if (x.id == val.id) {
navto.woitemindex = itemindex;
navto.childindex = childindex;
keepgoing = false;
}
});
break;
case window.$gz.type.QuoteItemUnit:
z.units.forEach((x, childindex) => {
if (x.id == val.id) {
navto.woitemindex = itemindex;
navto.childindex = childindex;
keepgoing = false;
}
});
break;
}
}
});
if (navto.woitemindex != null) {
this.selectedRow = [{ index: navto.woitemindex }];
this.activeItemIndex = navto.woitemindex;
this.$nextTick(() => {
const el = this.$refs.topform;
if (el) {
el.scrollIntoView({ behavior: "smooth" });
}
});
if (navto.childindex != null) {
this.$nextTick(() => {
switch (val.type) {
case window.$gz.type.QuoteItemOutsideService:
this.gotoOutsideServiceIndex = navto.childindex;
break;
case window.$gz.type.QuoteItemExpense:
this.gotoExpenseIndex = navto.childindex;
break;
case window.$gz.type.QuoteItemLabor:
this.gotoLaborIndex = navto.childindex;
break;
case window.$gz.type.QuoteItemLoan:
this.gotoLoanIndex = navto.childindex;
break;
case window.$gz.type.QuoteItemPart:
this.gotoPartIndex = navto.childindex;
break;
case window.$gz.type.QuoteItemTask:
this.gotoTaskIndex = navto.childindex;
break;
case window.$gz.type.QuoteItemScheduledUser:
this.gotoScheduledUserIndex = navto.childindex;
break;
case window.$gz.type.QuoteItemTravel:
this.gotoTravelIndex = navto.childindex;
break;
case window.$gz.type.QuoteItemUnit:
this.gotoUnitIndex = navto.childindex;
break;
}
});
}
}
}
}
},
methods: {
newItem() {
const newIndex = this.value.items.length;
this.value.items.push({
id: 0,
concurrency: 0,
notes: undefined, //to trigger validation on new
wiki: null,
customFields: "{}",
tags: [],
quoteId: this.value.id,
techNotes: null,
workOrderItemStatusId: null,
workOrderItemPriorityId: null,
requestDate: null,
warrantyService: false,
sequence: newIndex + 1, //indexes are zero based but sequences are visible to user so 1 based
isDirty: true,
expenses: [],
labors: [],
loans: [],
parts: [],
scheduledUsers: [],
tasks: [],
travels: [],
units: [],
outsideServices: [],
uid: Date.now() //used for error tracking / display
});
this.$emit("change");
this.selectedRow = [{ index: newIndex }];
this.activeItemIndex = newIndex;
//trigger rule breaking / validation
this.$nextTick(() => {
this.value.items[this.activeItemIndex].notes = null;
this.fieldValueChanged(`items[${this.activeItemIndex}].notes`);
});
},
newSubItem(atype) {
//new Id value to use (by convention goto negative will trigger create and then goto instead of simple goto)
const newId = -Math.abs(Date.now());
switch (atype) {
case window.$gz.type.WorkOrderItemOutsideService:
this.gotoOutsideServiceIndex = newId;
break;
case window.$gz.type.WorkOrderItemExpense:
this.gotoExpenseIndex = newId;
break;
case window.$gz.type.WorkOrderItemLabor:
this.gotoLaborIndex = newId;
break;
case window.$gz.type.WorkOrderItemLoan:
this.gotoLoanIndex = newId;
break;
case window.$gz.type.WorkOrderItemPart:
this.gotoPartIndex = newId;
break;
case window.$gz.type.WorkOrderItemTask:
this.gotoTaskIndex = newId;
break;
case window.$gz.type.WorkOrderItemScheduledUser:
this.gotoScheduledUserIndex = newId;
break;
case window.$gz.type.WorkOrderItemTravel:
this.gotoTravelIndex = newId;
break;
case window.$gz.type.WorkOrderItemUnit:
this.gotoUnitIndex = newId;
break;
}
},
unDeleteItem() {
this.value.items[this.activeItemIndex].deleted = false;
this.setDefaultView();
},
deleteItem() {
this.value.items[this.activeItemIndex].deleted = true;
this.setDefaultView();
this.$emit("change");
},
deleteAllItem() {
this.value.items.forEach(z => (z.deleted = true));
this.setDefaultView();
this.$emit("change");
},
setDefaultView: function() {
//if only one record left then display it otherwise just let the datatable show what the user can click on
if (this.value && this.value.items && this.value.items.length == 1) {
this.selectedRow = [{ index: 0 }];
this.activeItemIndex = 0;
} else {
this.selectedRow = [];
this.activeItemIndex = null; //select nothing in essence resetting a child selects and this one too clearing form
}
},
handleRowClick: function(item) {
this.activeItemIndex = item.index;
this.selectedRow = [{ index: item.index }];
},
handleEditItemStatusClick: function() {
window.$gz.eventBus.$emit("openobject", {
type: window.$gz.type.WorkOrderItemStatus,
id: this.value.items[this.activeItemIndex].workOrderItemStatusId
});
},
handleEditItemPriorityClick: function() {
window.$gz.eventBus.$emit("openobject", {
type: window.$gz.type.WorkOrderItemPriority,
id: this.value.items[this.activeItemIndex].workOrderItemPriorityId
});
},
form() {
return window.$gz.form;
},
fieldValueChanged(ref) {
if (!this.formState.loading && !this.formState.readonly) {
//flag this record dirty so it gets picked up by save
this.value.items[this.activeItemIndex].isDirty = true;
window.$gz.form.fieldValueChanged(this.pvm, ref);
}
},
itemRowClasses: function(item) {
let ret = "";
const isDeleted = this.value.items[item.index].deleted === true;
const hasError = this.form().childRowHasError(
this,
`Items[${item.index}].`
);
if (isDeleted) {
ret += this.form().tableRowDeletedClass();
}
if (hasError) {
ret += this.form().tableRowErrorClass();
}
return ret;
}
},
computed: {
isDeleted: function() {
if (this.value.items[this.activeItemIndex] == null) {
@@ -1218,6 +927,297 @@ export default {
!this.value.userIsRestrictedType
);
}
},
watch: {
goto(val, oldVal) {
if (val != oldVal) {
const navto = { woitemindex: null, childindex: null };
//find the item in question then trigger the nav
let keepgoing = true;
this.value.items.forEach((z, itemindex) => {
if (keepgoing) {
switch (val.type) {
case window.$gz.type.QuoteItem:
if (z.id == val.id) {
navto.woitemindex = itemindex;
keepgoing = false;
}
break;
case window.$gz.type.QuoteItemOutsideService:
z.outsideServices.forEach((x, childindex) => {
if (x.id == val.id) {
navto.woitemindex = itemindex;
navto.childindex = childindex;
keepgoing = false;
}
});
break;
case window.$gz.type.QuoteItemExpense:
z.expenses.forEach((x, childindex) => {
if (x.id == val.id) {
navto.woitemindex = itemindex;
navto.childindex = childindex;
keepgoing = false;
}
});
break;
case window.$gz.type.QuoteItemLabor:
z.labors.forEach((x, childindex) => {
if (x.id == val.id) {
navto.woitemindex = itemindex;
navto.childindex = childindex;
keepgoing = false;
}
});
break;
case window.$gz.type.QuoteItemLoan:
z.loans.forEach((x, childindex) => {
if (x.id == val.id) {
navto.woitemindex = itemindex;
navto.childindex = childindex;
keepgoing = false;
}
});
break;
case window.$gz.type.QuoteItemPart:
z.parts.forEach((x, childindex) => {
if (x.id == val.id) {
navto.woitemindex = itemindex;
navto.childindex = childindex;
keepgoing = false;
}
});
break;
case window.$gz.type.QuoteItemScheduledUser:
z.scheduledUsers.forEach((x, childindex) => {
if (x.id == val.id) {
navto.woitemindex = itemindex;
navto.childindex = childindex;
keepgoing = false;
}
});
break;
case window.$gz.type.QuoteItemTask:
z.tasks.forEach((x, childindex) => {
if (x.id == val.id) {
navto.woitemindex = itemindex;
navto.childindex = childindex;
keepgoing = false;
}
});
break;
case window.$gz.type.QuoteItemTravel:
z.travels.forEach((x, childindex) => {
if (x.id == val.id) {
navto.woitemindex = itemindex;
navto.childindex = childindex;
keepgoing = false;
}
});
break;
case window.$gz.type.QuoteItemUnit:
z.units.forEach((x, childindex) => {
if (x.id == val.id) {
navto.woitemindex = itemindex;
navto.childindex = childindex;
keepgoing = false;
}
});
break;
}
}
});
if (navto.woitemindex != null) {
this.selectedRow = [{ index: navto.woitemindex }];
this.activeItemIndex = navto.woitemindex;
this.$nextTick(() => {
const el = this.$refs.topform;
if (el) {
el.scrollIntoView({ behavior: "smooth" });
}
});
if (navto.childindex != null) {
this.$nextTick(() => {
switch (val.type) {
case window.$gz.type.QuoteItemOutsideService:
this.gotoOutsideServiceIndex = navto.childindex;
break;
case window.$gz.type.QuoteItemExpense:
this.gotoExpenseIndex = navto.childindex;
break;
case window.$gz.type.QuoteItemLabor:
this.gotoLaborIndex = navto.childindex;
break;
case window.$gz.type.QuoteItemLoan:
this.gotoLoanIndex = navto.childindex;
break;
case window.$gz.type.QuoteItemPart:
this.gotoPartIndex = navto.childindex;
break;
case window.$gz.type.QuoteItemTask:
this.gotoTaskIndex = navto.childindex;
break;
case window.$gz.type.QuoteItemScheduledUser:
this.gotoScheduledUserIndex = navto.childindex;
break;
case window.$gz.type.QuoteItemTravel:
this.gotoTravelIndex = navto.childindex;
break;
case window.$gz.type.QuoteItemUnit:
this.gotoUnitIndex = navto.childindex;
break;
}
});
}
}
}
}
},
created() {
this.setDefaultView();
},
methods: {
newItem() {
const newIndex = this.value.items.length;
this.value.items.push({
id: 0,
concurrency: 0,
notes: undefined, //to trigger validation on new
wiki: null,
customFields: "{}",
tags: [],
quoteId: this.value.id,
techNotes: null,
workOrderItemStatusId: null,
workOrderItemPriorityId: null,
requestDate: null,
warrantyService: false,
sequence: newIndex + 1, //indexes are zero based but sequences are visible to user so 1 based
isDirty: true,
expenses: [],
labors: [],
loans: [],
parts: [],
scheduledUsers: [],
tasks: [],
travels: [],
units: [],
outsideServices: [],
uid: Date.now() //used for error tracking / display
});
this.$emit("change");
this.selectedRow = [{ index: newIndex }];
this.activeItemIndex = newIndex;
//trigger rule breaking / validation
this.$nextTick(() => {
this.value.items[this.activeItemIndex].notes = null;
this.fieldValueChanged(`items[${this.activeItemIndex}].notes`);
});
},
newSubItem(atype) {
//new Id value to use (by convention goto negative will trigger create and then goto instead of simple goto)
const newId = -Math.abs(Date.now());
switch (atype) {
case window.$gz.type.WorkOrderItemOutsideService:
this.gotoOutsideServiceIndex = newId;
break;
case window.$gz.type.WorkOrderItemExpense:
this.gotoExpenseIndex = newId;
break;
case window.$gz.type.WorkOrderItemLabor:
this.gotoLaborIndex = newId;
break;
case window.$gz.type.WorkOrderItemLoan:
this.gotoLoanIndex = newId;
break;
case window.$gz.type.WorkOrderItemPart:
this.gotoPartIndex = newId;
break;
case window.$gz.type.WorkOrderItemTask:
this.gotoTaskIndex = newId;
break;
case window.$gz.type.WorkOrderItemScheduledUser:
this.gotoScheduledUserIndex = newId;
break;
case window.$gz.type.WorkOrderItemTravel:
this.gotoTravelIndex = newId;
break;
case window.$gz.type.WorkOrderItemUnit:
this.gotoUnitIndex = newId;
break;
}
},
unDeleteItem() {
this.value.items[this.activeItemIndex].deleted = false;
this.setDefaultView();
},
deleteItem() {
this.value.items[this.activeItemIndex].deleted = true;
this.setDefaultView();
this.$emit("change");
},
deleteAllItem() {
this.value.items.forEach(z => (z.deleted = true));
this.setDefaultView();
this.$emit("change");
},
setDefaultView: function() {
//if only one record left then display it otherwise just let the datatable show what the user can click on
if (this.value && this.value.items && this.value.items.length == 1) {
this.selectedRow = [{ index: 0 }];
this.activeItemIndex = 0;
} else {
this.selectedRow = [];
this.activeItemIndex = null; //select nothing in essence resetting a child selects and this one too clearing form
}
},
handleRowClick: function(item) {
this.activeItemIndex = item.index;
this.selectedRow = [{ index: item.index }];
},
handleEditItemStatusClick: function() {
window.$gz.eventBus.$emit("openobject", {
type: window.$gz.type.WorkOrderItemStatus,
id: this.value.items[this.activeItemIndex].workOrderItemStatusId
});
},
handleEditItemPriorityClick: function() {
window.$gz.eventBus.$emit("openobject", {
type: window.$gz.type.WorkOrderItemPriority,
id: this.value.items[this.activeItemIndex].workOrderItemPriorityId
});
},
form() {
return window.$gz.form;
},
fieldValueChanged(ref) {
if (!this.formState.loading && !this.formState.readonly) {
//flag this record dirty so it gets picked up by save
this.value.items[this.activeItemIndex].isDirty = true;
window.$gz.form.fieldValueChanged(this.pvm, ref);
}
},
itemRowClasses: function(item) {
let ret = "";
const isDeleted = this.value.items[item.index].deleted === true;
const hasError = this.form().childRowHasError(
this,
`Items[${item.index}].`
);
if (isDeleted) {
ret += this.form().tableRowDeletedClass();
}
if (hasError) {
ret += this.form().tableRowErrorClass();
}
return ret;
}
}
};