From 88b738828b51ae0b084f1983afcd63e3646523de Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 24 May 2022 12:45:11 +0200 Subject: [PATCH] Bug 32030: eHoldings - Vue Please enter the commit message for your changes. Lines starting Signed-off-by: Jonathan Field Signed-off-by: Martin Renvoize Signed-off-by: Kyle M Hall Signed-off-by: Tomas Cohen Arazi --- .../intranet-tmpl/prog/en/modules/erm/erm.tt | 12 + .../vue/components/ERM/EHoldingsFormAdd.vue | 463 ++++++++++++++++++ .../ERM/EHoldingsFormConfirmDelete.vue | 86 ++++ .../js/vue/components/ERM/EHoldingsList.vue | 149 ++++++ .../js/vue/components/ERM/EHoldingsShow.vue | 253 ++++++++++ .../vue/components/ERM/EHoldingsToolbar.vue | 12 + .../prog/js/vue/components/ERM/ERMMain.vue | 8 + koha-tmpl/intranet-tmpl/prog/js/vue/fetch.js | 59 ++- koha-tmpl/intranet-tmpl/prog/js/vue/routes.js | 67 ++- 9 files changed, 1100 insertions(+), 9 deletions(-) create mode 100644 koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsFormAdd.vue create mode 100644 koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsFormConfirmDelete.vue create mode 100644 koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsList.vue create mode 100644 koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsShow.vue create mode 100644 koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsToolbar.vue diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/erm/erm.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/erm/erm.tt index 79ba61a18a..1c27013397 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/erm/erm.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/erm/erm.tt @@ -78,6 +78,18 @@ packages_table_url += 'q='+ encodeURIComponent(JSON.stringify(package_name_filter)); [% END %] + var eholding_table_settings = [% TablesSettings.GetTableSettings( 'erm', 'eholdings', 'eholdings', 'json' ) | $raw %]; + + var eholdings_table_url = '/api/v1/erm/eholdings?'; + [% IF eholding_name_filter %] + var eholding_name_filter = { + 'name': { + "like": '%[%- eholding_name_filter | html -%]%' + } + }; + eholdings_table_url += 'q='+ encodeURIComponent(JSON.stringify(eholding_name_filter)); + [% END %] + [% Asset.js("js/vue/dist/main.js") | $raw %] diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsFormAdd.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsFormAdd.vue new file mode 100644 index 0000000000..d7ebb4885f --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsFormAdd.vue @@ -0,0 +1,463 @@ + + + + \ No newline at end of file diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsFormConfirmDelete.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsFormConfirmDelete.vue new file mode 100644 index 0000000000..ae08c91eb4 --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsFormConfirmDelete.vue @@ -0,0 +1,86 @@ + + + diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsList.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsList.vue new file mode 100644 index 0000000000..3516470952 --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsList.vue @@ -0,0 +1,149 @@ + + + diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsShow.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsShow.vue new file mode 100644 index 0000000000..07e70e50e3 --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsShow.vue @@ -0,0 +1,253 @@ + + + + \ No newline at end of file diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsToolbar.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsToolbar.vue new file mode 100644 index 0000000000..8403568549 --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsToolbar.vue @@ -0,0 +1,12 @@ + + + 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 index 4001bd95eb..ffe1f1f72a 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/ERMMain.vue +++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/ERMMain.vue @@ -31,6 +31,14 @@ {{ $t("Packages") }} +
  • + + + {{ $t("eHoldings") }} +
  • res.json()) + .then(checkError) .then( (result) => { agreement = result; @@ -26,7 +26,7 @@ export const fetchAgreements = async function () { const apiUrl = "/api/v1/erm/agreements"; let agreements; await fetch(apiUrl) - .then((res) => res.json()) + .then(checkError) .then( (result) => { agreements = result; @@ -43,7 +43,7 @@ export const fetchLicense = async function (license_id) { const apiUrl = "/api/v1/erm/licenses/" + license_id; let license; await fetch(apiUrl) - .then((res) => res.json()) + .then(checkError) .then( (result) => { license = result; @@ -59,7 +59,7 @@ export const fetchLicenses = async function () { const apiUrl = "/api/v1/erm/licenses"; let licenses; await fetch(apiUrl) - .then((res) => res.json()) + .then(checkError) .then( (result) => { licenses = result; @@ -76,7 +76,7 @@ export const fetchPatron = async function (patron_id) { const apiUrl = "/api/v1/patrons/" + patron_id; let patron; await fetch(apiUrl) - .then((res) => res.json()) + .then(checkError) .then( (result) => { patron = result; @@ -92,7 +92,7 @@ export const fetchVendors = async function () { const apiUrl = "/api/v1/acquisitions/vendors"; let vendors; await fetch(apiUrl) - .then((res) => res.json()) + .then(checkError) .then( (result) => { vendors = result; @@ -113,7 +113,7 @@ export const fetchPackage = async function (package_id) { "x-koha-embed": "package_agreements,package_agreements.agreement", }, }) - .then((res) => res.json()) + .then(checkError) .then( (result) => { erm_package = result; @@ -129,7 +129,7 @@ export const fetchPackages = async function () { const apiUrl = "/api/v1/erm/packages"; let packages; await fetch(apiUrl) - .then((res) => res.json()) + .then(checkError) .then( (result) => { packages = result; @@ -140,3 +140,46 @@ export const fetchPackages = async function () { ); return packages; }; + +export const fetchEHolding = async function (eholding_id) { + if (!eholding_id) return; + const apiUrl = "/api/v1/erm/eholdings/" + eholding_id; + let erm_eholding; + await fetch(apiUrl) + .then(checkError) + .then( + (result) => { + erm_eholding = result; + }, + (error) => { + setError(error); + } + ); + return erm_eholding; +}; + +export const fetchEHoldings = async function () { + const apiUrl = "/api/v1/erm/eholdings"; + let eholdings; + await fetch(apiUrl) + .then(checkError) + .then( + (result) => { + eholdings = result; + }, + (error) => { + setError(error); + } + ); + return eholdings; +}; + +function checkError(response) { + if (response.status >= 200 && response.status <= 299) { + return response.json(); + } else { + console.log("Server returned an error:"); + console.log(response); + setError("%s (%s)".format(response.statusText, response.status)); + } +} diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/routes.js b/koha-tmpl/intranet-tmpl/prog/js/vue/routes.js index 5c3c91063c..76ce3f383b 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/vue/routes.js +++ b/koha-tmpl/intranet-tmpl/prog/js/vue/routes.js @@ -7,6 +7,10 @@ import PackagesList from "./components/ERM/PackagesList.vue"; import PackagesShow from "./components/ERM/PackagesShow.vue"; import PackagesFormAdd from "./components/ERM/PackagesFormAdd.vue"; import PackagesFormConfirmDelete from "./components/ERM/PackagesFormConfirmDelete.vue"; +import EHoldingsList from "./components/ERM/EHoldingsList.vue"; +import EHoldingsShow from "./components/ERM/EHoldingsShow.vue"; +import EHoldingsFormAdd from "./components/ERM/EHoldingsFormAdd.vue"; +import EHoldingsFormConfirmDelete from "./components/ERM/EHoldingsFormConfirmDelete.vue"; import LicensesList from "./components/ERM/LicensesList.vue"; import LicensesShow from "./components/ERM/LicensesShow.vue"; import LicensesFormAdd from "./components/ERM/LicensesFormAdd.vue"; @@ -19,8 +23,9 @@ const breadcrumbs = { path: "/cgi-bin/koha/erm/erm.pl", }, agreements: { text: "Agreements", path: "/cgi-bin/koha/erm/agreements" }, - licenses: { text: "Licenses", path: "/cgi-bin/koha/erm/licenses" }, packages: { text: "Packages", path: "/cgi-bin/koha/erm/packages" }, + eholdings: { text: "eHoldings", path: "/cgi-bin/koha/erm/eholdings" }, + licenses: { text: "Licenses", path: "/cgi-bin/koha/erm/licenses" }, }; export const routes = [ { path: "/cgi-bin/koha/mainpage.pl" }, @@ -151,6 +156,66 @@ export const routes = [ view: "edit", }, }, + { + path: "/cgi-bin/koha/erm/eholdings", + component: EHoldingsList, + meta: { + breadcrumb: [ + breadcrumbs.home, + breadcrumbs.erm_home, + breadcrumbs.eholdings, + ], + view: "list", + }, + }, + { + path: "/cgi-bin/koha/erm/eholdings/:eholding_id", + component: EHoldingsShow, + meta: { + breadcrumb: [ + breadcrumbs.home, + breadcrumbs.erm_home, + breadcrumbs.eholdings, + ], + view: "show", + }, + }, + { + path: "/cgi-bin/koha/erm/eholdings/delete/:eholding_id", + component: EHoldingsFormConfirmDelete, + meta: { + breadcrumb: [ + breadcrumbs.home, + breadcrumbs.erm_home, + breadcrumbs.eholdings, + ], + view: "confirm-delete-form", + }, + }, + { + path: "/cgi-bin/koha/erm/eholdings/add", + component: EHoldingsFormAdd, + meta: { + breadcrumb: [ + breadcrumbs.home, + breadcrumbs.erm_home, + breadcrumbs.eholdings, + ], + view: "add", + }, + }, + { + path: "/cgi-bin/koha/erm/eholdings/edit/:eholding_id", + component: EHoldingsFormAdd, + meta: { + breadcrumb: [ + breadcrumbs.home, + breadcrumbs.erm_home, + breadcrumbs.eholdings, + ], + view: "edit", + }, + }, { path: "/cgi-bin/koha/erm/licenses", component: LicensesList, -- 2.39.5