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

(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/vendor-menu.inc (-1 / +1 lines)
Lines 1-7 Link Here
1
[% IF ( booksellerid ) %]
1
[% IF ( booksellerid ) %]
2
<div id="menu">
2
<div id="menu">
3
    <ul>
3
    <ul>
4
        [% IF ( CAN_user_acquisition_order_manage ) %]<li><a href="/cgi-bin/koha/vendors/[% booksellerid | uri %]">Baskets</a></li>[% END %]
4
        [% IF ( CAN_user_acquisition_order_manage ) %]<li><a href="/cgi-bin/koha/vendors/[% booksellerid | uri %]/baskets">Baskets</a></li>[% END %]
5
        [% IF ( CAN_user_acquisition_group_manage ) %]<li><a href="/cgi-bin/koha/acqui/basketgroup.pl?booksellerid=[% booksellerid | uri %]">Basket groups</a></li>[% END %]
5
        [% IF ( CAN_user_acquisition_group_manage ) %]<li><a href="/cgi-bin/koha/acqui/basketgroup.pl?booksellerid=[% booksellerid | uri %]">Basket groups</a></li>[% END %]
6
        [% IF ( CAN_user_acquisition_contracts_manage ) %]<li><a href="/cgi-bin/koha/admin/aqcontract.pl?booksellerid=[% booksellerid | uri %]">Contracts</a></li>[% END %]
6
        [% IF ( CAN_user_acquisition_contracts_manage ) %]<li><a href="/cgi-bin/koha/admin/aqcontract.pl?booksellerid=[% booksellerid | uri %]">Contracts</a></li>[% END %]
7
        [% IF ( CAN_user_acquisition_issue_manage ) %]<li><a href="/cgi-bin/koha/acqui/vendor_issues.pl?booksellerid=[% booksellerid | uri %]">Vendor issues</a></li>[% END %]
7
        [% IF ( CAN_user_acquisition_issue_manage ) %]<li><a href="/cgi-bin/koha/acqui/vendor_issues.pl?booksellerid=[% booksellerid | uri %]">Vendor issues</a></li>[% END %]
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/components/Vendors/VendorBaskets.vue (+218 lines)
Line 0 Link Here
1
<template>
2
    <div id="vendor_baskets">
3
        <div v-if="parseInt(basketCount) > 0" class="page-section">
4
            <KohaTable
5
                ref="table"
6
                v-bind="tableOptions"
7
                @show="doShow"
8
                @edit="doEdit"
9
                @delete="doDelete"
10
                @select="doSelect"
11
            ></KohaTable>
12
        </div>
13
        <div v-else class="alert alert-info">
14
            {{ $__("There are no baskets defined") }}
15
        </div>
16
    </div>
17
</template>
18
19
<script>
20
import { inject, ref } from "vue"
21
import { storeToRefs } from "pinia"
22
import KohaTable from "../KohaTable.vue"
23
24
export default {
25
    setup() {
26
        const vendorStore = inject("vendorStore")
27
        const { vendors } = storeToRefs(vendorStore)
28
29
        const { setConfirmationDialog, setMessage } = inject("mainStore")
30
31
        const table = ref()
32
33
        return {
34
            vendors,
35
            table,
36
            setConfirmationDialog,
37
            setMessage,
38
            escape_str,
39
        }
40
    },
41
    data() {
42
        return {
43
            fp_config: flatpickr_defaults,
44
            initialized: false,
45
            tableOptions: {
46
                columns: this.getTableColumns(),
47
                url: () => this.tableURL(),
48
                add_filters: true,
49
                // filters_options: {
50
                //     1: [
51
                //         { _id: 0, _str: this.$__("Inactive") },
52
                //         { _id: 1, _str: this.$__("Active") },
53
                //     ],
54
                //     ...(this.map_av_dt_filter("vendor_types").length && {
55
                //         2: () => this.map_av_dt_filter("vendor_types"),
56
                //     }),
57
                // },
58
                actions: {
59
                    "-1": ["edit", "delete"],
60
                },
61
            },
62
            before_route_entered: false,
63
            building_table: false,
64
        }
65
    },
66
    methods: {
67
        doShow({ id }, dt, event) {
68
            event.preventDefault()
69
            this.$router.push({
70
                name: "VendorShow",
71
                params: { vendor_id: id },
72
            })
73
        },
74
        doEdit({ id }, dt, event) {
75
            this.$router.push({
76
                name: "VendorFormAddEdit",
77
                params: { vendor_id: id },
78
            })
79
        },
80
        doDelete(vendor, dt, event) {
81
            this.setConfirmationDialog(
82
                {
83
                    title: this.$__(
84
                        "Are you sure you want to remove this vendor?"
85
                    ),
86
                    message: vendor.name,
87
                    accept_label: this.$__("Yes, delete"),
88
                    cancel_label: this.$__("No, do not delete"),
89
                },
90
                () => {
91
                    const client = APIClient.acquisition
92
                    client.vendors.delete(vendor.id).then(
93
                        success => {
94
                            this.setMessage(
95
                                this.$__("Vendor %s deleted").format(
96
                                    vendor.name
97
                                ),
98
                                true
99
                            )
100
                            dt.draw()
101
                        },
102
                        error => {}
103
                    )
104
                }
105
            )
106
        },
107
        doSelect(vendor, dt, event) {
108
            this.$emit("select-vendor", vendor.id)
109
            this.$emit("close")
110
        },
111
        tableURL() {
112
            let url =
113
                "/api/v1/acquisitions/baskets?q=" +
114
                JSON.stringify({ vendor_id: this.vendorId })
115
            return url
116
        },
117
        getTableColumns() {
118
            const escape_str = this.escape_str
119
            const get_lib_from_av = this.get_lib_from_av
120
121
            return [
122
                {
123
                    title: __("Name"),
124
                    data: "me.name:me.basket_id",
125
                    searchable: true,
126
                    orderable: true,
127
                    render(data, type, row, meta) {
128
                        return (
129
                            '<a href="/cgi-bin/koha/acqui/basket.pl?basket_id=' +
130
                            row.basket_id +
131
                            '" class="show">' +
132
                            escape_str(`${row.name} (#${row.basket_id})`) +
133
                            "</a>"
134
                        )
135
                    },
136
                },
137
                {
138
                    title: __("Item count"),
139
                    data: "name",
140
                    searchable: true,
141
                    orderable: true,
142
                    render(data, type, row, meta) {
143
                        return escape_str(row.name)
144
                    },
145
                },
146
                {
147
                    title: __("Bibliographic record count"),
148
                    data: "name",
149
                    searchable: true,
150
                    orderable: true,
151
                    render(data, type, row, meta) {
152
                        return escape_str(row.name)
153
                    },
154
                },
155
                {
156
                    title: __("Items expected"),
157
                    data: "name",
158
                    searchable: true,
159
                    orderable: true,
160
                    render(data, type, row, meta) {
161
                        return escape_str(row.name)
162
                    },
163
                },
164
                {
165
                    title: __("Created by"),
166
                    data: "creator_id",
167
                    searchable: true,
168
                    orderable: true,
169
                },
170
                {
171
                    title: __("Date"),
172
                    data: "creation_date",
173
                    searchable: true,
174
                    orderable: true,
175
                },
176
                {
177
                    title: __("Basket group"),
178
                    data: "basket_group_id",
179
                    searchable: true,
180
                    orderable: true,
181
                },
182
                {
183
                    title: __("Internal note"),
184
                    data: "note",
185
                    searchable: true,
186
                    orderable: true,
187
                },
188
                {
189
                    title: __("Close"),
190
                    data: "close_date",
191
                    searchable: true,
192
                    orderable: true,
193
                },
194
            ]
195
        },
196
    },
197
    components: { KohaTable },
198
    props: {
199
        basketCount: {
200
            type: String,
201
            default: "0",
202
        },
203
        vendorId: {
204
            type: Number,
205
        },
206
    },
207
    name: "VendorBaskets",
208
    emits: ["select-vendor", "close"],
209
}
210
</script>
211
212
<style scoped>
213
.filters > label[for="by_mine_filter"],
214
.filters > input[type="checkbox"],
215
.filters > input[type="button"] {
216
    margin-left: 1rem;
217
}
218
</style>
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/components/Vendors/VendorList.vue (-3 / +3 lines)
Lines 214-225 export default { Link Here
214
                    title: __("Baskets"),
214
                    title: __("Baskets"),
215
                    data: "baskets",
215
                    data: "baskets",
216
                    searchable: false,
216
                    searchable: false,
217
                    orderable: true,
217
                    orderable: false,
218
                    render(data, type, row, meta) {
218
                    render(data, type, row, meta) {
219
                        return row.baskets.length
219
                        return row.baskets.length
220
                            ? '<a href="/cgi-bin/koha/vendors/' +
220
                            ? '<a href="/cgi-bin/koha/vendors/' +
221
                                  row.id +
221
                                  row.id +
222
                                  '" class="show">' +
222
                                  '/baskets" class="show">' +
223
                                  escape_str(
223
                                  escape_str(
224
                                      `${row.baskets.length} basket(s)`
224
                                      `${row.baskets.length} basket(s)`
225
                                  ) +
225
                                  ) +
Lines 231-237 export default { Link Here
231
                    title: __("Subscriptions"),
231
                    title: __("Subscriptions"),
232
                    data: "subscriptions",
232
                    data: "subscriptions",
233
                    searchable: false,
233
                    searchable: false,
234
                    orderable: true,
234
                    orderable: false,
235
                    render(data, type, row, meta) {
235
                    render(data, type, row, meta) {
236
                        return row.subscriptions.length
236
                        return row.subscriptions.length
237
                            ? '<a href="/cgi-bin/koha/serials/serials-search.pl?bookseller_filter=' +
237
                            ? '<a href="/cgi-bin/koha/serials/serials-search.pl?bookseller_filter=' +
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/components/Vendors/VendorShow.vue (-21 / +51 lines)
Lines 28-54 Link Here
28
        <h1>
28
        <h1>
29
            {{ vendor.name }}
29
            {{ vendor.name }}
30
        </h1>
30
        </h1>
31
        <div class="row">
31
        <template v-if="!basketView">
32
            <div class="col-sm-6">
32
            <div class="row">
33
                <VendorDetails :vendor="vendor" :display="true" />
33
                <div class="col-sm-6">
34
                <VendorOrderingInformation :vendor="vendor" :display="true" />
34
                    <VendorDetails :vendor="vendor" :display="true" />
35
                <VendorInterfaces
35
                    <VendorOrderingInformation
36
                    :vendor="vendor"
36
                        :vendor="vendor"
37
                    v-if="vendor.interfaces.length > 0"
37
                        :display="true"
38
                    :display="true"
38
                    />
39
                />
39
                    <VendorInterfaces
40
                        :vendor="vendor"
41
                        v-if="vendor.interfaces.length > 0"
42
                        :display="true"
43
                    />
44
                </div>
45
                <div class="col-sm-6">
46
                    <VendorContacts :vendor="vendor" :display="true" />
47
                    <VendorSubscriptions :vendor="vendor" />
48
                </div>
40
            </div>
49
            </div>
41
            <div class="col-sm-6">
50
            <div
42
                <VendorContacts :vendor="vendor" :display="true" />
51
                class="page-section rows"
43
                <VendorSubscriptions :vendor="vendor" />
52
                v-if="vendor.contracts && vendor.contracts.length > 0"
53
            >
54
                <VendorContracts :vendor="vendor" />
44
            </div>
55
            </div>
45
        </div>
56
        </template>
46
        <div
57
        <template v-if="basketView">
47
            class="page-section rows"
58
            <h2>{{ $__("Baskets") }}</h2>
48
            v-if="vendor.contracts && vendor.contracts.length > 0"
59
            <VendorBaskets :basketCount="basketCount" :vendorId="vendor.id" />
49
        >
60
        </template>
50
            <VendorContracts :vendor="vendor" />
51
        </div>
52
    </div>
61
    </div>
53
</template>
62
</template>
54
63
Lines 64-69 import VendorInterfaces from "./VendorInterfaces.vue" Link Here
64
import VendorContacts from "./VendorContacts.vue"
73
import VendorContacts from "./VendorContacts.vue"
65
import VendorSubscriptions from "./VendorSubscriptions.vue"
74
import VendorSubscriptions from "./VendorSubscriptions.vue"
66
import VendorContracts from "./VendorContracts.vue"
75
import VendorContracts from "./VendorContracts.vue"
76
import VendorBaskets from "./VendorBaskets.vue"
67
77
68
export default {
78
export default {
69
    setup() {
79
    setup() {
Lines 83-99 export default { Link Here
83
        return {
93
        return {
84
            vendor: null,
94
            vendor: null,
85
            initialized: false,
95
            initialized: false,
96
            basketView: false,
97
            basketCount: null,
86
        }
98
        }
87
    },
99
    },
88
    beforeRouteEnter(to, from, next) {
100
    beforeRouteEnter(to, from, next) {
89
        next(vm => {
101
        next(vm => {
90
            vm.getVendor(to.params.vendor_id)
102
            if (to.path.includes("basket")) {
103
                vm.basketView = true
104
                vm.getVendor(to.params.vendor_id).then(() =>
105
                    vm.getBasketCount(to.params.vendor_id)
106
                )
107
            } else {
108
                vm.getVendor(to.params.vendor_id)
109
            }
91
        })
110
        })
92
    },
111
    },
93
    methods: {
112
    methods: {
94
        async getVendor(vendor_id) {
113
        async getVendor(vendor_id) {
95
            const client = APIClient.acquisition
114
            const client = APIClient.acquisition
96
            client.vendors.get(vendor_id).then(
115
            await client.vendors.get(vendor_id).then(
97
                vendor => {
116
                vendor => {
98
                    this.vendor = vendor
117
                    this.vendor = vendor
99
                    this.initialized = true
118
                    this.initialized = true
Lines 101-106 export default { Link Here
101
                error => {}
120
                error => {}
102
            )
121
            )
103
        },
122
        },
123
        async getBasketCount(booksellerid) {
124
            const client = APIClient.acquisition
125
            await client.baskets.count({ booksellerid }).then(
126
                count => {
127
                    this.basketCount = count
128
                    this.initialized = true
129
                },
130
                error => {}
131
            )
132
        },
104
    },
133
    },
105
    components: {
134
    components: {
106
        Toolbar,
135
        Toolbar,
Lines 111-116 export default { Link Here
111
        VendorContacts,
140
        VendorContacts,
112
        VendorSubscriptions,
141
        VendorSubscriptions,
113
        VendorContracts,
142
        VendorContracts,
143
        VendorBaskets,
114
    },
144
    },
115
    name: "VendorShow",
145
    name: "VendorShow",
116
}
146
}
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/fetch/acquisition-api-client.js (-1 / +16 lines)
Lines 14-20 export class AcquisitionAPIClient extends HttpClient { Link Here
14
                    endpoint: "vendors/" + id,
14
                    endpoint: "vendors/" + id,
15
                    headers: {
15
                    headers: {
16
                        "x-koha-embed":
16
                        "x-koha-embed":
17
                            "baskets,aliases,subscriptions,interfaces,contacts,contracts",
17
                            "aliases,subscriptions,interfaces,contacts,contracts",
18
                    },
18
                    },
19
                }),
19
                }),
20
            getAll: (query, params) =>
20
            getAll: (query, params) =>
Lines 52-57 export class AcquisitionAPIClient extends HttpClient { Link Here
52
                }),
52
                }),
53
        };
53
        };
54
    }
54
    }
55
56
    get baskets() {
57
        return {
58
            count: (query = {}) =>
59
                this.count({
60
                    endpoint:
61
                        "baskets?" +
62
                        new URLSearchParams({
63
                            _page: 1,
64
                            _per_page: 1,
65
                            ...(query && { q: JSON.stringify(query) }),
66
                        }),
67
                }),
68
        };
69
    }
55
}
70
}
56
71
57
export default AcquisitionAPIClient;
72
export default AcquisitionAPIClient;
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/routes/acquisitions.js (-1 / +6 lines)
Lines 50-55 export const routes = [ Link Here
50
                        component: markRaw(VendorFormAdd),
50
                        component: markRaw(VendorFormAdd),
51
                        title: $__("Edit vendor"),
51
                        title: $__("Edit vendor"),
52
                    },
52
                    },
53
                    {
54
                        path: ":vendor_id/baskets",
55
                        name: "VendorShowBaskets",
56
                        component: markRaw(VendorShow),
57
                        title: $__("Baskets"),
58
                    },
53
                ],
59
                ],
54
            },
60
            },
55
        ],
61
        ],
56
- 

Return to bug 38010