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

(-)a/acqui/booksellers.pl (+10 lines)
Lines 172-175 $template->param( Link Here
172
);
172
);
173
$template->{VARS}->{'allbaskets'} = $allbaskets;
173
$template->{VARS}->{'allbaskets'} = $allbaskets;
174
174
175
176
177
$template->param(
178
    loop_suppliers => $loop_suppliers,
179
    supplier       => ( $booksellerid || $supplier ),
180
    count          => $supplier_count,
181
    has_budgets          => $has_budgets,
182
);
183
$template->{VARS}->{'allbaskets'} = $allbaskets;
184
175
output_html_with_http_headers $query, $cookie, $template->output;
185
output_html_with_http_headers $query, $cookie, $template->output;
(-)a/acqui/vendors.pl (+54 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# Copyright 2024 PTFS Europe
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it
8
# under the terms of the GNU General Public License as published by
9
# the Free Software Foundation; either version 3 of the License, or
10
# (at your option) any later version.
11
#
12
# Koha is distributed in the hope that it will be useful, but
13
# WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
16
#
17
# You should have received a copy of the GNU General Public License
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
19
20
use Modern::Perl;
21
use C4::Auth   qw( get_template_and_user haspermission );
22
use C4::Output qw( output_html_with_http_headers );
23
use CGI        qw ( -utf8 );
24
25
use C4::Context;
26
27
use Koha::Acquisition::Currencies;
28
29
my $query = CGI->new;
30
my ( $template, $loggedinuser, $cookie, $userflags ) = get_template_and_user(
31
    {
32
        template_name => 'acqui/vendors.tt',
33
        query         => $query,
34
        type          => 'intranet',
35
        flagsrequired => { acquisition => '*' },
36
    }
37
);
38
39
my $user_permissions = {};
40
my $var_data         = $template->{VARS};
41
foreach my $key ( keys %{$var_data} ) {
42
    $user_permissions->{$key} = $var_data->{$key} if ( $key =~ /CAN_user_(.*)/ );
43
}
44
45
my @gst_values = map { option => $_ + 0.0 }, split( '\|', C4::Context->preference("TaxRates") );
46
47
$template->param(
48
    user_permissions => $user_permissions,
49
    currencies       => Koha::Acquisition::Currencies->search->unblessed,
50
    gst_values       => \@gst_values,
51
    edifact          => C4::Context->preference('EDIFACT')
52
);
53
54
output_html_with_http_headers $query, $cookie, $template->output;
(-)a/api/v1/swagger/definitions/vendor.yaml (+3 lines)
Lines 119-124 properties: Link Here
119
    description: List of aliases
119
    description: List of aliases
120
    items:
120
    items:
121
      $ref: "vendor_alias.yaml"
121
      $ref: "vendor_alias.yaml"
122
  baskets:
123
    type: array
124
    description: List of baskets
122
  subscriptions_count:
125
  subscriptions_count:
123
    type:
126
    type:
124
      - integer
127
      - integer
(-)a/api/v1/swagger/paths/acquisitions_vendors.yaml (+1 lines)
Lines 35-40 Link Here
35
          type: string
35
          type: string
36
          enum:
36
          enum:
37
            - aliases
37
            - aliases
38
            - baskets
38
            - subscriptions+count
39
            - subscriptions+count
39
        collectionFormat: csv
40
        collectionFormat: csv
40
    responses:
41
    responses:
(-)a/debian/templates/apache-shared-intranet.conf (+1 lines)
Lines 24-29 RewriteRule ^/cgi-bin/koha/erm/.*$ /cgi-bin/koha/erm/erm.pl [PT] Link Here
24
RewriteCond %{REQUEST_URI} !^/cgi-bin/koha/preservation/.*.pl$
24
RewriteCond %{REQUEST_URI} !^/cgi-bin/koha/preservation/.*.pl$
25
RewriteRule ^/cgi-bin/koha/preservation/.*$ /cgi-bin/koha/preservation/home.pl [PT]
25
RewriteRule ^/cgi-bin/koha/preservation/.*$ /cgi-bin/koha/preservation/home.pl [PT]
26
RewriteRule ^/cgi-bin/koha/admin/record_sources(.*)?$ /cgi-bin/koha/admin/record_sources.pl$1 [PT]
26
RewriteRule ^/cgi-bin/koha/admin/record_sources(.*)?$ /cgi-bin/koha/admin/record_sources.pl$1 [PT]
27
RewriteRule ^/cgi-bin/koha/vendors(.*)?$ /cgi-bin/koha/acqui/vendors.pl$1 [PT]
27
28
28
Alias "/api" "/usr/share/koha/api"
29
Alias "/api" "/usr/share/koha/api"
29
<Directory "/usr/share/koha/api">
30
<Directory "/usr/share/koha/api">
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/acquisitions-toolbar.inc (-1 / +1 lines)
Lines 30-36 Link Here
30
                <div class="btn-group"><a class="btn btn-default" id="receive" href="/cgi-bin/koha/acqui/parcels.pl?booksellerid=[% booksellerid | html %]"><i class="fa fa-inbox"></i> Receive shipments</a></div>
30
                <div class="btn-group"><a class="btn btn-default" id="receive" href="/cgi-bin/koha/acqui/parcels.pl?booksellerid=[% booksellerid | html %]"><i class="fa fa-inbox"></i> Receive shipments</a></div>
31
            [% END %]
31
            [% END %]
32
        [% ELSIF ( CAN_user_acquisition_vendors_manage ) %]
32
        [% ELSIF ( CAN_user_acquisition_vendors_manage ) %]
33
            <div class="btn-group"><a class="btn btn-default" href="/cgi-bin/koha/acqui/supplier.pl?op=enter"><i class="fa fa-plus"></i> New vendor</a></div>
33
            <div class="btn-group"><a class="btn btn-default" href="/cgi-bin/koha/vendors"><i class="fa fa-plus"></i> New vendor</a></div>
34
        [% END %]
34
        [% END %]
35
</div>
35
</div>
36
<!-- / acquisitions-toolbar.inc -->
36
<!-- / acquisitions-toolbar.inc -->
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/acqui-home.tt (-6 / +2 lines)
Lines 49-60 Link Here
49
    <div class="col">
49
    <div class="col">
50
<div id="acqui_acqui_home_order">
50
<div id="acqui_acqui_home_order">
51
    <fieldset>
51
    <fieldset>
52
        <legend>Search vendors</legend>
52
        <legend>View vendors</legend>
53
        <form name="findsupplier" action="/cgi-bin/koha/acqui/booksellers.pl" method="get">
53
        <a href="/cgi-bin/koha/vendors" class="btn btn-default">Vendor list</a>
54
            <p><label for="supplierpage">Vendor: </label><input type="text" size="25" name="supplier" id="supplierpage" class="focus" />
55
            <input type="submit" class="btn btn-primary" value="Search" />
56
            </p>
57
        </form>
58
    </fieldset>
54
    </fieldset>
59
</div>
55
</div>
60
</div>
56
</div>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/booksellers.tt (-1 / +1 lines)
Lines 13-19 Link Here
13
[% INCLUDE 'doc-head-close.inc' %]
13
[% INCLUDE 'doc-head-close.inc' %]
14
<style>
14
<style>
15
#vendors td{
15
#vendors td{
16
	vertical-align: top;
16
    vertical-align: top;
17
}
17
}
18
</style>
18
</style>
19
</head>
19
</head>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/vendors.tt (+47 lines)
Line 0 Link Here
1
[% USE raw %]
2
[% USE To %]
3
[% USE Asset %]
4
[% USE KohaDates %]
5
[% USE TablesSettings %]
6
[% PROCESS 'i18n.inc' %]
7
[% SET footerjs = 1 %]
8
[% PROCESS 'patron-search.inc' %]
9
[% INCLUDE 'doc-head-open.inc' %]
10
<title>[% FILTER collapse %]
11
    [% t("Vendors") | html %] &rsaquo;
12
    [% t("Koha") | html %]
13
[% END %]</title>
14
[% INCLUDE 'doc-head-close.inc' %]
15
</head>
16
17
<body id="acq_booksellers" class="acq">
18
[% WRAPPER 'header.inc' %]
19
    [% INCLUDE 'acquisitions-search.inc' %]
20
[% END %]
21
22
<div id="__vendors"> <!-- this is closed in intranet-bottom.inc -->
23
24
[% MACRO jsinclude BLOCK %]
25
    [% INCLUDE 'calendar.inc' %]
26
    [% INCLUDE 'datatables.inc' %]
27
    [% INCLUDE 'columns_settings.inc' %]
28
    [% INCLUDE 'js-patron-format.inc' %]
29
    [% INCLUDE 'js-date-format.inc' %]
30
31
    <script>
32
        const userPermissions = [% To.json(user_permissions) | $raw %];
33
        const currencies = [% To.json(currencies) | $raw %];
34
        const gstValues = [% To.json(gst_values) | $raw %];
35
        const edifact = [% To.json(edifact) | $raw %]
36
        const viewBaskets = [% To.json(viewbaskets) | $raw %]
37
    </script>
38
39
40
    [% Asset.js("js/vue/dist/acquisitions.js") | $raw %]
41
    [% INCLUDE 'select2.inc' %]
42
    [% SET columns = ['cardnumber','name','category','branch','action'] %]
43
    [% PROCESS patron_search_modal columns => columns, modal_title => t("Select user") %]
44
    [% PROCESS patron_search_js columns => columns, filter => erm_users, actions => ["select"], preview_on_name_click => 1 %]
45
46
[% END %]
47
[% INCLUDE 'intranet-bottom.inc' %]
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/components/Vendors/Home.vue (+9 lines)
Line 0 Link Here
1
<template>
2
    <h1>Vendors</h1>
3
</template>
4
5
<script>
6
export default {}
7
</script>
8
9
<style></style>
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/components/Vendors/Main.vue (+154 lines)
Line 0 Link Here
1
<template>
2
    <div v-if="initialized">
3
        <div id="sub-header">
4
            <Breadcrumbs />
5
            <Help />
6
        </div>
7
        <div class="main container-fluid">
8
            <div class="row">
9
                <div class="col-md-10 order-md-2 order-sm-1">
10
                    <main>
11
                        <Dialog />
12
                        <router-view />
13
                    </main>
14
                </div>
15
16
                <div class="col-md-2 order-sm-2 order-md-1">
17
                    <LeftMenu :title="$__('Vendors')"></LeftMenu>
18
                </div>
19
            </div>
20
        </div>
21
    </div>
22
    <div class="main container-fluid" v-else>
23
        <Dialog />
24
    </div>
25
</template>
26
27
<script>
28
import { inject } from "vue"
29
import Breadcrumbs from "../Breadcrumbs.vue"
30
import Help from "../Help.vue"
31
import LeftMenu from "../LeftMenu.vue"
32
import Dialog from "../Dialog.vue"
33
import "vue-select/dist/vue-select.css"
34
import { storeToRefs } from "pinia"
35
import { APIClient } from "../../fetch/api-client"
36
37
export default {
38
    setup() {
39
        const vendorStore = inject("vendorStore")
40
41
        const AVStore = inject("AVStore")
42
43
        const mainStore = inject("mainStore")
44
45
        const { loading, loaded, setError } = mainStore
46
47
        return {
48
            vendorStore,
49
            AVStore,
50
            setError,
51
            loading,
52
            loaded,
53
            AVStore,
54
        }
55
    },
56
    beforeCreate() {
57
        this.loading()
58
59
        const fetchConfig = () => {
60
            let promises = []
61
62
            const av_client = APIClient.authorised_values
63
            const authorised_values = {
64
                av_vendor_types: "VENDOR_TYPE",
65
                av_vendor_interface_types: "VENDOR_INTERFACE_TYPE",
66
            }
67
68
            let av_cat_array = Object.keys(authorised_values).map(function (
69
                av_cat
70
            ) {
71
                return '"' + authorised_values[av_cat] + '"'
72
            })
73
74
            promises.push(
75
                av_client.values
76
                    .getCategoriesWithValues(av_cat_array)
77
                    .then(av_categories => {
78
                        Object.entries(authorised_values).forEach(
79
                            ([av_var, av_cat]) => {
80
                                const av_match = av_categories.find(
81
                                    element => element.category_name == av_cat
82
                                )
83
                                this.AVStore[av_var] =
84
                                    av_match.authorised_values
85
                            }
86
                        )
87
                    })
88
            )
89
90
            return Promise.all(promises)
91
        }
92
93
        fetchConfig().then(() => {
94
            this.vendorStore.currencies = currencies
95
            this.vendorStore.gstValues = gstValues.map(gv => {
96
                return {
97
                    label: `${(gv.option * 100).toFixed(2)}%`,
98
                    value: gv.option,
99
                }
100
            })
101
            this.loaded()
102
            this.initialized = true
103
        })
104
    },
105
    data() {
106
        return {
107
            initialized: true,
108
        }
109
    },
110
    methods: {},
111
    components: {
112
        Breadcrumbs,
113
        Dialog,
114
        Help,
115
        LeftMenu,
116
    },
117
}
118
</script>
119
120
<style>
121
#menu ul ul,
122
#navmenulist ul ul {
123
    padding-left: 2em;
124
    font-size: 100%;
125
}
126
127
form .v-select {
128
    display: inline-block;
129
    background-color: white;
130
    width: 30%;
131
}
132
133
.v-select,
134
input:not([type="submit"]):not([type="search"]):not([type="button"]):not([type="checkbox"]):not([type="radio"]),
135
textarea {
136
    border-color: rgba(60, 60, 60, 0.26);
137
    border-width: 1px;
138
    border-radius: 4px;
139
    min-width: 30%;
140
}
141
.flatpickr-input {
142
    width: 30%;
143
}
144
#navmenulist ul li a.current.disabled {
145
    background-color: inherit;
146
    border-left: 5px solid #e6e6e6;
147
    color: #000;
148
}
149
#navmenulist ul li a.disabled {
150
    color: #666;
151
    pointer-events: none;
152
    font-weight: 700;
153
}
154
</style>
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/components/Vendors/VendorList.vue (+250 lines)
Line 0 Link Here
1
<template>
2
    <div v-if="!initialized">{{ $__("Loading") }}</div>
3
    <div v-else id="vendors_list">
4
        <Toolbar>
5
            <ToolbarButton
6
                :to="{ name: 'VendorList' }"
7
                icon="plus"
8
                :title="$__('New vendor')"
9
            />
10
        </Toolbar>
11
        <div v-if="vendor_count > 0" class="page-section">
12
            <KohaTable
13
                ref="table"
14
                v-bind="tableOptions"
15
                @show="doShow"
16
                @edit="doEdit"
17
                @delete="doDelete"
18
                @select="doSelect"
19
            ></KohaTable>
20
        </div>
21
        <div v-else class="alert alert-info">
22
            {{ $__("There are no vendors defined") }}
23
        </div>
24
    </div>
25
</template>
26
27
<script>
28
import flatPickr from "vue-flatpickr-component"
29
import Toolbar from "../Toolbar.vue"
30
import ToolbarButton from "../ToolbarButton.vue"
31
import { inject, ref, reactive } from "vue"
32
import { APIClient } from "../../fetch/api-client.js"
33
import { storeToRefs } from "pinia"
34
import { build_url } from "../../composables/datatables"
35
import KohaTable from "../KohaTable.vue"
36
37
export default {
38
    setup() {
39
        const vendorStore = inject("vendorStore")
40
        const { vendors } = storeToRefs(vendorStore)
41
42
        const { setConfirmationDialog, setMessage } = inject("mainStore")
43
44
        const { get_lib_from_av, map_av_dt_filter } = inject("AVStore")
45
46
        const table = ref()
47
48
        // const filters = reactive({
49
        //     by_expired: false,
50
        //     max_expiration_date: "",
51
        //     by_mine: false,
52
        // })
53
        return {
54
            vendors,
55
            get_lib_from_av,
56
            map_av_dt_filter,
57
            table,
58
            setConfirmationDialog,
59
            setMessage,
60
            escape_str,
61
            // filters,
62
        }
63
    },
64
    data() {
65
        return {
66
            fp_config: flatpickr_defaults,
67
            vendor_count: 0,
68
            initialized: false,
69
            tableOptions: {
70
                columns: this.getTableColumns(),
71
                options: { embed: "aliases,baskets,subscriptions" },
72
                url: () => this.table_url(),
73
                add_filters: true,
74
                filters_options: {
75
                    1: [
76
                        { _id: 0, _str: this.$__("Inactive") },
77
                        { _id: 1, _str: this.$__("Active") },
78
                    ],
79
                    ...(this.map_av_dt_filter("av_vendor_types").length && {
80
                        2: () => this.map_av_dt_filter("av_vendor_types"),
81
                    }),
82
                },
83
                actions: {
84
                    0: ["show"],
85
                    "-1": ["edit", "delete"],
86
                },
87
            },
88
            before_route_entered: false,
89
            building_table: false,
90
        }
91
    },
92
    beforeRouteEnter(to, from, next) {
93
        next(vm => {
94
            vm.getVendorCount().then(() => (vm.initialized = true))
95
        })
96
    },
97
    methods: {
98
        async getVendorCount() {
99
            const client = APIClient.acquisition
100
            await client.vendors.count().then(
101
                count => {
102
                    this.vendor_count = count
103
                },
104
                error => {}
105
            )
106
        },
107
        doShow: function ({ id }, dt, event) {
108
            event.preventDefault()
109
            this.$router.push({
110
                name: "VendorShow",
111
                params: { vendor_id: id },
112
            })
113
        },
114
        doEdit: function ({ id }, dt, event) {
115
            this.$router.push({
116
                name: "Home",
117
            })
118
        },
119
        doDelete: function (vendor, dt, event) {
120
            this.setConfirmationDialog(
121
                {
122
                    title: this.$__(
123
                        "Are you sure you want to remove this vendor?"
124
                    ),
125
                    message: vendor.name,
126
                    accept_label: this.$__("Yes, delete"),
127
                    cancel_label: this.$__("No, do not delete"),
128
                },
129
                () => {
130
                    const client = APIClient.erm
131
                    client.vendors.delete(vendor.id).then(
132
                        success => {
133
                            this.setMessage(
134
                                this.$__("Vendor %s deleted").format(
135
                                    vendor.name
136
                                ),
137
                                true
138
                            )
139
                            dt.draw()
140
                        },
141
                        error => {}
142
                    )
143
                }
144
            )
145
        },
146
        doSelect: function (vendor, dt, event) {
147
            this.$emit("select-vendor", vendor.id)
148
            this.$emit("close")
149
        },
150
        table_url: function () {
151
            let url = "/api/v1/acquisitions/vendors"
152
            return url
153
        },
154
        getTableColumns: function () {
155
            const escape_str = this.escape_str
156
            const get_lib_from_av = this.get_lib_from_av
157
158
            return [
159
                {
160
                    title: __("Name"),
161
                    data: "me.name:me.id",
162
                    searchable: true,
163
                    orderable: true,
164
                    render: function (data, type, row, meta) {
165
                        return (
166
                            '<a href="/cgi-bin/koha/vendors/' +
167
                            row.id +
168
                            '" class="show">' +
169
                            escape_str(`${row.name} (#${row.id})`) +
170
                            "</a>"
171
                        )
172
                    },
173
                },
174
                {
175
                    title: __("Status"),
176
                    data: "active",
177
                    searchable: true,
178
                    orderable: true,
179
                    render: function (data, type, row, meta) {
180
                        return escape_str(
181
                            row.active ? __("Active") : __("Inactive")
182
                        )
183
                    },
184
                },
185
                {
186
                    title: __("Type"),
187
                    data: "type",
188
                    searchable: true,
189
                    orderable: true,
190
                    render(data, type, row, meta) {
191
                        return get_lib_from_av("av_vendor_types", row.type)
192
                    },
193
                },
194
                {
195
                    title: __("Currency"),
196
                    data: "invoice_currency",
197
                    searchable: true,
198
                    orderable: true,
199
                },
200
                {
201
                    title: __("Baskets"),
202
                    data: "baskets",
203
                    searchable: false,
204
                    orderable: true,
205
                    render: function (data, type, row, meta) {
206
                        return row.baskets.length
207
                            ? '<a href="/cgi-bin/koha/vendors/' +
208
                                  row.id +
209
                                  '" class="show">' +
210
                                  escape_str(
211
                                      `${row.baskets.length} basket(s)`
212
                                  ) +
213
                                  "</a>"
214
                            : escape_str(__("No baskets"))
215
                    },
216
                },
217
                {
218
                    title: __("Subscriptions"),
219
                    data: "subscriptions",
220
                    searchable: false,
221
                    orderable: true,
222
                    render: function (data, type, row, meta) {
223
                        return row.subscriptions.length
224
                            ? '<a href="/cgi-bin/koha/serials/serials-search.pl?bookseller_filter=' +
225
                                  row.name +
226
                                  "&searched=1" +
227
                                  '" class="show">' +
228
                                  escape_str(
229
                                      `${row.subscriptions.length} subscription(s)`
230
                                  ) +
231
                                  "</a>"
232
                            : escape_str(__("No subscriptions"))
233
                    },
234
                },
235
            ]
236
        },
237
    },
238
    components: { flatPickr, Toolbar, ToolbarButton, KohaTable },
239
    name: "VendorList",
240
    emits: ["select-vendor", "close"],
241
}
242
</script>
243
244
<style scoped>
245
.filters > label[for="by_mine_filter"],
246
.filters > input[type="checkbox"],
247
.filters > input[type="button"] {
248
    margin-left: 1rem;
249
}
250
</style>
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/fetch/acquisition-api-client.js (-1 / +32 lines)
Lines 9-23 export class AcquisitionAPIClient extends HttpClient { Link Here
9
9
10
    get vendors() {
10
    get vendors() {
11
        return {
11
        return {
12
            get: id =>
13
                this.get({
14
                    endpoint: "vendors/" + id,
15
                    headers: {
16
                        "x-koha-embed": "aliases",
17
                    },
18
                }),
12
            getAll: (query, params) =>
19
            getAll: (query, params) =>
13
                this.getAll({
20
                this.getAll({
14
                    endpoint: "vendors",
21
                    endpoint: "vendors",
15
                    query,
22
                    query,
16
                    params,
23
                    params,
17
                    headers: {
24
                    headers: {
18
                        "x-koha-embed": "aliases",
25
                        "x-koha-embed": "aliases,baskets",
19
                    },
26
                    },
20
                }),
27
                }),
28
            delete: id =>
29
                this.delete({
30
                    endpoint: "vendors/" + id,
31
                }),
32
            create: vendor =>
33
                this.post({
34
                    endpoint: "vendors",
35
                    body: vendor,
36
                }),
37
            update: (vendor, id) =>
38
                this.put({
39
                    endpoint: "vendors/" + id,
40
                    body: vendor,
41
                }),
42
            count: (query = {}) =>
43
                this.count({
44
                    endpoint:
45
                        "vendors?" +
46
                        new URLSearchParams({
47
                            _page: 1,
48
                            _per_page: 1,
49
                            ...(query && { q: JSON.stringify(query) }),
50
                        }),
51
                }),
21
        };
52
        };
22
    }
53
    }
23
}
54
}
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/modules/vendors.ts (+62 lines)
Line 0 Link Here
1
import { createApp } from "vue";
2
import { createWebHistory, createRouter } from "vue-router";
3
import { createPinia } from "pinia";
4
5
import { library } from "@fortawesome/fontawesome-svg-core";
6
import {
7
    faPlus,
8
    faMinus,
9
    faPencil,
10
    faTrash,
11
    faSpinner,
12
} from "@fortawesome/free-solid-svg-icons";
13
import { FontAwesomeIcon } from "@fortawesome/vue-fontawesome";
14
import vSelect from "vue-select";
15
16
library.add(faPlus, faMinus, faPencil, faTrash, faSpinner);
17
18
import App from "../components/Vendors/Main.vue";
19
20
import { routes as routesDef } from "../routes/vendors";
21
22
import { useMainStore } from "../stores/main";
23
import { useVendorStore } from "../stores/vendors";
24
import { useAVStore } from "../stores/authorised-values";
25
import { useNavigationStore } from "../stores/navigation";
26
import i18n from "../i18n";
27
28
const pinia = createPinia();
29
30
const mainStore = useMainStore(pinia);
31
const AVStore = useAVStore(pinia);
32
const navigationStore = useNavigationStore(pinia);
33
const routes = navigationStore.setRoutes(routesDef);
34
35
const router = createRouter({
36
    history: createWebHistory(),
37
    linkActiveClass: "current",
38
    routes,
39
});
40
41
const app = createApp(App);
42
43
const rootComponent = app
44
    .use(i18n)
45
    .use(pinia)
46
    .use(router)
47
    .component("font-awesome-icon", FontAwesomeIcon)
48
    .component("v-select", vSelect);
49
50
app.config.unwrapInjectedRef = true;
51
app.provide("vendorStore", useVendorStore(pinia));
52
app.provide("mainStore", mainStore);
53
app.provide("AVStore", AVStore);
54
app.provide("navigationStore", navigationStore);
55
56
app.mount("#__vendors");
57
58
const { removeMessages } = mainStore;
59
router.beforeEach((to, from) => {
60
    navigationStore.$patch({ current: to.matched, params: to.params || {} });
61
    removeMessages(); // This will actually flag the messages as displayed already
62
});
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/routes/vendors.js (+43 lines)
Line 0 Link Here
1
import { markRaw } from "vue";
2
3
import Home from "../components/Vendors/Home.vue";
4
import VendorList from "../components/Vendors/VendorList.vue";
5
import VendorShow from "../components/Vendors/VendorShow.vue";
6
7
import { $__ } from "../i18n";
8
9
export const routes = [
10
    {
11
        path: "/cgi-bin/koha/acqui/booksellers.pl",
12
        is_default: true,
13
        is_base: true,
14
        title: $__("Vendors"),
15
        children: [
16
            {
17
                path: "",
18
                name: "Home",
19
                component: markRaw(Home),
20
                is_navigation_item: false,
21
            },
22
            {
23
                path: "/cgi-bin/koha/vendors",
24
                title: $__("Vendor list"),
25
                icon: "fa fa-check-circle",
26
                is_end_node: true,
27
                children: [
28
                    {
29
                        path: "",
30
                        name: "VendorList",
31
                        component: markRaw(VendorList),
32
                    },
33
                    {
34
                        path: ":vendor_id",
35
                        name: "VendorShow",
36
                        component: markRaw(VendorShow),
37
                        title: $__("Show vendor"),
38
                    },
39
                ],
40
            },
41
        ],
42
    },
43
];
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/stores/authorised-values.js (+2 lines)
Lines 42-47 export const useAVStore = defineStore("authorised_values", { Link Here
42
        av_database_reports_metrics: [],
42
        av_database_reports_metrics: [],
43
        av_title_reports_metrics: [],
43
        av_title_reports_metrics: [],
44
        av_item_reports_metrics: [],
44
        av_item_reports_metrics: [],
45
        av_vendor_types: [],
46
        av_vendor_interface_types: [],
45
    }),
47
    }),
46
    actions: {
48
    actions: {
47
        get_lib_from_av(arr_name, av) {
49
        get_lib_from_av(arr_name, av) {
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/stores/vendors.js (+7 lines)
Lines 3-7 import { defineStore } from "pinia"; Link Here
3
export const useVendorStore = defineStore("vendors", {
3
export const useVendorStore = defineStore("vendors", {
4
    state: () => ({
4
    state: () => ({
5
        vendors: [],
5
        vendors: [],
6
        currencies: [],
7
        gstValues: [],
8
        config: {
9
            settings: {
10
                edifact: false,
11
            },
12
        },
6
    }),
13
    }),
7
});
14
});
(-)a/rspack.config.js (-1 / +2 lines)
Lines 13-18 module.exports = { Link Here
13
            "./koha-tmpl/intranet-tmpl/prog/js/vue/modules/preservation.ts",
13
            "./koha-tmpl/intranet-tmpl/prog/js/vue/modules/preservation.ts",
14
        "admin/record_sources":
14
        "admin/record_sources":
15
            "./koha-tmpl/intranet-tmpl/prog/js/vue/modules/admin/record_sources.ts",
15
            "./koha-tmpl/intranet-tmpl/prog/js/vue/modules/admin/record_sources.ts",
16
        vendors: "./koha-tmpl/intranet-tmpl/prog/js/vue/modules/vendors.ts",
16
    },
17
    },
17
    output: {
18
    output: {
18
        filename: "[name].js",
19
        filename: "[name].js",
Lines 72-75 module.exports = { Link Here
72
        "datatables.net-buttons/js/buttons.print": "DataTable",
73
        "datatables.net-buttons/js/buttons.print": "DataTable",
73
        "datatables.net-buttons/js/buttons.colVis": "DataTable",
74
        "datatables.net-buttons/js/buttons.colVis": "DataTable",
74
    },
75
    },
75
};
76
};
(-)a/webpack.config.js (-1 / +1 lines)
Lines 8-13 module.exports = { Link Here
8
    erm: "./koha-tmpl/intranet-tmpl/prog/js/vue/modules/erm.ts",
8
    erm: "./koha-tmpl/intranet-tmpl/prog/js/vue/modules/erm.ts",
9
    preservation: "./koha-tmpl/intranet-tmpl/prog/js/vue/modules/preservation.ts",
9
    preservation: "./koha-tmpl/intranet-tmpl/prog/js/vue/modules/preservation.ts",
10
    "admin/record_sources": "./koha-tmpl/intranet-tmpl/prog/js/vue/modules/admin/record_sources.ts",
10
    "admin/record_sources": "./koha-tmpl/intranet-tmpl/prog/js/vue/modules/admin/record_sources.ts",
11
    vendors: "./koha-tmpl/intranet-tmpl/prog/js/vue/modules/vendors.ts",
11
  },
12
  },
12
  output: {
13
  output: {
13
    filename: "[name].js",
14
    filename: "[name].js",
14
- 

Return to bug 38010