2 <div v-if="!initialized">{{ $t("Loading") }}</div>
3 <div v-else id="titles_add">
4 <h2 v-if="title.title_id">
5 {{ $t("Edit title .id", { id: title.title_id }) }}
7 <h2 v-else>{{ $t("New title") }}</h2>
9 <form @submit="onSubmit($event)">
10 <fieldset class="rows">
12 <li v-if="title.title_id">
13 <label for="title_title_id"
14 >{{ $t("Title identifier") }}:</label
18 v-model="title.title_id"
19 :placeholder="$t('Title identifier')"
24 <label class="required" for="title_name"
25 >{{ $t("Publication title") }}:</label
28 id="title_publication_title"
29 v-model="title.publication_title"
30 :placeholder="$t('Publication title')"
33 <span class="required">{{ $t("Required") }}</span>
37 <label for="title_print_identifier"
38 >{{ $t("Print-format identifier") }}:</label
41 id="title_print_identifier"
42 v-model="title.print_identifier"
43 :placeholder="$t('Print-format identifier')"
48 <label for="title_online_identifier"
49 >{{ $t("Online-format identifier") }}:</label
52 id="title_online_identifier"
53 v-model="title.online_identifier"
54 :placeholder="$t('Online-format identifier')"
59 <label for="title_date_first_issue_online"
62 "Date of first serial issue available online"
67 id="title_date_first_issue_online"
68 v-model="title.date_first_issue_online"
71 'Date of first serial issue available online'
78 <label for="title_num_first_vol_online"
81 "Number of first volume available online"
86 id="title_num_first_vol_online"
87 v-model="title.num_first_vol_online"
90 'Number of first volume available online'
97 <label for="title_num_first_issue_online"
100 "Number of first issue available online"
105 id="title_num_first_issue_online"
106 v-model="title.num_first_issue_online"
108 $t('Number of first issue available online')
114 <label for="title_date_last_issue_online"
116 $t("Date of last issue available online")
120 id="title_date_last_issue_online"
121 v-model="title.date_last_issue_online"
123 $t('Date of last issue available online')
129 <label for="title_num_last_vol_online"
132 "Number of last volume available online"
137 id="title_num_last_vol_online"
138 v-model="title.num_last_vol_online"
140 $t('Number of last volume available online')
146 <label for="title_num_last_issue_online"
148 $t("Number of last issue available online")
152 id="title_num_last_issue_online"
153 v-model="title.num_last_issue_online"
155 $t('Number of last issue available online')
161 <label for="title_title_url"
162 >{{ $t("Title-level URL") }}:</label
166 v-model="title.title_url"
167 :placeholder="$t('Title-level URL')"
172 <label for="title_first_author"
173 >{{ $t("First author") }}:</label
176 id="title_first_author"
177 v-model="title.first_author"
178 :placeholder="$t('First author')"
183 <label for="title_embargo_info"
184 >{{ $t("Embargo information") }}:</label
187 id="title_embargo_info"
188 v-model="title.embargo_info"
189 :placeholder="$t('Embargo information')"
194 <label for="title_coverage_depth"
195 >{{ $t("Coverage depth") }}:</label
198 id="title_coverage_depth"
199 v-model="title.coverage_depth"
200 :placeholder="$t('Coverage depth')"
205 <label for="title_notes">{{ $t("Notes") }}:</label>
208 v-model="title.notes"
209 :placeholder="$t('Notes')"
214 <label for="title_publisher_name"
215 >{{ $t("Publisher name") }}:</label
218 id="title_publisher_name"
219 v-model="title.publisher_name"
220 :placeholder="$t('Publisher name')"
225 <label for="title_publication_type"
226 >{{ $t("Publication type") }}:</label
229 id="title_publication_type"
230 v-model="title.publication_type"
232 <option value=""></option>
234 v-for="type in av_title_publication_types"
235 :key="type.authorised_values"
236 :value="type.authorised_value"
238 type.authorised_value ==
239 title.publication_type
250 <label for="title_date_monograph_published_print"
253 "Date the monograph is first published in print"
258 id="title_date_monograph_published_print"
259 v-model="title.date_monograph_published_print"
262 'Date the monograph is first published in print'
269 <label for="title_date_monograph_published_online"
272 "Date the monograph is first published online"
277 id="title_date_monograph_published_online"
278 v-model="title.date_monograph_published_online"
281 'Date the monograph is first published online'
288 <label for="title_monograph_volume"
290 $t("Number of volume for monograph")
294 id="title_monograph_volume"
295 v-model="title.monograph_volume"
297 $t('Number of volume for monograph')
303 <label for="title_monograph_edition"
304 >{{ $t("Edition of the monograph") }}:</label
307 id="title_monograph_edition"
308 v-model="title.monograph_edition"
309 :placeholder="$t('Edition of the monograph')"
314 <label for="title_first_editor"
315 >{{ $t("First editor") }}:</label
318 id="title_first_editor"
319 v-model="title.first_editor"
320 :placeholder="$t('First editor')"
325 <label for="title_parent_publication_title_id"
328 "Title identifier of the parent publication"
333 id="title_parent_publication_title_id"
334 v-model="title.parent_publication_title_id"
337 'Title identifier of the parent publication'
344 <label for="title_preceeding_publication_title_id"
347 "Title identifier of any preceding publication title"
352 id="title_preceeding_publication_title_id"
353 v-model="title.preceeding_publication_title_id"
356 'Title identifier of any preceding publication title'
363 <label for="title_access_type"
365 // FIXME May be fee-based (P) or Open Access (F).
370 id="title_access_type"
371 v-model="title.access_type"
372 :placeholder="$t('Access type')"
376 <EHoldingsTitlesFormAddResources
377 :resources="title.resources"
381 <fieldset class="action">
382 <input type="submit" value="Submit" />
384 to="/cgi-bin/koha/erm/eholdings/titles"
387 >{{ $t("Cancel") }}</router-link
396 import { useVendorStore } from "../../stores/vendors"
397 import { useAVStore } from "../../stores/authorised_values"
398 import EHoldingsTitlesFormAddResources from "./EHoldingsTitlesFormAddResources.vue"
399 import { setMessage, setError } from "../../messages"
400 import { fetchTitle } from '../../fetch'
401 import { storeToRefs } from "pinia"
405 const vendorStore = useVendorStore()
406 const { vendors } = storeToRefs(vendorStore)
408 const AVStore = useAVStore()
409 const { av_title_publication_types } = storeToRefs(AVStore)
410 const { get_lib_from_av } = AVStore
414 av_title_publication_types,
422 publication_title: '',
424 print_identifier: '',
425 online_identifier: '',
426 date_first_issue_online: '',
427 num_first_vol_online: '',
428 num_first_issue_online: '',
429 date_last_issue_online: '',
430 num_last_vol_online: '',
431 num_last_issue_online: '',
438 publication_type: '',
439 date_monograph_published_print: '',
440 date_monograph_published_online: '',
441 monograph_volume: '',
442 monograph_edition: '',
444 parent_publication_title_id: '',
445 preceeding_publication_title_id: '',
452 beforeRouteEnter(to, from, next) {
454 if (to.params.title_id) {
455 vm.title = vm.getTitle(to.params.title_id)
457 vm.initialized = true
462 async getTitle(title_id) {
463 const title = await fetchTitle(title_id)
465 this.initialized = true
470 let title = JSON.parse(JSON.stringify(this.title)) // copy
471 let apiUrl = '/api/v1/erm/eholdings/titles'
474 if (title.title_id) {
476 apiUrl += '/' + title.title_id
478 delete title.title_id
479 delete title.biblio_id
481 title.resources.forEach(r => {
482 r.started_on = r.started_on ? $date_to_rfc3339(r.started_on) : null
483 r.ended_on = r.ended_on ? $date_to_rfc3339(r.ended_on) : null
486 // Cannot use the map/keepAttrs because of the reserved keywork 'package'
487 title.resources.forEach(function (e) { delete e.package; delete e.resource_id })
491 body: JSON.stringify(title),
493 'Content-Type': 'application/json;charset=utf-8'
497 fetch(apiUrl, options)
499 if (response.status == 200) {
500 this.$router.push("/cgi-bin/koha/erm/eholdings/titles")
501 setMessage(this.$t("Title updated"))
502 } else if (response.status == 201) {
503 this.$router.push("/cgi-bin/koha/erm/eholdings/titles")
504 setMessage(this.$t("Title created"))
506 setError(response.message || response.statusText)
510 }).catch(e => { console.log(e) })
513 components: { EHoldingsTitlesFormAddResources },
514 name: "EHoldingsTitlesFormAdd",
518 fieldset.rows label {