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

@@ -57,10 +57,10 @@
<!-- ############################################################### -->
<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
@@ -69,9 +69,9 @@
data-cy="unitsTable"
dense
:item-class="itemRowClasses"
@click:row="handleRowClick"
:show-select="$vuetify.breakpoint.xs"
single-select
@click:row="handleRowClick"
>
</v-data-table>
</v-col>
@@ -81,8 +81,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
>
@@ -94,20 +94,20 @@
xl="3"
>
<gz-pick-list
:aya-type="$ay.ayt().Unit"
:variant="'customerid:' + value.customerId"
:show-edit-icon="!value.userIsRestrictedType"
:ref="
`Items[${activeWoItemIndex}].units[${activeItemIndex}].unitId`
"
v-model="
value.items[activeWoItemIndex].units[activeItemIndex].unitId
"
:aya-type="$ay.ayt().Unit"
:variant="'customerid:' + value.customerId"
:show-edit-icon="!value.userIsRestrictedType"
:readonly="
formState.readOnly || isDeleted || value.userIsRestrictedType
"
:disabled="isDeleted"
:label="$ay.t('Unit')"
:ref="
`Items[${activeWoItemIndex}].units[${activeItemIndex}].unitId`
"
data-cy="units.unitId"
:rules="[
form().required(
@@ -166,6 +166,7 @@
cols="12"
>
<v-textarea
:ref="`Items[${activeWoItemIndex}].units[${activeItemIndex}].notes`"
v-model="
value.items[activeWoItemIndex].units[activeItemIndex].notes
"
@@ -178,14 +179,13 @@
`Items[${activeWoItemIndex}].units[${activeItemIndex}].notes`
)
"
:ref="`Items[${activeWoItemIndex}].units[${activeItemIndex}].notes`"
data-cy="unitUnitNotes"
auto-grow
@input="
fieldValueChanged(
`Items[${activeWoItemIndex}].units[${activeItemIndex}].notes`
)
"
auto-grow
></v-textarea>
</v-col>
@@ -197,6 +197,7 @@
cols="12"
>
<gz-tag-picker
:ref="`Items[${activeWoItemIndex}].units[${activeItemIndex}].tags`"
v-model="value.items[activeWoItemIndex].units[activeItemIndex].tags"
:readonly="formState.readOnly"
data-cy="unitTags"
@@ -206,7 +207,6 @@
`Items[${activeWoItemIndex}].units[${activeItemIndex}].tags`
)
"
:ref="`Items[${activeWoItemIndex}].units[${activeItemIndex}].tags`"
@input="
fieldValueChanged(
`Items[${activeWoItemIndex}].units[${activeItemIndex}].tags`
@@ -217,6 +217,9 @@
<v-col v-if="!value.userIsRestrictedType" cols="12">
<gz-custom-fields
:ref="
`Items[${activeWoItemIndex}].units[${activeItemIndex}].customFields`
"
v-model="
value.items[activeWoItemIndex].units[activeItemIndex].customFields
"
@@ -224,9 +227,6 @@
:readonly="formState.readOnly"
:parent-v-m="this"
key-start-with="WorkOrderItemUnitCustom"
:ref="
`Items[${activeWoItemIndex}].units[${activeItemIndex}].customFields`
"
data-cy="unitCustomFields"
:error-messages="
form().serverErrors(
@@ -250,10 +250,10 @@
cols="12"
>
<gz-wiki
:aya-type="$ay.ayt().WorkOrderItem"
:aya-id="value.id"
:ref="`Items[${activeWoItemIndex}].units[${activeItemIndex}].wiki`"
v-model="value.items[activeWoItemIndex].units[activeItemIndex].wiki"
:aya-type="$ay.ayt().WorkOrderItem"
:aya-id="value.id"
:readonly="formState.readOnly"
@input="
fieldValueChanged(
@@ -284,22 +284,22 @@
<!-- ################################################################################-->
<template>
<v-row justify="center">
<v-dialog persistent max-width="600px" v-model="bulkUnitsDialog">
<v-dialog v-model="bulkUnitsDialog" persistent max-width="600px">
<v-card>
<v-card-title>{{ $ay.t("AddMultipleUnits") }}</v-card-title>
<v-card-text>
<gz-tag-picker v-model="selectedBulkUnitTags"></gz-tag-picker>
<gz-pick-list
v-model="selectedBulkUnitCustomer"
:aya-type="$ay.ayt().Customer"
:show-edit-icon="false"
v-model="selectedBulkUnitCustomer"
:label="$ay.t('Customer')"
:can-clear="true"
></gz-pick-list>
<v-data-table
dense
v-model="selectedBulkUnits"
dense
:headers="bulkUnitTableHeaders"
:items="availableBulkUnits"
class="my-10"
@@ -312,7 +312,7 @@
</v-data-table>
</v-card-text>
<v-card-actions>
<v-btn text @click="bulkUnitsDialog = false" color="primary">{{
<v-btn text color="primary" @click="bulkUnitsDialog = false">{{
$ay.t("Cancel")
}}</v-btn>
<v-spacer></v-spacer>
@@ -339,21 +339,6 @@
</template>
<script>
export default {
created() {
this.setDefaultView();
},
data() {
return {
activeItemIndex: null,
selectedRow: [],
bulkUnitsDialog: false,
selectedBulkUnitCustomer: this.value.customerId,
availableBulkUnits: [],
selectedBulkUnits: [],
selectedBulkUnitTags: [],
bulkUnitTableHeaders: []
};
},
props: {
value: {
default: null,
@@ -376,6 +361,126 @@ export default {
type: Number
}
},
data() {
return {
activeItemIndex: null,
selectedRow: [],
bulkUnitsDialog: false,
selectedBulkUnitCustomer: this.value.customerId,
availableBulkUnits: [],
selectedBulkUnits: [],
selectedBulkUnitTags: [],
bulkUnitTableHeaders: []
};
},
computed: {
isDeleted: function() {
if (
this.value.items[this.activeWoItemIndex].units[this.activeItemIndex] ==
null
) {
this.setDefaultView();
return true;
}
return (
this.value.items[this.activeWoItemIndex].units[this.activeItemIndex]
.deleted === true
);
},
parentDeleted: function() {
return this.value.items[this.activeWoItemIndex].deleted === true;
},
headerList: function() {
const headers = [];
if (this.form().showMe(this, "WorkOrderItemUnit")) {
headers.push({
text: this.$ay.t("Unit"),
align: "left",
value: "unitViz"
});
}
if (this.form().showMe(this, "UnitModelName")) {
headers.push({
text: this.$ay.t("UnitModelName"),
align: "left",
value: "unitModelNameViz"
});
}
if (this.form().showMe(this, "UnitModelVendorID")) {
headers.push({
text: this.$ay.t("UnitModelVendorID"),
align: "left",
value: "unitModelVendorViz"
});
}
if (this.form().showMe(this, "UnitDescription")) {
headers.push({
text: this.$ay.t("UnitDescription"),
align: "left",
value: "unitDescriptionViz"
});
}
if (
this.form().showMe(this, "WorkOrderItemUnitNotes") &&
!this.value.userIsRestrictedType
) {
headers.push({
text: this.$ay.t("WorkOrderItemUnitNotes"),
align: "left",
value: "notes"
});
}
return headers;
},
itemList: function() {
return this.value.items[this.activeWoItemIndex].units.map((x, i) => {
return {
index: i,
id: x.id,
unitViz: x.unitViz,
unitModelVendorViz: x.unitModelVendorViz,
unitModelNameViz: x.unitModelNameViz,
unitDescriptionViz: x.unitDescriptionViz,
notes: window.$gz.util.truncateString(
x.notes,
this.pvm.maxTableNotesLength
)
};
});
},
formState: function() {
return this.pvm.formState;
},
formCustomTemplateKey: function() {
return this.pvm.formCustomTemplateKey;
},
hasData: function() {
return this.value.items[this.activeWoItemIndex].units.length > 0;
},
hasSelection: function() {
return this.activeItemIndex != null;
},
canAdd: function() {
return this.pvm.rights.change && !this.value.userIsRestrictedType;
},
canDelete: function() {
return (
this.activeItemIndex != null &&
this.canDeleteAll &&
!this.value.userIsRestrictedType
);
},
canDeleteAll: function() {
return this.pvm.rights.change && !this.value.userIsRestrictedType;
}
},
watch: {
activeWoItemIndex(val, oldVal) {
if (val != oldVal) {
@@ -400,6 +505,9 @@ export default {
}
}
},
created() {
this.setDefaultView();
},
methods: {
async updateContractIfApplicable() {
const id = this.value.items[this.activeWoItemIndex].units[
@@ -688,114 +796,6 @@ export default {
}
return ret;
}
},
computed: {
isDeleted: function() {
if (
this.value.items[this.activeWoItemIndex].units[this.activeItemIndex] ==
null
) {
this.setDefaultView();
return true;
}
return (
this.value.items[this.activeWoItemIndex].units[this.activeItemIndex]
.deleted === true
);
},
parentDeleted: function() {
return this.value.items[this.activeWoItemIndex].deleted === true;
},
headerList: function() {
const headers = [];
if (this.form().showMe(this, "WorkOrderItemUnit")) {
headers.push({
text: this.$ay.t("Unit"),
align: "left",
value: "unitViz"
});
}
if (this.form().showMe(this, "UnitModelName")) {
headers.push({
text: this.$ay.t("UnitModelName"),
align: "left",
value: "unitModelNameViz"
});
}
if (this.form().showMe(this, "UnitModelVendorID")) {
headers.push({
text: this.$ay.t("UnitModelVendorID"),
align: "left",
value: "unitModelVendorViz"
});
}
if (this.form().showMe(this, "UnitDescription")) {
headers.push({
text: this.$ay.t("UnitDescription"),
align: "left",
value: "unitDescriptionViz"
});
}
if (
this.form().showMe(this, "WorkOrderItemUnitNotes") &&
!this.value.userIsRestrictedType
) {
headers.push({
text: this.$ay.t("WorkOrderItemUnitNotes"),
align: "left",
value: "notes"
});
}
return headers;
},
itemList: function() {
return this.value.items[this.activeWoItemIndex].units.map((x, i) => {
return {
index: i,
id: x.id,
unitViz: x.unitViz,
unitModelVendorViz: x.unitModelVendorViz,
unitModelNameViz: x.unitModelNameViz,
unitDescriptionViz: x.unitDescriptionViz,
notes: window.$gz.util.truncateString(
x.notes,
this.pvm.maxTableNotesLength
)
};
});
},
formState: function() {
return this.pvm.formState;
},
formCustomTemplateKey: function() {
return this.pvm.formCustomTemplateKey;
},
hasData: function() {
return this.value.items[this.activeWoItemIndex].units.length > 0;
},
hasSelection: function() {
return this.activeItemIndex != null;
},
canAdd: function() {
return this.pvm.rights.change && !this.value.userIsRestrictedType;
},
canDelete: function() {
return (
this.activeItemIndex != null &&
this.canDeleteAll &&
!this.value.userIsRestrictedType
);
},
canDeleteAll: function() {
return this.pvm.rights.change && !this.value.userIsRestrictedType;
}
}
};
</script>