From 38fe4442d2901a28220d25206dc13cebc469a06c Mon Sep 17 00:00:00 2001 From: Pedro Amorim Date: Thu, 10 Oct 2024 09:31:24 +0000 Subject: [PATCH] Bug 37893: SIP2 VueJS module scaffolding Signed-off-by: Andrew Fuerste Henry Signed-off-by: Lisette Scheer Signed-off-by: Martin Renvoize Signed-off-by: Lucas Gass --- Makefile.PL | 1 + debian/templates/apache-shared-intranet.conf | 1 + .../prog/en/modules/sip2/sip2.tt | 22 ++++ .../prog/js/fetch/sip2-api-client.js | 18 +++ .../prog/js/vue/components/SIP2/Home.vue | 11 ++ .../prog/js/vue/components/SIP2/Main.vue | 118 ++++++++++++++++++ .../components/SIP2/SIP2InstitutionsList.vue | 35 ++++++ .../prog/js/vue/fetch/api-client.js | 2 + .../intranet-tmpl/prog/js/vue/modules/sip2.ts | 65 ++++++++++ .../intranet-tmpl/prog/js/vue/routes/sip2.js | 36 ++++++ .../intranet-tmpl/prog/js/vue/stores/sip2.js | 9 ++ rspack.config.js | 1 + sip2/sip2.pl | 37 ++++++ 13 files changed, 356 insertions(+) create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/sip2/sip2.tt create mode 100644 koha-tmpl/intranet-tmpl/prog/js/fetch/sip2-api-client.js create mode 100644 koha-tmpl/intranet-tmpl/prog/js/vue/components/SIP2/Home.vue create mode 100644 koha-tmpl/intranet-tmpl/prog/js/vue/components/SIP2/Main.vue create mode 100644 koha-tmpl/intranet-tmpl/prog/js/vue/components/SIP2/SIP2InstitutionsList.vue create mode 100644 koha-tmpl/intranet-tmpl/prog/js/vue/modules/sip2.ts create mode 100644 koha-tmpl/intranet-tmpl/prog/js/vue/routes/sip2.js create mode 100644 koha-tmpl/intranet-tmpl/prog/js/vue/stores/sip2.js create mode 100644 sip2/sip2.pl diff --git a/Makefile.PL b/Makefile.PL index 757a8d85cd..bac08cbd7b 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -362,6 +362,7 @@ my $target_map = { './rotating_collections' => 'INTRANET_CGI_DIR', './serials' => 'INTRANET_CGI_DIR', './services' => 'INTRANET_CGI_DIR', + './sip2' => 'INTRANET_CGI_DIR', './skel' => 'NONE', './skel/var/lock/koha' => { target => 'LOCK_DIR', trimdir => -1 }, './skel/var/log/koha' => { target => 'LOG_DIR', trimdir => -1 }, diff --git a/debian/templates/apache-shared-intranet.conf b/debian/templates/apache-shared-intranet.conf index ad00145832..672cf8fe03 100644 --- a/debian/templates/apache-shared-intranet.conf +++ b/debian/templates/apache-shared-intranet.conf @@ -21,6 +21,7 @@ RewriteRule ^/issn/([^\/]*)/?$ /search?q=issn:$1 [PT] RewriteRule ^(.*)_[0-9]{2}\.[0-9]{7}\.(js|css)$ $1.$2 [L] RewriteRule ^/cgi-bin/koha/erm/.*$ /cgi-bin/koha/erm/erm.pl [PT] +RewriteRule ^/cgi-bin/koha/sip2/.*$ /cgi-bin/koha/sip2/sip2.pl [PT] RewriteCond %{REQUEST_URI} !^/cgi-bin/koha/preservation/.*.pl$ RewriteRule ^/cgi-bin/koha/preservation/.*$ /cgi-bin/koha/preservation/home.pl [PT] RewriteRule ^/cgi-bin/koha/admin/record_sources(.*)?$ /cgi-bin/koha/admin/record_sources.pl$1 [PT] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/sip2/sip2.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/sip2/sip2.tt new file mode 100644 index 0000000000..6c0a0eee0b --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/sip2/sip2.tt @@ -0,0 +1,22 @@ +[% SET footerjs = 1 %] +[% INCLUDE 'doc-head-open.inc' %] + SIP2 › Koha +[% INCLUDE 'doc-head-close.inc' %] + + + +[% WRAPPER 'header.inc' %] + [% INCLUDE 'prefs-admin-search.inc' %] +[% END %] + +
+ + + [% MACRO jsinclude BLOCK %] + [% INCLUDE 'calendar.inc' %] + [% INCLUDE 'datatables.inc' %] + + [% Asset.js("js/vue/dist/sip2.js") | $raw %] + [% END %] + [% INCLUDE 'intranet-bottom.inc' %] +
diff --git a/koha-tmpl/intranet-tmpl/prog/js/fetch/sip2-api-client.js b/koha-tmpl/intranet-tmpl/prog/js/fetch/sip2-api-client.js new file mode 100644 index 0000000000..993c7f1b66 --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/js/fetch/sip2-api-client.js @@ -0,0 +1,18 @@ +export class SIP2APIClient { + constructor(HttpClient) { + this.httpClient = new HttpClient({ + baseURL: "/api/v1/sip2", + }); + } + + get institutions() { + return { + getAll: params => + this.getAll({ + endpoint: "institutions", + }), + }; + } +} + +export default SIP2APIClient; diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/SIP2/Home.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/SIP2/Home.vue new file mode 100644 index 0000000000..26914ef9b9 --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/SIP2/Home.vue @@ -0,0 +1,11 @@ + + + diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/SIP2/Main.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/SIP2/Main.vue new file mode 100644 index 0000000000..08b75c8d67 --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/SIP2/Main.vue @@ -0,0 +1,118 @@ + + + + + diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/SIP2/SIP2InstitutionsList.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/SIP2/SIP2InstitutionsList.vue new file mode 100644 index 0000000000..f3c4be2667 --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/SIP2/SIP2InstitutionsList.vue @@ -0,0 +1,35 @@ + + + diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/fetch/api-client.js b/koha-tmpl/intranet-tmpl/prog/js/vue/fetch/api-client.js index d7b00857aa..1b962d3cb2 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/vue/fetch/api-client.js +++ b/koha-tmpl/intranet-tmpl/prog/js/vue/fetch/api-client.js @@ -8,6 +8,7 @@ import AVAPIClient from "@fetch/authorised-values-api-client"; import ItemAPIClient from "@fetch/item-api-client"; import RecordSourcesAPIClient from "@fetch/record-sources-api-client"; import SysprefAPIClient from "@fetch/system-preferences-api-client"; +import SIP2APIClient from "@fetch/ssip2-api-client"; import PreservationAPIClient from "@fetch/preservation-api-client"; export const APIClient = { @@ -18,6 +19,7 @@ export const APIClient = { authorised_values: new AVAPIClient(HttpClient), item: new ItemAPIClient(HttpClient), sysprefs: new SysprefAPIClient(HttpClient), + sip2: new SIP2APIClient(HttpClient), preservation: new PreservationAPIClient(HttpClient), record_sources: new RecordSourcesAPIClient(HttpClient), }; diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/modules/sip2.ts b/koha-tmpl/intranet-tmpl/prog/js/vue/modules/sip2.ts new file mode 100644 index 0000000000..c12a3fb08f --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/js/vue/modules/sip2.ts @@ -0,0 +1,65 @@ +import { createApp } from "vue"; +import { createWebHistory, createRouter } from "vue-router"; +import { createPinia } from "pinia"; + +import { library } from "@fortawesome/fontawesome-svg-core"; +import { + faPlus, + faMinus, + faPencil, + faTrash, + faSpinner, +} from "@fortawesome/free-solid-svg-icons"; +import { FontAwesomeIcon } from "@fortawesome/vue-fontawesome"; +import vSelect from "vue-select"; + +library.add(faPlus, faMinus, faPencil, faTrash, faSpinner); + +import App from "../components/SIP2/Main.vue"; + +import { routes as routesDef } from "../routes/sip2"; + +import { useMainStore } from "../stores/main"; +import { useVendorStore } from "../stores/vendors"; +import { useAVStore } from "../stores/authorised-values"; +import { useSIP2Store } from "../stores/sip2"; +import { useNavigationStore } from "../stores/navigation"; +import i18n from "../i18n"; + +const pinia = createPinia(); + +const mainStore = useMainStore(pinia); +const AVStore = useAVStore(pinia); +const navigationStore = useNavigationStore(pinia); +const routes = navigationStore.setRoutes(routesDef); + +const router = createRouter({ + history: createWebHistory(), + linkActiveClass: "current", + routes, +}); + +const app = createApp(App); + +const rootComponent = app + .use(i18n) + .use(pinia) + .use(router) + .component("font-awesome-icon", FontAwesomeIcon) + .component("v-select", vSelect); + +app.config.unwrapInjectedRef = true; +app.provide("vendorStore", useVendorStore(pinia)); +app.provide("mainStore", mainStore); +app.provide("AVStore", AVStore); +app.provide("navigationStore", navigationStore); +const SIP2Store = useSIP2Store(pinia); +app.provide("SIP2Store", SIP2Store); + +app.mount("#sip2"); + +const { removeMessages } = mainStore; +router.beforeEach((to, from) => { + navigationStore.$patch({ current: to.matched, params: to.params || {} }); + removeMessages(); // This will actually flag the messages as displayed already +}); diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/routes/sip2.js b/koha-tmpl/intranet-tmpl/prog/js/vue/routes/sip2.js new file mode 100644 index 0000000000..6cf9309dfb --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/js/vue/routes/sip2.js @@ -0,0 +1,36 @@ +import { markRaw } from "vue"; + +import Home from "../components/SIP2/Home.vue"; +import SIP2InstitutionsList from "../components/SIP2/SIP2InstitutionsList.vue"; + +import { $__ } from "../i18n"; + +export const routes = [ + { + path: "/cgi-bin/koha/sip2/sip2.pl", + is_default: true, + is_base: true, + title: $__("SIP2"), + children: [ + { + path: "", + name: "Home", + component: markRaw(Home), + is_navigation_item: false, + }, + { + path: "/cgi-bin/koha/sip2/institutions", + title: $__("Institutions"), + icon: "fa fa-building-columns", + is_end_node: true, + children: [ + { + path: "", + name: "SIP2InstitutionsList", + component: markRaw(SIP2InstitutionsList), + }, + ], + }, + ], + }, +]; diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/stores/sip2.js b/koha-tmpl/intranet-tmpl/prog/js/vue/stores/sip2.js new file mode 100644 index 0000000000..ae48e649c8 --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/js/vue/stores/sip2.js @@ -0,0 +1,9 @@ +import { defineStore } from "pinia"; + +export const useSIP2Store = defineStore("sip2", { + state: () => ({ + config: { + displayRestartSIPDialog: true, + }, + }), +}); diff --git a/rspack.config.js b/rspack.config.js index e05273fb7b..a2c403d6cb 100644 --- a/rspack.config.js +++ b/rspack.config.js @@ -27,6 +27,7 @@ module.exports = [ acquisitions: "./koha-tmpl/intranet-tmpl/prog/js/vue/modules/acquisitions.ts", islands: "./koha-tmpl/intranet-tmpl/prog/js/vue/modules/islands.ts", + sip2: "./koha-tmpl/intranet-tmpl/prog/js/vue/modules/sip2.ts", }, output: { filename: "[name].js", diff --git a/sip2/sip2.pl b/sip2/sip2.pl new file mode 100644 index 0000000000..eea7eae149 --- /dev/null +++ b/sip2/sip2.pl @@ -0,0 +1,37 @@ +#!/usr/bin/perl + +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# Koha is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Koha; if not, see . + +use Modern::Perl; + +use CGI qw ( -utf8 ); +use C4::Context; +use C4::Auth qw( get_template_and_user ); +use C4::Output qw( output_html_with_http_headers ); + +my $input = CGI->new; + +my ( $template, $loggedinuser, $cookie ) = get_template_and_user( + { + template_name => "sip2/sip2.tt", + query => $input, + type => "intranet", + + # flagsrequired => { 'plugins' => '*' }, + } +); + +output_html_with_http_headers $input, $cookie, $template->output;