Bug 34789: Update usage throughout Koha modules and Vue components
[koha.git] / koha-tmpl / intranet-tmpl / prog / js / vue / components / ERM / EHoldingsLocalTitlesShow.vue
1 <template>
2     <div v-if="!initialized">{{ $__("Loading") }}</div>
3     <div v-else-if="title" id="eholdings_title_show">
4         <h2>
5             {{ $__("Title #%s").format(title.title_id) }}
6             <span class="action_links">
7                 <router-link
8                     :to="{
9                         name: 'EHoldingsLocalTitlesFormAddEdit',
10                         params: { title_id: title.title_id },
11                     }"
12                     :title="$__('Edit')"
13                     ><i class="fa fa-pencil"></i
14                 ></router-link>
15
16                 <a
17                     @click="
18                         delete_title(title.title_id, title.publication_title)
19                     "
20                     ><i class="fa fa-trash"></i
21                 ></a>
22             </span>
23         </h2>
24         <div>
25             <fieldset class="rows">
26                 <ol>
27                     <li v-if="title.title_id">
28                         <label>{{ $__("Title identifier") }}:</label>
29                         <span>
30                             {{ title.title_id }}
31                         </span>
32                     </li>
33                     <li>
34                         <label>{{ $__("Publication title") }}:</label>
35                         <span>
36                             {{ title.publication_title }}
37                             <a
38                                 v-if="title.biblio_id"
39                                 :href="`/cgi-bin/koha/catalogue/detail.pl?biblionumber=${title.biblio_id}`"
40                             >
41                                 {{ $__("Local bibliographic record") }}
42                             </a>
43                         </span>
44                     </li>
45                     <li v-if="title.print_identifier">
46                         <label>{{ $__("Print-format identifier") }}:</label>
47                         <span>
48                             {{ title.print_identifier }}
49                         </span>
50                     </li>
51                     <li v-if="title.online_identifier">
52                         <label>{{ $__("Online-format identifier") }}:</label>
53                         <span>
54                             {{ title.online_identifier }}
55                         </span>
56                     </li>
57                     <li v-if="title.date_first_issue_online">
58                         <label
59                             >{{
60                                 $__(
61                                     "Date of first serial issue available online"
62                                 )
63                             }}:</label
64                         >
65                         <span>
66                             {{ title.date_first_issue_online }}
67                         </span>
68                     </li>
69                     <li v-if="title.num_first_vol_online">
70                         <label
71                             >{{
72                                 $__("Number of first volume available online")
73                             }}:</label
74                         >
75                         <span>
76                             {{ title.num_first_vol_online }}
77                         </span>
78                     </li>
79                     <li v-if="title.num_first_issue_online">
80                         <label
81                             >{{
82                                 $__("Number of first issue available online")
83                             }}:</label
84                         >
85                         <span>
86                             {{ title.num_first_issue_online }}
87                         </span>
88                     </li>
89                     <li v-if="title.date_last_issue_online">
90                         <label
91                             >{{
92                                 $__("Date of last issue available online")
93                             }}:</label
94                         >
95                         <span>
96                             {{ title.date_last_issue_online }}
97                         </span>
98                     </li>
99                     <li v-if="title.num_last_vol_online">
100                         <label
101                             >{{
102                                 $__("Number of last volume available online")
103                             }}:</label
104                         >
105                         <span>
106                             {{ title.num_last_vol_online }}
107                         </span>
108                     </li>
109                     <li v-if="title.num_last_issue_online">
110                         <label
111                             >{{
112                                 $__("Number of last issue available online")
113                             }}:</label
114                         >
115                         <span>
116                             {{ title.num_last_issue_online }}
117                         </span>
118                     </li>
119                     <li v-if="title.title_url">
120                         <label>{{ $__("Title-level URL") }}:</label>
121                         <span>
122                             {{ title.title_url }}
123                         </span>
124                     </li>
125                     <li v-if="title.first_author">
126                         <label>{{ $__("First author") }}:</label>
127                         <span>
128                             {{ title.first_author }}
129                         </span>
130                     </li>
131                     <li v-if="title.embargo_info">
132                         <label>{{ $__("Embargo information") }}:</label>
133                         <span>
134                             {{ title.embargo_info }}
135                         </span>
136                     </li>
137                     <li v-if="title.coverage_depth">
138                         <label>{{ $__("Coverage depth") }}:</label>
139                         <span>
140                             {{ title.coverage_depth }}
141                         </span>
142                     </li>
143                     <li v-if="title.notes">
144                         <label>{{ $__("Notes") }}:</label>
145                         <span>
146                             {{ title.notes }}
147                         </span>
148                     </li>
149                     <li v-if="title.publisher_name">
150                         <label>{{ $__("Publisher name") }}:</label>
151                         <span>
152                             {{ title.publisher_name }}
153                         </span>
154                     </li>
155                     <li v-if="title.publication_type">
156                         <label>{{ $__("Publication type") }}:</label>
157                         <span
158                             >{{
159                                 get_lib_from_av(
160                                     "av_title_publication_types",
161                                     title.publication_type
162                                 )
163                             }}
164                         </span>
165                     </li>
166                     <li v-if="title.date_monograph_published_print">
167                         <label
168                             >{{
169                                 $__(
170                                     "Date the monograph is first published in print"
171                                 )
172                             }}:</label
173                         >
174                         <span>
175                             {{ title.date_monograph_published_print }}
176                         </span>
177                     </li>
178                     <li v-if="title.date_monograph_published_online">
179                         <label
180                             >{{
181                                 $__(
182                                     "Date the monograph is first published online"
183                                 )
184                             }}:</label
185                         >
186                         <span>
187                             {{ title.date_monograph_published_online }}
188                         </span>
189                     </li>
190                     <li v-if="title.monograph_volume">
191                         <label
192                             >{{ $__("Number of volume for monograph") }}:</label
193                         >
194                         <span>
195                             {{ title.monograph_volume }}
196                         </span>
197                     </li>
198                     <li v-if="title.monograph_edition">
199                         <label>{{ $__("Edition of the monograph") }}:</label>
200                         <span>
201                             {{ title.monograph_edition }}
202                         </span>
203                     </li>
204                     <li v-if="title.first_editor">
205                         <label>{{ $__("First editor") }}:</label>
206                         <span>
207                             {{ title.first_editor }}
208                         </span>
209                     </li>
210                     <li v-if="title.parent_publication_title_id">
211                         <label
212                             >{{
213                                 $__(
214                                     "Title identifier of the parent publication"
215                                 )
216                             }}:</label
217                         >
218                         <span>
219                             {{ title.parent_publication_title_id }}
220                         </span>
221                     </li>
222                     <li v-if="title.preceding_publication_title_id">
223                         <label
224                             >{{
225                                 $__(
226                                     "Title identifier of any preceding publication title"
227                                 )
228                             }}:</label
229                         >
230                         <span>
231                             {{ title.preceding_publication_title_id }}
232                         </span>
233                     </li>
234                     <li v-if="title.access_type">
235                         <label>{{ $__("Access type") }}:</label>
236                         <span>
237                             {{ title.access_type }}
238                         </span>
239                     </li>
240                     <li>
241                         <label>Packages ({{ title.resources.length }})</label>
242                         <div v-if="title.resources.length">
243                             <EHoldingsTitlePackagesList
244                                 :resources="title.resources"
245                             />
246                         </div>
247                     </li>
248                 </ol>
249             </fieldset>
250             <fieldset class="action">
251                 <router-link
252                     :to="{ name: 'EHoldingsLocalTitlesList' }"
253                     role="button"
254                     class="cancel"
255                     >{{ $__("Close") }}</router-link
256                 >
257             </fieldset>
258         </div>
259     </div>
260 </template>
261
262 <script>
263 import { inject } from "vue"
264 import EHoldingsTitlePackagesList from "./EHoldingsLocalTitlePackagesList.vue"
265 import { APIClient } from "../../fetch/api-client.js"
266
267 export default {
268     setup() {
269         const AVStore = inject("AVStore")
270         const { get_lib_from_av } = AVStore
271         const { setConfirmationDialog, setMessage } = inject("mainStore")
272
273         return {
274             get_lib_from_av,
275             setConfirmationDialog,
276             setMessage,
277         }
278     },
279     data() {
280         return {
281             title: {
282                 title_id: null,
283                 publication_title: "",
284                 external_id: "",
285                 print_identifier: "",
286                 online_identifier: "",
287                 date_first_issue_online: "",
288                 num_first_vol_online: "",
289                 num_first_issue_online: "",
290                 date_last_issue_online: "",
291                 num_last_vol_online: "",
292                 num_last_issue_online: "",
293                 title_url: "",
294                 first_author: "",
295                 embargo_info: "",
296                 coverage_depth: "",
297                 notes: "",
298                 publisher_name: "",
299                 publication_type: "",
300                 date_monograph_published_print: "",
301                 date_monograph_published_online: "",
302                 monograph_volume: "",
303                 monograph_edition: "",
304                 first_editor: "",
305                 parent_publication_title_id: "",
306                 preceding_publication_title_id: "",
307                 access_type: "",
308                 resources: [],
309             },
310             initialized: false,
311         }
312     },
313     beforeRouteEnter(to, from, next) {
314         next(vm => {
315             vm.getTitle(to.params.title_id)
316         })
317     },
318     beforeRouteUpdate(to, from) {
319         this.title = this.getTitle(to.params.title_id)
320     },
321     methods: {
322         getTitle(title_id) {
323             const client = APIClient.erm
324             client.localTitles.get(title_id).then(
325                 title => {
326                     this.title = title
327                     this.initialized = true
328                 },
329                 error => {}
330             )
331         },
332         delete_title: function (title_id, title_publication_title) {
333             this.setConfirmationDialog(
334                 {
335                     title: this.$__(
336                         "Are you sure you want to remove this title?"
337                     ),
338                     message: title_publication_title,
339                     accept_label: this.$__("Yes, delete"),
340                     cancel_label: this.$__("No, do not delete"),
341                 },
342                 () => {
343                     const client = APIClient.erm
344                     client.localTitles.delete(title_id).then(
345                         success => {
346                             this.setMessage(
347                                 this.$__("Local title %s deleted").format(
348                                     title_publication_title
349                                 ),
350                                 true
351                             )
352                             this.$router.push({
353                                 name: "EHoldingsLocalTitlesList",
354                             })
355                         },
356                         error => {}
357                     )
358                 }
359             )
360         },
361     },
362     components: {
363         EHoldingsTitlePackagesList,
364     },
365     name: "EHoldingsLocalTitlesShow",
366 }
367 </script>
368 <style scoped>
369 .action_links a {
370     padding-left: 0.2em;
371     font-size: 11px;
372     cursor: pointer;
373 }
374 fieldset.rows label {
375     width: 25rem;
376 }
377 </style>