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

(-)a/acqui/booksellers.pl (-11 / +1 lines)
Lines 52-58 The id of the supplier whose baskets we will display Link Here
52
=cut
52
=cut
53
53
54
use Modern::Perl;
54
use Modern::Perl;
55
use C4::Auth qw( get_template_and_user );
55
use C4::Auth qw( get_template_and_user haspermission );
56
use C4::Budgets qw( GetBudgetHierarchy GetBudget CanUserUseBudget );
56
use C4::Budgets qw( GetBudgetHierarchy GetBudget CanUserUseBudget );
57
use C4::Output qw( output_html_with_http_headers );
57
use C4::Output qw( output_html_with_http_headers );
58
use CGI qw ( -utf8 );
58
use CGI qw ( -utf8 );
Lines 172-185 $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
185
output_html_with_http_headers $query, $cookie, $template->output;
175
output_html_with_http_headers $query, $cookie, $template->output;
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/components/Vendors/Main.vue (-1 / +50 lines)
Lines 14-20 Link Here
14
                </div>
14
                </div>
15
15
16
                <div class="col-md-2 order-sm-2 order-md-1">
16
                <div class="col-md-2 order-sm-2 order-md-1">
17
                    <LeftMenu :title="$__('Vendors')"></LeftMenu>
17
                    <LeftMenu :title="$__('Vendor management')"></LeftMenu>
18
                </div>
18
                </div>
19
            </div>
19
            </div>
20
        </div>
20
        </div>
Lines 44-55 export default { Link Here
44
44
45
        const { loading, loaded, setError } = mainStore
45
        const { loading, loaded, setError } = mainStore
46
46
47
        const permissionsStore = inject("permissionsStore")
48
        const { userPermissions } = storeToRefs(permissionsStore)
49
47
        return {
50
        return {
48
            vendorStore,
51
            vendorStore,
49
            AVStore,
52
            AVStore,
50
            setError,
53
            setError,
51
            loading,
54
            loading,
52
            loaded,
55
            loaded,
56
            userPermissions,
53
            AVStore,
57
            AVStore,
54
        }
58
        }
55
    },
59
    },
Lines 90-95 export default { Link Here
90
            return Promise.all(promises)
94
            return Promise.all(promises)
91
        }
95
        }
92
96
97
        fetchConfig().then(() => {
98
            this.loaded()
99
            this.initialized = true
100
        })
101
    },
102
    beforeCreate() {
103
        this.loading()
104
105
        const fetchConfig = () => {
106
            let promises = []
107
108
            const av_client = APIClient.authorised_values
109
            const authorised_values = {
110
                vendor_types: "VENDOR_TYPE",
111
                vendor_interface_types: "VENDOR_INTERFACE_TYPE",
112
                vendor_payment_methods: "VENDOR_PAYMENT_METHOD",
113
                lang: "LANG",
114
            }
115
116
            let av_cat_array = Object.keys(authorised_values).map(function (
117
                av_cat
118
            ) {
119
                return '"' + authorised_values[av_cat] + '"'
120
            })
121
122
            promises.push(
123
                av_client.values
124
                    .getCategoriesWithValues(av_cat_array)
125
                    .then(av_categories => {
126
                        Object.entries(authorised_values).forEach(
127
                            ([av_var, av_cat]) => {
128
                                const av_match = av_categories.find(
129
                                    element => element.category_name == av_cat
130
                                )
131
                                this.AVStore[av_var] =
132
                                    av_match.authorised_values
133
                            }
134
                        )
135
                    })
136
            )
137
138
            return Promise.all(promises)
139
        }
140
93
        fetchConfig().then(() => {
141
        fetchConfig().then(() => {
94
            this.vendorStore.currencies = currencies
142
            this.vendorStore.currencies = currencies
95
            this.vendorStore.gstValues = gstValues.map(gv => {
143
            this.vendorStore.gstValues = gstValues.map(gv => {
Lines 103-108 export default { Link Here
103
        })
151
        })
104
    },
152
    },
105
    data() {
153
    data() {
154
        this.userPermissions = userPermissions
106
        return {
155
        return {
107
            initialized: true,
156
            initialized: true,
108
        }
157
        }
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/components/Vendors/VendorContracts.vue (-4 / +28 lines)
Lines 8-15 Link Here
8
                    <th scope="col">{{ $__("Description") }}</th>
8
                    <th scope="col">{{ $__("Description") }}</th>
9
                    <th scope="col">{{ $__("Start date") }}</th>
9
                    <th scope="col">{{ $__("Start date") }}</th>
10
                    <th scope="col">{{ $__("End date") }}</th>
10
                    <th scope="col">{{ $__("End date") }}</th>
11
                    <!-- PERMISSION CAN_user_acquisition_contracts_manage -->
11
                    <th
12
                    <th v-if="false" scope="col" class="NoSort noExport">
12
                        v-if="
13
                            isUserPermitted(
14
                                'CAN_user_acquisition_contracts_manage'
15
                            )
16
                        "
17
                        scope="col"
18
                        class="NoSort noExport"
19
                    >
13
                        {{ $__("Actions") }}
20
                        {{ $__("Actions") }}
14
                    </th>
21
                    </th>
15
                </tr>
22
                </tr>
Lines 29-36 Link Here
29
                    <td :data-order="contract.contractenddate">
36
                    <td :data-order="contract.contractenddate">
30
                        {{ contract.contractenddate }}
37
                        {{ contract.contractenddate }}
31
                    </td>
38
                    </td>
32
                    <!-- PERMISSION CAN_user_acquisition_contracts_manage -->
39
                    <td
33
                    <td class="actions" v-if="false">
40
                        class="actions"
41
                        v-if="
42
                            isUserPermitted(
43
                                'CAN_user_acquisition_contracts_manage'
44
                            )
45
                        "
46
                    >
34
                        <a
47
                        <a
35
                            class="btn btn-default btn-xs"
48
                            class="btn btn-default btn-xs"
36
                            :href="`/cgi-bin/koha/admin/aqcontract.pl?op=add_form&contractnumber=${contract.contractnumber}&booksellerid=${contract.booksellerid}`"
49
                            :href="`/cgi-bin/koha/admin/aqcontract.pl?op=add_form&contractnumber=${contract.contractnumber}&booksellerid=${contract.booksellerid}`"
Lines 54-63 Link Here
54
</template>
67
</template>
55
68
56
<script>
69
<script>
70
import { inject } from "vue"
71
57
export default {
72
export default {
58
    props: {
73
    props: {
59
        vendor: Object,
74
        vendor: Object,
60
    },
75
    },
76
    setup() {
77
        const permissionsStore = inject("permissionsStore")
78
79
        const { isUserPermitted } = permissionsStore
80
81
        return {
82
            isUserPermitted,
83
        }
84
    },
61
}
85
}
62
</script>
86
</script>
63
87
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/components/Vendors/VendorSubscriptions.vue (-3 / +13 lines)
Lines 3-26 Link Here
3
        <h2>
3
        <h2>
4
            {{ $__("Subscription details") }}
4
            {{ $__("Subscription details") }}
5
        </h2>
5
        </h2>
6
        <!-- PERMISSION -->
7
        <p>
6
        <p>
8
            <strong>{{ $__("Number of subscriptions") }}: </strong>
7
            <strong>{{ $__("Number of subscriptions") }}: </strong>
9
            <a
8
            <a
10
                v-if="false"
9
                v-if="isUserPermitted('CAN_user_serials')"
11
                :href="`/cgi-bin/koha/serials/serials-search.pl?bookseller_filter=${vendor.name}&searched=1`"
10
                :href="`/cgi-bin/koha/serials/serials-search.pl?bookseller_filter=${vendor.name}&searched=1`"
12
                >{{ vendor.subscriptions.length }}</a
11
                >{{ vendor.subscriptions.length }}</a
13
            >
12
            >
14
            <span v-if="true">{{ vendor.subscriptions.length }}</span>
13
            <span v-else>{{ vendor.subscriptions.length }}</span>
15
        </p>
14
        </p>
16
    </fieldset>
15
    </fieldset>
17
</template>
16
</template>
18
17
19
<script>
18
<script>
19
import { inject } from "vue"
20
20
export default {
21
export default {
21
    props: {
22
    props: {
22
        vendor: Object,
23
        vendor: Object,
23
    },
24
    },
25
    setup() {
26
        const permissionsStore = inject("permissionsStore")
27
28
        const { isUserPermitted } = permissionsStore
29
30
        return {
31
            isUserPermitted,
32
        }
33
    },
24
}
34
}
25
</script>
35
</script>
26
36
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/modules/vendors.ts (+3 lines)
Lines 23-28 import { useMainStore } from "../stores/main"; Link Here
23
import { useVendorStore } from "../stores/vendors";
23
import { useVendorStore } from "../stores/vendors";
24
import { useAVStore } from "../stores/authorised-values";
24
import { useAVStore } from "../stores/authorised-values";
25
import { useNavigationStore } from "../stores/navigation";
25
import { useNavigationStore } from "../stores/navigation";
26
import { usePermissionsStore } from "../stores/permissions";
26
import i18n from "../i18n";
27
import i18n from "../i18n";
27
28
28
const pinia = createPinia();
29
const pinia = createPinia();
Lines 30-35 const pinia = createPinia(); Link Here
30
const mainStore = useMainStore(pinia);
31
const mainStore = useMainStore(pinia);
31
const AVStore = useAVStore(pinia);
32
const AVStore = useAVStore(pinia);
32
const navigationStore = useNavigationStore(pinia);
33
const navigationStore = useNavigationStore(pinia);
34
const permissionsStore = usePermissionsStore(pinia);
33
const routes = navigationStore.setRoutes(routesDef);
35
const routes = navigationStore.setRoutes(routesDef);
34
36
35
const router = createRouter({
37
const router = createRouter({
Lines 52-57 app.provide("vendorStore", useVendorStore(pinia)); Link Here
52
app.provide("mainStore", mainStore);
54
app.provide("mainStore", mainStore);
53
app.provide("AVStore", AVStore);
55
app.provide("AVStore", AVStore);
54
app.provide("navigationStore", navigationStore);
56
app.provide("navigationStore", navigationStore);
57
app.provide("permissionsStore", permissionsStore);
55
58
56
app.mount("#__vendors");
59
app.mount("#__vendors");
57
60
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/routes/vendors.js (-3 / +3 lines)
Lines 11-17 export const routes = [ Link Here
11
        path: "/cgi-bin/koha/acqui/booksellers.pl",
11
        path: "/cgi-bin/koha/acqui/booksellers.pl",
12
        is_default: true,
12
        is_default: true,
13
        is_base: true,
13
        is_base: true,
14
        title: $__("Vendors"),
14
        title: $__("Vendor management"),
15
        children: [
15
        children: [
16
            {
16
            {
17
                path: "",
17
                path: "",
Lines 21-28 export const routes = [ Link Here
21
            },
21
            },
22
            {
22
            {
23
                path: "/cgi-bin/koha/vendors",
23
                path: "/cgi-bin/koha/vendors",
24
                title: $__("Vendor list"),
24
                title: $__("Vendors"),
25
                icon: "fa fa-check-circle",
25
                icon: "fa fa-shopping-cart",
26
                is_end_node: true,
26
                is_end_node: true,
27
                children: [
27
                children: [
28
                    {
28
                    {
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/stores/permissions.js (-1 / +21 lines)
Line 0 Link Here
0
- 
1
import { defineStore } from "pinia";
2
3
export const usePermissionsStore = defineStore("permissions", {
4
    state: () => ({
5
        userPermissions: null,
6
    }),
7
    actions: {
8
        isUserPermitted(operation, permissions) {
9
            const userPermissions = permissions
10
                ? permissions
11
                : this.userPermissions;
12
            if (!operation) return true;
13
            if (!userPermissions) return false;
14
15
            return (
16
                userPermissions.hasOwnProperty(operation) &&
17
                userPermissions[operation]
18
            );
19
        },
20
    },
21
});

Return to bug 38010