This commit is contained in:
@@ -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];
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -76,7 +75,7 @@ function getControlValue(ctrl) {
|
|||||||
// debugger;
|
// debugger;
|
||||||
// if(ctrl._props){
|
// if(ctrl._props){
|
||||||
// var subvalue=ctrl._props;
|
// var subvalue=ctrl._props;
|
||||||
|
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
return value;
|
return value;
|
||||||
@@ -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
|
||||||
//
|
//
|
||||||
@@ -159,7 +155,7 @@ export default {
|
|||||||
if (vm.formState.loading) {
|
if (vm.formState.loading) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
var ctrl = getControl(vm, ref);
|
var ctrl = getControl(vm, ref);
|
||||||
if (typeof ctrl == "undefined") {
|
if (typeof ctrl == "undefined") {
|
||||||
return false;
|
return false;
|
||||||
@@ -169,7 +165,7 @@ export default {
|
|||||||
if (!isEmpty(value)) {
|
if (!isEmpty(value)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// "ErrorRequiredFieldEmpty": "{0} is a required field. Please enter a value for {0}",
|
// "ErrorRequiredFieldEmpty": "{0} is a required field. Please enter a value for {0}",
|
||||||
var err = window.$gz.locale.get("ErrorRequiredFieldEmpty");
|
var err = window.$gz.locale.get("ErrorRequiredFieldEmpty");
|
||||||
var fieldName = getControlLabel(ctrl);
|
var fieldName = getControlLabel(ctrl);
|
||||||
@@ -344,31 +340,29 @@ export default {
|
|||||||
valid: false
|
valid: false
|
||||||
});
|
});
|
||||||
return err;
|
return err;
|
||||||
},
|
},
|
||||||
///////////////////////////////
|
///////////////////////////////
|
||||||
// CUSTOMFIELDS
|
// CUSTOMFIELDS
|
||||||
// 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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,37 +194,29 @@ 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) {
|
||||||
cData[dataKey] = null;
|
cData[dataKey] = null;
|
||||||
} else {
|
} else {
|
||||||
//then set item in the cData
|
//then set item in the cData
|
||||||
|
|
||||||
//TODO: This will likely need also to be converted because dates and stuff
|
//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.$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() {
|
||||||
|
|||||||
Reference in New Issue
Block a user