2 <div v-if="!initialized">{{ $__("Loading") }}</div>
3 <div v-else id="licenses_list">
5 <div v-if="license_count > 0" class="page-section">
14 <div v-else class="dialog message">
15 {{ $__("There are no licenses defined") }}
21 import Toolbar from "./LicensesToolbar.vue"
22 import { inject, ref } from "vue"
23 import { storeToRefs } from "pinia"
24 import { APIClient } from "../../fetch/api-client.js"
25 import KohaTable from "../KohaTable.vue"
29 const vendorStore = inject("vendorStore")
30 const { vendors } = storeToRefs(vendorStore)
32 const AVStore = inject("AVStore")
33 const { get_lib_from_av, map_av_dt_filter } = AVStore
35 const { setConfirmationDialog, setMessage } = inject("mainStore")
44 setConfirmationDialog,
46 license_table_settings,
54 columns: this.getTableColumns(),
55 url: "/api/v1/erm/licenses",
56 options: { embed: "vendor" },
57 table_settings: this.license_table_settings,
61 this.vendors.map(e => {
66 3: () => this.map_av_dt_filter("av_license_types"),
67 4: () => this.map_av_dt_filter("av_license_statuses"),
71 "-1": ["edit", "delete"],
76 beforeRouteEnter(to, from, next) {
78 vm.getLicenseCount().then(() => (vm.initialized = true))
82 async getLicenseCount() {
83 const client = APIClient.erm
84 await client.licenses.count().then(
86 this.license_count = count
91 doShow: function ({ license_id }, dt, event) {
92 event.preventDefault()
93 this.$router.push({ name: "LicensesShow", params: { license_id } })
95 doEdit: function ({ license_id }, dt, event) {
97 name: "LicensesFormAddEdit",
98 params: { license_id },
101 doDelete: function (license, dt, event) {
102 this.setConfirmationDialog(
105 "Are you sure you want to remove this license?"
107 message: license.name,
108 accept_label: this.$__("Yes, delete"),
109 cancel_label: this.$__("No, do not delete"),
112 const client = APIClient.erm
113 client.licenses.delete(license.license_id).then(
116 this.$__("License %s deleted").format(
128 getTableColumns: function () {
129 let get_lib_from_av = this.get_lib_from_av
134 data: "me.license_id:me.name",
137 render: function (data, type, row, meta) {
139 '<a href="/cgi-bin/koha/erm/licenses/' +
142 escape_str(`${row.name} (#${row.license_id})`) +
152 render: function (data, type, row, meta) {
153 return row.vendor_id != undefined
154 ? '<a href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=' +
157 escape_str(row.vendor.name) +
164 title: __("Description"),
174 render: function (data, type, row, meta) {
176 get_lib_from_av("av_license_types", row.type)
185 render: function (data, type, row, meta) {
187 get_lib_from_av("av_license_statuses", row.status)
192 title: __("Started on"),
196 render: function (data, type, row, meta) {
197 return $date(row.started_on)
201 title: __("Ended on"),
205 render: function (data, type, row, meta) {
206 return $date(row.ended_on)
213 av_license_types: Array,
214 av_license_statuses: Array,
216 components: { Toolbar, KohaTable },
217 name: "LicensesList",