Use common POST logic for submitting new customer order
This commit is contained in:
parent
ccb4661b39
commit
a9fbf48053
|
@ -1091,6 +1091,7 @@
|
||||||
|
|
||||||
const CustomerOrderCreator = {
|
const CustomerOrderCreator = {
|
||||||
template: '#customer-order-creator-template',
|
template: '#customer-order-creator-template',
|
||||||
|
mixins: [SimpleRequestMixin],
|
||||||
data() {
|
data() {
|
||||||
|
|
||||||
let defaultUnitChoices = ${json.dumps(default_uom_choices)|n}
|
let defaultUnitChoices = ${json.dumps(default_uom_choices)|n}
|
||||||
|
@ -1198,9 +1199,6 @@
|
||||||
pendingProduct: {},
|
pendingProduct: {},
|
||||||
departmentOptions: ${json.dumps(department_options)|n},
|
departmentOptions: ${json.dumps(department_options)|n},
|
||||||
|
|
||||||
## TODO: should find a better way to handle CSRF token
|
|
||||||
csrftoken: ${json.dumps(request.session.get_csrf_token() or request.session.new_csrf_token())|n},
|
|
||||||
|
|
||||||
submittingOrder: false,
|
submittingOrder: false,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -1500,31 +1498,11 @@
|
||||||
submitBatchData(params, success, failure) {
|
submitBatchData(params, success, failure) {
|
||||||
let url = ${json.dumps(request.current_route_url())|n}
|
let url = ${json.dumps(request.current_route_url())|n}
|
||||||
|
|
||||||
let headers = {
|
this.simplePOST(url, params, response => {
|
||||||
## TODO: should find a better way to handle CSRF token
|
if (success) {
|
||||||
'X-CSRF-TOKEN': this.csrftoken,
|
|
||||||
}
|
|
||||||
|
|
||||||
## TODO: should find a better way to handle CSRF token
|
|
||||||
this.$http.post(url, params, {headers: headers}).then((response) => {
|
|
||||||
if (response.data.error) {
|
|
||||||
this.$buefy.toast.open({
|
|
||||||
message: response.data.error,
|
|
||||||
type: 'is-danger',
|
|
||||||
duration: 2000, // 2 seconds
|
|
||||||
})
|
|
||||||
if (failure) {
|
|
||||||
failure(response)
|
|
||||||
}
|
|
||||||
} else if (success) {
|
|
||||||
success(response)
|
success(response)
|
||||||
}
|
}
|
||||||
}, response => {
|
}, response => {
|
||||||
this.$buefy.toast.open({
|
|
||||||
message: "Unexpected error occurred",
|
|
||||||
type: 'is-danger',
|
|
||||||
duration: 2000, // 2 seconds
|
|
||||||
})
|
|
||||||
if (failure) {
|
if (failure) {
|
||||||
failure(response)
|
failure(response)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue