This commit is contained in:
@@ -150,6 +150,76 @@ export default {
|
|||||||
readOnly: Boolean,
|
readOnly: Boolean,
|
||||||
parentVM: Object
|
parentVM: Object
|
||||||
},
|
},
|
||||||
|
|
||||||
|
methods: {
|
||||||
|
lt: function(ltkey) {
|
||||||
|
return window.$gz.locale.get(ltkey);
|
||||||
|
},
|
||||||
|
ltFormat() {
|
||||||
|
return window.$gz.locale.format();
|
||||||
|
},
|
||||||
|
form() {
|
||||||
|
//nothing
|
||||||
|
return window.$gz.form;
|
||||||
|
},
|
||||||
|
onChange(ref) {
|
||||||
|
if (
|
||||||
|
!this.parentVM.formState.loading &&
|
||||||
|
!this.parentVM.formState.readOnly
|
||||||
|
) {
|
||||||
|
window.$gz.form.onChange(this.parentVM, ref);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
GetValueForField: function(dataKey) {
|
||||||
|
if (!this.value) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
//debugger;
|
||||||
|
//get the data out of the JSON string value
|
||||||
|
var cData = JSON.parse(this.value);
|
||||||
|
|
||||||
|
//get the type it *should* be
|
||||||
|
//TODO: method here
|
||||||
|
|
||||||
|
//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
|
||||||
|
|
||||||
|
//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 current data out of the json string value
|
||||||
|
//
|
||||||
|
var cData = JSON.parse(this.value);
|
||||||
|
if (!window.$gz._.has(cData, dataKey)) {
|
||||||
|
cData[dataKey] = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
//handle null or undefined
|
||||||
|
if (newValue === null || newValue === undefined) {
|
||||||
|
cData[dataKey] = null;
|
||||||
|
} else {
|
||||||
|
//then set item in the cData
|
||||||
|
|
||||||
|
//TODO: This will likely need also to be converted because dates and stuff
|
||||||
|
//initial naive attempt: (tostring is suspect)
|
||||||
|
cData[dataKey] = newValue.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
//emit the new data so it syncs with the parent source
|
||||||
|
var ret = JSON.stringify(cData);
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
},
|
||||||
computed: {
|
computed: {
|
||||||
c1: {
|
c1: {
|
||||||
get: function() {
|
get: function() {
|
||||||
@@ -280,75 +350,6 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
|
||||||
lt: function(ltkey) {
|
|
||||||
return window.$gz.locale.get(ltkey);
|
|
||||||
},
|
|
||||||
ltFormat() {
|
|
||||||
return window.$gz.locale.format();
|
|
||||||
},
|
|
||||||
form() {
|
|
||||||
//nothing
|
|
||||||
return window.$gz.form;
|
|
||||||
},
|
|
||||||
onChange(ref) {
|
|
||||||
if (
|
|
||||||
!this.parentVM.formState.loading &&
|
|
||||||
!this.parentVM.formState.readOnly
|
|
||||||
) {
|
|
||||||
window.$gz.form.onChange(this.parentVM, ref);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
GetValueForField: function(dataKey) {
|
|
||||||
if (!this.value) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
//debugger;
|
|
||||||
//get the data out of the JSON string value
|
|
||||||
var cData = JSON.parse(this.value);
|
|
||||||
|
|
||||||
//get the type it *should* be
|
|
||||||
//TODO: method here
|
|
||||||
|
|
||||||
//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
|
|
||||||
|
|
||||||
//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 current data out of the json string value
|
|
||||||
//
|
|
||||||
var cData = JSON.parse(this.value);
|
|
||||||
if (!window.$gz._.has(cData, dataKey)) {
|
|
||||||
cData[dataKey] = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
//handle null or undefined
|
|
||||||
if (newValue === null || newValue === undefined) {
|
|
||||||
cData[dataKey] = null;
|
|
||||||
} else {
|
|
||||||
//then set item in the cData
|
|
||||||
|
|
||||||
//TODO: This will likely need also to be converted because dates and stuff
|
|
||||||
//initial naive attempt: (tostring is suspect)
|
|
||||||
cData[dataKey] = newValue.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
//emit the new data so it syncs with the parent source
|
|
||||||
var ret = JSON.stringify(cData);
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
beforeCreate() {
|
beforeCreate() {
|
||||||
//check pre-requisites exist just in case
|
//check pre-requisites exist just in case
|
||||||
if (window.$gz.errorHandler.devMode()) {
|
if (window.$gz.errorHandler.devMode()) {
|
||||||
|
|||||||
Reference in New Issue
Block a user