Koha/koha-tmpl/intranet-tmpl/prog/js/vue/stores/authorised-values.js
Jonathan Druart 1139972748 Bug 33625: Pretty .js files for vue
Test plan:
= Koha =
Apply the first patch, prove xt/vue_tidy.t and notice the failure
Apply this patch, now it passes

= QA test =
Apply the change to the merge request linked with this qa-test-tools' issue:
https://gitlab.com/koha-community/qa-test-tools/-/issues/62
inside your ktd container (at /kohadevbox/qa-test-tools/)
Edit a .js within koha-tmpl/intranet-tmpl/prog/js/vue and a .ts file
(cypress test) with something not pretty
Commit and run the QA script
=> It's failing!
Pretty the change, commit again, run the QA script
=> It's happy!

= KTD - git hook =
Go to the merge request linked with this ktd's issue:
https://gitlab.com/koha-community/koha-testing-docker/-/issues/374
Copy the modified git hook to .git/hooks/ktd/pre-commit
Edit a .js within koha-tmpl/intranet-tmpl/prog/js/vue and a .ts file
(cypress test) with something not pretty
Commit
=> Notice that the commit content is pretty!

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
2023-05-16 11:38:04 +02:00

61 lines
2.2 KiB
JavaScript

import { defineStore } from "pinia";
export const useAVStore = defineStore("authorised_values", {
state: () => ({
av_agreement_statuses: [],
av_agreement_closure_reasons: [],
av_agreement_renewal_priorities: [],
av_user_roles: [],
av_license_types: [],
av_license_statuses: [],
av_agreement_license_statuses: [],
av_agreement_license_location: [],
av_agreement_relationships: [
{ value: "supersedes", description: __("supersedes") },
{ value: "is-superseded-by", description: __("is superseded by") },
{
value: "provides_post-cancellation_access_for",
description: __("provides post-cancellation access for"),
},
{
value: "has-post-cancellation-access-in",
description: __("has post-cancellation access in"),
},
{
value: "tracks_demand-driven_acquisitions_for",
description: __("tracks demand-driven acquisitions for"),
},
{
value: "has-demand-driven-acquisitions-in",
description: __("has demand-driven acquisitions in"),
},
{ value: "has_backfile_in", description: __("has backfile in") },
{ value: "has_frontfile_in", description: __("has frontfile in") },
{ value: "related_to", description: __("related to") },
],
av_package_types: [],
av_package_content_types: [],
av_title_publication_types: [],
}),
actions: {
get_lib_from_av(arr_name, av) {
if (this[arr_name] === undefined) {
console.warn(
"The authorised value category for '%s' is not defined.".format(
arr_name
)
);
return;
}
let o = this[arr_name].find(e => e.value == av);
return o ? o.description : av;
},
map_av_dt_filter(arr_name) {
return this[arr_name].map(e => {
e["_id"] = e["value"];
e["_str"] = e["description"];
return e;
});
},
},
});