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

(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/Main.vue (-50 / +82 lines)
Lines 1-5 Link Here
1
<template>
1
<template>
2
    <div v-if="ERMModule">
2
    <div v-if="initialized">
3
        <div id="sub-header">
3
        <div id="sub-header">
4
            <Breadcrumb />
4
            <Breadcrumb />
5
            <Help />
5
            <Help />
Lines 140-147 export default { Link Here
140
            vendorStore,
140
            vendorStore,
141
            AVStore,
141
            AVStore,
142
            setError,
142
            setError,
143
            erm_providers,
144
            ERMModule,
145
            loading,
143
            loading,
146
            loaded,
144
            loaded,
147
        }
145
        }
Lines 149-210 export default { Link Here
149
    data() {
147
    data() {
150
        return {
148
        return {
151
            component: "agreement",
149
            component: "agreement",
150
            initialized: false,
151
            ERMModule: null,
152
            erm_providers: [],
152
        }
153
        }
153
    },
154
    },
154
    beforeCreate() {
155
    beforeCreate() {
155
        if (!this.ERMModule) {
156
            return this.setError(
157
                this.$__(
158
                    'The e-resource management module is disabled, turn on <a href="/cgi-bin/koha/admin/preferences.pl?tab=&op=search&searchfield=ERMModule">ERMModule</a> to use it'
159
                ),
160
                false
161
            )
162
        }
163
        this.loading()
156
        this.loading()
164
157
165
        const acq_client = APIClient.acquisition
158
        const fetch_config = () => {
166
        acq_client.vendors.getAll().then(
159
            let promises = []
167
            vendors => {
168
                this.vendorStore.vendors = vendors
169
                this.initialized = true
170
            },
171
            error => {}
172
        )
173
174
        const av_client = APIClient.authorised_values
175
        const authorised_values = {
176
            av_agreement_statuses: "ERM_AGREEMENT_STATUS",
177
            av_agreement_closure_reasons: "ERM_AGREEMENT_CLOSURE_REASON",
178
            av_agreement_renewal_priorities: "ERM_AGREEMENT_RENEWAL_PRIORITY",
179
            av_user_roles: "ERM_USER_ROLES",
180
            av_license_types: "ERM_LICENSE_TYPE",
181
            av_license_statuses: "ERM_LICENSE_STATUS",
182
            av_agreement_license_statuses: "ERM_AGREEMENT_LICENSE_STATUS",
183
            av_agreement_license_location: "ERM_AGREEMENT_LICENSE_LOCATION",
184
            av_package_types: "ERM_PACKAGE_TYPE",
185
            av_package_content_types: "ERM_PACKAGE_CONTENT_TYPE",
186
            av_title_publication_types: "ERM_TITLE_PUBLICATION_TYPE",
187
        }
188
160
189
        let av_cat_array = Object.keys(authorised_values).map(function (
161
            const acq_client = APIClient.acquisition
190
            av_cat
162
            promises.push(
191
        ) {
163
                acq_client.vendors.getAll().then(
192
            return '"' + authorised_values[av_cat] + '"'
164
                    vendors => {
193
        })
165
                        this.vendorStore.vendors = vendors
194
166
                    },
195
        av_client.values
167
                    error => {}
196
            .getCategoriesWithValues(av_cat_array)
168
                )
197
            .then(av_categories => {
169
            )
198
                Object.entries(authorised_values).forEach(
170
199
                    ([av_var, av_cat]) => {
171
            const av_client = APIClient.authorised_values
200
                        const av_match = av_categories.find(
172
            const authorised_values = {
201
                            element => element.category_name == av_cat
173
                av_agreement_statuses: "ERM_AGREEMENT_STATUS",
174
                av_agreement_closure_reasons: "ERM_AGREEMENT_CLOSURE_REASON",
175
                av_agreement_renewal_priorities:
176
                    "ERM_AGREEMENT_RENEWAL_PRIORITY",
177
                av_user_roles: "ERM_USER_ROLES",
178
                av_license_types: "ERM_LICENSE_TYPE",
179
                av_license_statuses: "ERM_LICENSE_STATUS",
180
                av_agreement_license_statuses: "ERM_AGREEMENT_LICENSE_STATUS",
181
                av_agreement_license_location: "ERM_AGREEMENT_LICENSE_LOCATION",
182
                av_package_types: "ERM_PACKAGE_TYPE",
183
                av_package_content_types: "ERM_PACKAGE_CONTENT_TYPE",
184
                av_title_publication_types: "ERM_TITLE_PUBLICATION_TYPE",
185
            }
186
187
            let av_cat_array = Object.keys(authorised_values).map(function (
188
                av_cat
189
            ) {
190
                return '"' + authorised_values[av_cat] + '"'
191
            })
192
193
            promises.push(
194
                av_client.values
195
                    .getCategoriesWithValues(av_cat_array)
196
                    .then(av_categories => {
197
                        Object.entries(authorised_values).forEach(
198
                            ([av_var, av_cat]) => {
199
                                const av_match = av_categories.find(
200
                                    element => element.category_name == av_cat
201
                                )
202
                                this.AVStore[av_var] =
203
                                    av_match.authorised_values
204
                            }
202
                        )
205
                        )
203
                        this.AVStore[av_var] = av_match.authorised_values
206
                    })
204
                    }
207
            )
208
209
            promises.push(
210
                sysprefs_client.sysprefs.get("ERMProviders").then(
211
                    providers => {
212
                        this.erm_providers = providers.value.split(",")
213
                    },
214
                    error => {}
205
                )
215
                )
216
            )
217
            return Promise.all(promises)
218
        }
219
220
        const sysprefs_client = APIClient.sysprefs
221
        sysprefs_client.sysprefs
222
            .get("ERMModule")
223
            .then(value => {
224
                this.ERMModule = value
225
                if (!this.ERMModule) {
226
                    this.loaded()
227
                    return this.setError(
228
                        this.$__(
229
                            'The e-resource management module is disabled, turn on <a href="/cgi-bin/koha/admin/preferences.pl?tab=&op=search&searchfield=ERMModule">ERMModule</a> to use it'
230
                        ),
231
                        false
232
                    )
233
                }
234
                return fetch_config()
235
            })
236
            .then(() => {
237
                this.loaded()
238
                this.initialized = true
206
            })
239
            })
207
            .then(() => this.loaded())
208
    },
240
    },
209
    components: {
241
    components: {
210
        Breadcrumb,
242
        Breadcrumb,
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/fetch/system-preferences-api-client.js (+4 lines)
Lines 9-14 export class SysprefAPIClient extends HttpClient { Link Here
9
9
10
    get sysprefs() {
10
    get sysprefs() {
11
        return {
11
        return {
12
            get: (variable) =>
13
                this.get({
14
                    endpoint: `/?pref=${variable}`,
15
                }),
12
            update: (variable, value) =>
16
            update: (variable, value) =>
13
                this.post({
17
                this.post({
14
                    endpoint: "",
18
                    endpoint: "",
(-)a/svc/config/systempreferences (-1 / +30 lines)
Lines 70-75 sub set_preference { Link Here
70
    C4::Service->return_success( $response );
70
    C4::Service->return_success( $response );
71
}
71
}
72
72
73
=head2 get_preference
74
75
=over 4
76
77
=item url path
78
79
GET /svc/config/systempreferences/$preference
80
81
=item url query
82
83
preference=$pref_name
84
85
=back
86
87
Used to get a single system preference.
88
89
=cut
90
91
sub get_preference {
92
    my $preference = scalar $query->param('pref');
93
94
    my $value = C4::Context->preference( $preference );
95
    $response->param( value => $value );
96
97
    C4::Service->return_success( $response );
98
}
99
100
101
73
=head2 set_preferences
102
=head2 set_preferences
74
103
75
=over 4
104
=over 4
Lines 109-112 sub set_preferences { Link Here
109
C4::Service->dispatch(
138
C4::Service->dispatch(
110
    [ 'POST /([A-Za-z0-9_-]+)', [ 'value' ], \&set_preference ],
139
    [ 'POST /([A-Za-z0-9_-]+)', [ 'value' ], \&set_preference ],
111
    [ 'POST /', [], \&set_preferences ],
140
    [ 'POST /', [], \&set_preferences ],
141
    [ 'GET /', [ 'pref' ], \&get_preference],
112
);
142
);
113
- 

Return to bug 33408