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
//
@@ -52,7 +52,6 @@ function getControl(vm, ref) {
var customFields = vm.$refs["customFields"];
if (customFields !== undefined) {
ctrl = customFields.$refs[ref];
}
}
@@ -76,7 +75,7 @@ function getControlValue(ctrl) {
// debugger;
// if(ctrl._props){
// var subvalue=ctrl._props;
// }
// }
return value;
@@ -87,13 +86,11 @@ function getControlValue(ctrl) {
// Get field name from control
//
function getControlLabel(ctrl) {
if(ctrl.label==undefined){
if (ctrl.label == undefined) {
return "UNKNOWN CONTROL";
}else{
} else {
return ctrl.label;
}
}
/////////////////////////////////////////
@@ -151,7 +148,6 @@ function getErrorBoxErrors(vm, errs) {
}
export default {
///////////////////////////////
// REQUIRED
//
@@ -159,7 +155,7 @@ export default {
if (vm.formState.loading) {
return false;
}
var ctrl = getControl(vm, ref);
if (typeof ctrl == "undefined") {
return false;
@@ -169,7 +165,7 @@ export default {
if (!isEmpty(value)) {
return false;
}
// "ErrorRequiredFieldEmpty": "{0} is a required field. Please enter a value for {0}",
var err = window.$gz.locale.get("ErrorRequiredFieldEmpty");
var fieldName = getControlLabel(ctrl);
@@ -344,31 +340,29 @@ export default {
valid: false
});
return err;
},
},
///////////////////////////////
// CUSTOMFIELDS
// For now the only rule is that they can be required or not
//
customFieldsCheck(vm, templateItem, subvm, fieldName) {
//templateItem sample
// dataKey: "c2"
// fld: "WidgetCustom2"
// hide: "false"
// required: "true"
// type: "text"
//templateItem sample
// dataKey: "c2"
// fld: "WidgetCustom2"
// hide: "false"
// required: "true"
// type: "text"
if (vm.formState.loading) {
return false;
}
if(!templateItem.required){
if (!templateItem.required) {
return false;
}
var value=subvm.GetValueForField(templateItem.dataKey);
if(!isEmpty(value)){
var value = subvm.GetValueForField(templateItem.dataKey);
if (!isEmpty(value)) {
return false;
}

View File

@@ -93,7 +93,7 @@
</template>
<script>
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
/* eslint-disable */
/* xeslint-disable */
////////////////////////////////////////////////////////////////////////////////////////////////////////////
/**
* v-if="item.hide == false"
@@ -173,7 +173,10 @@ export default {
return window.$gz.form;
},
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);
}
},
@@ -191,37 +194,29 @@ export default {
//coerce it to that type and return it
//TODO: Method here
return cData[dataKey];
},
SetValueForField: function(dataKey, newValue) {
//https://stackoverflow.com/questions/39868963/vue-2-mutating-props-vue-warn
debugger;
//debugger;
//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...
//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
}
//Is this a new or empty custom fields object?
if (this.value === null || this.value === undefined) {
this.value = "{}"; //empty json fragment, field will be added later below
}
//Get the data out of the json string value
//
var cData = JSON.parse(this.value);
if (!window.$gz._.has(cData, dataKey)) {
cData[dataKey]=null;
}
if (!window.$gz._.has(cData, dataKey)) {
cData[dataKey] = null;
}
//handle null or undefined
if (newValue === null || newValue === undefined) {
cData[dataKey] = null;
} else {
} else {
//then set item in the cData
//TODO: This will likely need also to be converted because dates and stuff
@@ -234,7 +229,7 @@ if (!window.$gz._.has(cData, dataKey)) {
this.$emit("update:value", ret);
//this triggers the onchange routine in the parent form
//mainly for custom fields purposes so that the dirty checking works
this.$emit("change",ret);
this.$emit("change", ret);
}
},
beforeCreate() {