re-factor / cleanup
This commit is contained in:
@@ -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(
|
||||
@@ -160,8 +160,8 @@
|
||||
<v-btn
|
||||
color="primary"
|
||||
text
|
||||
@click="getWarrantyInfo"
|
||||
data-cy="woItemUnitGetWarrantyInfo"
|
||||
@click="getWarrantyInfo"
|
||||
>{{ $ay.t("Search") }}</v-btn
|
||||
>
|
||||
</v-card-actions>
|
||||
@@ -176,6 +176,7 @@
|
||||
cols="12"
|
||||
>
|
||||
<v-textarea
|
||||
:ref="`Items[${activeWoItemIndex}].units[${activeItemIndex}].notes`"
|
||||
v-model="
|
||||
value.items[activeWoItemIndex].units[activeItemIndex].notes
|
||||
"
|
||||
@@ -188,14 +189,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>
|
||||
|
||||
@@ -207,6 +207,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"
|
||||
@@ -216,7 +217,6 @@
|
||||
`Items[${activeWoItemIndex}].units[${activeItemIndex}].tags`
|
||||
)
|
||||
"
|
||||
:ref="`Items[${activeWoItemIndex}].units[${activeItemIndex}].tags`"
|
||||
@input="
|
||||
fieldValueChanged(
|
||||
`Items[${activeWoItemIndex}].units[${activeItemIndex}].tags`
|
||||
@@ -227,6 +227,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
|
||||
"
|
||||
@@ -234,9 +237,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(
|
||||
@@ -260,10 +260,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(
|
||||
@@ -294,22 +294,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"
|
||||
@@ -322,7 +322,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>
|
||||
@@ -349,21 +349,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,
|
||||
@@ -386,6 +371,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) {
|
||||
@@ -410,6 +515,9 @@ export default {
|
||||
}
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.setDefaultView();
|
||||
},
|
||||
methods: {
|
||||
canOpenMeter: function() {
|
||||
return (
|
||||
@@ -728,114 +836,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>
|
||||
|
||||
Reference in New Issue
Block a user