re-factor / cleanup
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
<div v-if="formState.ready">
|
||||
<gz-error :error-box-message="formState.errorBoxMessage"></gz-error>
|
||||
<v-form ref="form">
|
||||
<v-tabs mobile-breakpoint="100" v-model="tab">
|
||||
<v-tabs v-model="tab" mobile-breakpoint="100">
|
||||
<v-tab>{{ $ay.t("Unit") }}</v-tab>
|
||||
<v-tab>{{ $ay.t("Address") }}</v-tab>
|
||||
<v-tab>{{ $ay.t("UnitOverrideWarranty") }}</v-tab>
|
||||
@@ -13,12 +13,12 @@
|
||||
<v-row>
|
||||
<v-col cols="12" sm="6" lg="4" xl="3">
|
||||
<v-text-field
|
||||
ref="serial"
|
||||
v-model="obj.serial"
|
||||
:readonly="formState.readOnly"
|
||||
:label="$ay.t('UnitSerial')"
|
||||
:rules="[form().required(this, 'serial')]"
|
||||
:error-messages="form().serverErrors(this, 'serial')"
|
||||
ref="serial"
|
||||
data-cy="serial"
|
||||
@input="fieldValueChanged('serial')"
|
||||
></v-text-field>
|
||||
@@ -26,12 +26,12 @@
|
||||
|
||||
<v-col cols="12" sm="6" lg="4" xl="3">
|
||||
<gz-pick-list
|
||||
ref="customerId"
|
||||
v-model="obj.customerId"
|
||||
:aya-type="ayaTypes().Customer"
|
||||
show-edit-icon
|
||||
v-model="obj.customerId"
|
||||
:readonly="formState.readOnly"
|
||||
:label="$ay.t('Customer')"
|
||||
ref="customerId"
|
||||
data-cy="customerId"
|
||||
:error-messages="form().serverErrors(this, 'customerId')"
|
||||
@input="fieldValueChanged('customerId')"
|
||||
@@ -46,10 +46,10 @@
|
||||
xl="3"
|
||||
>
|
||||
<v-text-field
|
||||
ref="description"
|
||||
v-model="obj.description"
|
||||
:readonly="formState.readOnly"
|
||||
:label="$ay.t('UnitDescription')"
|
||||
ref="description"
|
||||
data-cy="description"
|
||||
:error-messages="form().serverErrors(this, 'description')"
|
||||
@input="fieldValueChanged('description')"
|
||||
@@ -64,12 +64,12 @@
|
||||
xl="3"
|
||||
>
|
||||
<gz-pick-list
|
||||
ref="unitModelId"
|
||||
v-model="obj.unitModelId"
|
||||
:aya-type="ayaTypes().UnitModel"
|
||||
show-edit-icon
|
||||
v-model="obj.unitModelId"
|
||||
:readonly="formState.readOnly"
|
||||
:label="$ay.t('UnitModel')"
|
||||
ref="unitModelId"
|
||||
data-cy="unitModelId"
|
||||
:error-messages="form().serverErrors(this, 'unitModelId')"
|
||||
@input="fieldValueChanged('unitModelId')"
|
||||
@@ -84,12 +84,12 @@
|
||||
xl="3"
|
||||
>
|
||||
<gz-pick-list
|
||||
ref="replacedByUnitId"
|
||||
v-model="obj.replacedByUnitId"
|
||||
:aya-type="ayaTypes().Unit"
|
||||
show-edit-icon
|
||||
v-model="obj.replacedByUnitId"
|
||||
:readonly="formState.readOnly"
|
||||
:label="$ay.t('UnitReplacedByUnitID')"
|
||||
ref="replacedByUnitId"
|
||||
data-cy="replacedByUnitId"
|
||||
:error-messages="
|
||||
form().serverErrors(this, 'replacedByUnitId')
|
||||
@@ -106,12 +106,12 @@
|
||||
xl="3"
|
||||
>
|
||||
<gz-pick-list
|
||||
ref="parentUnitId"
|
||||
v-model="obj.parentUnitId"
|
||||
:aya-type="ayaTypes().Unit"
|
||||
show-edit-icon
|
||||
v-model="obj.parentUnitId"
|
||||
:readonly="formState.readOnly"
|
||||
:label="$ay.t('UnitParentUnitID')"
|
||||
ref="parentUnitId"
|
||||
data-cy="parentUnitId"
|
||||
:error-messages="form().serverErrors(this, 'parentUnitId')"
|
||||
@input="fieldValueChanged('parentUnitId')"
|
||||
@@ -126,12 +126,12 @@
|
||||
xl="3"
|
||||
>
|
||||
<gz-pick-list
|
||||
ref="contractId"
|
||||
v-model="obj.contractId"
|
||||
:aya-type="ayaTypes().Contract"
|
||||
show-edit-icon
|
||||
v-model="obj.contractId"
|
||||
:readonly="formState.readOnly"
|
||||
:label="$ay.t('Contract')"
|
||||
ref="contractId"
|
||||
data-cy="contractId"
|
||||
:error-messages="form().serverErrors(this, 'contractId')"
|
||||
@input="fieldValueChanged('contractId')"
|
||||
@@ -148,10 +148,10 @@
|
||||
xl="3"
|
||||
>
|
||||
<gz-date-time-picker
|
||||
:label="$ay.t('ContractExpires')"
|
||||
v-model="obj.contractExpires"
|
||||
:readonly="formState.readOnly"
|
||||
ref="contractExpires"
|
||||
v-model="obj.contractExpires"
|
||||
:label="$ay.t('ContractExpires')"
|
||||
:readonly="formState.readOnly"
|
||||
data-cy="contractExpires"
|
||||
:error-messages="
|
||||
form().serverErrors(this, 'contractExpires')
|
||||
@@ -198,15 +198,15 @@
|
||||
xl="3"
|
||||
>
|
||||
<v-checkbox
|
||||
ref="metered"
|
||||
v-model="obj.metered"
|
||||
:readonly="formState.readOnly"
|
||||
:label="$ay.t('UnitMetered')"
|
||||
ref="metered"
|
||||
data-cy="metered"
|
||||
:error-messages="form().serverErrors(this, 'metered')"
|
||||
@change="fieldValueChanged('metered')"
|
||||
>
|
||||
<template v-slot:append v-if="canOpenMeter()">
|
||||
<template v-if="canOpenMeter()" v-slot:append>
|
||||
<v-btn outlined small color="primary" @click="openMeter">
|
||||
<v-icon>$ayiWeight</v-icon></v-btn
|
||||
>
|
||||
@@ -222,10 +222,10 @@
|
||||
xl="3"
|
||||
>
|
||||
<v-checkbox
|
||||
ref="boughtHere"
|
||||
v-model="obj.boughtHere"
|
||||
:readonly="formState.readOnly"
|
||||
:label="$ay.t('UnitBoughtHere')"
|
||||
ref="boughtHere"
|
||||
data-cy="boughtHere"
|
||||
:error-messages="form().serverErrors(this, 'boughtHere')"
|
||||
@change="fieldValueChanged('boughtHere')"
|
||||
@@ -240,12 +240,12 @@
|
||||
xl="3"
|
||||
>
|
||||
<gz-pick-list
|
||||
ref="purchasedFromVendorId"
|
||||
v-model="obj.purchasedFromVendorId"
|
||||
:aya-type="ayaTypes().Vendor"
|
||||
show-edit-icon
|
||||
v-model="obj.purchasedFromVendorId"
|
||||
:readonly="formState.readOnly"
|
||||
:label="$ay.t('UnitPurchaseFromID')"
|
||||
ref="purchasedFromVendorId"
|
||||
data-cy="purchasedFromVendorId"
|
||||
:error-messages="
|
||||
form().serverErrors(this, 'purchasedFromVendorId')
|
||||
@@ -262,10 +262,10 @@
|
||||
xl="3"
|
||||
>
|
||||
<gz-date-time-picker
|
||||
:label="$ay.t('UnitPurchasedDate')"
|
||||
v-model="obj.purchasedDate"
|
||||
:readonly="formState.readOnly"
|
||||
ref="purchasedDate"
|
||||
v-model="obj.purchasedDate"
|
||||
:label="$ay.t('UnitPurchasedDate')"
|
||||
:readonly="formState.readOnly"
|
||||
data-cy="purchasedDate"
|
||||
:error-messages="form().serverErrors(this, 'purchasedDate')"
|
||||
@input="fieldValueChanged('purchasedDate')"
|
||||
@@ -280,10 +280,10 @@
|
||||
xl="3"
|
||||
>
|
||||
<v-text-field
|
||||
ref="receipt"
|
||||
v-model="obj.receipt"
|
||||
:readonly="formState.readOnly"
|
||||
:label="$ay.t('UnitReceipt')"
|
||||
ref="receipt"
|
||||
data-cy="receipt"
|
||||
:error-messages="form().serverErrors(this, 'receipt')"
|
||||
@input="fieldValueChanged('receipt')"
|
||||
@@ -298,11 +298,11 @@
|
||||
xl="3"
|
||||
>
|
||||
<v-text-field
|
||||
ref="text1"
|
||||
v-model="obj.text1"
|
||||
:readonly="formState.readOnly"
|
||||
:label="$ay.t('UnitText1')"
|
||||
:error-messages="form().serverErrors(this, 'text1')"
|
||||
ref="text1"
|
||||
data-cy="text1"
|
||||
@input="fieldValueChanged('text1')"
|
||||
></v-text-field>
|
||||
@@ -316,11 +316,11 @@
|
||||
xl="3"
|
||||
>
|
||||
<v-text-field
|
||||
ref="text2"
|
||||
v-model="obj.text2"
|
||||
:readonly="formState.readOnly"
|
||||
:label="$ay.t('UnitText2')"
|
||||
:error-messages="form().serverErrors(this, 'text2')"
|
||||
ref="text2"
|
||||
data-cy="text2"
|
||||
@input="fieldValueChanged('text2')"
|
||||
></v-text-field>
|
||||
@@ -334,11 +334,11 @@
|
||||
xl="3"
|
||||
>
|
||||
<v-text-field
|
||||
ref="text3"
|
||||
v-model="obj.text3"
|
||||
:readonly="formState.readOnly"
|
||||
:label="$ay.t('UnitText3')"
|
||||
:error-messages="form().serverErrors(this, 'text3')"
|
||||
ref="text3"
|
||||
data-cy="text3"
|
||||
@input="fieldValueChanged('text3')"
|
||||
></v-text-field>
|
||||
@@ -352,21 +352,21 @@
|
||||
xl="3"
|
||||
>
|
||||
<v-text-field
|
||||
ref="text4"
|
||||
v-model="obj.text4"
|
||||
:readonly="formState.readOnly"
|
||||
:label="$ay.t('UnitText4')"
|
||||
:error-messages="form().serverErrors(this, 'text4')"
|
||||
ref="text4"
|
||||
data-cy="text4"
|
||||
@input="fieldValueChanged('text4')"
|
||||
></v-text-field>
|
||||
</v-col>
|
||||
<v-col cols="12" sm="6" lg="4" xl="3">
|
||||
<v-checkbox
|
||||
ref="active"
|
||||
v-model="obj.active"
|
||||
:readonly="formState.readOnly"
|
||||
:label="$ay.t('Active')"
|
||||
ref="active"
|
||||
data-cy="active"
|
||||
:error-messages="form().serverErrors(this, 'active')"
|
||||
@change="fieldValueChanged('active')"
|
||||
@@ -375,22 +375,22 @@
|
||||
<!-- --------------------------------- -->
|
||||
<v-col v-if="form().showMe(this, 'Notes')" cols="12">
|
||||
<v-textarea
|
||||
ref="notes"
|
||||
v-model="obj.notes"
|
||||
:readonly="formState.readOnly"
|
||||
:label="$ay.t('UnitNotes')"
|
||||
:error-messages="form().serverErrors(this, 'notes')"
|
||||
ref="notes"
|
||||
data-cy="notes"
|
||||
@input="fieldValueChanged('notes')"
|
||||
auto-grow
|
||||
@input="fieldValueChanged('notes')"
|
||||
></v-textarea>
|
||||
</v-col>
|
||||
|
||||
<v-col v-if="form().showMe(this, 'Tags')" cols="12">
|
||||
<gz-tag-picker
|
||||
ref="tags"
|
||||
v-model="obj.tags"
|
||||
:readonly="formState.readOnly"
|
||||
ref="tags"
|
||||
data-cy="tags"
|
||||
:error-messages="form().serverErrors(this, 'tags')"
|
||||
@input="fieldValueChanged('tags')"
|
||||
@@ -399,11 +399,11 @@
|
||||
|
||||
<v-col cols="12">
|
||||
<gz-custom-fields
|
||||
ref="customFields"
|
||||
v-model="obj.customFields"
|
||||
:form-key="formCustomTemplateKey"
|
||||
:readonly="formState.readOnly"
|
||||
:parent-v-m="this"
|
||||
ref="customFields"
|
||||
data-cy="customFields"
|
||||
:error-messages="form().serverErrors(this, 'customFields')"
|
||||
@input="fieldValueChanged('customFields')"
|
||||
@@ -412,10 +412,10 @@
|
||||
|
||||
<v-col v-if="form().showMe(this, 'Wiki')" cols="12">
|
||||
<gz-wiki
|
||||
:aya-type="ayaType"
|
||||
:aya-id="obj.id"
|
||||
ref="wiki"
|
||||
v-model="obj.wiki"
|
||||
:aya-type="ayaType"
|
||||
:aya-id="obj.id"
|
||||
:readonly="formState.readOnly"
|
||||
@input="fieldValueChanged('wiki')"
|
||||
></gz-wiki
|
||||
@@ -442,18 +442,18 @@
|
||||
<v-row>
|
||||
<v-col cols="12">
|
||||
<v-checkbox
|
||||
ref="unitHasOwnAddress"
|
||||
v-model="obj.unitHasOwnAddress"
|
||||
:readonly="formState.readOnly"
|
||||
:label="$ay.t('UnitUnitHasOwnAddress')"
|
||||
ref="unitHasOwnAddress"
|
||||
data-cy="unitHasOwnAddress"
|
||||
:error-messages="
|
||||
form().serverErrors(this, 'unitHasOwnAddress')
|
||||
"
|
||||
@change="fieldValueChanged('unitHasOwnAddress')"
|
||||
></v-checkbox>
|
||||
<v-col cols="12" v-if="obj.unitHasOwnAddress">
|
||||
<v-menu offset-y v-if="rights.change">
|
||||
<v-col v-if="obj.unitHasOwnAddress" cols="12">
|
||||
<v-menu v-if="rights.change" offset-y>
|
||||
<template v-slot:activator="{ on, attrs }">
|
||||
<span class="text-h6">
|
||||
{{ $ay.t("AddressTypePhysical") }}</span
|
||||
@@ -481,7 +481,7 @@
|
||||
</v-list-item>
|
||||
</v-list>
|
||||
</v-menu>
|
||||
<span class="text-h6" v-else>
|
||||
<span v-else class="text-h6">
|
||||
{{ $ay.t("AddressTypePhysical") }}</span
|
||||
>
|
||||
</v-col>
|
||||
@@ -494,10 +494,10 @@
|
||||
xl="3"
|
||||
>
|
||||
<v-text-field
|
||||
ref="address"
|
||||
v-model="obj.address"
|
||||
:readonly="formState.readOnly"
|
||||
:label="$ay.t('AddressDeliveryAddress')"
|
||||
ref="address"
|
||||
data-cy="address"
|
||||
:error-messages="form().serverErrors(this, 'address')"
|
||||
@input="fieldValueChanged('address')"
|
||||
@@ -512,10 +512,10 @@
|
||||
xl="3"
|
||||
>
|
||||
<v-text-field
|
||||
ref="city"
|
||||
v-model="obj.city"
|
||||
:readonly="formState.readOnly"
|
||||
:label="$ay.t('AddressCity')"
|
||||
ref="city"
|
||||
data-cy="city"
|
||||
:error-messages="form().serverErrors(this, 'city')"
|
||||
@input="fieldValueChanged('city')"
|
||||
@@ -530,10 +530,10 @@
|
||||
xl="3"
|
||||
>
|
||||
<v-text-field
|
||||
ref="region"
|
||||
v-model="obj.region"
|
||||
:readonly="formState.readOnly"
|
||||
:label="$ay.t('AddressStateProv')"
|
||||
ref="region"
|
||||
data-cy="region"
|
||||
:error-messages="form().serverErrors(this, 'region')"
|
||||
@input="fieldValueChanged('region')"
|
||||
@@ -548,10 +548,10 @@
|
||||
xl="3"
|
||||
>
|
||||
<v-text-field
|
||||
ref="country"
|
||||
v-model="obj.country"
|
||||
:readonly="formState.readOnly"
|
||||
:label="$ay.t('AddressCountry')"
|
||||
ref="country"
|
||||
data-cy="country"
|
||||
:error-messages="form().serverErrors(this, 'country')"
|
||||
@input="fieldValueChanged('country')"
|
||||
@@ -566,15 +566,15 @@
|
||||
xl="3"
|
||||
>
|
||||
<gz-decimal
|
||||
ref="latitude"
|
||||
v-model="obj.latitude"
|
||||
:readonly="formState.readOnly"
|
||||
:label="$ay.t('AddressLatitude')"
|
||||
ref="latitude"
|
||||
data-cy="latitude"
|
||||
:rules="[form().decimalValid(this, 'latitude')]"
|
||||
:error-messages="form().serverErrors(this, 'latitude')"
|
||||
@input="fieldValueChanged('latitude')"
|
||||
:precision="6"
|
||||
@input="fieldValueChanged('latitude')"
|
||||
></gz-decimal>
|
||||
</v-col>
|
||||
|
||||
@@ -586,15 +586,15 @@
|
||||
xl="3"
|
||||
>
|
||||
<gz-decimal
|
||||
ref="longitude"
|
||||
v-model="obj.longitude"
|
||||
:readonly="formState.readOnly"
|
||||
:label="$ay.t('AddressLongitude')"
|
||||
ref="longitude"
|
||||
data-cy="longitude"
|
||||
:rules="[form().decimalValid(this, 'longitude')]"
|
||||
:error-messages="form().serverErrors(this, 'longitude')"
|
||||
@input="fieldValueChanged('longitude')"
|
||||
:precision="6"
|
||||
@input="fieldValueChanged('longitude')"
|
||||
></gz-decimal>
|
||||
</v-col>
|
||||
</v-row>
|
||||
@@ -608,10 +608,10 @@
|
||||
<v-row>
|
||||
<v-col cols="12" sm="6" lg="4" xl="3">
|
||||
<v-checkbox
|
||||
ref="overrideModelWarranty"
|
||||
v-model="obj.overrideModelWarranty"
|
||||
:readonly="formState.readOnly"
|
||||
:label="$ay.t('UnitOverrideWarranty')"
|
||||
ref="overrideModelWarranty"
|
||||
data-cy="overrideModelWarranty"
|
||||
:error-messages="
|
||||
form().serverErrors(this, 'overrideModelWarranty')
|
||||
@@ -631,10 +631,10 @@
|
||||
xl="3"
|
||||
>
|
||||
<v-checkbox
|
||||
ref="lifeTimeWarranty"
|
||||
v-model="obj.lifeTimeWarranty"
|
||||
:readonly="formState.readOnly"
|
||||
:label="$ay.t('UnitOverrideLifeTime')"
|
||||
ref="lifeTimeWarranty"
|
||||
data-cy="lifeTimeWarranty"
|
||||
:error-messages="
|
||||
form().serverErrors(this, 'lifeTimeWarranty')
|
||||
@@ -655,17 +655,17 @@
|
||||
xl="3"
|
||||
>
|
||||
<v-text-field
|
||||
ref="warrantyLength"
|
||||
v-model="obj.warrantyLength"
|
||||
:readonly="formState.readOnly"
|
||||
:label="$ay.t('UnitOverrideLength')"
|
||||
ref="warrantyLength"
|
||||
data-cy="warrantyLength"
|
||||
:rules="[form().integerValid(this, 'warrantyLength')]"
|
||||
:error-messages="
|
||||
form().serverErrors(this, 'warrantyLength')
|
||||
"
|
||||
@input="fieldValueChanged('warrantyLength')"
|
||||
type="number"
|
||||
@input="fieldValueChanged('warrantyLength')"
|
||||
></v-text-field>
|
||||
</v-col>
|
||||
|
||||
@@ -677,14 +677,14 @@
|
||||
cols="12"
|
||||
>
|
||||
<v-textarea
|
||||
ref="warrantyTerms"
|
||||
v-model="obj.warrantyTerms"
|
||||
:readonly="formState.readOnly"
|
||||
:label="$ay.t('UnitOverrideWarrantyTerms')"
|
||||
:error-messages="form().serverErrors(this, 'warrantyTerms')"
|
||||
ref="warrantyTerms"
|
||||
data-cy="warrantyTerms"
|
||||
@input="fieldValueChanged('warrantyTerms')"
|
||||
auto-grow
|
||||
@input="fieldValueChanged('warrantyTerms')"
|
||||
></v-textarea>
|
||||
</v-col>
|
||||
</v-row>
|
||||
@@ -703,6 +703,92 @@ const FORM_KEY = "unit-edit";
|
||||
const API_BASE_URL = "unit/";
|
||||
const FORM_CUSTOM_TEMPLATE_KEY = "Unit";
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
formCustomTemplateKey: FORM_CUSTOM_TEMPLATE_KEY,
|
||||
obj: {
|
||||
id: 0,
|
||||
concurrency: 0,
|
||||
serial: null,
|
||||
active: true,
|
||||
notes: null,
|
||||
wiki: null,
|
||||
customFields: "{}",
|
||||
tags: [],
|
||||
customerId: null,
|
||||
parentUnitId: null,
|
||||
unitModelId: null,
|
||||
unitHasOwnAddress: false,
|
||||
boughtHere: false,
|
||||
purchasedFromVendorId: null,
|
||||
receipt: null,
|
||||
purchasedDate: null,
|
||||
description: null,
|
||||
replacedByUnitId: null,
|
||||
overrideModelWarranty: false,
|
||||
warrantyLength: null,
|
||||
warrantyTerms: null,
|
||||
//usesBanking: false,
|
||||
contractId: null,
|
||||
contractExpires: null,
|
||||
metered: false,
|
||||
lifeTimeWarranty: false,
|
||||
text1: null,
|
||||
text2: null,
|
||||
text3: null,
|
||||
text4: null,
|
||||
address: null,
|
||||
city: null,
|
||||
region: null,
|
||||
country: null,
|
||||
latitude: null,
|
||||
longitude: null
|
||||
},
|
||||
tab: 0,
|
||||
formState: {
|
||||
ready: false,
|
||||
dirty: false,
|
||||
valid: true,
|
||||
readOnly: false,
|
||||
loading: true,
|
||||
errorBoxMessage: null,
|
||||
appError: null,
|
||||
serverError: {}
|
||||
},
|
||||
rights: window.$gz.role.defaultRightsObject(),
|
||||
ayaType: window.$gz.type.Unit
|
||||
};
|
||||
},
|
||||
watch: {
|
||||
formState: {
|
||||
handler: function(val) {
|
||||
if (this.formState.loading) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (val.dirty && val.valid && !val.readOnly) {
|
||||
window.$gz.eventBus.$emit("menu-enable-item", FORM_KEY + ":save");
|
||||
} else {
|
||||
window.$gz.eventBus.$emit("menu-disable-item", FORM_KEY + ":save");
|
||||
}
|
||||
|
||||
if (!val.dirty && val.valid && !val.readOnly) {
|
||||
window.$gz.eventBus.$emit(
|
||||
"menu-enable-item",
|
||||
FORM_KEY + ":duplicate"
|
||||
);
|
||||
window.$gz.eventBus.$emit("menu-enable-item", FORM_KEY + ":new");
|
||||
} else {
|
||||
window.$gz.eventBus.$emit(
|
||||
"menu-disable-item",
|
||||
FORM_KEY + ":duplicate"
|
||||
);
|
||||
window.$gz.eventBus.$emit("menu-disable-item", FORM_KEY + ":new");
|
||||
}
|
||||
},
|
||||
deep: true
|
||||
}
|
||||
},
|
||||
async created() {
|
||||
const vm = this;
|
||||
try {
|
||||
@@ -803,92 +889,6 @@ export default {
|
||||
beforeDestroy() {
|
||||
window.$gz.eventBus.$off("menu-click", clickHandler);
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
formCustomTemplateKey: FORM_CUSTOM_TEMPLATE_KEY,
|
||||
obj: {
|
||||
id: 0,
|
||||
concurrency: 0,
|
||||
serial: null,
|
||||
active: true,
|
||||
notes: null,
|
||||
wiki: null,
|
||||
customFields: "{}",
|
||||
tags: [],
|
||||
customerId: null,
|
||||
parentUnitId: null,
|
||||
unitModelId: null,
|
||||
unitHasOwnAddress: false,
|
||||
boughtHere: false,
|
||||
purchasedFromVendorId: null,
|
||||
receipt: null,
|
||||
purchasedDate: null,
|
||||
description: null,
|
||||
replacedByUnitId: null,
|
||||
overrideModelWarranty: false,
|
||||
warrantyLength: null,
|
||||
warrantyTerms: null,
|
||||
//usesBanking: false,
|
||||
contractId: null,
|
||||
contractExpires: null,
|
||||
metered: false,
|
||||
lifeTimeWarranty: false,
|
||||
text1: null,
|
||||
text2: null,
|
||||
text3: null,
|
||||
text4: null,
|
||||
address: null,
|
||||
city: null,
|
||||
region: null,
|
||||
country: null,
|
||||
latitude: null,
|
||||
longitude: null
|
||||
},
|
||||
tab: 0,
|
||||
formState: {
|
||||
ready: false,
|
||||
dirty: false,
|
||||
valid: true,
|
||||
readOnly: false,
|
||||
loading: true,
|
||||
errorBoxMessage: null,
|
||||
appError: null,
|
||||
serverError: {}
|
||||
},
|
||||
rights: window.$gz.role.defaultRightsObject(),
|
||||
ayaType: window.$gz.type.Unit
|
||||
};
|
||||
},
|
||||
watch: {
|
||||
formState: {
|
||||
handler: function(val) {
|
||||
if (this.formState.loading) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (val.dirty && val.valid && !val.readOnly) {
|
||||
window.$gz.eventBus.$emit("menu-enable-item", FORM_KEY + ":save");
|
||||
} else {
|
||||
window.$gz.eventBus.$emit("menu-disable-item", FORM_KEY + ":save");
|
||||
}
|
||||
|
||||
if (!val.dirty && val.valid && !val.readOnly) {
|
||||
window.$gz.eventBus.$emit(
|
||||
"menu-enable-item",
|
||||
FORM_KEY + ":duplicate"
|
||||
);
|
||||
window.$gz.eventBus.$emit("menu-enable-item", FORM_KEY + ":new");
|
||||
} else {
|
||||
window.$gz.eventBus.$emit(
|
||||
"menu-disable-item",
|
||||
FORM_KEY + ":duplicate"
|
||||
);
|
||||
window.$gz.eventBus.$emit("menu-disable-item", FORM_KEY + ":new");
|
||||
}
|
||||
},
|
||||
deep: true
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
// canOpenServiceBank: function() {
|
||||
// return this.obj.usesBanking == true && this.$route.params.recordid != 0;
|
||||
@@ -1132,17 +1132,19 @@ async function clickHandler(menuItem) {
|
||||
m.vm.duplicate();
|
||||
break;
|
||||
case "report":
|
||||
const res = await m.vm.$refs.reportSelector.open(
|
||||
{
|
||||
AType: window.$gz.type.Unit,
|
||||
selectedRowIds: [m.vm.obj.id]
|
||||
},
|
||||
m.id
|
||||
);
|
||||
if (res == null) {
|
||||
return;
|
||||
{
|
||||
const res = await m.vm.$refs.reportSelector.open(
|
||||
{
|
||||
AType: window.$gz.type.Unit,
|
||||
selectedRowIds: [m.vm.obj.id]
|
||||
},
|
||||
m.id
|
||||
);
|
||||
if (res == null) {
|
||||
return;
|
||||
}
|
||||
window.$gz.form.setLastReportMenuItem(FORM_KEY, res, m.vm);
|
||||
}
|
||||
window.$gz.form.setLastReportMenuItem(FORM_KEY, res, m.vm);
|
||||
break;
|
||||
case "geoview":
|
||||
window.$gz.util.viewGeoLocation({
|
||||
@@ -1317,7 +1319,7 @@ let JUST_DELETED = false;
|
||||
//
|
||||
//
|
||||
async function initForm(vm) {
|
||||
await fetchTranslatedText(vm);
|
||||
await fetchTranslatedText();
|
||||
await window.$gz.formCustomTemplate.get(FORM_CUSTOM_TEMPLATE_KEY, vm);
|
||||
}
|
||||
|
||||
@@ -1325,7 +1327,7 @@ async function initForm(vm) {
|
||||
//
|
||||
// Ensures UI translated text is available
|
||||
//
|
||||
async function fetchTranslatedText(vm) {
|
||||
async function fetchTranslatedText() {
|
||||
await window.$gz.translation.cacheTranslations([
|
||||
"Unit",
|
||||
"UnitSerial",
|
||||
|
||||
Reference in New Issue
Block a user