Bug 33169: (QA follow-up) Tidy Vue-related files
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
parent
c61669f92c
commit
7b1391ea9f
|
|
@ -1,9 +1,9 @@
|
|||
export const $__ = (key) => {
|
||||
export const $__ = key => {
|
||||
return window["__"](key);
|
||||
};
|
||||
|
||||
export default {
|
||||
install: (app, options) => {
|
||||
app.config.globalProperties.$__ = $__
|
||||
app.config.globalProperties.$__ = $__;
|
||||
},
|
||||
};
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ app.mount("#erm");
|
|||
|
||||
const { removeMessages } = mainStore;
|
||||
router.beforeEach((to, from) => {
|
||||
navigationStore.$patch({current: to.matched, params: to.params||{}});
|
||||
navigationStore.$patch({ current: to.matched, params: to.params || {} });
|
||||
removeMessages(); // This will actually flag the messages as displayed already
|
||||
});
|
||||
router.afterEach((to, from) => {
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ export const routes = [
|
|||
path: "/cgi-bin/koha/erm/erm.pl",
|
||||
is_default: true,
|
||||
is_base: true,
|
||||
title: $__('E-resource management'),
|
||||
title: $__("E-resource management"),
|
||||
children: [
|
||||
{
|
||||
path: "",
|
||||
|
|
@ -47,8 +47,8 @@ export const routes = [
|
|||
},
|
||||
{
|
||||
path: "/cgi-bin/koha/erm/agreements",
|
||||
title: $__('Agreements'),
|
||||
icon: 'fa fa-check-circle',
|
||||
title: $__("Agreements"),
|
||||
icon: "fa fa-check-circle",
|
||||
is_end_node: true,
|
||||
children: [
|
||||
{
|
||||
|
|
@ -60,25 +60,25 @@ export const routes = [
|
|||
path: ":agreement_id",
|
||||
name: "AgreementsShow",
|
||||
component: markRaw(AgreementsShow),
|
||||
title: $__('Show agreement'),
|
||||
title: $__("Show agreement"),
|
||||
},
|
||||
{
|
||||
path: "add",
|
||||
name: "AgreementsFormAdd",
|
||||
component: markRaw(AgreementsFormAdd),
|
||||
title: $__('Add agreement'),
|
||||
title: $__("Add agreement"),
|
||||
},
|
||||
{
|
||||
path: "edit/:agreement_id",
|
||||
name: "AgreementsFormAddEdit",
|
||||
component: markRaw(AgreementsFormAdd),
|
||||
title: $__('Edit agreement'),
|
||||
title: $__("Edit agreement"),
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
path: "/cgi-bin/koha/erm/licenses",
|
||||
title: $__('Licenses'),
|
||||
title: $__("Licenses"),
|
||||
icon: "fa fa-gavel",
|
||||
is_end_node: true,
|
||||
children: [
|
||||
|
|
@ -91,105 +91,125 @@ export const routes = [
|
|||
path: ":license_id",
|
||||
name: "LicensesShow",
|
||||
component: markRaw(LicensesShow),
|
||||
title: $__('Show license'),
|
||||
title: $__("Show license"),
|
||||
},
|
||||
{
|
||||
path: "add",
|
||||
name: "LicensesFormAdd",
|
||||
component: markRaw(LicensesFormAdd),
|
||||
title: $__('Add license'),
|
||||
title: $__("Add license"),
|
||||
},
|
||||
{
|
||||
path: "edit/:license_id",
|
||||
name: "LicensesFormAddEdit",
|
||||
component: markRaw(LicensesFormAdd),
|
||||
title: $__('Edit license'),
|
||||
title: $__("Edit license"),
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
path: "/cgi-bin/koha/erm/eholdings",
|
||||
title: $__('eHoldings'),
|
||||
icon: 'fa fa-crosshairs',
|
||||
title: $__("eHoldings"),
|
||||
icon: "fa fa-crosshairs",
|
||||
disabled: true,
|
||||
children: [
|
||||
{
|
||||
path: "local",
|
||||
title: $__('Local'),
|
||||
title: $__("Local"),
|
||||
icon: "fa-solid fa-location-dot",
|
||||
disabled: true,
|
||||
children: [
|
||||
{
|
||||
path: "packages",
|
||||
title: $__('Packages'),
|
||||
title: $__("Packages"),
|
||||
icon: "fa fa-archive",
|
||||
is_end_node: true,
|
||||
children: [
|
||||
{
|
||||
path: "",
|
||||
name: "EHoldingsLocalPackagesList",
|
||||
component: markRaw(EHoldingsLocalPackagesList),
|
||||
component: markRaw(
|
||||
EHoldingsLocalPackagesList
|
||||
),
|
||||
},
|
||||
{
|
||||
path: ":package_id",
|
||||
name: "EHoldingsLocalPackagesShow",
|
||||
component: markRaw(EHoldingsLocalPackagesShow),
|
||||
title: $__('Show package'),
|
||||
component: markRaw(
|
||||
EHoldingsLocalPackagesShow
|
||||
),
|
||||
title: $__("Show package"),
|
||||
},
|
||||
{
|
||||
path: "add",
|
||||
name: "EHoldingsLocalPackagesFormAdd",
|
||||
component: markRaw(EHoldingsLocalPackagesFormAdd),
|
||||
title: $__('Add package'),
|
||||
component: markRaw(
|
||||
EHoldingsLocalPackagesFormAdd
|
||||
),
|
||||
title: $__("Add package"),
|
||||
},
|
||||
{
|
||||
path: "edit/:package_id",
|
||||
name: "EHoldingsLocalPackagesFormAddEdit",
|
||||
component: markRaw(EHoldingsLocalPackagesFormAdd),
|
||||
title: $__('Edit package'),
|
||||
component: markRaw(
|
||||
EHoldingsLocalPackagesFormAdd
|
||||
),
|
||||
title: $__("Edit package"),
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
path: "titles",
|
||||
title: $__('Titles'),
|
||||
title: $__("Titles"),
|
||||
icon: "fa-solid fa-arrow-down-a-z",
|
||||
is_end_node: true,
|
||||
children: [
|
||||
{
|
||||
path: "",
|
||||
name: "EHoldingsLocalTitlesList",
|
||||
component: markRaw(EHoldingsLocalTitlesList),
|
||||
component: markRaw(
|
||||
EHoldingsLocalTitlesList
|
||||
),
|
||||
},
|
||||
{
|
||||
path: ":title_id",
|
||||
name: "EHoldingsLocalTitlesShow",
|
||||
component: markRaw(EHoldingsLocalTitlesShow),
|
||||
title: $__('Show title'),
|
||||
component: markRaw(
|
||||
EHoldingsLocalTitlesShow
|
||||
),
|
||||
title: $__("Show title"),
|
||||
},
|
||||
{
|
||||
path: "add",
|
||||
name: "EHoldingsLocalTitlesFormAdd",
|
||||
component: markRaw(EHoldingsLocalTitlesFormAdd),
|
||||
title: $__('Add title'),
|
||||
component: markRaw(
|
||||
EHoldingsLocalTitlesFormAdd
|
||||
),
|
||||
title: $__("Add title"),
|
||||
},
|
||||
{
|
||||
path: "edit/:title_id",
|
||||
name: "EHoldingsLocalTitlesFormAddEdit",
|
||||
component: markRaw(EHoldingsLocalTitlesFormAdd),
|
||||
title: $__('Edit title'),
|
||||
component: markRaw(
|
||||
EHoldingsLocalTitlesFormAdd
|
||||
),
|
||||
title: $__("Edit title"),
|
||||
},
|
||||
{
|
||||
path: "import",
|
||||
name: "EHoldingsLocalTitlesFormImport",
|
||||
component: markRaw(EHoldingsLocalTitlesFormImport),
|
||||
title: $__('Import from a list'),
|
||||
component: markRaw(
|
||||
EHoldingsLocalTitlesFormImport
|
||||
),
|
||||
title: $__("Import from a list"),
|
||||
},
|
||||
{
|
||||
path: "/cgi-bin/koha/erm/eholdings/local/resources/:resource_id",
|
||||
name: "EHoldingsLocalResourcesShow",
|
||||
component: markRaw(EHoldingsLocalResourcesShow),
|
||||
title: $__('Resource'),
|
||||
component: markRaw(
|
||||
EHoldingsLocalResourcesShow
|
||||
),
|
||||
title: $__("Resource"),
|
||||
},
|
||||
],
|
||||
},
|
||||
|
|
@ -197,51 +217,61 @@ export const routes = [
|
|||
},
|
||||
{
|
||||
path: "ebsco",
|
||||
title: $__('EBSCO'),
|
||||
icon: 'fa fa-globe',
|
||||
title: $__("EBSCO"),
|
||||
icon: "fa fa-globe",
|
||||
disabled: true,
|
||||
children: [
|
||||
{
|
||||
path: "packages",
|
||||
title: $__('Packages'),
|
||||
title: $__("Packages"),
|
||||
icon: "fa fa-archive",
|
||||
is_end_node: true,
|
||||
children: [
|
||||
{
|
||||
path: "",
|
||||
name: "EHoldingsEBSCOPackagesList",
|
||||
component: markRaw(EHoldingsEBSCOPackagesList),
|
||||
component: markRaw(
|
||||
EHoldingsEBSCOPackagesList
|
||||
),
|
||||
},
|
||||
{
|
||||
path: ":package_id",
|
||||
name: "EHoldingsEBSCOPackagesShow",
|
||||
component: markRaw(EHoldingsEBSCOPackagesShow),
|
||||
title: $__('Show package'),
|
||||
component: markRaw(
|
||||
EHoldingsEBSCOPackagesShow
|
||||
),
|
||||
title: $__("Show package"),
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
path: "titles",
|
||||
title: $__('Titles'),
|
||||
title: $__("Titles"),
|
||||
icon: "fa-solid fa-arrow-down-a-z",
|
||||
is_end_node: true,
|
||||
children: [
|
||||
{
|
||||
path: "",
|
||||
name: "EHoldingsEBSCOTitlesList",
|
||||
component: markRaw(EHoldingsEBSCOTitlesList),
|
||||
component: markRaw(
|
||||
EHoldingsEBSCOTitlesList
|
||||
),
|
||||
},
|
||||
{
|
||||
path: ":title_id",
|
||||
name: "EHoldingsEBSCOTitlesShow",
|
||||
component: markRaw(EHoldingsEBSCOTitlesShow),
|
||||
title: $__('Show title'),
|
||||
component: markRaw(
|
||||
EHoldingsEBSCOTitlesShow
|
||||
),
|
||||
title: $__("Show title"),
|
||||
},
|
||||
{
|
||||
path: "/cgi-bin/koha/erm/eholdings/ebsco/resources/:resource_id",
|
||||
name: "EHoldingsEBSCOResourcesShow",
|
||||
component: markRaw(EHoldingsEBSCOResourcesShow),
|
||||
title: $__('Resource'),
|
||||
component: markRaw(
|
||||
EHoldingsEBSCOResourcesShow
|
||||
),
|
||||
title: $__("Resource"),
|
||||
is_navigation_item: false,
|
||||
},
|
||||
],
|
||||
|
|
@ -250,6 +280,6 @@ export const routes = [
|
|||
},
|
||||
],
|
||||
},
|
||||
]
|
||||
],
|
||||
},
|
||||
];
|
||||
|
|
|
|||
|
|
@ -1,6 +1,4 @@
|
|||
import {
|
||||
defineStore
|
||||
} from "pinia";
|
||||
import { defineStore } from "pinia";
|
||||
|
||||
export const useNavigationStore = defineStore("navigation", {
|
||||
state: () => ({
|
||||
|
|
@ -9,7 +7,7 @@ export const useNavigationStore = defineStore("navigation", {
|
|||
href: "/cgi-bin/koha/mainpage.pl",
|
||||
is_navigation_item: false,
|
||||
is_base: true,
|
||||
children: []
|
||||
children: [],
|
||||
},
|
||||
current: null,
|
||||
params: {},
|
||||
|
|
@ -17,12 +15,12 @@ export const useNavigationStore = defineStore("navigation", {
|
|||
actions: {
|
||||
setRoutes(routesDef) {
|
||||
if (!Array.isArray(routesDef)) {
|
||||
routesDef = [routesDef]
|
||||
routesDef = [routesDef];
|
||||
}
|
||||
this.routeState.children = routesDef
|
||||
_traverseChildren(this.routeState)
|
||||
this.routeState.children = routesDef;
|
||||
_traverseChildren(this.routeState);
|
||||
|
||||
return this.navigationRoutes
|
||||
return this.navigationRoutes;
|
||||
|
||||
// Function declarations
|
||||
|
||||
|
|
@ -30,8 +28,8 @@ export const useNavigationStore = defineStore("navigation", {
|
|||
if (isParent(parent)) {
|
||||
parent.children.forEach(child => {
|
||||
_setChildDefaults(parent, child);
|
||||
_traverseChildren(child)
|
||||
})
|
||||
_traverseChildren(child);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -43,54 +41,63 @@ export const useNavigationStore = defineStore("navigation", {
|
|||
if (parent.children.length === 1 && parent.is_base) {
|
||||
_setBaseAndNavigationDefaults(child, {
|
||||
is_base: true,
|
||||
is_navigation_item: false
|
||||
is_navigation_item: false,
|
||||
});
|
||||
} else {
|
||||
_setBaseAndNavigationDefaults(child, {
|
||||
is_base: false,
|
||||
is_navigation_item: true
|
||||
is_navigation_item: true,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function _setBaseAndNavigationDefaults(child, {
|
||||
is_base,
|
||||
is_navigation_item
|
||||
}) {
|
||||
child.is_base = child.is_base !== undefined ? child.is_base : is_base;
|
||||
child.is_navigation_item = child.is_navigation_item !== undefined ? child.is_navigation_item : is_navigation_item;
|
||||
function _setBaseAndNavigationDefaults(
|
||||
child,
|
||||
{ is_base, is_navigation_item }
|
||||
) {
|
||||
child.is_base =
|
||||
child.is_base !== undefined ? child.is_base : is_base;
|
||||
child.is_navigation_item =
|
||||
child.is_navigation_item !== undefined
|
||||
? child.is_navigation_item
|
||||
: is_navigation_item;
|
||||
}
|
||||
|
||||
function _setMetadata(child) {
|
||||
if (!child.meta)
|
||||
child.meta = {};
|
||||
if (!child.meta) child.meta = {};
|
||||
child.meta.self = child;
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
getters: {
|
||||
breadcrumbs() {
|
||||
if (this.current)
|
||||
return _buildFromCurrentMatches(this.current, this.routeState)
|
||||
return _buildFromCurrentMatches(this.current, this.routeState);
|
||||
|
||||
return _getBaseElements(this.routeState)
|
||||
return _getBaseElements(this.routeState);
|
||||
|
||||
// Function declarations
|
||||
|
||||
function _getBaseElements(parent) {
|
||||
if (!parent.is_base) return []
|
||||
let next = {}
|
||||
if (!parent.is_base) return [];
|
||||
let next = {};
|
||||
if (isParent(parent)) {
|
||||
next = _defineNextElement(parent)
|
||||
next = _defineNextElement(parent);
|
||||
}
|
||||
return [{
|
||||
...parent,
|
||||
children: null
|
||||
}, ..._getBaseElements(next)]
|
||||
return [
|
||||
{
|
||||
...parent,
|
||||
children: null,
|
||||
},
|
||||
..._getBaseElements(next),
|
||||
];
|
||||
}
|
||||
|
||||
function _defineNextElement(parent) {
|
||||
return parent.children.find(child => child.is_default) || parent.children[0];
|
||||
return (
|
||||
parent.children.find(child => child.is_default) ||
|
||||
parent.children[0]
|
||||
);
|
||||
}
|
||||
|
||||
function _buildFromCurrentMatches(currentMatches, routeState) {
|
||||
|
|
@ -98,50 +105,49 @@ export const useNavigationStore = defineStore("navigation", {
|
|||
{
|
||||
...routeState,
|
||||
icon: null,
|
||||
children: null
|
||||
children: null,
|
||||
},
|
||||
..._mapMatches(currentMatches)
|
||||
..._mapMatches(currentMatches),
|
||||
];
|
||||
}
|
||||
|
||||
function _isBaseOrNotStub(child) {
|
||||
return child.is_base || (child.path && child.path !== '');
|
||||
return child.is_base || (child.path && child.path !== "");
|
||||
}
|
||||
|
||||
function _mapMatches(currentMatches) {
|
||||
return currentMatches
|
||||
.filter((match) => _isBaseOrNotStub(match.meta.self))
|
||||
.map((match) => ({
|
||||
.filter(match => _isBaseOrNotStub(match.meta.self))
|
||||
.map(match => ({
|
||||
...match.meta.self,
|
||||
icon: null,
|
||||
path: match.path,
|
||||
children: null
|
||||
children: null,
|
||||
}));
|
||||
}
|
||||
|
||||
},
|
||||
leftNavigation() {
|
||||
return _getNavigationElements(this.routeState)
|
||||
return _getNavigationElements(this.routeState);
|
||||
|
||||
// Function declarations
|
||||
|
||||
function _getNavigationElements(parent, prevPath = '') {
|
||||
function _getNavigationElements(parent, prevPath = "") {
|
||||
if (_isBaseAndNoChildren(parent)) return [];
|
||||
if (parent.is_base)
|
||||
return _buildChildNavigationElements(parent).flat(Infinity)
|
||||
return _buildChildNavigationElements(parent).flat(Infinity);
|
||||
|
||||
const builtPath = _buildPath(prevPath, parent);
|
||||
|
||||
let children = []
|
||||
let children = [];
|
||||
if (!parent.is_end_node && isParent(parent)) {
|
||||
children = _buildChildNavigationElements(parent, builtPath)
|
||||
children = _buildChildNavigationElements(parent, builtPath);
|
||||
}
|
||||
|
||||
return {
|
||||
...parent,
|
||||
path: builtPath ? builtPath : parent.path,
|
||||
children
|
||||
}
|
||||
children,
|
||||
};
|
||||
}
|
||||
|
||||
function _buildPath(prevPath, element) {
|
||||
|
|
@ -151,9 +157,10 @@ export const useNavigationStore = defineStore("navigation", {
|
|||
builtPath = element.path;
|
||||
} else {
|
||||
if (prevPath)
|
||||
builtPath = '' + prevPath + addSlashIfNotPresent(prevPath);
|
||||
builtPath =
|
||||
"" + prevPath + addSlashIfNotPresent(prevPath);
|
||||
if (isRoutable(element))
|
||||
builtPath = '' + builtPath + element.path;
|
||||
builtPath = "" + builtPath + element.path;
|
||||
}
|
||||
|
||||
return builtPath;
|
||||
|
|
@ -166,19 +173,21 @@ export const useNavigationStore = defineStore("navigation", {
|
|||
}
|
||||
|
||||
function _isBaseAndNoChildren(parent) {
|
||||
return parent.is_base && (!parent.children || !parent.children.length);
|
||||
return (
|
||||
parent.is_base &&
|
||||
(!parent.children || !parent.children.length)
|
||||
);
|
||||
}
|
||||
},
|
||||
navigationRoutes() {
|
||||
let routes = _toRoute(this.routeState)
|
||||
return Array.isArray(routes) ? routes : [routes]
|
||||
let routes = _toRoute(this.routeState);
|
||||
return Array.isArray(routes) ? routes : [routes];
|
||||
|
||||
// Function declarations
|
||||
|
||||
function _toRoute(parent) {
|
||||
if (!isRoutable(parent))
|
||||
return _getRoutableChildren(parent)
|
||||
return parent
|
||||
if (!isRoutable(parent)) return _getRoutableChildren(parent);
|
||||
return parent;
|
||||
}
|
||||
|
||||
function _getRoutableChildren(parent) {
|
||||
|
|
@ -186,12 +195,12 @@ export const useNavigationStore = defineStore("navigation", {
|
|||
.map(child => _toRoute(child))
|
||||
.flat(Infinity);
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
function addSlashIfNotPresent(path) {
|
||||
return /\/$/.test(path) ? '' : '/';
|
||||
return /\/$/.test(path) ? "" : "/";
|
||||
}
|
||||
|
||||
function isRoutable(element) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue