|
Lines 10-16
Link Here
|
| 10 |
<VendorDetails :vendor="vendor" /> |
10 |
<VendorDetails :vendor="vendor" /> |
| 11 |
<VendorContacts :vendor="vendor" /> |
11 |
<VendorContacts :vendor="vendor" /> |
| 12 |
<VendorInterfaces :vendor="vendor" /> |
12 |
<VendorInterfaces :vendor="vendor" /> |
| 13 |
<VendorOrderingInformation :vendor="vendor" /> |
13 |
<VendorOrderingInformation |
|
|
14 |
:vendor="vendor" |
| 15 |
:verifyDiscountValue="verifyDiscountValue" |
| 16 |
:discountValid="discountValid" |
| 17 |
/> |
| 14 |
<fieldset class="action"> |
18 |
<fieldset class="action"> |
| 15 |
<ButtonSubmit /> |
19 |
<ButtonSubmit /> |
| 16 |
<router-link |
20 |
<router-link |
|
Lines 27-33
Link Here
|
| 27 |
|
31 |
|
| 28 |
<script> |
32 |
<script> |
| 29 |
import ButtonSubmit from "../ButtonSubmit.vue"; |
33 |
import ButtonSubmit from "../ButtonSubmit.vue"; |
| 30 |
import { setMessage } from "../../messages"; |
34 |
import { setMessage, setWarning } from "../../messages"; |
| 31 |
import { APIClient } from "../../fetch/api-client.js"; |
35 |
import { APIClient } from "../../fetch/api-client.js"; |
| 32 |
import VendorDetails from "./VendorDetails.vue"; |
36 |
import VendorDetails from "./VendorDetails.vue"; |
| 33 |
import VendorContacts from "./VendorContacts.vue"; |
37 |
import VendorContacts from "./VendorContacts.vue"; |
|
Lines 66-71
export default {
Link Here
|
| 66 |
interfaces: [], |
70 |
interfaces: [], |
| 67 |
}, |
71 |
}, |
| 68 |
initialized: false, |
72 |
initialized: false, |
|
|
73 |
discountValid: true, |
| 69 |
}; |
74 |
}; |
| 70 |
}, |
75 |
}, |
| 71 |
beforeRouteEnter(to, from, next) { |
76 |
beforeRouteEnter(to, from, next) { |
|
Lines 89-94
export default {
Link Here
|
| 89 |
vendor.address3 && (physical += vendor.address3 + "\n"); |
94 |
vendor.address3 && (physical += vendor.address3 + "\n"); |
| 90 |
vendor.address4 && (physical += vendor.address4 + "\n"); |
95 |
vendor.address4 && (physical += vendor.address4 + "\n"); |
| 91 |
this.vendor.physical = physical; |
96 |
this.vendor.physical = physical; |
|
|
97 |
|
| 98 |
if (!this.vendor.discount) this.vendor.discount = 0.0; |
| 99 |
const decimalPlaces = |
| 100 |
this.vendor.discount.toString().split(".")[1]?.length || |
| 101 |
0; |
| 102 |
if (!decimalPlaces) { |
| 103 |
this.vendor.discount = this.vendor.discount.toFixed(1); |
| 104 |
} |
| 105 |
|
| 92 |
this.initialized = true; |
106 |
this.initialized = true; |
| 93 |
}, |
107 |
}, |
| 94 |
error => {} |
108 |
error => {} |
|
Lines 96-102
export default {
Link Here
|
| 96 |
}, |
110 |
}, |
| 97 |
onSubmit(e) { |
111 |
onSubmit(e) { |
| 98 |
e.preventDefault(); |
112 |
e.preventDefault(); |
| 99 |
|
113 |
const errors = []; |
| 100 |
const vendor = JSON.parse(JSON.stringify(this.vendor)); |
114 |
const vendor = JSON.parse(JSON.stringify(this.vendor)); |
| 101 |
|
115 |
|
| 102 |
const vendorId = vendor.id; |
116 |
const vendorId = vendor.id; |
|
Lines 114-119
export default {
Link Here
|
| 114 |
delete vendor.physical; |
128 |
delete vendor.physical; |
| 115 |
delete vendor.subscriptions_count; |
129 |
delete vendor.subscriptions_count; |
| 116 |
|
130 |
|
|
|
131 |
if (!this.discountValid) |
| 132 |
errors.push(this.$__("Invalid discount value")); |
| 133 |
|
| 117 |
vendor.contacts = this.checkContactOrInterface( |
134 |
vendor.contacts = this.checkContactOrInterface( |
| 118 |
vendor.contacts.map( |
135 |
vendor.contacts.map( |
| 119 |
({ id, booksellerid, ...requiredProperties }) => |
136 |
({ id, booksellerid, ...requiredProperties }) => |
|
Lines 127-132
export default {
Link Here
|
| 127 |
) |
144 |
) |
| 128 |
); |
145 |
); |
| 129 |
|
146 |
|
|
|
147 |
setWarning(errors.join("<br>")); |
| 148 |
if (errors.length) return false; |
| 149 |
|
| 130 |
const client = APIClient.acquisition; |
150 |
const client = APIClient.acquisition; |
| 131 |
if (vendorId) { |
151 |
if (vendorId) { |
| 132 |
client.vendors.update(vendor, vendorId).then( |
152 |
client.vendors.update(vendor, vendorId).then( |
|
Lines 157-162
export default {
Link Here
|
| 157 |
return acc; |
177 |
return acc; |
| 158 |
}, []); |
178 |
}, []); |
| 159 |
}, |
179 |
}, |
|
|
180 |
verifyDiscountValue(e) { |
| 181 |
this.discountValid = /^[\-]?\d{0,2}(\.\d{0,3})*$/.test( |
| 182 |
this.vendor.discount |
| 183 |
); |
| 184 |
}, |
| 160 |
}, |
185 |
}, |
| 161 |
components: { |
186 |
components: { |
| 162 |
ButtonSubmit, |
187 |
ButtonSubmit, |