Bugzilla – Attachment 180701 Details for
Bug 37930
Change how we handle authorised values in Vue
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 37930: Extend new AV logic to the Preservation module
Bug-37930-Extend-new-AV-logic-to-the-Preservation-.patch (text/plain), 17.69 KB, created by
Matt Blenkinsop
on 2025-04-07 16:24:22 UTC
(
hide
)
Description:
Bug 37930: Extend new AV logic to the Preservation module
Filename:
MIME Type:
Creator:
Matt Blenkinsop
Created:
2025-04-07 16:24:22 UTC
Size:
17.69 KB
patch
obsolete
>From f634bb43b3c5e07c991ed425efd1159bbc5748aa Mon Sep 17 00:00:00 2001 >From: Matt Blenkinsop <matt.blenkinsop@openfifth.co.uk> >Date: Mon, 7 Apr 2025 17:21:59 +0100 >Subject: [PATCH] Bug 37930: Extend new AV logic to the Preservation module > >--- > .../js/vue/components/Preservation/Main.vue | 54 +++++------ > .../vue/components/Preservation/Settings.vue | 14 ++- > .../SettingsProcessingsFormAdd.vue | 3 - > .../components/Preservation/TrainsFormAdd.vue | 12 +-- > .../components/Preservation/TrainsList.vue | 4 +- > .../components/Preservation/TrainsShow.vue | 4 +- > .../prog/js/vue/stores/preservation.js | 7 ++ > .../integration/Preservation/Settings.ts | 75 ++++++++------- > t/cypress/integration/Preservation/Trains.ts | 93 +++++++++++-------- > 9 files changed, 134 insertions(+), 132 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/Preservation/Main.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/Preservation/Main.vue >index d0d4104dd50..106b427e79d 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/vue/components/Preservation/Main.vue >+++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/Preservation/Main.vue >@@ -36,22 +36,23 @@ import { storeToRefs } from "pinia"; > > export default { > setup() { >- const AVStore = inject("AVStore"); >- > const mainStore = inject("mainStore"); > > const { loading, loaded, setError } = mainStore; > > const PreservationStore = inject("PreservationStore"); > >- const { config } = storeToRefs(PreservationStore); >+ const { config, authorisedValues } = storeToRefs(PreservationStore); >+ const { loadAuthorisedValues } = PreservationStore; > > return { >- AVStore, > loading, > loaded, > config, > setError, >+ authorisedValues, >+ loadAuthorisedValues, >+ PreservationStore, > }; > }, > data() { >@@ -62,39 +63,26 @@ export default { > beforeCreate() { > this.loading(); > >- const fetch_additional_config = () => { >- let promises = []; >- const av_client = APIClient.authorised_values; >- promises.push( >- av_client.values.get("NOT_LOAN").then( >- values => { >- this.AVStore.av_notforloan = values; >- }, >- error => {} >- ) >- ); >- return Promise.all(promises); >- }; >- > const client = APIClient.preservation; >- client.config >- .get() >- .then(config => { >- this.config = config; >- if (this.config.settings.enabled != 1) { >- return this.setError( >- this.$__( >- 'The preservation module is disabled, turn on <a href="/cgi-bin/koha/admin/preferences.pl?tab=&op=search&searchfield=PreservationModule">PreservationModule</a> to use it' >- ), >- false >- ); >- } >- return fetch_additional_config(); >- }) >- .then(() => { >+ client.config.get().then(config => { >+ this.config = config; >+ if (this.config.settings.enabled != 1) { >+ this.loaded(); >+ return this.setError( >+ this.$__( >+ 'The preservation module is disabled, turn on <a href="/cgi-bin/koha/admin/preferences.pl?tab=&op=search&searchfield=PreservationModule">PreservationModule</a> to use it' >+ ), >+ false >+ ); >+ } >+ this.loadAuthorisedValues( >+ this.authorisedValues, >+ this.PreservationStore >+ ).then(() => { > this.loaded(); > this.initialized = true; > }); >+ }); > }, > > components: { >diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/Preservation/Settings.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/Preservation/Settings.vue >index 3db5d715419..9d3a8bce8b2 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/vue/components/Preservation/Settings.vue >+++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/Preservation/Settings.vue >@@ -29,7 +29,7 @@ > " > label="description" > :reduce="av => av.value" >- :options="av_notforloan" >+ :options="authorisedValues.av_notforloan" > > > <template #search="{ attributes, events }"> > <input >@@ -60,7 +60,7 @@ > " > label="description" > :reduce="av => av.value" >- :options="av_notforloan" >+ :options="authorisedValues.av_notforloan" > /> > </li> > </ol> >@@ -124,16 +124,14 @@ import SettingsProcessings from "./SettingsProcessings.vue"; > > export default { > setup() { >- const AVStore = inject("AVStore"); >- const { av_notforloan } = storeToRefs(AVStore); >- const { get_lib_from_av } = AVStore; >+ const PreservationStore = inject("PreservationStore"); >+ const { authorisedValues } = storeToRefs(PreservationStore); >+ const { get_lib_from_av, config } = PreservationStore; > > const { setMessage, setWarning } = inject("mainStore"); >- const PreservationStore = inject("PreservationStore"); >- const { config } = PreservationStore; > > return { >- av_notforloan, >+ authorisedValues, > get_lib_from_av, > setMessage, > setWarning, >diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/Preservation/SettingsProcessingsFormAdd.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/Preservation/SettingsProcessingsFormAdd.vue >index 5a53ce0c8de..4d36f9589d1 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/vue/components/Preservation/SettingsProcessingsFormAdd.vue >+++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/Preservation/SettingsProcessingsFormAdd.vue >@@ -204,9 +204,6 @@ import { storeToRefs } from "pinia"; > > export default { > setup() { >- const AVStore = inject("AVStore"); >- const {} = storeToRefs(AVStore); >- > const { setMessage, setWarning } = inject("mainStore"); > > const db_column_options = Object.keys(db_columns).map(function (c) { >diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/Preservation/TrainsFormAdd.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/Preservation/TrainsFormAdd.vue >index 283377eef36..2713cea1139 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/vue/components/Preservation/TrainsFormAdd.vue >+++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/Preservation/TrainsFormAdd.vue >@@ -47,7 +47,7 @@ > v-model="train.not_for_loan" > label="description" > :reduce="av => av.value" >- :options="av_notforloan" >+ :options="authorisedValues.av_notforloan" > /> > </li> > <li> >@@ -101,15 +101,13 @@ import { APIClient } from "../../fetch/api-client.js"; > > export default { > setup() { >- const AVStore = inject("AVStore"); >- const { av_notforloan } = storeToRefs(AVStore); >- >- const { setMessage, setWarning } = inject("mainStore"); >- > const PreservationStore = inject("PreservationStore"); >+ const { authorisedValues } = storeToRefs(PreservationStore); > const { config } = PreservationStore; > >- return { av_notforloan, setMessage, setWarning, config }; >+ const { setMessage, setWarning } = inject("mainStore"); >+ >+ return { authorisedValues, setMessage, setWarning, config }; > }, > data() { > return { >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 da3eb3fc864..531d89d22af 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 >@@ -69,8 +69,8 @@ import KohaTable from "../KohaTable.vue"; > > export default { > setup() { >- const AVStore = inject("AVStore"); >- const { get_lib_from_av, map_av_dt_filter } = AVStore; >+ const PreservationStore = inject("PreservationStore"); >+ const { get_lib_from_av, map_av_dt_filter } = PreservationStore; > const { setConfirmationDialog, setMessage, setWarning } = > inject("mainStore"); > const table = ref(); >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 7b24f6e9f15..d161719764c 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 >@@ -291,8 +291,8 @@ export default { > setup() { > const format_date = $date; > >- const AVStore = inject("AVStore"); >- const { get_lib_from_av } = AVStore; >+ const PreservationStore = inject("PreservationStore"); >+ const { get_lib_from_av } = PreservationStore; > > const { setConfirmationDialog, setMessage, setWarning } = > inject("mainStore"); >diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/stores/preservation.js b/koha-tmpl/intranet-tmpl/prog/js/vue/stores/preservation.js >index 3cefe2717c2..fa7621e13d4 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/vue/stores/preservation.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/vue/stores/preservation.js >@@ -1,5 +1,6 @@ > import { defineStore } from "pinia"; > import { reactive, toRefs } from "vue"; >+import { withAuthorisedValueActions } from "../composables/authorisedValues"; > > export const usePreservationStore = defineStore("preservation", () => { > const store = reactive({ >@@ -10,9 +11,15 @@ export const usePreservationStore = defineStore("preservation", () => { > not_for_loan_default_train_in: 0, > }, > }, >+ authorisedValues: { >+ av_notforloan: "NOT_LOAN", >+ }, > }); > >+ const sharedActions = withAuthorisedValueActions(store); >+ > return { > ...toRefs(store), >+ ...sharedActions, > }; > }); >diff --git a/t/cypress/integration/Preservation/Settings.ts b/t/cypress/integration/Preservation/Settings.ts >index fe03a3fd0d9..6026b146f06 100644 >--- a/t/cypress/integration/Preservation/Settings.ts >+++ b/t/cypress/integration/Preservation/Settings.ts >@@ -42,42 +42,45 @@ describe("Processings", () => { > '{"permissions":{"manage_sysprefs":"1"},"settings":{"enabled":"1","not_for_loan_default_train_in":"42","not_for_loan_waiting_list_in": "24"}}' > ); > >- cy.intercept( >- "GET", >- "/api/v1/authorised_value_categories/NOT_LOAN/authorised_values", >- [ >- { >- category_name: "NOT_LOAN", >- description: "Ordered", >- value: "-1", >- }, >- { >- category_name: "NOT_LOAN", >- description: "Not for loan", >- value: "1", >- }, >- { >- category_name: "NOT_LOAN", >- description: "Staff collection", >- value: "2", >- }, >- { >- category_name: "NOT_LOAN", >- description: "Added to bundle", >- value: "3", >- }, >- { >- category_name: "NOT_LOAN", >- description: "In preservation", >- value: "24", >- }, >- { >- category_name: "NOT_LOAN", >- description: "In preservation external", >- value: "42", >- }, >- ] >- ); >+ cy.intercept("GET", "/api/v1/authorised_value_categories?q=*", [ >+ { >+ authorised_values: [ >+ { >+ category_name: "NOT_LOAN", >+ description: "Ordered", >+ value: "-1", >+ }, >+ { >+ category_name: "NOT_LOAN", >+ description: "Not for loan", >+ value: "1", >+ }, >+ { >+ category_name: "NOT_LOAN", >+ description: "Staff collection", >+ value: "2", >+ }, >+ { >+ category_name: "NOT_LOAN", >+ description: "Added to bundle", >+ value: "3", >+ }, >+ { >+ category_name: "NOT_LOAN", >+ description: "In preservation", >+ value: "24", >+ }, >+ { >+ category_name: "NOT_LOAN", >+ description: "In preservation external", >+ value: "42", >+ }, >+ ], >+ category_name: "NOT_LOAN", >+ is_integer_only: false, >+ is_system: true, >+ }, >+ ]); > }); > > it("Settings", () => { >diff --git a/t/cypress/integration/Preservation/Trains.ts b/t/cypress/integration/Preservation/Trains.ts >index b03582e033f..2c6a69d356a 100644 >--- a/t/cypress/integration/Preservation/Trains.ts >+++ b/t/cypress/integration/Preservation/Trains.ts >@@ -212,47 +212,50 @@ describe("Trains", () => { > '{"permissions":{"manage_sysprefs":"1"},"settings":{"enabled":"1","not_for_loan_default_train_in":"42","not_for_loan_waiting_list_in": "24"}}' > ); > >- cy.intercept( >- "GET", >- "/api/v1/authorised_value_categories/NOT_LOAN/authorised_values", >- [ >- { >- category_name: "NOT_LOAN", >- description: "Ordered", >- value: "-1", >- }, >- { >- category_name: "NOT_LOAN", >- description: "Not for loan", >- value: "1", >- }, >- { >- category_name: "NOT_LOAN", >- description: "Staff collection", >- value: "2", >- }, >- { >- category_name: "NOT_LOAN", >- description: "Added to bundle", >- value: "3", >- }, >- { >- category_name: "NOT_LOAN", >- description: "In preservation", >- value: "24", >- }, >- { >- category_name: "NOT_LOAN", >- description: "In preservation external", >- value: "42", >- }, >- { >- category_name: "NOT_LOAN", >- description: "In preservation other", >- value: "43", >- }, >- ] >- ); >+ cy.intercept("GET", "/api/v1/authorised_value_categories?q=*", [ >+ { >+ authorised_values: [ >+ { >+ category_name: "NOT_LOAN", >+ description: "Ordered", >+ value: "-1", >+ }, >+ { >+ category_name: "NOT_LOAN", >+ description: "Not for loan", >+ value: "1", >+ }, >+ { >+ category_name: "NOT_LOAN", >+ description: "Staff collection", >+ value: "2", >+ }, >+ { >+ category_name: "NOT_LOAN", >+ description: "Added to bundle", >+ value: "3", >+ }, >+ { >+ category_name: "NOT_LOAN", >+ description: "In preservation", >+ value: "24", >+ }, >+ { >+ category_name: "NOT_LOAN", >+ description: "In preservation external", >+ value: "42", >+ }, >+ { >+ category_name: "NOT_LOAN", >+ description: "In preservation other", >+ value: "43", >+ }, >+ ], >+ category_name: "NOT_LOAN", >+ is_integer_only: false, >+ is_system: true, >+ }, >+ ]); > }); > > it("List trains", () => { >@@ -668,6 +671,14 @@ describe("Trains", () => { > }); > } > ); >+ cy.intercept("GET", "/api/v1/authorised_value_categories?q=*", [ >+ { >+ authorised_values: [], >+ category_name: "COUNTRY", >+ is_integer_only: false, >+ is_system: false, >+ }, >+ ]); > cy.get("#add_to_train .approve").click(); > train.items = get_train_items().filter( > train_item => train_item.item_id == 1 || train_item.item_id == 2 >-- >2.48.1
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 37930
:
171556
|
171557
|
171558
|
171628
|
172863
|
172864
|
172865
|
172886
|
172887
|
172888
|
172979
|
173069
|
176677
|
176678
|
176679
|
176719
|
176720
|
176721
|
176722
|
176830
|
178248
|
178249
|
178250
|
178251
|
180243
|
180244
|
180245
|
180246
|
180689
|
180698
|
180699
|
180700
|
180701
|
180767
|
180768
|
180769
|
180770
|
180771
|
180772
|
180773
|
180774
|
180775