Bugzilla – Attachment 172920 Details for
Bug 37301
Further improve how we build Vue components
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 37301: Apply changes to preservation trains
Bug-37301-Apply-changes-to-preservation-trains.patch (text/plain), 10.62 KB, created by
Pedro Amorim
on 2024-10-17 16:24:43 UTC
(
hide
)
Description:
Bug 37301: Apply changes to preservation trains
Filename:
MIME Type:
Creator:
Pedro Amorim
Created:
2024-10-17 16:24:43 UTC
Size:
10.62 KB
patch
obsolete
>From 6b796a25ed380a66c51c4ca6a5db7e6c88e12004 Mon Sep 17 00:00:00 2001 >From: Pedro Amorim <pedro.amorim@ptfs-europe.com> >Date: Thu, 17 Oct 2024 16:15:43 +0000 >Subject: [PATCH] Bug 37301: Apply changes to preservation trains > >Also update edit route from TrainsFormEdit to TrainsFormAddEdit for consistency >--- > .../components/Preservation/TrainResource.vue | 29 ++++++++ > .../components/Preservation/TrainsList.vue | 66 +++++-------------- > .../components/Preservation/TrainsShow.vue | 50 +++----------- > .../prog/js/vue/routes/preservation.js | 2 +- > 4 files changed, 54 insertions(+), 93 deletions(-) > create mode 100644 koha-tmpl/intranet-tmpl/prog/js/vue/components/Preservation/TrainResource.vue > >diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/Preservation/TrainResource.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/Preservation/TrainResource.vue >new file mode 100644 >index 0000000000..6dfbe4cf62 >--- /dev/null >+++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/Preservation/TrainResource.vue >@@ -0,0 +1,29 @@ >+<script> >+import BaseResource from "../BaseResource.vue" >+import { APIClient } from "../../fetch/api-client.js" >+ >+export default { >+ extends: BaseResource, >+ setup(props) { >+ return { >+ ...BaseResource.setup({ >+ resource_name: "train", >+ name_attr: "name", >+ id_attr: "train_id", >+ show_component: "TrainsShow", >+ list_component: "TrainsList", >+ add_component: "TrainsFormAdd", >+ edit_component: "TrainsFormAddEdit", >+ api_client: APIClient.preservation.trains, >+ resource_table_url: APIClient.preservation._baseURL + "trains", >+ i18n: { >+ display_name: __("Train"), >+ }, >+ }), >+ //TrainResource specific setup here >+ } >+ }, >+ methods: {}, >+ name: "TrainResource", >+} >+</script> >diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/Preservation/TrainsList.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/Preservation/TrainsList.vue >index 29f5b52e56..efe2660677 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/vue/components/Preservation/TrainsList.vue >+++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/Preservation/TrainsList.vue >@@ -3,8 +3,8 @@ > <div v-else id="trains_list"> > <Toolbar> > <ToolbarButton >- :to="{ name: 'TrainsFormAdd' }" >- icon="plus" >+ action="add" >+ @go-to-add-resource="goToResourceAdd" > :title="$__('New train')" > /> > </Toolbar> >@@ -45,9 +45,9 @@ > <KohaTable > ref="table" > v-bind="tableOptions" >- @show="doShow" >- @edit="doEdit" >- @delete="doDelete" >+ @show="goToResourceShow" >+ @edit="goToResourceEdit" >+ @delete="doResourceDelete" > @addItems="doAddItems" > ></KohaTable> > </div> >@@ -66,21 +66,20 @@ import { inject, ref, reactive } from "vue" > import { APIClient } from "../../fetch/api-client" > import { build_url } from "../../composables/datatables" > import KohaTable from "../KohaTable.vue" >+import TrainResource from "./TrainResource.vue" > > export default { >+ extends: TrainResource, > setup() { > const AVStore = inject("AVStore") > const { get_lib_from_av, map_av_dt_filter } = AVStore >- const { setConfirmationDialog, setMessage, setWarning } = >- inject("mainStore") > const table = ref() > const filters = reactive({ status: "" }) > return { >+ ...TrainResource.setup(), > get_lib_from_av, > map_av_dt_filter, >- setConfirmationDialog, >- setMessage, >- setWarning, >+ escape_str, > table, > filters, > } >@@ -136,44 +135,6 @@ export default { > error => {} > ) > }, >- doShow: function (train, dt, event) { >- event.preventDefault() >- this.$router.push({ >- name: "TrainsShow", >- params: { train_id: train.train_id }, >- }) >- }, >- doEdit: function (train, dt, event) { >- this.$router.push({ >- name: "TrainsFormEdit", >- params: { train_id: train.train_id }, >- }) >- }, >- doDelete: function (train, dt, event) { >- this.setConfirmationDialog( >- { >- title: this.$__( >- "Are you sure you want to remove this train?" >- ), >- message: train.name, >- accept_label: this.$__("Yes, delete"), >- cancel_label: this.$__("No, do not delete"), >- }, >- () => { >- const client = APIClient.preservation >- client.trains.delete(train.train_id).then( >- success => { >- this.setMessage( >- this.$__("Train %s deleted").format(train.name), >- true >- ) >- dt.draw() >- }, >- error => {} >- ) >- } >- ) >- }, > doAddItems: function (train, dt, event) { > if (train.closed_on != null) { > this.setWarning(this.$__("Cannot add items to a closed train")) >@@ -185,7 +146,7 @@ export default { > } > }, > table_url() { >- let url = "/api/v1/preservation/trains" >+ let url = this.getResourceTableUrl() > let q > if (this.filters.status == "closed") { > q = { >@@ -231,7 +192,10 @@ export default { > searchable: true, > orderable: true, > render: function (data, type, row, meta) { >- return `<a href="/cgi-bin/koha/preservation/trains/${row.train_id}" class="show">${row.name} (#${row.train_id})</a>` >+ return ( >+ '<a role="button" class="show">' + >+ escape_str(`${row.name} (#${row.train_id})`) >+ ) > }, > }, > { >@@ -274,7 +238,7 @@ export default { > }, > }, > components: { flatPickr, Toolbar, ToolbarButton, KohaTable }, >- name: "trainsList", >+ name: "TrainsList", > emits: ["select-train", "close"], > } > </script> >diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/Preservation/TrainsShow.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/Preservation/TrainsShow.vue >index 9b3496b09d..a0612ff2ac 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/vue/components/Preservation/TrainsShow.vue >+++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/Preservation/TrainsShow.vue >@@ -92,17 +92,13 @@ > <font-awesome-icon icon="plus" /> {{ $__("Add items") }} > </span> > <ToolbarButton >- :to="{ >- name: 'TrainsFormEdit', >- params: { train_id: train.train_id }, >- }" >- class="btn btn-default" >- icon="pencil" >- :title="$__('Edit')" >+ action="edit" >+ @go-to-edit-resource="goToResourceEdit" >+ /> >+ <ToolbarButton >+ action="delete" >+ @delete-resource="doResourceDelete" > /> >- <a @click="deleteTrain(train)" class="btn btn-default" >- ><font-awesome-icon icon="trash" /> {{ $__("Delete") }}</a >- > > <a > v-if="!train.closed_on" > class="btn btn-default" >@@ -288,27 +284,24 @@ import { APIClient } from "../../fetch/api-client" > import { useDataTable } from "../../composables/datatables" > import Toolbar from "../Toolbar.vue" > import ToolbarButton from "../ToolbarButton.vue" >+import TrainResource from "./TrainResource.vue" > > export default { >+ extends: TrainResource, > setup() { > const format_date = $date > > const AVStore = inject("AVStore") > const { get_lib_from_av } = AVStore > >- const { setConfirmationDialog, setMessage, setWarning } = >- inject("mainStore") >- > const table_id = "item_list" > useDataTable(table_id) > > return { >+ ...TrainResource.setup(), > format_date, > get_lib_from_av, > table_id, >- setConfirmationDialog, >- setMessage, >- setWarning, > } > }, > data() { >@@ -419,31 +412,6 @@ export default { > error => {} > ) > }, >- deleteTrain: function (train) { >- this.setConfirmationDialog( >- { >- title: this.$__( >- "Are you sure you want to remove this train?" >- ), >- message: train.name, >- accept_label: this.$__("Yes, delete"), >- cancel_label: this.$__("No, do not delete"), >- }, >- () => { >- const client = APIClient.preservation >- client.trains.delete(train.train_id).then( >- success => { >- this.setMessage( >- this.$__("Train %s deleted").format(train.name), >- true >- ) >- this.$router.push({ name: "TrainsList" }) >- }, >- error => {} >- ) >- } >- ) >- }, > async updateTrainDate(attribute) { > let train = JSON.parse(JSON.stringify(this.train)) > let train_id = train.train_id >diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/routes/preservation.js b/koha-tmpl/intranet-tmpl/prog/js/vue/routes/preservation.js >index ac9df94e8f..592c1c4416 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/vue/routes/preservation.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/vue/routes/preservation.js >@@ -89,7 +89,7 @@ export const routes = [ > }, > { > path: "edit/:train_id", >- name: "TrainsFormEdit", >+ name: "TrainsFormAddEdit", > component: markRaw(TrainsFormAdd), > title: $__("Edit train"), > }, >-- >2.39.5
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 37301
:
168709
|
168739
|
168740
|
168741
|
168800
|
168827
|
168828
|
168829
|
168836
|
172713
|
172911
|
172912
|
172913
|
172914
|
172915
|
172916
|
172917
|
172918
|
172919
|
172920
|
172921
|
174612
|
174613
|
174614
|
174615
|
174616
|
174617
|
174618
|
174619
|
174620
|
174621
|
174622
|
174623
|
174624
|
174625
|
174626
|
174627
|
174628
|
174629
|
174630
|
174631