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);
|
||||
}
|
||||
|
||||
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) {
|
||||
return Promise.resolve(response);
|
||||
} else {
|
||||
|
||||
@@ -286,55 +286,29 @@ export default {
|
||||
});
|
||||
},
|
||||
submit() {
|
||||
//COPIED FROM CUSTOM TO BE MODIFIED
|
||||
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
|
||||
window.$gz.form.deleteAllErrorBoxErrors(vm);
|
||||
|
||||
//Create template data object here....
|
||||
//Note that server expects to see a string array of json template, not actual json
|
||||
var newObj = {
|
||||
formKey: vm.formCustomTemplateKey,
|
||||
concurrencyToken: vm.concurrencyToken,
|
||||
id: vm.templateId,
|
||||
template: "[]"
|
||||
};
|
||||
//temporary array to hold template for later stringification
|
||||
var temp = [];
|
||||
//Rules:
|
||||
for (var i = 0; i < vm.obj.length; i++) {
|
||||
var fldItem = vm.obj[i];
|
||||
if (fldItem.custom == false) {
|
||||
//Process regular stock field
|
||||
//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
|
||||
});
|
||||
}
|
||||
for (var i = 0; i < vm.workingArray.length; i++) {
|
||||
var ti = vm.workingArray[i];
|
||||
if (ti.include == true) {
|
||||
temp.push({
|
||||
fld: ti.key
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
//now set the template as a json string
|
||||
newObj.template = JSON.stringify(temp);
|
||||
|
||||
window.$gz.api
|
||||
.upsert(url, newObj)
|
||||
.then(res => {
|
||||
@@ -343,11 +317,7 @@ export default {
|
||||
vm.formState.serverError = res.error;
|
||||
window.$gz.form.setErrorBoxErrors(vm);
|
||||
} else {
|
||||
//Handle "put" of an existing record (UPDATE) (there is no POST of a new record for this particular object)
|
||||
|
||||
//set our local concurrency token value
|
||||
vm.concurrencyToken = res.data.concurrencyToken;
|
||||
|
||||
//It's a 204 no data response so no error means it's ok
|
||||
//form is now clean
|
||||
window.$gz.form.setFormState({
|
||||
vm: vm,
|
||||
|
||||
Reference in New Issue
Block a user