This commit is contained in:
@@ -1,20 +1,15 @@
|
||||
<template>
|
||||
<div v-if="templateHasVisibleCustomFields()">
|
||||
<!-- <div v-if="templateHasVisibleCustomFields()"> -->
|
||||
<div v-if="availableCustomFields.length !== 0">
|
||||
<span class="text-caption">
|
||||
{{ $ay.t("ObjectCustomFieldCustomGrid") }}
|
||||
</span>
|
||||
|
||||
<div>
|
||||
<v-row align-center justify-left row wrap>
|
||||
<template v-for="item in this.$store.state.formCustomTemplate[formKey]">
|
||||
<v-col
|
||||
v-if="item.type"
|
||||
:key="item.fld"
|
||||
cols="12"
|
||||
sm="6"
|
||||
lg="4"
|
||||
xl="3"
|
||||
px-2
|
||||
>
|
||||
<!-- <template v-for="item in this.$store.state.formCustomTemplate[formKey]"> -->
|
||||
<template v-for="item in availableCustomFields">
|
||||
<v-col :key="item.fld" cols="12" sm="6" lg="4" xl="3" px-2>
|
||||
<!-- DATETIME -->
|
||||
<div v-if="item.type === 1">
|
||||
<gz-date-time-picker
|
||||
@@ -209,6 +204,7 @@ export default {
|
||||
type: String
|
||||
},
|
||||
formKey: { type: String, default: "" }, //used to grab template from store
|
||||
keyStartWith: { type: String, default: "" }, //prefix of key names used to differentiate when more than one custom fields collection on same form (i.e. workorder, workorderitem, workoritemunit etc)
|
||||
readonly: Boolean,
|
||||
disabled: Boolean,
|
||||
parentVM: {
|
||||
@@ -230,16 +226,20 @@ export default {
|
||||
window.$gz.form.fieldValueChanged(this.parentVM, ref);
|
||||
}
|
||||
},
|
||||
templateHasVisibleCustomFields() {
|
||||
let template = this.$store.state.formCustomTemplate[this.formKey];
|
||||
if (template == undefined) {
|
||||
return false;
|
||||
}
|
||||
//iterate template and see if it has any custom fields set to display
|
||||
//de-lodash
|
||||
//return window.$gz. _.find(template, "type") != undefined;
|
||||
return template.find(z => z.type != undefined);
|
||||
},
|
||||
// templateHasVisibleCustomFields() {
|
||||
// let template = this.$store.state.formCustomTemplate[this.formKey];
|
||||
// console.log(
|
||||
// "custom-fields-control templateHasVisibleCustomFields template=",
|
||||
// template
|
||||
// );
|
||||
// if (template == undefined) {
|
||||
// return false;
|
||||
// }
|
||||
// //iterate template and see if it has any custom fields set to display
|
||||
// //de-lodash
|
||||
// //return window.$gz. _.find(template, "type") != undefined;
|
||||
// return template.find(z => z.type != undefined);
|
||||
// },
|
||||
GetValueForField: function(dataKey) {
|
||||
let cData = {};
|
||||
//get the data out of the JSON string value
|
||||
@@ -358,6 +358,25 @@ export default {
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
availableCustomFields() {
|
||||
//item.type only exists for custom fields so they are the ones to return
|
||||
//In addition if there is a keyStartWith then there are multiple custom field controls on same form so that's a different route to take
|
||||
let template = this.$store.state.formCustomTemplate[this.formKey];
|
||||
// debugger;
|
||||
|
||||
if (template != undefined) {
|
||||
if (this.keyStartWith != "") {
|
||||
return template.filter(
|
||||
z => z.type != undefined && z.fld.includes(this.keyStartWith)
|
||||
);
|
||||
} else {
|
||||
//single custom control form, just return the fields
|
||||
return template.filter(z => z.type != undefined);
|
||||
}
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
},
|
||||
c1: {
|
||||
get: function() {
|
||||
return this.GetValueForField("c1");
|
||||
|
||||
@@ -240,6 +240,7 @@
|
||||
:form-key="formCustomTemplateKey"
|
||||
:readonly="formState.readOnly"
|
||||
:parent-v-m="this"
|
||||
key-start-with="WorkOrderCustom"
|
||||
ref="customFields"
|
||||
data-cy="customFields"
|
||||
:error-messages="form().serverErrors(this, 'customFields')"
|
||||
|
||||
@@ -313,6 +313,7 @@
|
||||
:form-key="formCustomTemplateKey"
|
||||
:readonly="formState.readOnly"
|
||||
:parent-v-m="this"
|
||||
key-start-with="WorkOrderItemCustom"
|
||||
ref="customFields"
|
||||
data-cy="customFields"
|
||||
:error-messages="
|
||||
|
||||
Reference in New Issue
Block a user