Skip to content

Commit

Permalink
#156 updated form submitfunction loop to be simpler, fixed formatting…
Browse files Browse the repository at this point in the history
… issues in form and datalist scripts
  • Loading branch information
qial committed Sep 4, 2020
1 parent 448ee96 commit 66f1353
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 22 deletions.
6 changes: 3 additions & 3 deletions fragments/datalist/template.vue
Original file line number Diff line number Diff line change
Expand Up @@ -345,11 +345,11 @@
// load data from URL
axios.get(this.model.endpointurl)
.then( (response) => {
console.log(response)
this.loadData(response.data)
console.log(response)
this.loadData(response.data)
})
.catch( (error) => {
console.log(error)
console.log(error)
})
}
else {
Expand Down
16 changes: 8 additions & 8 deletions fragments/form/template.vue
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ export default {
if(this.model.submitfunction != 'onSubmit' && this.model.submitfunction != '') {
const objs = this.model.submitfunction.split('.')
let parent = window
let i = 0
while(i < objs.length && parent[objs[i]]) {
if(i == objs.length-1) {
let obj = objs.shift()
while(obj && parent[obj]) {
if(objs.length === 0) {
try {
const result = parent[objs[i]](this.model,this.formModel)
const result = parent[obj](this.model,this.formModel)
if(result === false) {
Vue.set(this, 'failureText', this.model.failmessage);
setTimeout(() => {
Expand All @@ -67,8 +67,8 @@ export default {
}
return
}
parent = parent[objs[i]]
i++
parent = parent[obj]
obj = objs.shift()
}
console.log('window.' + this.model.submitfunction + ' not found')
Vue.set(this, 'failureText', this.model.failmessage);
Expand All @@ -78,10 +78,10 @@ export default {
return
}
axios.post(this.model.endpointurl, {
form: this.formModel
form: this.formModel
})
.then( (response) => {
$peregrineApp.loadContent(this.model.successpage)
$peregrineApp.loadContent(this.model.successpage)
})
.catch( (error) => {
Vue.set(this, 'failureText', this.model.failmessage);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -345,11 +345,11 @@
// load data from URL
axios.get(this.model.endpointurl)
.then( (response) => {
console.log(response)
this.loadData(response.data)
console.log(response)
this.loadData(response.data)
})
.catch( (error) => {
console.log(error)
console.log(error)
})
}
else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ export default {
if(this.model.submitfunction != 'onSubmit' && this.model.submitfunction != '') {
const objs = this.model.submitfunction.split('.')
let parent = window
let i = 0
while(i < objs.length && parent[objs[i]]) {
if(i == objs.length-1) {
let obj = objs.shift()
while(obj && parent[obj]) {
if(objs.length === 0) {
try {
const result = parent[objs[i]](this.model,this.formModel)
const result = parent[obj](this.model,this.formModel)
if(result === false) {
Vue.set(this, 'failureText', this.model.failmessage);
setTimeout(() => {
Expand All @@ -67,8 +67,8 @@ export default {
}
return
}
parent = parent[objs[i]]
i++
parent = parent[obj]
obj = objs.shift()
}
console.log('window.' + this.model.submitfunction + ' not found')
Vue.set(this, 'failureText', this.model.failmessage);
Expand All @@ -78,10 +78,10 @@ export default {
return
}
axios.post(this.model.endpointurl, {
form: this.formModel
form: this.formModel
})
.then( (response) => {
$peregrineApp.loadContent(this.model.successpage)
$peregrineApp.loadContent(this.model.successpage)
})
.catch( (error) => {
Vue.set(this, 'failureText', this.model.failmessage);
Expand Down

0 comments on commit 66f1353

Please sign in to comment.