Lines 3-10
Link Here
|
3 |
<div v-else id="trains_list"> |
3 |
<div v-else id="trains_list"> |
4 |
<Toolbar> |
4 |
<Toolbar> |
5 |
<ToolbarButton |
5 |
<ToolbarButton |
6 |
:to="{ name: 'TrainsFormAdd' }" |
6 |
action="add" |
7 |
icon="plus" |
7 |
@go-to-add-resource="goToResourceAdd" |
8 |
:title="$__('New train')" |
8 |
:title="$__('New train')" |
9 |
/> |
9 |
/> |
10 |
</Toolbar> |
10 |
</Toolbar> |
Lines 45-53
Link Here
|
45 |
<KohaTable |
45 |
<KohaTable |
46 |
ref="table" |
46 |
ref="table" |
47 |
v-bind="tableOptions" |
47 |
v-bind="tableOptions" |
48 |
@show="doShow" |
48 |
@show="goToResourceShow" |
49 |
@edit="doEdit" |
49 |
@edit="goToResourceEdit" |
50 |
@delete="doDelete" |
50 |
@delete="doResourceDelete" |
51 |
@addItems="doAddItems" |
51 |
@addItems="doAddItems" |
52 |
></KohaTable> |
52 |
></KohaTable> |
53 |
</div> |
53 |
</div> |
Lines 66-86
import { inject, ref, reactive } from "vue"
Link Here
|
66 |
import { APIClient } from "../../fetch/api-client" |
66 |
import { APIClient } from "../../fetch/api-client" |
67 |
import { build_url } from "../../composables/datatables" |
67 |
import { build_url } from "../../composables/datatables" |
68 |
import KohaTable from "../KohaTable.vue" |
68 |
import KohaTable from "../KohaTable.vue" |
|
|
69 |
import TrainResource from "./TrainResource.vue" |
69 |
|
70 |
|
70 |
export default { |
71 |
export default { |
|
|
72 |
extends: TrainResource, |
71 |
setup() { |
73 |
setup() { |
72 |
const AVStore = inject("AVStore") |
74 |
const AVStore = inject("AVStore") |
73 |
const { get_lib_from_av, map_av_dt_filter } = AVStore |
75 |
const { get_lib_from_av, map_av_dt_filter } = AVStore |
74 |
const { setConfirmationDialog, setMessage, setWarning } = |
|
|
75 |
inject("mainStore") |
76 |
const table = ref() |
76 |
const table = ref() |
77 |
const filters = reactive({ status: "" }) |
77 |
const filters = reactive({ status: "" }) |
78 |
return { |
78 |
return { |
|
|
79 |
...TrainResource.setup(), |
79 |
get_lib_from_av, |
80 |
get_lib_from_av, |
80 |
map_av_dt_filter, |
81 |
map_av_dt_filter, |
81 |
setConfirmationDialog, |
82 |
escape_str, |
82 |
setMessage, |
|
|
83 |
setWarning, |
84 |
table, |
83 |
table, |
85 |
filters, |
84 |
filters, |
86 |
} |
85 |
} |
Lines 136-179
export default {
Link Here
|
136 |
error => {} |
135 |
error => {} |
137 |
) |
136 |
) |
138 |
}, |
137 |
}, |
139 |
doShow: function (train, dt, event) { |
|
|
140 |
event.preventDefault() |
141 |
this.$router.push({ |
142 |
name: "TrainsShow", |
143 |
params: { train_id: train.train_id }, |
144 |
}) |
145 |
}, |
146 |
doEdit: function (train, dt, event) { |
147 |
this.$router.push({ |
148 |
name: "TrainsFormEdit", |
149 |
params: { train_id: train.train_id }, |
150 |
}) |
151 |
}, |
152 |
doDelete: function (train, dt, event) { |
153 |
this.setConfirmationDialog( |
154 |
{ |
155 |
title: this.$__( |
156 |
"Are you sure you want to remove this train?" |
157 |
), |
158 |
message: train.name, |
159 |
accept_label: this.$__("Yes, delete"), |
160 |
cancel_label: this.$__("No, do not delete"), |
161 |
}, |
162 |
() => { |
163 |
const client = APIClient.preservation |
164 |
client.trains.delete(train.train_id).then( |
165 |
success => { |
166 |
this.setMessage( |
167 |
this.$__("Train %s deleted").format(train.name), |
168 |
true |
169 |
) |
170 |
dt.draw() |
171 |
}, |
172 |
error => {} |
173 |
) |
174 |
} |
175 |
) |
176 |
}, |
177 |
doAddItems: function (train, dt, event) { |
138 |
doAddItems: function (train, dt, event) { |
178 |
if (train.closed_on != null) { |
139 |
if (train.closed_on != null) { |
179 |
this.setWarning(this.$__("Cannot add items to a closed train")) |
140 |
this.setWarning(this.$__("Cannot add items to a closed train")) |
Lines 185-191
export default {
Link Here
|
185 |
} |
146 |
} |
186 |
}, |
147 |
}, |
187 |
table_url() { |
148 |
table_url() { |
188 |
let url = "/api/v1/preservation/trains" |
149 |
let url = this.getResourceTableUrl() |
189 |
let q |
150 |
let q |
190 |
if (this.filters.status == "closed") { |
151 |
if (this.filters.status == "closed") { |
191 |
q = { |
152 |
q = { |
Lines 231-237
export default {
Link Here
|
231 |
searchable: true, |
192 |
searchable: true, |
232 |
orderable: true, |
193 |
orderable: true, |
233 |
render: function (data, type, row, meta) { |
194 |
render: function (data, type, row, meta) { |
234 |
return `<a href="/cgi-bin/koha/preservation/trains/${row.train_id}" class="show">${row.name} (#${row.train_id})</a>` |
195 |
return ( |
|
|
196 |
'<a role="button" class="show">' + |
197 |
escape_str(`${row.name} (#${row.train_id})`) |
198 |
) |
235 |
}, |
199 |
}, |
236 |
}, |
200 |
}, |
237 |
{ |
201 |
{ |
Lines 274-280
export default {
Link Here
|
274 |
}, |
238 |
}, |
275 |
}, |
239 |
}, |
276 |
components: { flatPickr, Toolbar, ToolbarButton, KohaTable }, |
240 |
components: { flatPickr, Toolbar, ToolbarButton, KohaTable }, |
277 |
name: "trainsList", |
241 |
name: "TrainsList", |
278 |
emits: ["select-train", "close"], |
242 |
emits: ["select-train", "close"], |
279 |
} |
243 |
} |
280 |
</script> |
244 |
</script> |