All working, just need reset / delete method and Bob's my proverbial Lobster!
This commit is contained in:
@@ -116,6 +116,13 @@ export default {
|
|||||||
return Promise.resolve(response);
|
return Promise.resolve(response);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (response.status == 405) {
|
||||||
|
//Probably a development error
|
||||||
|
return Promise.reject(
|
||||||
|
new Error("Method Not Allowed (route issue?) " + response.url)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
if (response.status >= 200 && response.status < 300) {
|
if (response.status >= 200 && response.status < 300) {
|
||||||
return Promise.resolve(response);
|
return Promise.resolve(response);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -286,55 +286,29 @@ export default {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
submit() {
|
submit() {
|
||||||
//COPIED FROM CUSTOM TO BE MODIFIED
|
|
||||||
var vm = this;
|
var vm = this;
|
||||||
var url = API_BASE_URL + vm.formCustomTemplateKey;
|
var url = API_BASE_URL;
|
||||||
|
|
||||||
//clear any errors vm might be around from previous submit
|
//clear any errors vm might be around from previous submit
|
||||||
window.$gz.form.deleteAllErrorBoxErrors(vm);
|
window.$gz.form.deleteAllErrorBoxErrors(vm);
|
||||||
|
|
||||||
//Create template data object here....
|
//Create template data object here....
|
||||||
//Note that server expects to see a string array of json template, not actual json
|
//Note that server expects to see a string array of json template, not actual json
|
||||||
var newObj = {
|
var newObj = {
|
||||||
formKey: vm.formCustomTemplateKey,
|
id: vm.templateId,
|
||||||
concurrencyToken: vm.concurrencyToken,
|
|
||||||
template: "[]"
|
template: "[]"
|
||||||
};
|
};
|
||||||
//temporary array to hold template for later stringification
|
//temporary array to hold template for later stringification
|
||||||
var temp = [];
|
var temp = [];
|
||||||
//Rules:
|
for (var i = 0; i < vm.workingArray.length; i++) {
|
||||||
for (var i = 0; i < vm.obj.length; i++) {
|
var ti = vm.workingArray[i];
|
||||||
var fldItem = vm.obj[i];
|
if (ti.include == true) {
|
||||||
if (fldItem.custom == false) {
|
temp.push({
|
||||||
//Process regular stock field
|
fld: ti.key
|
||||||
//If it's *not* set to stockRequired (i.e. built in field with biz rules that can't be hidden or changed)
|
});
|
||||||
// and it's also set to hidden or required then it's template-worthy
|
|
||||||
if (
|
|
||||||
!fldItem.stockRequired &&
|
|
||||||
(fldItem.visible == false || fldItem.required == true)
|
|
||||||
) {
|
|
||||||
temp.push({
|
|
||||||
fld: fldItem.key,
|
|
||||||
required: fldItem.required,
|
|
||||||
hide: !fldItem.visible
|
|
||||||
});
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
//Process custom field
|
|
||||||
//If it's not visible then don't add it at all
|
|
||||||
if (fldItem.visible == true) {
|
|
||||||
temp.push({
|
|
||||||
fld: fldItem.key,
|
|
||||||
required: fldItem.required,
|
|
||||||
type: fldItem.type
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//now set the template as a json string
|
//now set the template as a json string
|
||||||
newObj.template = JSON.stringify(temp);
|
newObj.template = JSON.stringify(temp);
|
||||||
|
|
||||||
window.$gz.api
|
window.$gz.api
|
||||||
.upsert(url, newObj)
|
.upsert(url, newObj)
|
||||||
.then(res => {
|
.then(res => {
|
||||||
@@ -343,11 +317,7 @@ export default {
|
|||||||
vm.formState.serverError = res.error;
|
vm.formState.serverError = res.error;
|
||||||
window.$gz.form.setErrorBoxErrors(vm);
|
window.$gz.form.setErrorBoxErrors(vm);
|
||||||
} else {
|
} else {
|
||||||
//Handle "put" of an existing record (UPDATE) (there is no POST of a new record for this particular object)
|
//It's a 204 no data response so no error means it's ok
|
||||||
|
|
||||||
//set our local concurrency token value
|
|
||||||
vm.concurrencyToken = res.data.concurrencyToken;
|
|
||||||
|
|
||||||
//form is now clean
|
//form is now clean
|
||||||
window.$gz.form.setFormState({
|
window.$gz.form.setFormState({
|
||||||
vm: vm,
|
vm: vm,
|
||||||
|
|||||||
Reference in New Issue
Block a user