This commit is contained in:
@@ -1,20 +1,15 @@
|
|||||||
<template>
|
<template>
|
||||||
<div v-if="templateHasVisibleCustomFields()">
|
<!-- <div v-if="templateHasVisibleCustomFields()"> -->
|
||||||
|
<div v-if="availableCustomFields.length !== 0">
|
||||||
<span class="text-caption">
|
<span class="text-caption">
|
||||||
{{ $ay.t("ObjectCustomFieldCustomGrid") }}
|
{{ $ay.t("ObjectCustomFieldCustomGrid") }}
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<v-row align-center justify-left row wrap>
|
<v-row align-center justify-left row wrap>
|
||||||
<template v-for="item in this.$store.state.formCustomTemplate[formKey]">
|
<!-- <template v-for="item in this.$store.state.formCustomTemplate[formKey]"> -->
|
||||||
<v-col
|
<template v-for="item in availableCustomFields">
|
||||||
v-if="item.type"
|
<v-col :key="item.fld" cols="12" sm="6" lg="4" xl="3" px-2>
|
||||||
:key="item.fld"
|
|
||||||
cols="12"
|
|
||||||
sm="6"
|
|
||||||
lg="4"
|
|
||||||
xl="3"
|
|
||||||
px-2
|
|
||||||
>
|
|
||||||
<!-- DATETIME -->
|
<!-- DATETIME -->
|
||||||
<div v-if="item.type === 1">
|
<div v-if="item.type === 1">
|
||||||
<gz-date-time-picker
|
<gz-date-time-picker
|
||||||
@@ -209,6 +204,7 @@ export default {
|
|||||||
type: String
|
type: String
|
||||||
},
|
},
|
||||||
formKey: { type: String, default: "" }, //used to grab template from store
|
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,
|
readonly: Boolean,
|
||||||
disabled: Boolean,
|
disabled: Boolean,
|
||||||
parentVM: {
|
parentVM: {
|
||||||
@@ -230,16 +226,20 @@ export default {
|
|||||||
window.$gz.form.fieldValueChanged(this.parentVM, ref);
|
window.$gz.form.fieldValueChanged(this.parentVM, ref);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
templateHasVisibleCustomFields() {
|
// templateHasVisibleCustomFields() {
|
||||||
let template = this.$store.state.formCustomTemplate[this.formKey];
|
// let template = this.$store.state.formCustomTemplate[this.formKey];
|
||||||
if (template == undefined) {
|
// console.log(
|
||||||
return false;
|
// "custom-fields-control templateHasVisibleCustomFields template=",
|
||||||
}
|
// template
|
||||||
//iterate template and see if it has any custom fields set to display
|
// );
|
||||||
//de-lodash
|
// if (template == undefined) {
|
||||||
//return window.$gz. _.find(template, "type") != undefined;
|
// return false;
|
||||||
return template.find(z => z.type != undefined);
|
// }
|
||||||
},
|
// //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) {
|
GetValueForField: function(dataKey) {
|
||||||
let cData = {};
|
let cData = {};
|
||||||
//get the data out of the JSON string value
|
//get the data out of the JSON string value
|
||||||
@@ -358,6 +358,25 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
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: {
|
c1: {
|
||||||
get: function() {
|
get: function() {
|
||||||
return this.GetValueForField("c1");
|
return this.GetValueForField("c1");
|
||||||
|
|||||||
@@ -240,6 +240,7 @@
|
|||||||
:form-key="formCustomTemplateKey"
|
:form-key="formCustomTemplateKey"
|
||||||
:readonly="formState.readOnly"
|
:readonly="formState.readOnly"
|
||||||
:parent-v-m="this"
|
:parent-v-m="this"
|
||||||
|
key-start-with="WorkOrderCustom"
|
||||||
ref="customFields"
|
ref="customFields"
|
||||||
data-cy="customFields"
|
data-cy="customFields"
|
||||||
:error-messages="form().serverErrors(this, 'customFields')"
|
:error-messages="form().serverErrors(this, 'customFields')"
|
||||||
|
|||||||
@@ -313,6 +313,7 @@
|
|||||||
:form-key="formCustomTemplateKey"
|
:form-key="formCustomTemplateKey"
|
||||||
:readonly="formState.readOnly"
|
:readonly="formState.readOnly"
|
||||||
:parent-v-m="this"
|
:parent-v-m="this"
|
||||||
|
key-start-with="WorkOrderItemCustom"
|
||||||
ref="customFields"
|
ref="customFields"
|
||||||
data-cy="customFields"
|
data-cy="customFields"
|
||||||
:error-messages="
|
:error-messages="
|
||||||
|
|||||||
Reference in New Issue
Block a user