From 2adaddeea4321ed4c7e7a887dcbc0db4555b1e25 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 3 May 2022 15:55:22 +0200 Subject: [PATCH] Bug 32030: ERM - Refactoring We want the whole erm.pl to be a Vue app \o/ Signed-off-by: Jonathan Field Signed-off-by: Martin Renvoize Signed-off-by: Kyle M Hall Signed-off-by: Tomas Cohen Arazi --- erm/erm-home.pl | 38 ------------- erm/{agreements.pl => erm.pl} | 3 +- .../prog/en/includes/erm-menu.inc | 1 + .../intranet-tmpl/prog/en/includes/header.inc | 2 +- .../prog/en/modules/erm/erm-home.tt | 40 -------------- .../en/modules/erm/{agreements.tt => erm.tt} | 47 +--------------- .../prog/en/modules/intranet-main.tt | 2 +- .../vue/{ => components/ERM}/Agreements.vue | 10 ++-- .../prog/js/vue/components/ERM/Breadcrumb.vue | 33 +++++++++++ .../prog/js/vue/components/ERM/ERMHome.vue | 54 ++++++++++++++++++ .../prog/js/vue/components/ERM/ERMMain.vue | 55 +++++++++++++++++++ .../intranet-tmpl/prog/js/vue/main-erm.ts | 27 ++++++--- package.json | 3 +- 13 files changed, 176 insertions(+), 139 deletions(-) delete mode 100755 erm/erm-home.pl rename erm/{agreements.pl => erm.pl} (94%) delete mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/erm/erm-home.tt rename koha-tmpl/intranet-tmpl/prog/en/modules/erm/{agreements.tt => erm.tt} (54%) rename koha-tmpl/intranet-tmpl/prog/js/vue/{ => components/ERM}/Agreements.vue (91%) create mode 100644 koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/Breadcrumb.vue create mode 100644 koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/ERMHome.vue create mode 100644 koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/ERMMain.vue diff --git a/erm/erm-home.pl b/erm/erm-home.pl deleted file mode 100755 index e657e7df93..0000000000 --- a/erm/erm-home.pl +++ /dev/null @@ -1,38 +0,0 @@ -#! /usr/bin/perl - -# Copyright 2022 Koha Development Team -# -# 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 ); - -use Koha::Cities; - -my $input = CGI->new; - -my ( $template, $loggedinuser, $cookie ) = get_template_and_user( - { template_name => "erm/erm-home.tt", - query => $input, - type => "intranet", - flagsrequired => { erm => '*' }, - } -); - -output_html_with_http_headers $input, $cookie, $template->output; diff --git a/erm/agreements.pl b/erm/erm.pl similarity index 94% rename from erm/agreements.pl rename to erm/erm.pl index 99485df904..0e5dd55438 100755 --- a/erm/agreements.pl +++ b/erm/erm.pl @@ -23,13 +23,12 @@ use C4::Output qw( output_html_with_http_headers ); use Koha::DateUtils qw( dt_from_string ); use Koha::Acquisition::Booksellers; -use Koha::ERM::Agreements; my $input = CGI->new; my ( $template, $loggedinuser, $cookie ) = get_template_and_user( { - template_name => "erm/agreements.tt", + template_name => "erm/erm.tt", query => $input, type => "intranet", flagsrequired => { 'erm' => '1' }, diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/erm-menu.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/erm-menu.inc index f6a0f90649..d23e0fd0d9 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/erm-menu.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/erm-menu.inc @@ -3,6 +3,7 @@
ERM
diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/header.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/header.inc index d99ffe4929..147865d325 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/header.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/header.inc @@ -44,7 +44,7 @@
  • Serials
  • [% END %] [% IF Koha.Preference('ERMModule') && CAN_user_erm %] -
  • Electronic resources management
  • +
  • Electronic resources management
  • [% END %] [% IF ( Koha.Preference('UseCourseReserves') ) %]
  • Course reserves
  • diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/erm/erm-home.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/erm/erm-home.tt deleted file mode 100644 index 0417b04c84..0000000000 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/erm/erm-home.tt +++ /dev/null @@ -1,40 +0,0 @@ -[% USE raw %] -[% USE Koha %] -[% USE Branches %] -[% INCLUDE 'doc-head-open.inc' %] -Electronic resources management › Koha -[% INCLUDE 'doc-head-close.inc' %] - - -[% INCLUDE 'header.inc' %] -[% INCLUDE 'erm-search.inc' %] - - - -
    -
    -
    -

    Electronic resources management

    - - -
    -
    -
    - -[% INCLUDE 'intranet-bottom.inc' %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/erm/agreements.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/erm/erm.tt similarity index 54% rename from koha-tmpl/intranet-tmpl/prog/en/modules/erm/agreements.tt rename to koha-tmpl/intranet-tmpl/prog/en/modules/erm/erm.tt index 8680c6542d..bd71761c88 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/erm/agreements.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/erm/erm.tt @@ -7,16 +7,7 @@ [% SET footerjs = 1 %] [% INCLUDE 'doc-head-open.inc' %] - [% IF op =='add_form' %] - [% IF agreement.agreement_id %] - Modify agreement - [% ELSE %] - New agreement - [% END %] › [% ELSE %] - [% IF op == 'delete_confirm' %] - Confirm deletion of agreement › [% END %] - [% END %] - Agreements › Electronic resources management › Koha + Electronic resources management › Koha [% INCLUDE 'doc-head-close.inc' %] @@ -25,40 +16,9 @@ [% INCLUDE 'header.inc' %] [% INCLUDE 'erm-search.inc' %] - - -
    -
    -
    -
    - -
    - -
    -
    - -
    - -
    -
    +
    [% MACRO jsinclude BLOCK %] - [% Asset.js("js/erm-menu.js") | $raw %] [% INCLUDE 'calendar.inc' %] [% INCLUDE 'datatables.inc' %] [% INCLUDE 'columns_settings.inc' %] @@ -86,8 +46,7 @@ [% END %] - [% Asset.js("js/vue/dist/main.js") %] - [% Asset.js("js/vue/dist/runtime.js") %] + [% Asset.js("js/vue/dist/main.js") | $raw %] [% END %] [% INCLUDE 'intranet-bottom.inc' %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/intranet-main.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/intranet-main.tt index 3b9dbd00dd..744fd7ce4d 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/intranet-main.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/intranet-main.tt @@ -114,7 +114,7 @@ [% IF Koha.Preference('ERMModule') && CAN_user_erm %]
  • - Electronic resources management + Electronic resources management
  • [% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/Agreements.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/Agreements.vue similarity index 91% rename from koha-tmpl/intranet-tmpl/prog/js/vue/Agreements.vue rename to koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/Agreements.vue index 17ee020460..f5ca28b449 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/vue/Agreements.vue +++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/Agreements.vue @@ -46,11 +46,11 @@ diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/ERMHome.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/ERMHome.vue new file mode 100644 index 0000000000..d7fdfed4af --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/ERMHome.vue @@ -0,0 +1,54 @@ + + + diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/ERMMain.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/ERMMain.vue new file mode 100644 index 0000000000..f65874b6e2 --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/ERMMain.vue @@ -0,0 +1,55 @@ + + + diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/main-erm.ts b/koha-tmpl/intranet-tmpl/prog/js/vue/main-erm.ts index 691a47f31d..782bf678d4 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/vue/main-erm.ts +++ b/koha-tmpl/intranet-tmpl/prog/js/vue/main-erm.ts @@ -1,13 +1,26 @@ -import {createApp} from 'vue' +import { createApp } from "vue"; +import { createWebHistory, createRouter } from "vue-router"; -import {library} from "@fortawesome/fontawesome-svg-core" -import {faPlus, faPencil, faTrash} from "@fortawesome/free-solid-svg-icons" -import {FontAwesomeIcon} from "@fortawesome/vue-fontawesome" +import { library } from "@fortawesome/fontawesome-svg-core"; +import { faPlus, faPencil, faTrash } from "@fortawesome/free-solid-svg-icons"; +import { FontAwesomeIcon } from "@fortawesome/vue-fontawesome"; -library.add(faPlus, faPencil, faTrash) +library.add(faPlus, faPencil, faTrash); -import App from './Agreements.vue' +import App from "./components/ERM/ERMMain.vue"; +import Agreements from "./components/ERM/Agreements.vue"; + +const Bar = { template: "
    bar
    " }; +const Foo = { template: "
    foo
    " }; +const routes = [ + { path: "/cgi-bin/koha/erm/agreements", component: Agreements }, + { path: "/cgi-bin/koha/erm/licenses", component: Bar }, + { path: "/cgi-bin/koha/erm/erm.pl", component: Foo }, +]; + +const router = createRouter({ history: createWebHistory(), routes }); createApp(App) + .use(router) .component("font-awesome-icon", FontAwesomeIcon) - .mount('#agreements') + .mount("#erm"); diff --git a/package.json b/package.json index b428a0d417..c50f8c865e 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,8 @@ "mysql": "^2.18.1", "style-loader": "^3.3.1", "vue": "^3.2.31", - "vue-flatpickr-component": "^9" + "vue-flatpickr-component": "^9", + "vue-router": "^4.0.14" }, "scripts": { "build": "node_modules/.bin/gulp build", -- 2.39.5