View | Details | Raw Unified | Return to bug 38010
Collapse All | Expand All

(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/components/Vendors/VendorDetails.vue (-2 / +6 lines)
Lines 143-149 Link Here
143
            </li>
143
            </li>
144
            <li>
144
            <li>
145
                <label for="vendor_aliases">{{ $__("Aliases") }}:</label>
145
                <label for="vendor_aliases">{{ $__("Aliases") }}:</label>
146
                <input id="vendor_aliases" v-model="newAlias" />
146
                <input
147
                    id="vendor_aliases"
148
                    class="noEnterSubmit"
149
                    v-model="newAlias"
150
                />
147
                <span class="aliasAction" @click="addAlias()"
151
                <span class="aliasAction" @click="addAlias()"
148
                    ><i class="fa fa-plus"></i> {{ $__("Add") }}</span
152
                    ><i class="fa fa-plus"></i> {{ $__("Add") }}</span
149
                >
153
                >
Lines 201-207 export default { Link Here
201
        },
205
        },
202
        removeAlias(e) {
206
        removeAlias(e) {
203
            const aliasIndex = this.vendor.aliases
207
            const aliasIndex = this.vendor.aliases
204
                .map(e => e.alias)
208
                .map(a => a.alias)
205
                .indexOf(e.alias);
209
                .indexOf(e.alias);
206
            this.vendor.aliases.splice(aliasIndex, 1);
210
            this.vendor.aliases.splice(aliasIndex, 1);
207
        },
211
        },
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/components/Vendors/VendorFormAdd.vue (-3 / +28 lines)
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,
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/components/Vendors/VendorInterfaces.vue (-1 / +1 lines)
Lines 127-133 Link Here
127
                    />
127
                    />
128
                </li>
128
                </li>
129
            </ol>
129
            </ol>
130
            <span class="btn btn-default" @click.prevent="deleteContact(i)"
130
            <span class="btn btn-default" @click.prevent="deleteInterface(i)"
131
                ><font-awesome-icon icon="trash" />
131
                ><font-awesome-icon icon="trash" />
132
                {{ $__("Delete interface") }}</span
132
                {{ $__("Delete interface") }}</span
133
            >
133
            >
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/components/Vendors/VendorList.vue (-1 / +1 lines)
Lines 148-154 export default { Link Here
148
        doEdit({ id }, dt, event) {
148
        doEdit({ id }, dt, event) {
149
            this.$router.push({
149
            this.$router.push({
150
                name: "VendorFormAddEdit",
150
                name: "VendorFormAddEdit",
151
                params: { vendor_id: id },
151
                params: { id: id },
152
            });
152
            });
153
        },
153
        },
154
        doDelete(vendor, dt, event) {
154
        doDelete(vendor, dt, event) {
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/components/Vendors/VendorOrderingInformation.vue (-1 / +18 lines)
Lines 192-199 Link Here
192
                    id="discount"
192
                    id="discount"
193
                    name="discount"
193
                    name="discount"
194
                    v-model="vendor.discount"
194
                    v-model="vendor.discount"
195
                    @change="verifyDiscountValue(e)"
195
                />
196
                />
196
                %
197
                %
198
                <span class="error" v-if="!discountValid">
199
                    {{
200
                        $__("Please enter a decimal number in the format: 0.0")
201
                    }}
202
                </span>
197
            </li>
203
            </li>
198
            <li>
204
            <li>
199
                <label for="deliverytime">{{ $__("Delivery time") }}: </label>
205
                <label for="deliverytime">{{ $__("Delivery time") }}: </label>
Lines 228-233 export default { Link Here
228
    props: {
234
    props: {
229
        vendor: Object,
235
        vendor: Object,
230
        display: Boolean,
236
        display: Boolean,
237
        verifyDiscountValue: Function,
238
        discountValid: Boolean,
231
    },
239
    },
232
    setup() {
240
    setup() {
233
        const vendorStore = inject("vendorStore");
241
        const vendorStore = inject("vendorStore");
Lines 245-250 export default { Link Here
245
            const multiplier = 10 ** decimalPlaces;
253
            const multiplier = 10 ** decimalPlaces;
246
            return Math.round(taxRate * multiplier) / (multiplier / 100);
254
            return Math.round(taxRate * multiplier) / (multiplier / 100);
247
        },
255
        },
256
        formatDiscount() {
257
            if (!this.vendor.discount) return 0.0;
258
            const decimalPlaces =
259
                this.vendor.discount.toString().split(".")[1]?.length || 0;
260
            if (decimalPlaces) {
261
                return this.vendor.discount;
262
            } else {
263
                return this.vendor.discount.toFixed(1);
264
            }
265
        },
248
    },
266
    },
249
};
267
};
250
</script>
268
</script>
251
- 

Return to bug 38010