re-factor / cleanup
This commit is contained in:
@@ -7,23 +7,23 @@
|
||||
<v-row>
|
||||
<v-col cols="12">
|
||||
<gz-pick-list
|
||||
readonly
|
||||
ref="selectedPartId"
|
||||
v-model="selectedPartId"
|
||||
readonly
|
||||
:aya-type="ayaTypes().Part"
|
||||
show-edit-icon
|
||||
:label="$ay.t('Part')"
|
||||
ref="selectedPartId"
|
||||
data-cy="selectedPartId"
|
||||
></gz-pick-list>
|
||||
</v-col>
|
||||
<v-col cols="12" sm="6" v-if="!formState.readOnly">
|
||||
<v-col v-if="!formState.readOnly" cols="12" sm="6">
|
||||
<v-textarea
|
||||
outlined
|
||||
ref="newSerial"
|
||||
v-model="newSerial"
|
||||
outlined
|
||||
:label="$ay.t('Add')"
|
||||
clearable
|
||||
:rows="$vuetify.breakpoint.xs ? 3 : 10"
|
||||
ref="newSerial"
|
||||
data-cy="newSerial"
|
||||
append-outer-icon="$ayiPlus"
|
||||
@click:append-outer="addItem()"
|
||||
@@ -66,6 +66,44 @@
|
||||
const FORM_KEY = "inv-part-serials";
|
||||
const FORM_CUSTOM_TEMPLATE_KEY = "inv-part-serials";
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
formCustomTemplateKey: FORM_CUSTOM_TEMPLATE_KEY,
|
||||
obj: {
|
||||
id: 0,
|
||||
name: null
|
||||
},
|
||||
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.Part,
|
||||
selectedPartId: Number(this.$route.params.recordid),
|
||||
newSerial: null
|
||||
};
|
||||
},
|
||||
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");
|
||||
}
|
||||
},
|
||||
deep: true
|
||||
}
|
||||
},
|
||||
async created() {
|
||||
const vm = this;
|
||||
try {
|
||||
@@ -105,44 +143,6 @@ export default {
|
||||
beforeDestroy() {
|
||||
window.$gz.eventBus.$off("menu-click", clickHandler);
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
formCustomTemplateKey: FORM_CUSTOM_TEMPLATE_KEY,
|
||||
obj: {
|
||||
id: 0,
|
||||
name: null
|
||||
},
|
||||
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.Part,
|
||||
selectedPartId: Number(this.$route.params.recordid),
|
||||
newSerial: null
|
||||
};
|
||||
},
|
||||
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");
|
||||
}
|
||||
},
|
||||
deep: true
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
sortedList: function() {
|
||||
if (this.obj == null || this.obj.length == 0) {
|
||||
@@ -305,15 +305,15 @@ let JUST_DELETED = false;
|
||||
/////////////////////////////////
|
||||
//
|
||||
//
|
||||
async function initForm(vm) {
|
||||
await fetchTranslatedText(vm);
|
||||
async function initForm() {
|
||||
await fetchTranslatedText();
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////
|
||||
//
|
||||
// Ensures UI translated text is available
|
||||
//
|
||||
async function fetchTranslatedText(vm) {
|
||||
async function fetchTranslatedText() {
|
||||
await window.$gz.translation.cacheTranslations([
|
||||
"PartSerialNumbersAvailable"
|
||||
]);
|
||||
|
||||
Reference in New Issue
Block a user