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_vendor_id"
38 >{{ $t("Vendor") }}:</label
42 v-model="title.vendor_id"
44 <option value=""></option>
46 v-for="vendor in vendors"
47 :key="vendor.vendor_id"
50 vendor.id == title.vendor_id
61 <label for="title_print_identifier"
62 >{{ $t("Print-format identifier") }}:</label
65 id="title_print_identifier"
66 v-model="title.print_identifier"
67 :placeholder="$t('Print-format identifier')"
72 <label for="title_online_identifier"
73 >{{ $t("Online-format identifier") }}:</label
76 id="title_online_identifier"
77 v-model="title.online_identifier"
78 :placeholder="$t('Online-format identifier')"
83 <label for="title_date_first_issue_online"
86 "Date of first serial issue available online"
91 id="title_date_first_issue_online"
92 v-model="title.date_first_issue_online"
95 'Date of first serial issue available online'
102 <label for="title_num_first_vol_online"
105 "Number of first volume available online"
110 id="title_num_first_vol_online"
111 v-model="title.num_first_vol_online"
114 'Number of first volume available online'
121 <label for="title_num_first_issue_online"
124 "Number of first issue available online"
129 id="title_num_first_issue_online"
130 v-model="title.num_first_issue_online"
132 $t('Number of first issue available online')
138 <label for="title_date_last_issue_online"
140 $t("Date of last issue available online")
144 id="title_date_last_issue_online"
145 v-model="title.date_last_issue_online"
147 $t('Date of last issue available online')
153 <label for="title_num_last_vol_online"
156 "Number of last volume available online"
161 id="title_num_last_vol_online"
162 v-model="title.num_last_vol_online"
164 $t('Number of last volume available online')
170 <label for="title_num_last_issue_online"
172 $t("Number of last issue available online")
176 id="title_num_last_issue_online"
177 v-model="title.num_last_issue_online"
179 $t('Number of last issue available online')
185 <label for="title_title_url"
186 >{{ $t("Title-level URL") }}:</label
190 v-model="title.title_url"
191 :placeholder="$t('Title-level URL')"
196 <label for="title_first_author"
197 >{{ $t("First author") }}:</label
200 id="title_first_author"
201 v-model="title.first_author"
202 :placeholder="$t('First author')"
207 <label for="title_embargo_info"
208 >{{ $t("Embargo information") }}:</label
211 id="title_embargo_info"
212 v-model="title.embargo_info"
213 :placeholder="$t('Embargo information')"
218 <label for="title_coverage_depth"
219 >{{ $t("Coverage depth") }}:</label
222 id="title_coverage_depth"
223 v-model="title.coverage_depth"
224 :placeholder="$t('Coverage depth')"
229 <label for="title_notes">{{ $t("Notes") }}:</label>
232 v-model="title.notes"
233 :placeholder="$t('Notes')"
238 <label for="title_publisher_name"
239 >{{ $t("Publisher name") }}:</label
242 id="title_publisher_name"
243 v-model="title.publisher_name"
244 :placeholder="$t('Publisher name')"
249 <label for="title_publication_type"
250 >{{ $t("Publication type") }}:</label
253 id="title_publication_type"
254 v-model="title.publication_type"
255 :placeholder="$t('Publication type')"
260 <label for="title_date_monograph_published_print"
263 "Date the monograph is first published in print"
268 id="title_date_monograph_published_print"
269 v-model="title.date_monograph_published_print"
272 'Date the monograph is first published in print'
279 <label for="title_date_monograph_published_online"
282 "Date the monograph is first published online"
287 id="title_date_monograph_published_online"
288 v-model="title.date_monograph_published_online"
291 'Date the monograph is first published online'
298 <label for="title_monograph_volume"
300 $t("Number of volume for monograph")
304 id="title_monograph_volume"
305 v-model="title.monograph_volume"
307 $t('Number of volume for monograph')
313 <label for="title_monograph_edition"
314 >{{ $t("Edition of the monograph") }}:</label
317 id="title_monograph_edition"
318 v-model="title.monograph_edition"
319 :placeholder="$t('Edition of the monograph')"
324 <label for="title_first_editor"
325 >{{ $t("First editor") }}:</label
328 id="title_first_editor"
329 v-model="title.first_editor"
330 :placeholder="$t('First editor')"
335 <label for="title_parent_publication_title_id"
338 "Title identifier of the parent publication"
343 id="title_parent_publication_title_id"
344 v-model="title.parent_publication_title_id"
347 'Title identifier of the parent publication'
354 <label for="title_preceeding_publication_title_id"
357 "Title identifier of any preceding publication title"
362 id="title_preceeding_publication_title_id"
363 v-model="title.preceeding_publication_title_id"
366 'Title identifier of any preceding publication title'
373 <label for="title_access_type"
375 // FIXME May be fee-based (P) or Open Access (F).
380 id="title_access_type"
381 v-model="title.access_type"
382 :placeholder="$t('Access type')"
386 <EHoldingsTitlesFormAddResources
387 :resources="title.resources"
391 <fieldset class="action">
392 <input type="submit" value="Submit" />
394 to="/cgi-bin/koha/erm/eholdings/titles"
397 >{{ $t("Cancel") }}</router-link
406 import { useVendorStore } from "../../stores/vendors"
407 import EHoldingsTitlesFormAddResources from "./EHoldingsTitlesFormAddResources.vue"
408 import { setMessage, setError } from "../../messages"
409 import { fetchTitle } from '../../fetch'
410 import { storeToRefs } from "pinia"
414 const vendorStore = useVendorStore()
415 const { vendors } = storeToRefs(vendorStore)
426 publication_title: '',
428 print_identifier: '',
429 online_identifier: '',
430 date_first_issue_online: '',
431 num_first_vol_online: '',
432 num_first_issue_online: '',
433 date_last_issue_online: '',
434 num_last_vol_online: '',
435 num_last_issue_online: '',
442 publication_type: '',
443 date_monograph_published_print: '',
444 date_monograph_published_online: '',
445 monograph_volume: '',
446 monograph_edition: '',
448 parent_publication_title_id: '',
449 preceeding_publication_title_id: '',
456 beforeRouteEnter(to, from, next) {
458 if (to.params.title_id) {
459 vm.title = vm.getTitle(to.params.title_id)
461 vm.initialized = true
466 async getTitle(title_id) {
467 const title = await fetchTitle(title_id)
469 this.initialized = true
474 let title = JSON.parse(JSON.stringify(this.title)) // copy
475 let apiUrl = '/api/v1/erm/eholdings/titles'
478 if (title.title_id) {
480 apiUrl += '/' + title.title_id
482 delete title.title_id
483 delete title.biblio_id
485 title.resources.forEach(r => {
486 r.started_on = r.started_on ? $date_to_rfc3339(r.started_on) : null
487 r.ended_on = r.ended_on ? $date_to_rfc3339(r.ended_on) : null
490 // Cannot use the map/keepAttrs because of the reserved keywork 'package'
491 title.resources.forEach(function (e) { delete e.package; delete e.resource_id })
495 body: JSON.stringify(title),
497 'Content-Type': 'application/json;charset=utf-8'
501 fetch(apiUrl, options)
503 if (response.status == 200) {
504 this.$router.push("/cgi-bin/koha/erm/eholdings/titles")
505 setMessage(this.$t("Title updated"))
506 } else if (response.status == 201) {
507 this.$router.push("/cgi-bin/koha/erm/eholdings/titles")
508 setMessage(this.$t("Title created"))
510 setError(response.message || response.statusText)
514 }).catch(e => { console.log(e) })
517 components: { EHoldingsTitlesFormAddResources },
518 name: "EHoldingsTitlesFormAdd",
522 fieldset.rows label {