This commit is contained in:
2019-11-26 20:10:06 +00:00
parent dee340b9fa
commit 71d9a25687
2 changed files with 31 additions and 42 deletions

View File

@@ -1,4 +1,4 @@
/* eslint-disable */ /* Xeslint-disable */
/////////////////////////////// ///////////////////////////////
// gzform // gzform
// //
@@ -52,7 +52,6 @@ function getControl(vm, ref) {
var customFields = vm.$refs["customFields"]; var customFields = vm.$refs["customFields"];
if (customFields !== undefined) { if (customFields !== undefined) {
ctrl = customFields.$refs[ref]; ctrl = customFields.$refs[ref];
} }
} }
@@ -87,13 +86,11 @@ function getControlValue(ctrl) {
// Get field name from control // Get field name from control
// //
function getControlLabel(ctrl) { function getControlLabel(ctrl) {
if (ctrl.label == undefined) {
if(ctrl.label==undefined){
return "UNKNOWN CONTROL"; return "UNKNOWN CONTROL";
}else{ } else {
return ctrl.label; return ctrl.label;
} }
} }
///////////////////////////////////////// /////////////////////////////////////////
@@ -151,7 +148,6 @@ function getErrorBoxErrors(vm, errs) {
} }
export default { export default {
/////////////////////////////// ///////////////////////////////
// REQUIRED // REQUIRED
// //
@@ -350,25 +346,23 @@ export default {
// For now the only rule is that they can be required or not // For now the only rule is that they can be required or not
// //
customFieldsCheck(vm, templateItem, subvm, fieldName) { customFieldsCheck(vm, templateItem, subvm, fieldName) {
//templateItem sample
//templateItem sample // dataKey: "c2"
// dataKey: "c2" // fld: "WidgetCustom2"
// fld: "WidgetCustom2" // hide: "false"
// hide: "false" // required: "true"
// required: "true" // type: "text"
// type: "text"
if (vm.formState.loading) { if (vm.formState.loading) {
return false; return false;
} }
if (!templateItem.required) {
if(!templateItem.required){
return false; return false;
} }
var value=subvm.GetValueForField(templateItem.dataKey); var value = subvm.GetValueForField(templateItem.dataKey);
if(!isEmpty(value)){ if (!isEmpty(value)) {
return false; return false;
} }

View File

@@ -93,7 +93,7 @@
</template> </template>
<script> <script>
///////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////
/* eslint-disable */ /* xeslint-disable */
//////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////
/** /**
* v-if="item.hide == false" * v-if="item.hide == false"
@@ -173,7 +173,10 @@ export default {
return window.$gz.form; return window.$gz.form;
}, },
onChange(ref) { onChange(ref) {
if (!this.parentVM.formState.loading && !this.parentVM.formState.readOnly) { if (
!this.parentVM.formState.loading &&
!this.parentVM.formState.readOnly
) {
window.$gz.form.onChange(this.parentVM, ref); window.$gz.form.onChange(this.parentVM, ref);
} }
}, },
@@ -191,32 +194,24 @@ export default {
//coerce it to that type and return it //coerce it to that type and return it
//TODO: Method here //TODO: Method here
return cData[dataKey]; return cData[dataKey];
}, },
SetValueForField: function(dataKey, newValue) { SetValueForField: function(dataKey, newValue) {
//https://stackoverflow.com/questions/39868963/vue-2-mutating-props-vue-warn //https://stackoverflow.com/questions/39868963/vue-2-mutating-props-vue-warn
debugger; //debugger;
//Is this a new or empty custom fields object?
if (this.value === null || this.value === undefined) {
//Ok, could end up here with no value set yet at all for the entire custom fields control as it's a new record or something so... this.value = "{}"; //empty json fragment, field will be added later below
//what are valid values for custom fields on a new record, completely empty? }
// if(this.value=== null || this.value===undefined){
// this.value="{\"" + dataKey+"\":null}";
// }
if(this.value=== null || this.value===undefined){
this.value="{}";//empty json fragment
}
//Get the data out of the json string value //Get the data out of the json string value
// //
var cData = JSON.parse(this.value); var cData = JSON.parse(this.value);
if (!window.$gz._.has(cData, dataKey)) { if (!window.$gz._.has(cData, dataKey)) {
cData[dataKey]=null; cData[dataKey] = null;
} }
//handle null or undefined //handle null or undefined
if (newValue === null || newValue === undefined) { if (newValue === null || newValue === undefined) {
@@ -234,7 +229,7 @@ if (!window.$gz._.has(cData, dataKey)) {
this.$emit("update:value", ret); this.$emit("update:value", ret);
//this triggers the onchange routine in the parent form //this triggers the onchange routine in the parent form
//mainly for custom fields purposes so that the dirty checking works //mainly for custom fields purposes so that the dirty checking works
this.$emit("change",ret); this.$emit("change", ret);
} }
}, },
beforeCreate() { beforeCreate() {