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

(-)a/acqui/booksellers.pl (+8 lines)
Lines 176-179 $template->param( Link Here
176
);
176
);
177
$template->{VARS}->{'allbaskets'} = $allbaskets;
177
$template->{VARS}->{'allbaskets'} = $allbaskets;
178
178
179
$template->param(
180
    loop_suppliers => $loop_suppliers,
181
    supplier       => ( $booksellerid || $supplier ),
182
    count          => $supplier_count,
183
    has_budgets    => $has_budgets,
184
);
185
$template->{VARS}->{'allbaskets'} = $allbaskets;
186
179
output_html_with_http_headers $query, $cookie, $template->output;
187
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 (-1 / +4 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
Lines 126-129 properties: Link Here
126
    description: Number of linked subscriptions
129
    description: Number of linked subscriptions
127
additionalProperties: false
130
additionalProperties: false
128
required:
131
required:
129
  - name
132
  - name
(-)a/api/v1/swagger/paths/acquisitions_vendors.yaml (-1 / +2 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:
Lines 268-271 Link Here
268
          $ref: "../swagger.yaml#/definitions/error"
269
          $ref: "../swagger.yaml#/definitions/error"
269
    x-koha-authorization:
270
    x-koha-authorization:
270
      permissions:
271
      permissions:
271
        acquisition: vendors_manage
272
        acquisition: vendors_manage
(-)a/debian/templates/apache-shared-intranet.conf (-1 / +2 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">
Lines 35-38 Alias "/api" "/usr/share/koha/api" Link Here
35
    RewriteBase /api/
36
    RewriteBase /api/
36
    RewriteCond %{REQUEST_URI} !^/api/v[0-1]+/app.pl
37
    RewriteCond %{REQUEST_URI} !^/api/v[0-1]+/app.pl
37
    RewriteRule ^(v[0-9]+)/(.*)$ /api/$1/app.pl/api/$1/$2 [L]
38
    RewriteRule ^(v[0-9]+)/(.*)$ /api/$1/app.pl/api/$1/$2 [L]
38
</Directory>
39
</Directory>
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/acquisitions-toolbar.inc (-1 / +1 lines)
Lines 33-39 Link Here
33
        [% END %]
33
        [% END %]
34
    [% ELSIF ( CAN_user_acquisition_vendors_manage ) %]
34
    [% ELSIF ( CAN_user_acquisition_vendors_manage ) %]
35
        <div class="btn-group"
35
        <div class="btn-group"
36
            ><a class="btn btn-default" href="/cgi-bin/koha/acqui/supplier.pl?op=enter"><i class="fa fa-plus"></i> New vendor</a></div
36
            ><a class="btn btn-default" href="/cgi-bin/koha/vendors"><i class="fa fa-plus"></i> New vendor</a></div
37
        >
37
        >
38
    [% END %]
38
    [% END %]
39
</div>
39
</div>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/acqui-home.tt (-7 / +2 lines)
Lines 48-60 Link Here
48
        <div class="col">
48
        <div class="col">
49
            <div id="acqui_acqui_home_order">
49
            <div id="acqui_acqui_home_order">
50
                <fieldset>
50
                <fieldset>
51
                    <legend>Search vendors</legend>
51
                    <legend>View vendors</legend>
52
                    <form name="findsupplier" action="/cgi-bin/koha/acqui/booksellers.pl" method="get">
52
                    <a href="/cgi-bin/koha/vendors" class="btn btn-default">Vendor list</a>
53
                        <p
54
                            ><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>
53
                </fieldset>
59
            </div>
54
            </div>
60
        </div>
55
        </div>
(-)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
11
    >[% FILTER collapse %]
12
        [% t("Vendors") | html %]
13
        &rsaquo; [% t("Koha") | html %]
14
    [% END %]</title
15
>
16
[% INCLUDE 'doc-head-close.inc' %]
17
</head>
18
19
<body id="acq_booksellers" class="acq">
20
[% WRAPPER 'header.inc' %]
21
    [% INCLUDE 'acquisitions-search.inc' %]
22
[% END %]
23
24
<div id="__vendors">
25
    <!-- this is closed in intranet-bottom.inc -->
26
27
    [% MACRO jsinclude BLOCK %]
28
        [% INCLUDE 'calendar.inc' %]
29
        [% INCLUDE 'datatables.inc' %]
30
        [% INCLUDE 'columns_settings.inc' %]
31
        [% INCLUDE 'js-patron-format.inc' %]
32
        [% INCLUDE 'js-date-format.inc' %]
33
        <script>
34
            const userPermissions = [% To.json(user_permissions) | $raw %];
35
            const currencies = [% To.json(currencies) | $raw %];
36
            const gstValues = [% To.json(gst_values) | $raw %];
37
            const edifact = [% To.json(edifact) | $raw %]
38
            const viewBaskets = [% To.json(viewbaskets) | $raw %]
39
        </script>
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
    [% END %]
46
    [% INCLUDE 'intranet-bottom.inc' %]</div
47
>
(-)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 (+156 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(
69
                function (av_cat) {
70
                    return '"' + authorised_values[av_cat] + '"';
71
                }
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(
135
        [type="checkbox"]
136
    ):not([type="radio"]),
137
textarea {
138
    border-color: rgba(60, 60, 60, 0.26);
139
    border-width: 1px;
140
    border-radius: 4px;
141
    min-width: 30%;
142
}
143
.flatpickr-input {
144
    width: 30%;
145
}
146
#navmenulist ul li a.current.disabled {
147
    background-color: inherit;
148
    border-left: 5px solid #e6e6e6;
149
    color: #000;
150
}
151
#navmenulist ul li a.disabled {
152
    color: #666;
153
    pointer-events: none;
154
    font-weight: 700;
155
}
156
</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: { _order_by: "name", ...params },
23
                    params: { _order_by: "name", ...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/vendors.js (-1 / +7 lines)
Lines 3-8 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
        config: { settings: {} },
6
        currencies: [],
7
        gstValues: [],
8
        config: {
9
            settings: {
10
                edifact: false,
11
            },
12
        },
7
    }),
13
    }),
8
});
14
});
(-)a/rspack.config.js (+1 lines)
Lines 14-19 module.exports = [ Link Here
14
                "./koha-tmpl/intranet-tmpl/prog/js/vue/modules/preservation.ts",
14
                "./koha-tmpl/intranet-tmpl/prog/js/vue/modules/preservation.ts",
15
            "admin/record_sources":
15
            "admin/record_sources":
16
                "./koha-tmpl/intranet-tmpl/prog/js/vue/modules/admin/record_sources.ts",
16
                "./koha-tmpl/intranet-tmpl/prog/js/vue/modules/admin/record_sources.ts",
17
            vendors: "./koha-tmpl/intranet-tmpl/prog/js/vue/modules/vendors.ts",
17
            islands: "./koha-tmpl/intranet-tmpl/prog/js/vue/modules/islands.ts",
18
            islands: "./koha-tmpl/intranet-tmpl/prog/js/vue/modules/islands.ts",
18
        },
19
        },
19
        output: {
20
        output: {
(-)a/webpack.config.js (-1 / +1 lines)
Lines 10-15 module.exports = { Link Here
10
            "./koha-tmpl/intranet-tmpl/prog/js/vue/modules/preservation.ts",
10
            "./koha-tmpl/intranet-tmpl/prog/js/vue/modules/preservation.ts",
11
        "admin/record_sources":
11
        "admin/record_sources":
12
            "./koha-tmpl/intranet-tmpl/prog/js/vue/modules/admin/record_sources.ts",
12
            "./koha-tmpl/intranet-tmpl/prog/js/vue/modules/admin/record_sources.ts",
13
        vendors: "./koha-tmpl/intranet-tmpl/prog/js/vue/modules/vendors.ts",
13
    },
14
    },
14
    output: {
15
    output: {
15
        filename: "[name].js",
16
        filename: "[name].js",
16
- 

Return to bug 38010