Bug 38201: Implement copy item to train modal
Signed-off-by: Michaela Sieber <michaela.sieber@kit.edu> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
parent
3876b74ad8
commit
f7fe0a3924
|
|
@ -38,6 +38,10 @@ export default {
|
|||
relationshipRequiredKey: String | null,
|
||||
disabled: Boolean | false,
|
||||
required: Boolean | false,
|
||||
query: {
|
||||
type: Object,
|
||||
default: {},
|
||||
},
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
|
|
@ -47,7 +51,7 @@ export default {
|
|||
},
|
||||
created() {
|
||||
const relatedResources = this.relationshipAPIClient;
|
||||
relatedResources.getAll().then(
|
||||
relatedResources.getAll(this.query).then(
|
||||
relatedResources => {
|
||||
this.relatedResources = relatedResources;
|
||||
this.relatedResourcesLoaded = true;
|
||||
|
|
|
|||
|
|
@ -190,8 +190,33 @@ export default {
|
|||
);
|
||||
},
|
||||
selectTrainForCopy(train_item_id) {
|
||||
$("#copy_item_to_train").modal("show");
|
||||
this.train_item_id_to_copy = train_item_id;
|
||||
let copyItem = this.copyItem;
|
||||
|
||||
this.setConfirmationDialog(
|
||||
{
|
||||
title: this.$__("Copy item to the following train"),
|
||||
message: null,
|
||||
accept_label: this.$__("Save"),
|
||||
cancel_label: this.$__("Cancel"),
|
||||
inputs: [
|
||||
{
|
||||
name: "train_id",
|
||||
type: "relationshipSelect",
|
||||
label: __("Select a train"),
|
||||
required: true,
|
||||
relationshipAPIClient:
|
||||
APIClient.preservation.trains,
|
||||
relationshipOptionLabelAttr: "name",
|
||||
relationshipRequiredKey: "train_id",
|
||||
query: {
|
||||
"me.closed_on": null,
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
copyItem
|
||||
);
|
||||
},
|
||||
clearAll() {
|
||||
this.selected_items = [];
|
||||
|
|
@ -235,6 +260,27 @@ export default {
|
|||
);
|
||||
}
|
||||
},
|
||||
copyItem(result, trainToCopy) {
|
||||
const client = APIClient.preservation;
|
||||
client.train_items
|
||||
.copy(
|
||||
trainToCopy.train_id,
|
||||
this.train.train_id,
|
||||
this.train_item_id_to_copy
|
||||
)
|
||||
.then(
|
||||
success => {
|
||||
this.setMessage(this.$__("Item copied successfully."));
|
||||
},
|
||||
error => {
|
||||
this.setWarning(
|
||||
this.$__(
|
||||
"Item cannot be copied to a train, it is already in a non-received train."
|
||||
)
|
||||
);
|
||||
}
|
||||
);
|
||||
},
|
||||
build_datatable() {
|
||||
let table_id = this.table_id;
|
||||
let item_table = this.item_table;
|
||||
|
|
@ -244,6 +290,7 @@ export default {
|
|||
let selectTrainForCopy = this.selectTrainForCopy;
|
||||
let train = this.train;
|
||||
let updateSelectedItems = this.updateSelectedItems;
|
||||
let copyItem = this.copyItem;
|
||||
|
||||
let table = $("#" + table_id).kohaTable({
|
||||
data: item_table.data,
|
||||
|
|
|
|||
|
|
@ -194,16 +194,7 @@ export default {
|
|||
this.updateTrainDate(resource, "sent_on");
|
||||
},
|
||||
receiveTrain(resource) {
|
||||
this.updateTrainDate(resource, "received_on").then(
|
||||
success => {
|
||||
// Rebuild the table to show the "copy" button
|
||||
$("#" + this.table_id)
|
||||
.DataTable()
|
||||
.destroy();
|
||||
this.build_datatable();
|
||||
},
|
||||
error => {}
|
||||
);
|
||||
this.updateTrainDate(resource, "received_on");
|
||||
},
|
||||
onSubmit(e, trainToSave) {
|
||||
e.preventDefault();
|
||||
|
|
|
|||
Loading…
Reference in New Issue