This commit is contained in:
2019-07-19 19:48:15 +00:00
parent 7bbe2bd315
commit 5b94fd25e1
4 changed files with 44 additions and 43 deletions

View File

@@ -35,7 +35,7 @@ function dealWithError(msg, vm) {
} }
} }
vm.formState.appError = msg; vm.formState.appError = msg;
vm.$gzform.setErrorBoxErrors(vm); window.$gz.form.setErrorBoxErrors(vm);
} }
} }
export default { export default {

View File

@@ -115,7 +115,7 @@ export default {
.then(() => { .then(() => {
//don't have access to local data object until here //don't have access to local data object until here
that.rights = window.$gz.role.getRights(this, window.$gz.type.Widget); that.rights = window.$gz.role.getRights(this, window.$gz.type.Widget);
var formSettings = that.$gzform.getFormSettings(FORM_KEY); var formSettings = window.$gz.form.getFormSettings(FORM_KEY);
/** /**
* { * {
temp: { page: that.localFormSettings.pagination.page }, temp: { page: that.localFormSettings.pagination.page },
@@ -242,7 +242,7 @@ export default {
that.localFormSettings.pagination && that.localFormSettings.pagination &&
that.localFormSettings.pagination.rowsPerPage that.localFormSettings.pagination.rowsPerPage
) { ) {
that.$gzform.setFormSettings(FORM_KEY, { window.$gz.form.setFormSettings(FORM_KEY, {
temp: { page: that.localFormSettings.pagination.page }, temp: { page: that.localFormSettings.pagination.page },
saved: { saved: {
rowsPerPage: that.localFormSettings.pagination.rowsPerPage, rowsPerPage: that.localFormSettings.pagination.rowsPerPage,

View File

@@ -70,7 +70,7 @@ window.$gz = {
//Object.defineProperty(Vue.prototype, "$_", { value: lodash }); //Object.defineProperty(Vue.prototype, "$_", { value: lodash });
//Object.defineProperty(Vue.prototype, "$gzlocale", { value: locale }); //Object.defineProperty(Vue.prototype, "$gzlocale", { value: locale });
//Object.defineProperty(Vue.prototype, "$gzapi", { value: gzapi }); //Object.defineProperty(Vue.prototype, "$gzapi", { value: gzapi });
Object.defineProperty(Vue.prototype, "$gzform", { value: gzform }); //Object.defineProperty(Vue.prototype, "$gzform", { value: gzform });
Object.defineProperty(Vue.prototype, "$gzformcustomtemplate", { Object.defineProperty(Vue.prototype, "$gzformcustomtemplate", {
value: gzformcustomtemplate value: gzformcustomtemplate
}); });

View File

@@ -25,10 +25,10 @@
:counter="255" :counter="255"
:label="lt('WidgetName')" :label="lt('WidgetName')"
:rules="[ :rules="[
this.$gzform.max255(this, 'name'), form().max255(this, 'name'),
this.$gzform.required(this, 'name') form().required(this, 'name')
]" ]"
:error-messages="this.$gzform.serverErrors(this, 'name')" :error-messages="form().serverErrors(this, 'name')"
ref="name" ref="name"
@change="onChange('name')" @change="onChange('name')"
></v-text-field> ></v-text-field>
@@ -41,8 +41,8 @@
@click:clear="onChange('serial')" @click:clear="onChange('serial')"
:counter="10" :counter="10"
:label="lt('WidgetSerial')" :label="lt('WidgetSerial')"
:rules="[this.$gzform.maxLength(this, 'serial', 10)]" :rules="[form().maxLength(this, 'serial', 10)]"
:error-messages="this.$gzform.serverErrors(this, 'serial')" :error-messages="form().serverErrors(this, 'serial')"
ref="serial" ref="serial"
@change="onChange('serial')" @change="onChange('serial')"
></v-text-field> ></v-text-field>
@@ -57,10 +57,10 @@
:label="lt('WidgetCount')" :label="lt('WidgetCount')"
ref="count" ref="count"
:rules="[ :rules="[
this.$gzform.integerValid(this, 'count'), form().integerValid(this, 'count'),
this.$gzform.required(this, 'count') form().required(this, 'count')
]" ]"
:error-messages="this.$gzform.serverErrors(this, 'count')" :error-messages="form().serverErrors(this, 'count')"
required required
@change="onChange('count')" @change="onChange('count')"
type="number" type="number"
@@ -76,10 +76,10 @@
ref="dollarAmount" ref="dollarAmount"
required required
:rules="[ :rules="[
this.$gzform.decimalValid(this, 'dollarAmount'), form().decimalValid(this, 'dollarAmount'),
this.$gzform.required(this, 'dollarAmount') form().required(this, 'dollarAmount')
]" ]"
:error-messages="this.$gzform.serverErrors(this, 'dollarAmount')" :error-messages="form().serverErrors(this, 'dollarAmount')"
@change="onChange('dollarAmount')" @change="onChange('dollarAmount')"
type="number" type="number"
></v-text-field> ></v-text-field>
@@ -91,7 +91,7 @@
v-model="obj.startDate" v-model="obj.startDate"
:readonly="this.formState.readOnly" :readonly="this.formState.readOnly"
ref="startDate" ref="startDate"
:error-messages="this.$gzform.serverErrors(this, 'startDate')" :error-messages="form().serverErrors(this, 'startDate')"
@change="onChange('startDate')" @change="onChange('startDate')"
></gz-date-time-picker> ></gz-date-time-picker>
</v-flex> </v-flex>
@@ -99,10 +99,8 @@
<v-flex xs12 sm6 lg4 xl3 px-2> <v-flex xs12 sm6 lg4 xl3 px-2>
<gz-date-time-picker <gz-date-time-picker
:label="lt('WidgetEndDate')" :label="lt('WidgetEndDate')"
:rules="[ :rules="[form().datePrecedence(this, 'startDate', 'endDate')]"
this.$gzform.datePrecedence(this, 'startDate', 'endDate') :error-messages="form().serverErrors(this, 'endDate')"
]"
:error-messages="this.$gzform.serverErrors(this, 'endDate')"
v-model="obj.endDate" v-model="obj.endDate"
:readonly="this.formState.readOnly" :readonly="this.formState.readOnly"
ref="endDate" ref="endDate"
@@ -115,7 +113,7 @@
:readonly="this.formState.readOnly" :readonly="this.formState.readOnly"
:label="lt('Active')" :label="lt('Active')"
ref="active" ref="active"
:error-messages="this.$gzform.serverErrors(this, 'active')" :error-messages="form().serverErrors(this, 'active')"
required required
@change="onChange('active')" @change="onChange('active')"
></v-checkbox> ></v-checkbox>
@@ -130,10 +128,10 @@
:label="lt('WidgetRoles')" :label="lt('WidgetRoles')"
ref="roles" ref="roles"
:rules="[ :rules="[
this.$gzform.integerValid(this, 'roles'), form().integerValid(this, 'roles'),
this.$gzform.required(this, 'roles') form().required(this, 'roles')
]" ]"
:error-messages="this.$gzform.serverErrors(this, 'roles')" :error-messages="form().serverErrors(this, 'roles')"
required required
@change="onChange('roles')" @change="onChange('roles')"
></v-select> ></v-select>
@@ -144,7 +142,7 @@
v-model="obj.notes" v-model="obj.notes"
:readonly="this.formState.readOnly" :readonly="this.formState.readOnly"
:label="lt('WidgetNotes')" :label="lt('WidgetNotes')"
:error-messages="this.$gzform.serverErrors(this, 'notes')" :error-messages="form().serverErrors(this, 'notes')"
ref="notes" ref="notes"
@change="onChange('notes')" @change="onChange('notes')"
auto-grow auto-grow
@@ -157,7 +155,7 @@
v-model="obj.tags" v-model="obj.tags"
:readonly="this.formState.readOnly" :readonly="this.formState.readOnly"
ref="tags" ref="tags"
:error-messages="this.$gzform.serverErrors(this, 'tags')" :error-messages="form().serverErrors(this, 'tags')"
@change="onChange('tags')" @change="onChange('tags')"
></gz-tag-picker> ></gz-tag-picker>
</v-flex> </v-flex>
@@ -168,7 +166,7 @@
v-bind:value.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="form().serverErrors(this, 'customFields')"
@change="onChange('customFields')" @change="onChange('customFields')"
></gz-custom-fields> ></gz-custom-fields>
<!-- v-model="obj.customFields" --> <!-- v-model="obj.customFields" -->
@@ -270,7 +268,7 @@ export default {
//setup for new record //setup for new record
var readOnly = !this.rights.change; var readOnly = !this.rights.change;
//Update the form status //Update the form status
this.$gzform.setFormState({ window.$gz.form.setFormState({
vm: this, vm: this,
dirty: false, dirty: false,
valid: true, valid: true,
@@ -395,9 +393,12 @@ export default {
ltFormat() { ltFormat() {
return window.$gz.locale.format(); return window.$gz.locale.format();
}, },
form() {
return window.$gz.form;
},
onChange(ref) { onChange(ref) {
if (!this.formState.loading && !this.formState.readOnly) { if (!this.formState.loading && !this.formState.readOnly) {
this.$gzform.onChange(this, ref); window.$gz.form.onChange(this, ref);
} }
}, },
getDataFromApi(recordId) { getDataFromApi(recordId) {
@@ -407,7 +408,7 @@ export default {
} }
var url = FORM_BASE_URL + recordId; var url = FORM_BASE_URL + recordId;
var vm = this; var vm = this;
this.$gzform.deleteAllErrorBoxErrors(this); window.$gz.form.deleteAllErrorBoxErrors(this);
window.$gz.api window.$gz.api
.get(url) .get(url)
@@ -424,11 +425,11 @@ export default {
}); });
} }
vm.formState.serverError = res.error; vm.formState.serverError = res.error;
vm.$gzform.setErrorBoxErrors(vm); window.$gz.form.setErrorBoxErrors(vm);
} else { } else {
vm.obj = res.data; vm.obj = res.data;
//Update the form status //Update the form status
vm.$gzform.setFormState({ window.$gz.form.setFormState({
vm: vm, vm: vm,
dirty: false, dirty: false,
valid: true, valid: true,
@@ -441,7 +442,7 @@ export default {
}) })
.catch(function handleGetDataFromAPIError(error) { .catch(function handleGetDataFromAPIError(error) {
//Update the form status //Update the form status
vm.$gzform.setFormState({ window.$gz.form.setFormState({
vm: vm, vm: vm,
loading: false loading: false
}); });
@@ -455,20 +456,20 @@ export default {
var url = FORM_BASE_URL + this.$route.params.id; var url = FORM_BASE_URL + this.$route.params.id;
//clear any errors vm might be around from previous submit //clear any errors vm might be around from previous submit
this.$gzform.deleteAllErrorBoxErrors(this); window.$gz.form.deleteAllErrorBoxErrors(this);
window.$gz.api window.$gz.api
.upsert(url, this.obj) .upsert(url, this.obj)
.then(res => { .then(res => {
vm.formState.loading = false; vm.formState.loading = false;
if (res.error != undefined) { if (res.error != undefined) {
vm.formState.serverError = res.error; vm.formState.serverError = res.error;
vm.$gzform.setErrorBoxErrors(vm); window.$gz.form.setErrorBoxErrors(vm);
} else { } else {
//Logic for detecting if a post or put: if id then it was a post, if no id then it was a put //Logic for detecting if a post or put: if id then it was a post, if no id then it was a put
if (res.data.id) { if (res.data.id) {
//Handle "post" of new record (CREATE) //Handle "post" of new record (CREATE)
vm.obj = res.data; vm.obj = res.data;
vm.$gzform.setFormState({ window.$gz.form.setFormState({
vm: vm, vm: vm,
dirty: false, dirty: false,
readOnly: res.readOnly ? true : false readOnly: res.readOnly ? true : false
@@ -481,7 +482,7 @@ export default {
} else { } else {
//Handle "put" of an existing record (UPDATE) //Handle "put" of an existing record (UPDATE)
vm.obj.concurrencyToken = res.data.concurrencyToken; vm.obj.concurrencyToken = res.data.concurrencyToken;
vm.$gzform.setFormState({ window.$gz.form.setFormState({
vm: vm, vm: vm,
dirty: false dirty: false
}); });
@@ -509,13 +510,13 @@ export default {
} else { } else {
var url = FORM_BASE_URL + vm.$route.params.id; var url = FORM_BASE_URL + vm.$route.params.id;
vm.$gzform.deleteAllErrorBoxErrors(vm); window.$gz.form.deleteAllErrorBoxErrors(vm);
window.$gz.api window.$gz.api
.remove(url) .remove(url)
.then(res => { .then(res => {
if (res.error != undefined) { if (res.error != undefined) {
vm.formState.serverError = res.error; vm.formState.serverError = res.error;
vm.$gzform.setErrorBoxErrors(vm); window.$gz.form.setErrorBoxErrors(vm);
} else { } else {
//workaround to prevent warning about leaving dirty record //workaround to prevent warning about leaving dirty record
//For some reason I couldn't just reset isdirty in formstate //For some reason I couldn't just reset isdirty in formstate
@@ -526,7 +527,7 @@ export default {
}) })
.catch(function handleGetDataFromAPIError(error) { .catch(function handleGetDataFromAPIError(error) {
//Update the form status //Update the form status
vm.$gzform.setFormState({ window.$gz.form.setFormState({
vm: vm, vm: vm,
loading: false loading: false
}); });
@@ -543,7 +544,7 @@ export default {
var url = FORM_BASE_URL + "duplicate/" + this.$route.params.id; var url = FORM_BASE_URL + "duplicate/" + this.$route.params.id;
//clear any errors vm might be around from previous submit //clear any errors vm might be around from previous submit
this.$gzform.deleteAllErrorBoxErrors(this); window.$gz.form.deleteAllErrorBoxErrors(this);
window.$gz.api window.$gz.api
.duplicate(url) .duplicate(url)
.then(res => { .then(res => {
@@ -551,7 +552,7 @@ export default {
vm.formState.loading = false; vm.formState.loading = false;
if (res.error != undefined) { if (res.error != undefined) {
vm.formState.serverError = res.error; vm.formState.serverError = res.error;
vm.$gzform.setErrorBoxErrors(vm); window.$gz.form.setErrorBoxErrors(vm);
} else { } else {
//Navigate to new record //Navigate to new record
vm.$router.push( vm.$router.push(
@@ -676,7 +677,7 @@ var JUST_DELETED = false;
// function initForm(vm) { // function initForm(vm) {
// return fetchLocaleText(vm).then( // return fetchLocaleText(vm).then(
// populatePickLists(vm).then( // populatePickLists(vm).then(
// vm.$gzformcustomtemplate.get(FORM_CUSTOM_TEMPLATE_KEY) // window.$gz.formcustomtemplate.get(FORM_CUSTOM_TEMPLATE_KEY)
// ) // )
// ); // );
// } // }