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.$gzform.setErrorBoxErrors(vm);
window.$gz.form.setErrorBoxErrors(vm);
}
}
export default {

View File

@@ -115,7 +115,7 @@ export default {
.then(() => {
//don't have access to local data object until here
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 },
@@ -242,7 +242,7 @@ export default {
that.localFormSettings.pagination &&
that.localFormSettings.pagination.rowsPerPage
) {
that.$gzform.setFormSettings(FORM_KEY, {
window.$gz.form.setFormSettings(FORM_KEY, {
temp: { page: that.localFormSettings.pagination.page },
saved: {
rowsPerPage: that.localFormSettings.pagination.rowsPerPage,

View File

@@ -70,7 +70,7 @@ window.$gz = {
//Object.defineProperty(Vue.prototype, "$_", { value: lodash });
//Object.defineProperty(Vue.prototype, "$gzlocale", { value: locale });
//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", {
value: gzformcustomtemplate
});

View File

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