b065b7f9cd5c60dfddbbf05112a464abec8de692
[koha-ffzg.git] / koha-tmpl / intranet-tmpl / prog / js / vue / components / ERM / AgreementsShow.vue
1 <template>
2     <div v-if="!this.initialized">{{ $t("Loading") }}</div>
3     <div v-else id="agreements_show">
4         <h2>
5             {{ $t("Agreement .id", { id: agreement.agreement_id }) }}
6             <span class="action_links">
7                 <router-link
8                     :to="`/cgi-bin/koha/erm/agreements/edit/${agreement.agreement_id}`"
9                     :title="$t('Edit')"
10                     ><i class="fa fa-pencil"></i
11                 ></router-link>
12
13                 <router-link
14                     :to="`/cgi-bin/koha/erm/agreements/delete/${agreement.agreement_id}`"
15                     :title="$t('Delete')"
16                     ><i class="fa fa-trash"></i
17                 ></router-link>
18             </span>
19         </h2>
20         <div>
21             <fieldset class="rows">
22                 <ol>
23                     <li>
24                         <label>{{ $t("Agreement name") }}:</label>
25                         <span>
26                             {{ agreement.name }}
27                         </span>
28                     </li>
29                     <li>
30                         <label>{{ $t("Vendor") }}:</label>
31                         <span v-if="agreement.vendor_id">
32                             <a
33                                 :href="`/cgi-bin/koha/acqui/booksellers.pl?booksellerid=${agreement.vendor_id}`"
34                             >
35                                 {{
36                                     vendors.find(
37                                         (e) => e.id == agreement.vendor_id
38                                     ).name
39                                 }}</a
40                             >
41                         </span>
42                     </li>
43                     <li>
44                         <label>{{ $t("Description") }}:</label>
45                         <span>
46                             {{ agreement.description }}
47                         </span>
48                     </li>
49                     <li>
50                         <label>{{ $t("Status") }}:</label>
51                         <span>{{
52                             get_lib_from_av(
53                                 "av_agreement_statuses",
54                                 agreement.status
55                             )
56                         }}</span>
57                     </li>
58                     <li>
59                         <label>{{ $t("Closure reason") }}:</label>
60                         <span>{{
61                             get_lib_from_av(
62                                 "av_agreement_closure_reasons",
63                                 agreement.closure_reason
64                             )
65                         }}</span>
66                     </li>
67                     <li>
68                         <label>{{ $t("Is perpetual") }}:</label>
69                         <span v-if="agreement.is_perpetual">Yes</span>
70                         <span v-else>No</span>
71                     </li>
72                     <li>
73                         <label>{{ $t("Renewal priority") }}:</label>
74                         <span>{{
75                             get_lib_from_av(
76                                 "av_agreement_renewal_priorities",
77                                 agreement.renewal_priority
78                             )
79                         }}</span>
80                     </li>
81                     <li>
82                         <label>{{ $t("License info") }}:</label>
83                         <span>{{ agreement.license_info }}</span>
84                     </li>
85
86                     <li v-if="agreement.periods.length">
87                         <label>{{ $t("Periods") }}</label>
88                         <table>
89                             <thead>
90                                 <th>{{ $t("Period start") }}</th>
91                                 <th>{{ $t("Period end") }}</th>
92                                 <th>{{ $t("Cancellation deadline") }}</th>
93                                 <th>{{ $t("Period note") }}</th>
94                             </thead>
95                             <tbody>
96                                 <tr
97                                     v-for="(
98                                         period, counter
99                                     ) in agreement.periods"
100                                     v-bind:key="counter"
101                                 >
102                                     <td>
103                                         {{ format_date(period.started_on) }}
104                                     </td>
105                                     <td>{{ format_date(period.ended_on) }}</td>
106                                     <td>
107                                         {{
108                                             format_date(
109                                                 period.cancellation_deadline
110                                             )
111                                         }}
112                                     </td>
113                                     <td>{{ period.notes }}</td>
114                                 </tr>
115                             </tbody>
116                         </table>
117                     </li>
118
119                     <li v-if="agreement.user_roles.length">
120                         <label>{{ $t("Users") }}</label>
121                         <table>
122                             <thead>
123                                 <th>{{ $t("Name") }}</th>
124                                 <th>{{ $t("Role") }}</th>
125                             </thead>
126                             <tbody>
127                                 <tr
128                                     v-for="(
129                                         role, counter
130                                     ) in agreement.user_roles"
131                                     v-bind:key="counter"
132                                 >
133                                     <td>{{ patron_to_html(role.patron) }}</td>
134                                     <td>
135                                         {{
136                                             get_lib_from_av(
137                                                 "av_agreement_user_roles",
138                                                 role.role
139                                             )
140                                         }}
141                                     </td>
142                                 </tr>
143                             </tbody>
144                         </table>
145                     </li>
146
147                     <li v-if="agreement.agreement_licenses.length">
148                         <label>{{ $t("Licenses") }}</label>
149                         <table>
150                             <thead>
151                                 <th>{{ $t("Name") }}</th>
152                                 <th>{{ $t("Status") }}</th>
153                                 <th>{{ $t("Physical location") }}</th>
154                                 <th>{{ $t("Notes") }}</th>
155                                 <th>{{ $t("URI") }}</th>
156                             </thead>
157                             <tbody>
158                                 <tr
159                                     v-for="(
160                                         agreement_license, counter
161                                     ) in agreement.agreement_licenses"
162                                     v-bind:key="counter"
163                                 >
164                                     <td>
165                                         <router-link
166                                             :to="`/cgi-bin/koha/erm/licenses/${agreement_license.license_id}`"
167                                         >
168                                             {{ agreement_license.license.name }}
169                                         </router-link>
170                                     </td>
171                                     <td>
172                                         {{
173                                             get_lib_from_av(
174                                                 "av_agreement_license_statuses",
175                                                 agreement_license.status
176                                             )
177                                         }}
178                                     </td>
179                                     <td>
180                                         {{
181                                             get_lib_from_av(
182                                                 "av_agreement_license_location",
183                                                 agreement_license.physical_location
184                                             )
185                                         }}
186                                     </td>
187                                     <td>{{ agreement_license.notes }}</td>
188                                     <td>{{ agreement_license.uri }}</td>
189                                 </tr>
190                             </tbody>
191                         </table>
192                     </li>
193
194                     <li v-if="agreement.agreement_relationships.length">
195                         <label>{{ $t("Related agreements") }}</label>
196                         <div id="agreement_relationships">
197                             <div
198                                 v-for="relationship in agreement.agreement_relationships"
199                                 v-bind:key="relationship.related_agreement_id"
200                             >
201                                 <span
202                                     ><router-link
203                                         :to="`/cgi-bin/koha/erm/agreements/${relationship.related_agreement.agreement_id}`"
204                                         >{{
205                                             relationship.related_agreement.name
206                                         }}</router-link
207                                     ></span
208                                 >
209                                 {{
210                                     get_lib_from_av(
211                                         "av_agreement_relationships",
212                                         relationship.relationship
213                                     )
214                                 }}
215                                 {{ agreement.name }}
216                             </div>
217                         </div>
218                     </li>
219
220                     <li v-if="agreement.agreement_packages.length">
221                         <label>{{ $t("Packages") }}</label>
222                         <div id="agreement_packages">
223                             <div
224                                 v-for="agreement_package in agreement.agreement_packages"
225                                 v-bind:key="agreement_package.package_id"
226                             >
227                                 <span
228                                     v-if="
229                                         agreement_package.package.external_id &&
230                                         agreement_package.package.provider ==
231                                             'ebsco'
232                                     "
233                                 >
234                                     <router-link
235                                         :to="`/cgi-bin/koha/erm/eholdings/ebsco/packages/${agreement_package.package.external_id}`"
236                                         >{{
237                                             agreement_package.package.name
238                                         }}</router-link
239                                     >
240                                     (EBSCO)</span
241                                 >
242                                 <span v-else
243                                     ><router-link
244                                         :to="`/cgi-bin/koha/erm/eholdings/local/packages/${agreement_package.package.package_id}`"
245                                         >{{
246                                             agreement_package.package.name
247                                         }}</router-link
248                                     >
249                                     (local)</span
250                                 >
251                             </div>
252                         </div>
253                     </li>
254                 </ol>
255             </fieldset>
256             <fieldset class="action">
257                 <router-link
258                     to="/cgi-bin/koha/erm/agreements"
259                     role="button"
260                     class="cancel"
261                     >{{ $t("Close") }}</router-link
262                 >
263             </fieldset>
264         </div>
265     </div>
266 </template>
267
268 <script>
269 import { useVendorStore } from "../../stores/vendors"
270 import { useAVStore } from "../../stores/authorised_values"
271 import { fetchAgreement } from "../../fetch"
272 import { storeToRefs } from "pinia"
273
274 export default {
275     setup() {
276         const format_date = $date
277         const patron_to_html = $patron_to_html
278
279         const vendorStore = useVendorStore()
280         const { vendors } = storeToRefs(vendorStore)
281
282         const AVStore = useAVStore()
283         const { get_lib_from_av } = AVStore
284
285         return {
286             format_date,
287             patron_to_html,
288             get_lib_from_av,
289             vendors,
290         }
291     },
292     data() {
293         return {
294             agreement: {
295                 agreement_id: null,
296                 name: '',
297                 vendor_id: null,
298                 vendor: null,
299                 description: '',
300                 status: '',
301                 closure_reason: '',
302                 is_perpetual: false,
303                 renewal_priority: '',
304                 license_info: '',
305                 periods: [],
306                 user_roles: [],
307                 agreement_packages: [],
308             },
309             initialized: false,
310         }
311     },
312     beforeRouteEnter(to, from, next) {
313         next(vm => {
314             vm.getAgreement(to.params.agreement_id)
315         })
316     },
317     beforeRouteUpdate(to, from) {
318         this.agreement = this.getAgreement(to.params.agreement_id)
319     },
320     methods: {
321         async getAgreement(agreement_id) {
322             const agreement = await fetchAgreement(agreement_id)
323             this.agreement = agreement
324             this.initialized = true
325         },
326     },
327     name: "AgreementsShow",
328 }
329 </script>
330 <style scoped>
331 .action_links a {
332     padding-left: 0.2em;
333     font-size: 11px;
334 }
335 #agreement_relationships,
336 #agreement_packages {
337     padding-left: 10rem;
338 }
339 </style>