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
22 <label class="required" for="title_name"
23 >{{ $t("Publication title") }}:</label
26 id="title_publication_title"
27 v-model="title.publication_title"
28 :placeholder="$t('Publication title')"
31 <span class="required">{{ $t("Required") }}</span>
35 <label for="title_print_identifier"
36 >{{ $t("Print-format identifier") }}:</label
39 id="title_print_identifier"
40 v-model="title.print_identifier"
41 :placeholder="$t('Print-format identifier')"
46 <label for="title_online_identifier"
47 >{{ $t("Online-format identifier") }}:</label
50 id="title_online_identifier"
51 v-model="title.online_identifier"
52 :placeholder="$t('Online-format identifier')"
57 <label for="title_date_first_issue_online"
60 "Date of first serial issue available online"
65 id="title_date_first_issue_online"
66 v-model="title.date_first_issue_online"
69 'Date of first serial issue available online'
76 <label for="title_num_first_vol_online"
79 "Number of first volume available online"
84 id="title_num_first_vol_online"
85 v-model="title.num_first_vol_online"
88 'Number of first volume available online'
95 <label for="title_num_first_issue_online"
98 "Number of first issue available online"
103 id="title_num_first_issue_online"
104 v-model="title.num_first_issue_online"
106 $t('Number of first issue available online')
112 <label for="title_date_last_issue_online"
114 $t("Date of last issue available online")
118 id="title_date_last_issue_online"
119 v-model="title.date_last_issue_online"
121 $t('Date of last issue available online')
127 <label for="title_num_last_vol_online"
130 "Number of last volume available online"
135 id="title_num_last_vol_online"
136 v-model="title.num_last_vol_online"
138 $t('Number of last volume available online')
144 <label for="title_num_last_issue_online"
146 $t("Number of last issue available online")
150 id="title_num_last_issue_online"
151 v-model="title.num_last_issue_online"
153 $t('Number of last issue available online')
159 <label for="title_title_url"
160 >{{ $t("Title-level URL") }}:</label
164 v-model="title.title_url"
165 :placeholder="$t('Title-level URL')"
170 <label for="title_first_author"
171 >{{ $t("First author") }}:</label
174 id="title_first_author"
175 v-model="title.first_author"
176 :placeholder="$t('First author')"
181 <label for="title_embargo_info"
182 >{{ $t("Embargo information") }}:</label
185 id="title_embargo_info"
186 v-model="title.embargo_info"
187 :placeholder="$t('Embargo information')"
192 <label for="title_coverage_depth"
193 >{{ $t("Coverage depth") }}:</label
196 id="title_coverage_depth"
197 v-model="title.coverage_depth"
198 :placeholder="$t('Coverage depth')"
203 <label for="title_notes">{{ $t("Notes") }}:</label>
206 v-model="title.notes"
207 :placeholder="$t('Notes')"
212 <label for="title_publisher_name"
213 >{{ $t("Publisher name") }}:</label
216 id="title_publisher_name"
217 v-model="title.publisher_name"
218 :placeholder="$t('Publisher name')"
223 <label for="title_publication_type"
224 >{{ $t("Publication type") }}:</label
227 id="title_publication_type"
228 v-model="title.publication_type"
230 <option value=""></option>
232 v-for="type in av_title_publication_types"
233 :key="type.authorised_values"
234 :value="type.authorised_value"
236 type.authorised_value ==
237 title.publication_type
248 <label for="title_date_monograph_published_print"
251 "Date the monograph is first published in print"
256 id="title_date_monograph_published_print"
257 v-model="title.date_monograph_published_print"
260 'Date the monograph is first published in print'
267 <label for="title_date_monograph_published_online"
270 "Date the monograph is first published online"
275 id="title_date_monograph_published_online"
276 v-model="title.date_monograph_published_online"
279 'Date the monograph is first published online'
286 <label for="title_monograph_volume"
288 $t("Number of volume for monograph")
292 id="title_monograph_volume"
293 v-model="title.monograph_volume"
295 $t('Number of volume for monograph')
301 <label for="title_monograph_edition"
302 >{{ $t("Edition of the monograph") }}:</label
305 id="title_monograph_edition"
306 v-model="title.monograph_edition"
307 :placeholder="$t('Edition of the monograph')"
312 <label for="title_first_editor"
313 >{{ $t("First editor") }}:</label
316 id="title_first_editor"
317 v-model="title.first_editor"
318 :placeholder="$t('First editor')"
323 <label for="title_parent_publication_title_id"
326 "Title identifier of the parent publication"
331 id="title_parent_publication_title_id"
332 v-model="title.parent_publication_title_id"
335 'Title identifier of the parent publication'
342 <label for="title_preceeding_publication_title_id"
345 "Title identifier of any preceding publication title"
350 id="title_preceeding_publication_title_id"
351 v-model="title.preceeding_publication_title_id"
354 'Title identifier of any preceding publication title'
361 <label for="title_access_type"
363 // FIXME May be fee-based (P) or Open Access (F).
368 id="title_access_type"
369 v-model="title.access_type"
370 :placeholder="$t('Access type')"
374 <EHoldingsTitlesFormAddResources
375 :resources="title.resources"
379 <fieldset class="action">
380 <input type="submit" value="Submit" />
382 to="/cgi-bin/koha/erm/eholdings/local/titles"
385 >{{ $t("Cancel") }}</router-link
394 import { useVendorStore } from "../../stores/vendors"
395 import { useAVStore } from "../../stores/authorised_values"
396 import EHoldingsTitlesFormAddResources from "./EHoldingsLocalTitlesFormAddResources.vue"
397 import { setMessage, setError } from "../../messages"
398 import { fetchLocalTitle } from '../../fetch'
399 import { storeToRefs } from "pinia"
403 const vendorStore = useVendorStore()
404 const { vendors } = storeToRefs(vendorStore)
406 const AVStore = useAVStore()
407 const { av_title_publication_types } = storeToRefs(AVStore)
408 const { get_lib_from_av } = AVStore
412 av_title_publication_types,
420 publication_title: '',
422 print_identifier: '',
423 online_identifier: '',
424 date_first_issue_online: '',
425 num_first_vol_online: '',
426 num_first_issue_online: '',
427 date_last_issue_online: '',
428 num_last_vol_online: '',
429 num_last_issue_online: '',
436 publication_type: '',
437 date_monograph_published_print: '',
438 date_monograph_published_online: '',
439 monograph_volume: '',
440 monograph_edition: '',
442 parent_publication_title_id: '',
443 preceeding_publication_title_id: '',
450 beforeRouteEnter(to, from, next) {
452 if (to.params.title_id) {
453 vm.title = vm.getTitle(to.params.title_id)
455 vm.initialized = true
460 async getTitle(title_id) {
461 const title = await fetchLocalTitle(title_id)
463 this.initialized = true
468 let title = JSON.parse(JSON.stringify(this.title)) // copy
469 let apiUrl = '/api/v1/erm/eholdings/local/titles'
472 if (title.title_id) {
474 apiUrl += '/' + title.title_id
476 delete title.title_id
477 delete title.biblio_id
479 title.resources.forEach(r => {
480 r.started_on = r.started_on ? $date_to_rfc3339(r.started_on) : null
481 r.ended_on = r.ended_on ? $date_to_rfc3339(r.ended_on) : null
484 // Cannot use the map/keepAttrs because of the reserved keywork 'package'
485 title.resources.forEach(function (e) { delete e.package; delete e.resource_id })
489 body: JSON.stringify(title),
491 'Content-Type': 'application/json;charset=utf-8'
495 fetch(apiUrl, options)
497 if (response.status == 200) {
498 this.$router.push("/cgi-bin/koha/erm/eholdings/local/titles")
499 setMessage(this.$t("Title updated"))
500 } else if (response.status == 201) {
501 this.$router.push("/cgi-bin/koha/erm/eholdings/local/titles")
502 setMessage(this.$t("Title created"))
504 setError(response.message || response.statusText)
508 }).catch(e => { console.log(e) })
511 components: { EHoldingsTitlesFormAddResources },
512 name: "EHoldingsLocalTitlesFormAdd",
516 fieldset.rows label {