Line 0
Link Here
|
|
|
1 |
<template> |
2 |
<div id="vendor_baskets"> |
3 |
<div v-if="parseInt(basketCount) > 0" class="page-section"> |
4 |
<KohaTable |
5 |
ref="table" |
6 |
v-bind="tableOptions" |
7 |
@show="doShow" |
8 |
@edit="doEdit" |
9 |
@delete="doDelete" |
10 |
@select="doSelect" |
11 |
></KohaTable> |
12 |
</div> |
13 |
<div v-else class="alert alert-info"> |
14 |
{{ $__("There are no baskets defined") }} |
15 |
</div> |
16 |
</div> |
17 |
</template> |
18 |
|
19 |
<script> |
20 |
import { inject, ref } from "vue" |
21 |
import { storeToRefs } from "pinia" |
22 |
import KohaTable from "../KohaTable.vue" |
23 |
|
24 |
export default { |
25 |
setup() { |
26 |
const vendorStore = inject("vendorStore") |
27 |
const { vendors } = storeToRefs(vendorStore) |
28 |
|
29 |
const { setConfirmationDialog, setMessage } = inject("mainStore") |
30 |
|
31 |
const table = ref() |
32 |
|
33 |
return { |
34 |
vendors, |
35 |
table, |
36 |
setConfirmationDialog, |
37 |
setMessage, |
38 |
escape_str, |
39 |
} |
40 |
}, |
41 |
data() { |
42 |
return { |
43 |
fp_config: flatpickr_defaults, |
44 |
initialized: false, |
45 |
tableOptions: { |
46 |
columns: this.getTableColumns(), |
47 |
url: () => this.tableURL(), |
48 |
add_filters: true, |
49 |
// filters_options: { |
50 |
// 1: [ |
51 |
// { _id: 0, _str: this.$__("Inactive") }, |
52 |
// { _id: 1, _str: this.$__("Active") }, |
53 |
// ], |
54 |
// ...(this.map_av_dt_filter("vendor_types").length && { |
55 |
// 2: () => this.map_av_dt_filter("vendor_types"), |
56 |
// }), |
57 |
// }, |
58 |
actions: { |
59 |
"-1": ["edit", "delete"], |
60 |
}, |
61 |
}, |
62 |
before_route_entered: false, |
63 |
building_table: false, |
64 |
} |
65 |
}, |
66 |
methods: { |
67 |
doShow({ id }, dt, event) { |
68 |
event.preventDefault() |
69 |
this.$router.push({ |
70 |
name: "VendorShow", |
71 |
params: { vendor_id: id }, |
72 |
}) |
73 |
}, |
74 |
doEdit({ id }, dt, event) { |
75 |
this.$router.push({ |
76 |
name: "VendorFormAddEdit", |
77 |
params: { vendor_id: id }, |
78 |
}) |
79 |
}, |
80 |
doDelete(vendor, dt, event) { |
81 |
this.setConfirmationDialog( |
82 |
{ |
83 |
title: this.$__( |
84 |
"Are you sure you want to remove this vendor?" |
85 |
), |
86 |
message: vendor.name, |
87 |
accept_label: this.$__("Yes, delete"), |
88 |
cancel_label: this.$__("No, do not delete"), |
89 |
}, |
90 |
() => { |
91 |
const client = APIClient.acquisition |
92 |
client.vendors.delete(vendor.id).then( |
93 |
success => { |
94 |
this.setMessage( |
95 |
this.$__("Vendor %s deleted").format( |
96 |
vendor.name |
97 |
), |
98 |
true |
99 |
) |
100 |
dt.draw() |
101 |
}, |
102 |
error => {} |
103 |
) |
104 |
} |
105 |
) |
106 |
}, |
107 |
doSelect(vendor, dt, event) { |
108 |
this.$emit("select-vendor", vendor.id) |
109 |
this.$emit("close") |
110 |
}, |
111 |
tableURL() { |
112 |
let url = |
113 |
"/api/v1/acquisitions/baskets?q=" + |
114 |
JSON.stringify({ vendor_id: this.vendorId }) |
115 |
return url |
116 |
}, |
117 |
getTableColumns() { |
118 |
const escape_str = this.escape_str |
119 |
const get_lib_from_av = this.get_lib_from_av |
120 |
|
121 |
return [ |
122 |
{ |
123 |
title: __("Name"), |
124 |
data: "me.name:me.basket_id", |
125 |
searchable: true, |
126 |
orderable: true, |
127 |
render(data, type, row, meta) { |
128 |
return ( |
129 |
'<a href="/cgi-bin/koha/acqui/basket.pl?basket_id=' + |
130 |
row.basket_id + |
131 |
'" class="show">' + |
132 |
escape_str(`${row.name} (#${row.basket_id})`) + |
133 |
"</a>" |
134 |
) |
135 |
}, |
136 |
}, |
137 |
{ |
138 |
title: __("Item count"), |
139 |
data: "name", |
140 |
searchable: true, |
141 |
orderable: true, |
142 |
render(data, type, row, meta) { |
143 |
return escape_str(row.name) |
144 |
}, |
145 |
}, |
146 |
{ |
147 |
title: __("Bibliographic record count"), |
148 |
data: "name", |
149 |
searchable: true, |
150 |
orderable: true, |
151 |
render(data, type, row, meta) { |
152 |
return escape_str(row.name) |
153 |
}, |
154 |
}, |
155 |
{ |
156 |
title: __("Items expected"), |
157 |
data: "name", |
158 |
searchable: true, |
159 |
orderable: true, |
160 |
render(data, type, row, meta) { |
161 |
return escape_str(row.name) |
162 |
}, |
163 |
}, |
164 |
{ |
165 |
title: __("Created by"), |
166 |
data: "creator_id", |
167 |
searchable: true, |
168 |
orderable: true, |
169 |
}, |
170 |
{ |
171 |
title: __("Date"), |
172 |
data: "creation_date", |
173 |
searchable: true, |
174 |
orderable: true, |
175 |
}, |
176 |
{ |
177 |
title: __("Basket group"), |
178 |
data: "basket_group_id", |
179 |
searchable: true, |
180 |
orderable: true, |
181 |
}, |
182 |
{ |
183 |
title: __("Internal note"), |
184 |
data: "note", |
185 |
searchable: true, |
186 |
orderable: true, |
187 |
}, |
188 |
{ |
189 |
title: __("Close"), |
190 |
data: "close_date", |
191 |
searchable: true, |
192 |
orderable: true, |
193 |
}, |
194 |
] |
195 |
}, |
196 |
}, |
197 |
components: { KohaTable }, |
198 |
props: { |
199 |
basketCount: { |
200 |
type: String, |
201 |
default: "0", |
202 |
}, |
203 |
vendorId: { |
204 |
type: Number, |
205 |
}, |
206 |
}, |
207 |
name: "VendorBaskets", |
208 |
emits: ["select-vendor", "close"], |
209 |
} |
210 |
</script> |
211 |
|
212 |
<style scoped> |
213 |
.filters > label[for="by_mine_filter"], |
214 |
.filters > input[type="checkbox"], |
215 |
.filters > input[type="button"] { |
216 |
margin-left: 1rem; |
217 |
} |
218 |
</style> |