This commit is contained in:
2019-07-18 22:24:30 +00:00
parent a5c77af06c
commit 2137d57e76
2 changed files with 36 additions and 42 deletions

View File

@@ -3,7 +3,7 @@
<span class="v-label v-label--active theme--light"> <span class="v-label v-label--active theme--light">
{{ this.$gzlocale.get("ObjectCustomFieldCustomGrid") }} {{ this.$gzlocale.get("ObjectCustomFieldCustomGrid") }}
</span> </span>
<div> <!-- <div>
<h5>FORMKEY: {{ formKey }}</h5> <h5>FORMKEY: {{ formKey }}</h5>
<h5>TEMPLATE: {{ this.$store.state.formCustomTemplate[formKey] }}</h5> <h5>TEMPLATE: {{ this.$store.state.formCustomTemplate[formKey] }}</h5>
<h5>CUSTOM FIELD DATA:</h5> <h5>CUSTOM FIELD DATA:</h5>
@@ -11,7 +11,7 @@
{{ value }} {{ value }}
</span> </span>
</div> </div>
<hr /> <hr /> -->
<div> <div>
<v-layout align-center justify-left row wrap> <v-layout align-center justify-left row wrap>
@@ -113,18 +113,9 @@ export default {
}, },
props: { props: {
value: String, value: String,
customfielddata: String,
formKey: String, //used to grab template from store formKey: String, //used to grab template from store
readOnly: Boolean readOnly: Boolean
}, },
watch: {
// value(val) {
// //this ensures the parent form gets the onchange event
// //not actually sure why there are two here but it worked with the datetime picker so I replicated it here
// this.$emit("input", val);
// this.$emit("change", val);
// }
},
computed: { computed: {
c2: { c2: {
get: function() { get: function() {
@@ -140,12 +131,12 @@ export default {
return this.$gzlocale.get(ltkey); return this.$gzlocale.get(ltkey);
}, },
GetValueForField: function(dataKey) { GetValueForField: function(dataKey) {
if (!this.customfielddata) { if (!this.value) {
return null; return null;
} }
// debugger; // debugger;
//get the data out of the JSON string value //get the data out of the JSON string value
var cData = JSON.parse(this.customfielddata); var cData = JSON.parse(this.value);
//get the type it *should* be //get the type it *should* be
//TODO: method here //TODO: method here
@@ -157,32 +148,27 @@ export default {
return cData[dataKey]; return cData[dataKey];
}, },
SetValueForField: function(dataKey, newValue) { SetValueForField: function(dataKey, newValue) {
//console.log("Setting " + dataKey + " TO " + newValue); //https://stackoverflow.com/questions/39868963/vue-2-mutating-props-vue-warn
//Get the data out of the json string value //Get the data out of the json string value
// //
var cData = JSON.parse(this.customfielddata); var cData = JSON.parse(this.value);
//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
//initial naive attempt: (tostring is suspect) //initial naive attempt: (tostring is suspect)
cData[dataKey]=newValue.toString(); cData[dataKey] = newValue.toString();
//TODO: look at how the datetime and tags use the value vs a local cached value instead of mutating the props value
//to json text (opposite of Parse above)
//BUGBUG:
/*
//DEV ERROR errorHandler::devShowUnknownError - unexpected error:
Vue warning: //emit the new data so it syncs with the parent source
Avoid mutating a prop directly since the value will be overwritten whenever the parent component re-renders. Instead, use a data or computed property based on the prop's value. Prop being mutated: "value" var ret = JSON.stringify(cData);
this.$emit("update:value", ret);
//MAYBE I need to modify the value object, not simply replace it (somehow?) //this triggers the onchange routine in the parent form
*/ //mainly for custom fields purposes so that the dirty checking works
//this.value=JSON.stringify(cData) this.$emit("change");
this.$emit('update:customfielddata', JSON.stringify(cData));
} }
}, },
beforeCreate() { beforeCreate() {
console.log("custom-fields-control::BEFORECREATE: TOP");
//check pre-requisites exist just in case //check pre-requisites exist just in case
if (this.$gzdevmode()) { if (this.$gzdevmode()) {
if (!this.$_) { if (!this.$_) {
@@ -191,7 +177,11 @@ Avoid mutating a prop directly since the value will be overwritten whenever the
if (!this.$gzlocale) { if (!this.$gzlocale) {
throw "custom-fields-control: $gzlocale is required and missing"; throw "custom-fields-control: $gzlocale is required and missing";
} }
} }
//trigger the template fetch
//var v=this.$store.state.formCustomTemplate[this.formKey];
}, },
created() { created() {
if (this.$gzdevmode()) { if (this.$gzdevmode()) {
@@ -199,8 +189,7 @@ Avoid mutating a prop directly since the value will be overwritten whenever the
if (!this.formKey) { if (!this.formKey) {
throw "custom-fields-control: formKey property is required and missing"; throw "custom-fields-control: formKey property is required and missing";
} }
} }
} }
}; };
</script> </script>

View File

@@ -165,8 +165,7 @@
<v-flex xs12 px-2> <v-flex xs12 px-2>
<gz-custom-fields <gz-custom-fields
:formKey="formCustomTemplateKey" :formKey="formCustomTemplateKey"
v-bind:customfielddata.sync="obj.customFields" v-bind:value.sync="obj.customFields"
:readOnly="this.formState.readOnly" :readOnly="this.formState.readOnly"
ref="customFields" ref="customFields"
:error-messages="this.$gzform.serverErrors(this, 'customFields')" :error-messages="this.$gzform.serverErrors(this, 'customFields')"
@@ -199,7 +198,7 @@
<script> <script>
///////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////
/* Xeslint-disable */ /* eslint-disable */
//////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////
const FORM_KEY = "inventory-widget-edit"; const FORM_KEY = "inventory-widget-edit";
@@ -208,7 +207,7 @@ const FORM_CUSTOM_TEMPLATE_KEY = "widget";
export default { export default {
beforeCreate() { beforeCreate() {
//console.log("BEFORECREATE: TOP"); console.log("BEFORECREATE: TOP");
var vm = this; var vm = this;
initForm(this) initForm(this)
.then(() => { .then(() => {
@@ -618,11 +617,17 @@ var JUST_DELETED = false;
////////////////////// //////////////////////
// //
// //
// function initForm(vm) {
// return fetchLocaleText(vm).then(
// populatePickLists(vm).then(
// vm.$gzformcustomtemplate.get(FORM_CUSTOM_TEMPLATE_KEY)
// )
// );
// }
function initForm(vm) { function initForm(vm) {
return fetchLocaleText(vm).then( return vm.$gzformcustomtemplate.get(FORM_CUSTOM_TEMPLATE_KEY).then(fetchLocaleText(vm).then(
populatePickLists(vm).then( populatePickLists(vm))
vm.$gzformcustomtemplate.get(FORM_CUSTOM_TEMPLATE_KEY)
)
); );
} }