|
Lines 3-10
Link Here
|
| 3 |
<div v-else id="licenses_list"> |
3 |
<div v-else id="licenses_list"> |
| 4 |
<Toolbar> |
4 |
<Toolbar> |
| 5 |
<ToolbarButton |
5 |
<ToolbarButton |
| 6 |
:to="{ name: 'LicensesFormAdd' }" |
6 |
action="add" |
| 7 |
icon="plus" |
7 |
@go-to-add-resource="goToResourceAdd" |
| 8 |
:title="$__('New license')" |
8 |
:title="$__('New license')" |
| 9 |
/> |
9 |
/> |
| 10 |
</Toolbar> |
10 |
</Toolbar> |
|
Lines 14-22
Link Here
|
| 14 |
v-bind="tableOptions" |
14 |
v-bind="tableOptions" |
| 15 |
:searchable_additional_fields="searchable_additional_fields" |
15 |
:searchable_additional_fields="searchable_additional_fields" |
| 16 |
:searchable_av_options="searchable_av_options" |
16 |
:searchable_av_options="searchable_av_options" |
| 17 |
@show="doShow" |
17 |
@show="goToResourceShow" |
| 18 |
@edit="doEdit" |
18 |
@edit="goToResourceEdit" |
| 19 |
@delete="doDelete" |
19 |
@delete="doResourceDelete" |
| 20 |
></KohaTable> |
20 |
></KohaTable> |
| 21 |
</div> |
21 |
</div> |
| 22 |
<div v-else class="alert alert-info"> |
22 |
<div v-else class="alert alert-info"> |
|
Lines 32-39
import { inject, ref } from "vue"
Link Here
|
| 32 |
import { storeToRefs } from "pinia" |
32 |
import { storeToRefs } from "pinia" |
| 33 |
import { APIClient } from "../../fetch/api-client.js" |
33 |
import { APIClient } from "../../fetch/api-client.js" |
| 34 |
import KohaTable from "../KohaTable.vue" |
34 |
import KohaTable from "../KohaTable.vue" |
|
|
35 |
import LicenseResource from "./LicenseResource.vue" |
| 35 |
|
36 |
|
| 36 |
export default { |
37 |
export default { |
|
|
38 |
extends: LicenseResource, |
| 37 |
setup() { |
39 |
setup() { |
| 38 |
const vendorStore = inject("vendorStore") |
40 |
const vendorStore = inject("vendorStore") |
| 39 |
const { vendors } = storeToRefs(vendorStore) |
41 |
const { vendors } = storeToRefs(vendorStore) |
|
Lines 41-57
export default {
Link Here
|
| 41 |
const AVStore = inject("AVStore") |
43 |
const AVStore = inject("AVStore") |
| 42 |
const { get_lib_from_av, map_av_dt_filter } = AVStore |
44 |
const { get_lib_from_av, map_av_dt_filter } = AVStore |
| 43 |
|
45 |
|
| 44 |
const { setConfirmationDialog, setMessage } = inject("mainStore") |
|
|
| 45 |
|
| 46 |
const table = ref() |
46 |
const table = ref() |
| 47 |
|
47 |
|
| 48 |
return { |
48 |
return { |
|
|
49 |
...LicenseResource.setup(), |
| 49 |
vendors, |
50 |
vendors, |
| 50 |
get_lib_from_av, |
51 |
get_lib_from_av, |
| 51 |
map_av_dt_filter, |
52 |
map_av_dt_filter, |
| 52 |
table, |
53 |
table, |
| 53 |
setConfirmationDialog, |
|
|
| 54 |
setMessage, |
| 55 |
license_table_settings, |
54 |
license_table_settings, |
| 56 |
} |
55 |
} |
| 57 |
}, |
56 |
}, |
|
Lines 70-76
export default {
Link Here
|
| 70 |
searchable_av_options: [], |
69 |
searchable_av_options: [], |
| 71 |
tableOptions: { |
70 |
tableOptions: { |
| 72 |
columns: this.getTableColumns(), |
71 |
columns: this.getTableColumns(), |
| 73 |
url: "/api/v1/erm/licenses", |
72 |
url: this.getResourceTableUrl(), |
| 74 |
options: { embed: "vendor,extended_attributes,+strings" }, |
73 |
options: { embed: "vendor,extended_attributes,+strings" }, |
| 75 |
table_settings: this.license_table_settings, |
74 |
table_settings: this.license_table_settings, |
| 76 |
add_filters: true, |
75 |
add_filters: true, |
|
Lines 149-191
export default {
Link Here
|
| 149 |
}) |
148 |
}) |
| 150 |
}) |
149 |
}) |
| 151 |
}, |
150 |
}, |
| 152 |
doShow: function ({ license_id }, dt, event) { |
|
|
| 153 |
event.preventDefault() |
| 154 |
this.$router.push({ name: "LicensesShow", params: { license_id } }) |
| 155 |
}, |
| 156 |
doEdit: function ({ license_id }, dt, event) { |
| 157 |
this.$router.push({ |
| 158 |
name: "LicensesFormAddEdit", |
| 159 |
params: { license_id }, |
| 160 |
}) |
| 161 |
}, |
| 162 |
doDelete: function (license, dt, event) { |
| 163 |
this.setConfirmationDialog( |
| 164 |
{ |
| 165 |
title: this.$__( |
| 166 |
"Are you sure you want to remove this license?" |
| 167 |
), |
| 168 |
message: license.name, |
| 169 |
accept_label: this.$__("Yes, delete"), |
| 170 |
cancel_label: this.$__("No, do not delete"), |
| 171 |
}, |
| 172 |
() => { |
| 173 |
const client = APIClient.erm |
| 174 |
client.licenses.delete(license.license_id).then( |
| 175 |
success => { |
| 176 |
this.setMessage( |
| 177 |
this.$__("License %s deleted").format( |
| 178 |
license.name |
| 179 |
), |
| 180 |
true |
| 181 |
) |
| 182 |
dt.draw() |
| 183 |
}, |
| 184 |
error => {} |
| 185 |
) |
| 186 |
} |
| 187 |
) |
| 188 |
}, |
| 189 |
getTableColumns: function () { |
151 |
getTableColumns: function () { |
| 190 |
let get_lib_from_av = this.get_lib_from_av |
152 |
let get_lib_from_av = this.get_lib_from_av |
| 191 |
|
153 |
|
|
Lines 197-205
export default {
Link Here
|
| 197 |
orderable: true, |
159 |
orderable: true, |
| 198 |
render: function (data, type, row, meta) { |
160 |
render: function (data, type, row, meta) { |
| 199 |
return ( |
161 |
return ( |
| 200 |
'<a href="/cgi-bin/koha/erm/licenses/' + |
162 |
'<a role="button" class="show">' + |
| 201 |
row.license_id + |
|
|
| 202 |
'" class="show">' + |
| 203 |
escape_str(`${row.name} (#${row.license_id})`) + |
163 |
escape_str(`${row.name} (#${row.license_id})`) + |
| 204 |
"</a>" |
164 |
"</a>" |
| 205 |
) |
165 |
) |