From e9ff2dfda86afd324599db55b89f5683c1990e12 Mon Sep 17 00:00:00 2001 From: Johannes Raggam Date: Fri, 25 Oct 2024 02:15:52 +0200 Subject: [PATCH 01/24] maint(webpack): Set watcher dir to src. --- webpack.config.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/webpack.config.js b/webpack.config.js index 31a9ff4e87..50f489180f 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -147,14 +147,13 @@ module.exports = () => { // so for the devServer the public path set to "/". config.devServer.allowedHosts = ['localhost', 'plone.lan']; config.devServer.port = "8000"; - config.devServer.static.directory = path.resolve(__dirname, "./_site/"); + config.devServer.static.directory = path.resolve(__dirname, "_site/"); + config.devServer.watchFiles = ["src/"]; // TODO: path.resolve? relative to static directory? + config.devServer.liveReload = false; } if (process.env.DEPLOYMENT === "docs") { - config.output.path = path.resolve( - __dirname, - "./_site/dist/mockup/" - ); + config.output.path = path.resolve(__dirname, "./_site/dist/mockup/"); } if (process.env.DEPLOYMENT === "plone") { config.output.path = path.resolve( From bf8d5765ed808336df34af2f650c81a9311fdacc Mon Sep 17 00:00:00 2001 From: Johannes Raggam Date: Fri, 25 Oct 2024 02:13:27 +0200 Subject: [PATCH 02/24] feat(pat-structure): Support for pushStage, baseUrl. --- src/pat/structure/js/views/app.js | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/pat/structure/js/views/app.js b/src/pat/structure/js/views/app.js index 2844f1e783..e69e1a4703 100644 --- a/src/pat/structure/js/views/app.js +++ b/src/pat/structure/js/views/app.js @@ -60,7 +60,11 @@ export default BaseView.extend({ // ignore this, fake event trigger to element that is not visible return; } - if ($el.is("a") || $el.parent().is("a") || $el.hasClass("popover-structure-query-active")) { + if ( + $el.is("a") || + $el.parent().is("a") || + $el.hasClass("popover-structure-query-active") + ) { // elements that should not close // NOTE: "popover-structure-query-active" is set on body when // select2 elements are clicked inside the structure filter @@ -167,15 +171,15 @@ export default BaseView.extend({ "{path}" ); url = pushStateUrl.replace("{path}", path); - window.history.pushState(null, null, url); } else if (this.options.urlStructure) { // fallback to urlStructure specification url = this.options.urlStructure.base + path + this.options.urlStructure.appended; - window.history.pushState(null, null, url); } + console.log("a1"); + window.history.pushState(null, null, url); if (this.options.traverseView) { // flag specifies that the context view implements a traverse @@ -183,8 +187,9 @@ export default BaseView.extend({ // of some kind - use the base object instead for that by not // specifying a path. path = ""; - // TODO figure out whether the following event after this is - // needed at all. + } + if (path !== "") { + document.body.dataset.baseUrl = url; } $("body").trigger("structure-url-changed", [path]); @@ -224,6 +229,8 @@ export default BaseView.extend({ path = "/"; } this.setCurrentPath(path); + console.log("a2"); + document.body.dataset.baseUrl = `${document.body.dataset.portalUrl}${path}`; $("body").trigger("structure-url-changed", [path]); // since this next call causes state to be pushed... this.doNotPushState = true; From e6c678a62721268376dfb73daeb16642bd8f077a Mon Sep 17 00:00:00 2001 From: Johannes Raggam Date: Wed, 3 Jan 2024 04:42:07 +0100 Subject: [PATCH 03/24] breaking(pat-toolbar): Change to a class based Pattern. Should do no harm. The benefits for Patternslib BasePattern based Patterns are, for example: - Arguments are specified with default values, units and types. - Option inheritance - options defined on parent elements are inherited for child elements. - Better Integration in the Patternslib framework (event handling, etc). --- src/pat/toolbar/toolbar.js | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/src/pat/toolbar/toolbar.js b/src/pat/toolbar/toolbar.js index 7476889e03..33d1ed4b6f 100644 --- a/src/pat/toolbar/toolbar.js +++ b/src/pat/toolbar/toolbar.js @@ -1,16 +1,19 @@ import $ from "jquery"; -import Base from "@patternslib/patternslib/src/core/base"; +import { BasePattern } from "@patternslib/patternslib/src/core/basepattern"; +import Parser from "@patternslib/patternslib/src/core/parser"; import registry from "@patternslib/patternslib/src/core/registry"; import utils from "../../core/utils"; import Cookies from "js-cookie"; -export default Base.extend({ - name: "toolbar", - trigger: ".pat-toolbar", - parser: "mockup", - defaults: {}, +export const parser = new Parser("toolbar"); +parser.addArgument("example-option", "Stranger"); - init: function () { +class Pattern extends BasePattern { + static name = "toolbar"; + static trigger = ".pat-toolbar"; + static parser = parser; + + async init() { $("body").on("structure-url-changed", (e, path) => { $.ajax({ url: $("body").attr("data-portal-url") + path + "/@@render-toolbar", @@ -27,8 +30,10 @@ export default Base.extend({ }); }); + const $el = $(this.el); + // unpin toolbar and save state - this.$el.on("click", ".toolbar-collapse", () => { + $el.on("click", ".toolbar-collapse", () => { $("body").removeClass("plone-toolbar-left-expanded"); Cookies.set("plone-toolbar", JSON.stringify({ expanded: false }), { path: "/", @@ -36,7 +41,7 @@ export default Base.extend({ }); // pin toolbar and save state - this.$el.on("click", ".toolbar-expand", () => { + $el.on("click", ".toolbar-expand", () => { $("body").addClass("plone-toolbar-left-expanded"); Cookies.set("plone-toolbar", JSON.stringify({ expanded: true }), { path: "/", @@ -44,5 +49,8 @@ export default Base.extend({ }); this.el.classList.add("initialized"); - }, -}); + } +} +registry.register(Pattern); +export default Pattern; +export { Pattern }; From bac2b6781f3b94311669f8fdb5e5ea143b873ce9 Mon Sep 17 00:00:00 2001 From: Johannes Raggam Date: Wed, 3 Jan 2024 04:43:41 +0100 Subject: [PATCH 04/24] feat(pat-toolbar): Optionally import CSS. --- package.json | 1 + src/pat/toolbar/toolbar.js | 4 ++++ src/pat/toolbar/toolbar.scss | 2 ++ 3 files changed, 7 insertions(+) create mode 100644 src/pat/toolbar/toolbar.scss diff --git a/package.json b/package.json index b776eaef84..8d1ac49f7d 100644 --- a/package.json +++ b/package.json @@ -13,6 +13,7 @@ "@11ty/eleventy-upgrade-help": "3.0.1", "@patternslib/pat-code-editor": "4.0.1", "@patternslib/patternslib": "9.10.3", + "@plone/plonetheme-barceloneta-base": "^3.3.0", "@plone/registry": "^2.5.4", "backbone": "1.6.1", "backbone.paginator": "2.0.8", diff --git a/src/pat/toolbar/toolbar.js b/src/pat/toolbar/toolbar.js index 33d1ed4b6f..8fbf8e76a6 100644 --- a/src/pat/toolbar/toolbar.js +++ b/src/pat/toolbar/toolbar.js @@ -14,6 +14,10 @@ class Pattern extends BasePattern { static parser = parser; async init() { + if (window.__patternslib_import_styles) { + import("./toolbar.scss"); + } + $("body").on("structure-url-changed", (e, path) => { $.ajax({ url: $("body").attr("data-portal-url") + path + "/@@render-toolbar", diff --git a/src/pat/toolbar/toolbar.scss b/src/pat/toolbar/toolbar.scss new file mode 100644 index 0000000000..3bf5e85cc1 --- /dev/null +++ b/src/pat/toolbar/toolbar.scss @@ -0,0 +1,2 @@ +@import "bootstrap/scss/bootstrap"; +@import "@plone/plonetheme-barceloneta-base/scss/_toolbar.scss"; From f2be6aa240858f042d9931afb60d5102ac1596b4 Mon Sep 17 00:00:00 2001 From: Johannes Raggam Date: Wed, 3 Jan 2024 04:39:49 +0100 Subject: [PATCH 05/24] feat(pat-toolbar): Allow to customize via options. --- src/pat/toolbar/toolbar.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/pat/toolbar/toolbar.js b/src/pat/toolbar/toolbar.js index 8fbf8e76a6..a85b848b25 100644 --- a/src/pat/toolbar/toolbar.js +++ b/src/pat/toolbar/toolbar.js @@ -6,21 +6,24 @@ import utils from "../../core/utils"; import Cookies from "js-cookie"; export const parser = new Parser("toolbar"); -parser.addArgument("example-option", "Stranger"); +parser.addArgument("update-trigger", "structure-url-changed"); +parser.addArgument("render-url", "@@render-toolbar"); class Pattern extends BasePattern { static name = "toolbar"; static trigger = ".pat-toolbar"; static parser = parser; + parser_group_options = false; + async init() { if (window.__patternslib_import_styles) { import("./toolbar.scss"); } - $("body").on("structure-url-changed", (e, path) => { + $("body").on(this.options["update-trigger"], (e, path) => { $.ajax({ - url: $("body").attr("data-portal-url") + path + "/@@render-toolbar", + url: $("body").attr("data-portal-url") + path + "/" + this.options["render-url"], }).done((data) => { const wrapper = $(utils.parseBodyTag(data)); const $main_toolbar = wrapper.find("#edit-zone .plone-toolbar-main"); From 97763d67c7c97dbe2f0b766fd8c7b62a35711d72 Mon Sep 17 00:00:00 2001 From: Johannes Raggam Date: Wed, 3 Jan 2024 05:12:26 +0100 Subject: [PATCH 06/24] maint(pat-toolbar): Modernize code. --- src/pat/toolbar/toolbar.js | 40 ++++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/src/pat/toolbar/toolbar.js b/src/pat/toolbar/toolbar.js index a85b848b25..e2b1d546f0 100644 --- a/src/pat/toolbar/toolbar.js +++ b/src/pat/toolbar/toolbar.js @@ -2,7 +2,6 @@ import $ from "jquery"; import { BasePattern } from "@patternslib/patternslib/src/core/basepattern"; import Parser from "@patternslib/patternslib/src/core/parser"; import registry from "@patternslib/patternslib/src/core/registry"; -import utils from "../../core/utils"; import Cookies from "js-cookie"; export const parser = new Parser("toolbar"); @@ -21,27 +20,34 @@ class Pattern extends BasePattern { import("./toolbar.scss"); } - $("body").on(this.options["update-trigger"], (e, path) => { - $.ajax({ - url: $("body").attr("data-portal-url") + path + "/" + this.options["render-url"], - }).done((data) => { - const wrapper = $(utils.parseBodyTag(data)); - const $main_toolbar = wrapper.find("#edit-zone .plone-toolbar-main"); - const $personal_tools = wrapper.find( - "#edit-zone #collapse-personaltools" - ); - // setup modals - registry.scan($main_toolbar); - $(".plone-toolbar-main", this.$el).replaceWith($main_toolbar); - $("#collapse-personaltools", this.$el).replaceWith($personal_tools); - }); + $("body").on(this.options["update-trigger"], async (e, path) => { + // fetch toolbar + const response = await fetch( + `${document.body.dataset.portalUrl}${path}/${this.options["render-url"]}` + ); + const data = await response.text(); + + // Find toolbar nodes + const div = document.createElement("div"); + div.innerHTML = data; + const main_toolbar = div.querySelector("#edit-zone .plone-toolbar-main"); + const personal_tools = div.querySelector( + "#edit-zone #collapse-personaltools" + ); + + // setup modals + registry.scan(main_toolbar); + document.querySelector(".plone-toolbar-main").replaceWith(main_toolbar); + document + .querySelector("#collapse-personaltools") + .replaceWith(personal_tools); }); const $el = $(this.el); // unpin toolbar and save state $el.on("click", ".toolbar-collapse", () => { - $("body").removeClass("plone-toolbar-left-expanded"); + document.body.classList.remove("plone-toolbar-left-expanded"); Cookies.set("plone-toolbar", JSON.stringify({ expanded: false }), { path: "/", }); @@ -49,7 +55,7 @@ class Pattern extends BasePattern { // pin toolbar and save state $el.on("click", ".toolbar-expand", () => { - $("body").addClass("plone-toolbar-left-expanded"); + document.body.classList.add("plone-toolbar-left-expanded"); Cookies.set("plone-toolbar", JSON.stringify({ expanded: true }), { path: "/", }); From 88283684f820ad5ea407fd3880eadd478452c48e Mon Sep 17 00:00:00 2001 From: Johannes Raggam Date: Wed, 3 Jan 2024 05:30:14 +0100 Subject: [PATCH 07/24] maint(pat-toolbar): Restructure for better reusability. --- src/pat/toolbar/toolbar.js | 39 +++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/src/pat/toolbar/toolbar.js b/src/pat/toolbar/toolbar.js index e2b1d546f0..0b570bdcc1 100644 --- a/src/pat/toolbar/toolbar.js +++ b/src/pat/toolbar/toolbar.js @@ -20,27 +20,11 @@ class Pattern extends BasePattern { import("./toolbar.scss"); } + // Reload on context change in folder content browser. $("body").on(this.options["update-trigger"], async (e, path) => { - // fetch toolbar - const response = await fetch( - `${document.body.dataset.portalUrl}${path}/${this.options["render-url"]}` + await this.reload_toolbar( + `${document.body.dataset["portal-url"]}${path}/${this.options["render-url"]}` ); - const data = await response.text(); - - // Find toolbar nodes - const div = document.createElement("div"); - div.innerHTML = data; - const main_toolbar = div.querySelector("#edit-zone .plone-toolbar-main"); - const personal_tools = div.querySelector( - "#edit-zone #collapse-personaltools" - ); - - // setup modals - registry.scan(main_toolbar); - document.querySelector(".plone-toolbar-main").replaceWith(main_toolbar); - document - .querySelector("#collapse-personaltools") - .replaceWith(personal_tools); }); const $el = $(this.el); @@ -63,6 +47,23 @@ class Pattern extends BasePattern { this.el.classList.add("initialized"); } + + async reload_toolbar(url) { + // fetch toolbar + const response = await fetch(url); + const data = await response.text(); + + // Find toolbar nodes + const div = document.createElement("div"); + div.innerHTML = data; + const main_toolbar = div.querySelector("#edit-zone .plone-toolbar-main"); + const personal_tools = div.querySelector("#edit-zone #collapse-personaltools"); + + // setup modals + registry.scan(main_toolbar); + document.querySelector(".plone-toolbar-main").replaceWith(main_toolbar); + document.querySelector("#collapse-personaltools").replaceWith(personal_tools); + } } registry.register(Pattern); export default Pattern; From c40fbd0aabe4c961b05e5c0b9924c0ff56a1c795 Mon Sep 17 00:00:00 2001 From: Johannes Raggam Date: Wed, 3 Jan 2024 05:37:39 +0100 Subject: [PATCH 08/24] feat(pat-toolbar): After toolbar, also initialize patterns on personal tools. --- src/pat/toolbar/toolbar.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/pat/toolbar/toolbar.js b/src/pat/toolbar/toolbar.js index 0b570bdcc1..3ac2ade340 100644 --- a/src/pat/toolbar/toolbar.js +++ b/src/pat/toolbar/toolbar.js @@ -61,6 +61,7 @@ class Pattern extends BasePattern { // setup modals registry.scan(main_toolbar); + registry.scan(personal_tools); document.querySelector(".plone-toolbar-main").replaceWith(main_toolbar); document.querySelector("#collapse-personaltools").replaceWith(personal_tools); } From 793dde1ad0cc59b22a76915a8a836a3be1f692d2 Mon Sep 17 00:00:00 2001 From: Johannes Raggam Date: Fri, 5 Jan 2024 00:57:25 +0100 Subject: [PATCH 09/24] feat(pat-toolbar): Dispatch event on toolbar after reloading. --- src/pat/toolbar/toolbar.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/pat/toolbar/toolbar.js b/src/pat/toolbar/toolbar.js index 3ac2ade340..5cdd4b8415 100644 --- a/src/pat/toolbar/toolbar.js +++ b/src/pat/toolbar/toolbar.js @@ -64,6 +64,9 @@ class Pattern extends BasePattern { registry.scan(personal_tools); document.querySelector(".plone-toolbar-main").replaceWith(main_toolbar); document.querySelector("#collapse-personaltools").replaceWith(personal_tools); + + // Notify others that the toolbar has been reloaded. + this.el.dispatchEvent(events.generic_event("pat-toolbar--reloaded")); } } registry.register(Pattern); From fc5fd9b62065481979b0f368ec5a158750da6607 Mon Sep 17 00:00:00 2001 From: Johannes Raggam Date: Fri, 25 Oct 2024 02:14:30 +0200 Subject: [PATCH 10/24] feat(pat-toolbar): Reload itself on location change. --- src/pat/toolbar/toolbar.js | 41 +++++++++++++++++++++++++++++--------- 1 file changed, 32 insertions(+), 9 deletions(-) diff --git a/src/pat/toolbar/toolbar.js b/src/pat/toolbar/toolbar.js index 5cdd4b8415..c44e735606 100644 --- a/src/pat/toolbar/toolbar.js +++ b/src/pat/toolbar/toolbar.js @@ -1,5 +1,6 @@ import $ from "jquery"; import { BasePattern } from "@patternslib/patternslib/src/core/basepattern"; +import events from "@patternslib/patternslib/src/core/events"; import Parser from "@patternslib/patternslib/src/core/parser"; import registry from "@patternslib/patternslib/src/core/registry"; import Cookies from "js-cookie"; @@ -17,15 +18,37 @@ class Pattern extends BasePattern { async init() { if (window.__patternslib_import_styles) { - import("./toolbar.scss"); + //import("./toolbar.scss"); } - // Reload on context change in folder content browser. - $("body").on(this.options["update-trigger"], async (e, path) => { - await this.reload_toolbar( - `${document.body.dataset["portal-url"]}${path}/${this.options["render-url"]}` - ); - }); + //// Reload on context change in folder content browser. + //$("body").on(this.options["update-trigger"], async (e, path) => { + // await this.reload_toolbar( + // `${document.body.dataset.portalUrl}${path}/${this.options["render-url"]}` + // ); + //}); + + // Reload the toolbar on history change. + events.add_event_listener( + window.navigation, + "navigate", + "pat-toolbar--history-changed", + async () => { + const url = `${document.body.dataset.baseUrl}/${this.options["render-url"]}`; + await this.reload_toolbar(url); + } + ); + + //events.add_event_listener( + // document.body, + // "pat-inject-history-changed", + // "pat-toolbar--history-changed", + // async (e) => { + // await this.reload_toolbar( + // `${e.detail.url}/${this.options["render-url"]}` + // ); + // } + //); const $el = $(this.el); @@ -62,8 +85,8 @@ class Pattern extends BasePattern { // setup modals registry.scan(main_toolbar); registry.scan(personal_tools); - document.querySelector(".plone-toolbar-main").replaceWith(main_toolbar); - document.querySelector("#collapse-personaltools").replaceWith(personal_tools); + document.querySelector(".plone-toolbar-main")?.replaceWith(main_toolbar); + document.querySelector("#collapse-personaltools")?.replaceWith(personal_tools); // Notify others that the toolbar has been reloaded. this.el.dispatchEvent(events.generic_event("pat-toolbar--reloaded")); From d8f3315934544e719919c7d3de0484e1c7344af9 Mon Sep 17 00:00:00 2001 From: Johannes Raggam Date: Fri, 25 Oct 2024 02:05:15 +0200 Subject: [PATCH 11/24] fix(pat-toolbar): Improve toolbar reload method to not reload unnecessarily and correctly reload for edit forms, hash and query string urls. --- src/pat/toolbar/toolbar.js | 41 +++++++++++++++++++++++++++++++++++--- 1 file changed, 38 insertions(+), 3 deletions(-) diff --git a/src/pat/toolbar/toolbar.js b/src/pat/toolbar/toolbar.js index c44e735606..d4be3abc1d 100644 --- a/src/pat/toolbar/toolbar.js +++ b/src/pat/toolbar/toolbar.js @@ -1,10 +1,14 @@ import $ from "jquery"; import { BasePattern } from "@patternslib/patternslib/src/core/basepattern"; import events from "@patternslib/patternslib/src/core/events"; +import logging from "@patternslib/patternslib/src/core/logging"; import Parser from "@patternslib/patternslib/src/core/parser"; import registry from "@patternslib/patternslib/src/core/registry"; +import utils from "@patternslib/patternslib/src/core/utils"; import Cookies from "js-cookie"; +const log = logging.getLogger("pat-toolbar"); + export const parser = new Parser("toolbar"); parser.addArgument("update-trigger", "structure-url-changed"); parser.addArgument("render-url", "@@render-toolbar"); @@ -16,6 +20,8 @@ class Pattern extends BasePattern { parser_group_options = false; + previous_toolbar_url = null; + async init() { if (window.__patternslib_import_styles) { //import("./toolbar.scss"); @@ -34,8 +40,9 @@ class Pattern extends BasePattern { "navigate", "pat-toolbar--history-changed", async () => { - const url = `${document.body.dataset.baseUrl}/${this.options["render-url"]}`; - await this.reload_toolbar(url); + // Wait a tick to let other Patterns set the baseUrl. + await utils.timeout(1); + await this.reload_toolbar(); } ); @@ -71,11 +78,37 @@ class Pattern extends BasePattern { this.el.classList.add("initialized"); } - async reload_toolbar(url) { + async reload_toolbar() { + // Don't reload on content views but on their parent if so. + const split_words = [ + // NOTE: order matters. + "@@", // also catches @@folder_contents and @@edit + "folder_contents", + "edit", + "#", + "?", + ]; + let url = document.body.dataset.baseUrl; + log.debug("URL before cleanup: ", url); + // Split all split words out of url + url = split_words.reduce((url_, split_) => url_.split(split_)[0], url); + // Ensure a trailing slash in the URL. + url = url[url.length - 1] === "/" ? url : `${url}/` + url = `${url}${this.options["render-url"]}`; + log.debug("URL after cleanup: ", url); + + if (this.previous_toolbar_url === url) { + // no need to reload same url + log.debug("No URL change, no reload."); + return; + } + // fetch toolbar const response = await fetch(url); const data = await response.text(); + this.previous_toolbar_url = url; + // Find toolbar nodes const div = document.createElement("div"); div.innerHTML = data; @@ -87,9 +120,11 @@ class Pattern extends BasePattern { registry.scan(personal_tools); document.querySelector(".plone-toolbar-main")?.replaceWith(main_toolbar); document.querySelector("#collapse-personaltools")?.replaceWith(personal_tools); + log.debug("Re-scanned."); // Notify others that the toolbar has been reloaded. this.el.dispatchEvent(events.generic_event("pat-toolbar--reloaded")); + log.debug("Event pat-toolbar--reloaded dispatched."); } } registry.register(Pattern); From 843653c38389f3b27c481a660950ada71df6a9a9 Mon Sep 17 00:00:00 2001 From: Johannes Raggam Date: Tue, 10 Dec 2024 11:00:11 +0100 Subject: [PATCH 12/24] maint(pat-toolbar): Cleanup. --- src/pat/toolbar/toolbar.js | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/src/pat/toolbar/toolbar.js b/src/pat/toolbar/toolbar.js index d4be3abc1d..b43e88922f 100644 --- a/src/pat/toolbar/toolbar.js +++ b/src/pat/toolbar/toolbar.js @@ -10,7 +10,6 @@ import Cookies from "js-cookie"; const log = logging.getLogger("pat-toolbar"); export const parser = new Parser("toolbar"); -parser.addArgument("update-trigger", "structure-url-changed"); parser.addArgument("render-url", "@@render-toolbar"); class Pattern extends BasePattern { @@ -27,13 +26,6 @@ class Pattern extends BasePattern { //import("./toolbar.scss"); } - //// Reload on context change in folder content browser. - //$("body").on(this.options["update-trigger"], async (e, path) => { - // await this.reload_toolbar( - // `${document.body.dataset.portalUrl}${path}/${this.options["render-url"]}` - // ); - //}); - // Reload the toolbar on history change. events.add_event_listener( window.navigation, @@ -46,17 +38,6 @@ class Pattern extends BasePattern { } ); - //events.add_event_listener( - // document.body, - // "pat-inject-history-changed", - // "pat-toolbar--history-changed", - // async (e) => { - // await this.reload_toolbar( - // `${e.detail.url}/${this.options["render-url"]}` - // ); - // } - //); - const $el = $(this.el); // unpin toolbar and save state From fdf94143995c4c9f48bf2d2b0be5223d12e7722e Mon Sep 17 00:00:00 2001 From: Johannes Raggam Date: Thu, 26 Sep 2024 00:22:38 +0200 Subject: [PATCH 13/24] feat(pat-navigationmarker): Modernize: class based Pattern, add option portal-url, no jQuery. --- src/pat/navigationmarker/navigationmarker.js | 136 ++++++++++++------- 1 file changed, 87 insertions(+), 49 deletions(-) diff --git a/src/pat/navigationmarker/navigationmarker.js b/src/pat/navigationmarker/navigationmarker.js index effd3be060..514d060be3 100644 --- a/src/pat/navigationmarker/navigationmarker.js +++ b/src/pat/navigationmarker/navigationmarker.js @@ -1,52 +1,90 @@ -import $ from "jquery"; -import Base from "@patternslib/patternslib/src/core/base"; - -export default Base.extend({ - name: "navigationmarker", - trigger: ".pat-navigationmarker", - parser: "mockup", - init: function () { - const portal_url = document.body.dataset.portalUrl; - var href = - document.querySelector('head link[rel="canonical"]').href || +import { BasePattern } from "@patternslib/patternslib/src/core/basepattern"; +import Parser from "@patternslib/patternslib/src/core/parser"; +import registry from "@patternslib/patternslib/src/core/registry"; + +export const parser = new Parser("navigationmarker"); +parser.addArgument("portal-url", undefined); + +class Pattern extends BasePattern { + static name = "navigationmarker"; + static trigger = ".pat-navigationmarker"; + static parser = parser; + + async init() { + this.portal_url = this.options.portalUrl || document.body.dataset.portalUrl; + + this.scan_navigation(); + } + + scan_navigation() { + const href = + document.querySelector('head link[rel="canonical"]')?.href || window.location.href; - $("a", this.$el).each(function () { - var navlink = this.href.replace("/view", ""); - if (href.indexOf(navlink) !== -1) { - var parent = $(this).parent(); - - // check the input-openers within the path - var check = parent.find("> input"); - if (check.length) { - check[0].checked = true; - } - - // set "inPath" to all nav items which are within the current path - // check if parts of navlink are in canonical url parts - var hrefParts = href.split("/"); - var navParts = navlink.split("/"); - var inPath = false; - for (var i = 0, size = navParts.length; i < size; i++) { - // The last path-part must match. - inPath = false; - if (navParts[i] === hrefParts[i]) { - inPath = true; - } - } - if (navlink === portal_url && href !== portal_url) { - // Avoid marking "Home" with "inPath", when not actually there - inPath = false; - } - if (inPath) { - parent.addClass("inPath"); - } - - // set "current" to the current selected nav item, if it is in the navigation structure. - if (href === navlink) { - parent.addClass("current"); - } + const anchors = this.el.querySelectorAll("a"); + + for (const anchor of anchors) { + + const parent = anchor.parentElement; + const navlink = anchor.href.replace("/view", ""); + + // We can exit early, if the navlink is not part of the current URL. + if (href.indexOf(navlink) === -1) { + this.clear(parent); + continue; + } + + // BBB + // check the input-openers within the path + const check = parent.querySelector(":scope > input"); + if (check) { + check.checked = true; + } + + // set "inPath" to all nav items which are within the current path + // check if parts of navlink are in canonical url parts + // + const href_parts = href.split("/"); + const nav_parts = navlink.split("/"); + let inPath = false; + + // The last part of the URL must match. + const nav_compare = nav_parts[nav_parts.length - 1]; + const href_compare = href_parts[nav_parts.length - 1]; + if (nav_compare === href_compare) { + inPath = true; + } + + // Avoid marking "Home" with "inPath", when not actually there + if (navlink === this.portal_url && href !== this.portal_url) { + inPath = false; + } + + // Set the class + if (inPath) { + parent.classList.add("inPath"); } - }); - }, -}); + + // set "current" to the current selected nav item, if it is in the navigation structure. + if (href === navlink) { + parent.classList.add("current"); + } + } + } + + clear(element) { + // Clear all classes + if (element.classList.contains("inPath")) { + element.classList.remove("inPath"); + } + if (element.classList.contains("current")) { + element.classList.remove("current"); + } + } +} + +// Register Pattern class in the global pattern registry +registry.register(Pattern); + +// Make it available +export default Pattern; From 16bc8f2bfbc7616feba4887f88fdc4773de5eac6 Mon Sep 17 00:00:00 2001 From: Johannes Raggam Date: Thu, 26 Sep 2024 00:25:14 +0200 Subject: [PATCH 14/24] feat(pat-navigationmarker): re-scan nav after navigate event / url change. --- src/pat/navigationmarker/navigationmarker.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/pat/navigationmarker/navigationmarker.js b/src/pat/navigationmarker/navigationmarker.js index 514d060be3..4b7dfb7956 100644 --- a/src/pat/navigationmarker/navigationmarker.js +++ b/src/pat/navigationmarker/navigationmarker.js @@ -1,4 +1,5 @@ import { BasePattern } from "@patternslib/patternslib/src/core/basepattern"; +import events from "@patternslib/patternslib/src/core/events"; import Parser from "@patternslib/patternslib/src/core/parser"; import registry from "@patternslib/patternslib/src/core/registry"; @@ -13,6 +14,15 @@ class Pattern extends BasePattern { async init() { this.portal_url = this.options.portalUrl || document.body.dataset.portalUrl; + events.add_event_listener( + window.navigation, + "navigate", + "pat-navigationmarker--history-changed", + () => { + this.scan_navigation(); + } + ); + this.scan_navigation(); } From 0c3281285cf41148cefad65a0418a80a01e38ebe Mon Sep 17 00:00:00 2001 From: Johannes Raggam Date: Thu, 26 Sep 2024 00:28:08 +0200 Subject: [PATCH 15/24] feat(pat-navigationmarker): fire "pat-navigationmarker.scanned" event after re-scanning. This can be used to do something directly after the re-scanning, e.g. setting details state. --- src/pat/navigationmarker/navigationmarker.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/pat/navigationmarker/navigationmarker.js b/src/pat/navigationmarker/navigationmarker.js index 4b7dfb7956..596a264a41 100644 --- a/src/pat/navigationmarker/navigationmarker.js +++ b/src/pat/navigationmarker/navigationmarker.js @@ -80,6 +80,8 @@ class Pattern extends BasePattern { parent.classList.add("current"); } } + + this.el.dispatchEvent(events.generic_event(`${this.name}.scanned`)); } clear(element) { From 135238a254acc10b754bc7c3404175740f45b380 Mon Sep 17 00:00:00 2001 From: Johannes Raggam Date: Fri, 27 Sep 2024 02:33:07 +0200 Subject: [PATCH 16/24] feat(pat-navigationmarker): multiple things: details support, BBB breaks so disabled, parent-selector introduced. --- src/pat/navigationmarker/navigationmarker.js | 24 ++++++++++++++------ 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/src/pat/navigationmarker/navigationmarker.js b/src/pat/navigationmarker/navigationmarker.js index 596a264a41..461936a0c2 100644 --- a/src/pat/navigationmarker/navigationmarker.js +++ b/src/pat/navigationmarker/navigationmarker.js @@ -5,6 +5,7 @@ import registry from "@patternslib/patternslib/src/core/registry"; export const parser = new Parser("navigationmarker"); parser.addArgument("portal-url", undefined); +parser.addArgument("parent-selector", undefined); class Pattern extends BasePattern { static name = "navigationmarker"; @@ -35,7 +36,8 @@ class Pattern extends BasePattern { for (const anchor of anchors) { - const parent = anchor.parentElement; + //const parent = anchor.parentElement; + const parent = this.options.parentSelector ? anchor.closest(this.options.parentSelector) : anchor.parentElement; const navlink = anchor.href.replace("/view", ""); // We can exit early, if the navlink is not part of the current URL. @@ -44,12 +46,12 @@ class Pattern extends BasePattern { continue; } - // BBB - // check the input-openers within the path - const check = parent.querySelector(":scope > input"); - if (check) { - check.checked = true; - } + //// BBB + //// check the input-openers within the path + //const check = parent.querySelector(":scope > input"); + //if (check) { + // check.checked = true; + //} // set "inPath" to all nav items which are within the current path // check if parts of navlink are in canonical url parts @@ -72,7 +74,12 @@ class Pattern extends BasePattern { // Set the class if (inPath) { + // inPath is set along with current | TODO: OR NOT, verify. parent.classList.add("inPath"); + if (parent.tagName === "DETAILS") { + parent.open = true; + } + } // set "current" to the current selected nav item, if it is in the navigation structure. @@ -92,6 +99,9 @@ class Pattern extends BasePattern { if (element.classList.contains("current")) { element.classList.remove("current"); } + if (element.tagName === "DETAILS") { + element.open = false; + } } } From 555469b715d77898050164c9fb1e8bf7d12f94cf Mon Sep 17 00:00:00 2001 From: Johannes Raggam Date: Fri, 27 Sep 2024 14:38:55 +0200 Subject: [PATCH 17/24] feat(pat-navigationmarker): Also mark the anchor itself as current. --- src/pat/navigationmarker/navigationmarker.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/pat/navigationmarker/navigationmarker.js b/src/pat/navigationmarker/navigationmarker.js index 461936a0c2..4379db0839 100644 --- a/src/pat/navigationmarker/navigationmarker.js +++ b/src/pat/navigationmarker/navigationmarker.js @@ -43,6 +43,7 @@ class Pattern extends BasePattern { // We can exit early, if the navlink is not part of the current URL. if (href.indexOf(navlink) === -1) { this.clear(parent); + this.clear(anchor); continue; } @@ -85,6 +86,7 @@ class Pattern extends BasePattern { // set "current" to the current selected nav item, if it is in the navigation structure. if (href === navlink) { parent.classList.add("current"); + anchor.classList.add("current"); } } From 93be9103c20388c4e0ce07bfa50f182dc5e576f4 Mon Sep 17 00:00:00 2001 From: Johannes Raggam Date: Tue, 26 Aug 2025 02:59:49 +0200 Subject: [PATCH 18/24] fix(pat-navigationmarker): link-canonical isn't always updated. just use window.location. window.location is what the navigate event is about.. --- src/pat/navigationmarker/navigationmarker.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pat/navigationmarker/navigationmarker.js b/src/pat/navigationmarker/navigationmarker.js index 4379db0839..8ef3c15c67 100644 --- a/src/pat/navigationmarker/navigationmarker.js +++ b/src/pat/navigationmarker/navigationmarker.js @@ -29,7 +29,7 @@ class Pattern extends BasePattern { scan_navigation() { const href = - document.querySelector('head link[rel="canonical"]')?.href || + //document.querySelector('head link[rel="canonical"]')?.href || window.location.href; const anchors = this.el.querySelectorAll("a"); From c160dc08cce2e220e7dcfb4d75a2c1a44e703fe9 Mon Sep 17 00:00:00 2001 From: Johannes Raggam Date: Tue, 2 Sep 2025 22:37:49 +0200 Subject: [PATCH 19/24] yarn install. --- yarn.lock | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/yarn.lock b/yarn.lock index 4d0303796c..b53ec1ed6a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2104,6 +2104,13 @@ resolved "https://registry.yarnpkg.com/@pkgjs/parseargs/-/parseargs-0.11.0.tgz#a77ea742fab25775145434eb1d2328cf5013ac33" integrity sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg== +"@plone/plonetheme-barceloneta-base@^3.3.0": + version "3.3.0" + resolved "https://registry.yarnpkg.com/@plone/plonetheme-barceloneta-base/-/plonetheme-barceloneta-base-3.3.0.tgz#f1bc079ec932cdee1484e52f18b9880b41a92d72" + integrity sha512-cUVNWSt0M+3l0AmqwAK753X5JgU6lQqMDuo2IKECDJn8NKwmT9m1Hci9Y+MjGN+xZ5mVdbPFtWRxs891LkF+Pw== + dependencies: + bootstrap "5.3.7" + "@plone/registry@^2.5.4": version "2.5.4" resolved "https://registry.yarnpkg.com/@plone/registry/-/registry-2.5.4.tgz#6767936d8fca94bd7bf477fa0bc434ef3049081f" @@ -3240,6 +3247,11 @@ bootstrap-icons@1.13.1: resolved "https://registry.yarnpkg.com/bootstrap-icons/-/bootstrap-icons-1.13.1.tgz#0aad3f5b55b67402990e729ce3883416f9cef6c5" integrity sha512-ijombt4v6bv5CLeXvRWKy7CuM3TRTuPEuGaGKvTV5cz65rQSY8RQ2JcHt6b90cBBAC7s8fsf2EkQDldzCoXUjw== +bootstrap@5.3.7: + version "5.3.7" + resolved "https://registry.yarnpkg.com/bootstrap/-/bootstrap-5.3.7.tgz#8640065036124d961d885d80b5945745e1154d90" + integrity sha512-7KgiD8UHjfcPBHEpDNg+zGz8L3LqR3GVwqZiBRFX04a1BCArZOz1r2kjly2HQ0WokqTO0v1nF+QAt8dsW4lKlw== + bootstrap@5.3.8: version "5.3.8" resolved "https://registry.yarnpkg.com/bootstrap/-/bootstrap-5.3.8.tgz#6401a10057a22752d21f4e19055508980656aeed" From 0154bac67f59fb8bdac23ed8b5d4a0d3065074d7 Mon Sep 17 00:00:00 2001 From: Johannes Raggam Date: Fri, 10 Oct 2025 11:06:00 +0200 Subject: [PATCH 20/24] fixup structure. --- src/pat/structure/js/views/app.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/pat/structure/js/views/app.js b/src/pat/structure/js/views/app.js index e69e1a4703..12fe78f339 100644 --- a/src/pat/structure/js/views/app.js +++ b/src/pat/structure/js/views/app.js @@ -171,15 +171,15 @@ export default BaseView.extend({ "{path}" ); url = pushStateUrl.replace("{path}", path); + window.history.pushState(null, null, url); } else if (this.options.urlStructure) { // fallback to urlStructure specification url = this.options.urlStructure.base + path + this.options.urlStructure.appended; + window.history.pushState(null, null, url); } - console.log("a1"); - window.history.pushState(null, null, url); if (this.options.traverseView) { // flag specifies that the context view implements a traverse @@ -188,7 +188,7 @@ export default BaseView.extend({ // specifying a path. path = ""; } - if (path !== "") { + if (url && path !== "") { document.body.dataset.baseUrl = url; } $("body").trigger("structure-url-changed", [path]); @@ -229,7 +229,6 @@ export default BaseView.extend({ path = "/"; } this.setCurrentPath(path); - console.log("a2"); document.body.dataset.baseUrl = `${document.body.dataset.portalUrl}${path}`; $("body").trigger("structure-url-changed", [path]); // since this next call causes state to be pushed... From 62915898e72178fa1824185b559532172c845ab7 Mon Sep 17 00:00:00 2001 From: Johannes Raggam Date: Tue, 14 Oct 2025 13:09:55 +0200 Subject: [PATCH 21/24] feat(pat-base-url): Add new pattern to update data-base-url on the body tag when the URL changes. --- src/pat/base-url/README.md | 4 +++ src/pat/base-url/base-url.js | 49 +++++++++++++++++++++++++++++++ src/pat/base-url/base-url.test.js | 49 +++++++++++++++++++++++++++++++ src/patterns.js | 1 + 4 files changed, 103 insertions(+) create mode 100644 src/pat/base-url/README.md create mode 100644 src/pat/base-url/base-url.js create mode 100644 src/pat/base-url/base-url.test.js diff --git a/src/pat/base-url/README.md b/src/pat/base-url/README.md new file mode 100644 index 0000000000..b4aaddc8fe --- /dev/null +++ b/src/pat/base-url/README.md @@ -0,0 +1,4 @@ +# pat-base-url + +Update the `data-base-url` attribute on the body tag when a `navigate` event is +thrown and thus the browser's URL has changed. diff --git a/src/pat/base-url/base-url.js b/src/pat/base-url/base-url.js new file mode 100644 index 0000000000..6079a9f916 --- /dev/null +++ b/src/pat/base-url/base-url.js @@ -0,0 +1,49 @@ +// Set the base URL based on the current location, listening on navigation changes. +import { BasePattern } from "@patternslib/patternslib/src/core/basepattern"; +import registry from "@patternslib/patternslib/src/core/registry"; +import events from "@patternslib/patternslib/src/core/events"; + +class Pattern extends BasePattern { + static name = "pat-base-url"; + static trigger = "body"; + + init() { + events.add_event_listener( + window.navigation, + "navigate", + "thet-base-url--set", + this.set_base_url.bind(this) + ); + } + + set_base_url() { + let url = window.location.href; + + // Split the following words from the URL as we want to get the + // contents absolute URL. + const split_words = [ + // NOTE: order matters. + "/@@", // also catches @@folder_contents and @@edit + "/++", // traversal urls. + "/folder_contents", + "/edit", + "/view", + "#", + "?", + ]; + + // Split all split words out of url + url = split_words.reduce((url_, split_) => url_.split(split_)[0], url); + // Remove the trailing slash + if (url[url.length -1] === "/") { + url = url.substring(0, url.length - 1) + } + + // Set the contents absolute URL on `data-base-url`. + document.body.dataset.baseUrl = url; + } +} + +registry.register(Pattern); +export default Pattern; +export { Pattern }; diff --git a/src/pat/base-url/base-url.test.js b/src/pat/base-url/base-url.test.js new file mode 100644 index 0000000000..51da1be7dc --- /dev/null +++ b/src/pat/base-url/base-url.test.js @@ -0,0 +1,49 @@ +import "@patternslib/patternslib/src/core/polyfills"; +import utils from "@patternslib/patternslib/src/core/utils"; +import Pattern from "./base-url"; + +describe("pat-base-url tests", () => { + afterEach(() => { + document.body.innerHTML = ""; + }); + + it("is initialized correctly", async () => { + document.body.dataset.baseUrl = "http://localhost/not/okay" + + new Pattern(document.body); + await utils.timeout(1); // wait a tick for async to settle. + + expect(document.body.dataset.baseUrl).toBe("http://localhost/not/okay"); + history.pushState(null, "", "/okay/okay"); + expect(document.body.dataset.baseUrl).toBe("http://localhost/okay/okay"); + }); + + it("Cleans the URL from views and traversal URLs.", async () => { + new Pattern(document.body); + await utils.timeout(1); // wait a tick for async to settle. + + history.pushState(null, "", "/okay/@@okay"); + expect(document.body.dataset.baseUrl).toBe("http://localhost/okay"); + + history.pushState(null, "", "/okay/++okay"); + expect(document.body.dataset.baseUrl).toBe("http://localhost/okay"); + + history.pushState(null, "", "/okay/folder_contents"); + expect(document.body.dataset.baseUrl).toBe("http://localhost/okay"); + + history.pushState(null, "", "/okay/edit"); + expect(document.body.dataset.baseUrl).toBe("http://localhost/okay"); + + history.pushState(null, "", "/okay/view"); + expect(document.body.dataset.baseUrl).toBe("http://localhost/okay"); + + history.pushState(null, "", "/okay/#okay"); + expect(document.body.dataset.baseUrl).toBe("http://localhost/okay"); + + history.pushState(null, "", "/okay/?okay"); + expect(document.body.dataset.baseUrl).toBe("http://localhost/okay"); + + history.pushState(null, "", "/okay/?okay#okay"); + expect(document.body.dataset.baseUrl).toBe("http://localhost/okay"); + }); +}); diff --git a/src/patterns.js b/src/patterns.js index 96800ba2f3..b080dc9c6a 100644 --- a/src/patterns.js +++ b/src/patterns.js @@ -19,6 +19,7 @@ import "@patternslib/patternslib/src/pat/depends/depends"; // Import all used patterns for the bundle to be generated import "./pat/autotoc/autotoc"; import "./pat/backdrop/backdrop"; +import "./pat/base-url/base-url"; import "./pat/contentloader/contentloader"; import "./pat/contentbrowser/contentbrowser"; import "./pat/cookietrigger/cookietrigger"; From 8e68d0f44a3347998914f24b33a5db40aab5fe81 Mon Sep 17 00:00:00 2001 From: Johannes Raggam Date: Tue, 14 Oct 2025 13:18:41 +0200 Subject: [PATCH 22/24] fixup pat-toolbar: Remove the render URL cleanup method. This is now done directly in pat-base-url. --- src/pat/toolbar/toolbar.js | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/src/pat/toolbar/toolbar.js b/src/pat/toolbar/toolbar.js index b43e88922f..8fb39e6d4a 100644 --- a/src/pat/toolbar/toolbar.js +++ b/src/pat/toolbar/toolbar.js @@ -32,7 +32,7 @@ class Pattern extends BasePattern { "navigate", "pat-toolbar--history-changed", async () => { - // Wait a tick to let other Patterns set the baseUrl. + // Wait a tick to let other Patterns set the `data-base-url`. await utils.timeout(1); await this.reload_toolbar(); } @@ -60,23 +60,11 @@ class Pattern extends BasePattern { } async reload_toolbar() { - // Don't reload on content views but on their parent if so. - const split_words = [ - // NOTE: order matters. - "@@", // also catches @@folder_contents and @@edit - "folder_contents", - "edit", - "#", - "?", - ]; + const render_url = this.options["render-url"]; let url = document.body.dataset.baseUrl; - log.debug("URL before cleanup: ", url); - // Split all split words out of url - url = split_words.reduce((url_, split_) => url_.split(split_)[0], url); // Ensure a trailing slash in the URL. url = url[url.length - 1] === "/" ? url : `${url}/` - url = `${url}${this.options["render-url"]}`; - log.debug("URL after cleanup: ", url); + url = `${url}${render_url}`; if (this.previous_toolbar_url === url) { // no need to reload same url @@ -85,6 +73,7 @@ class Pattern extends BasePattern { } // fetch toolbar + log.debug("Reload toolbar on: ", url); const response = await fetch(url); const data = await response.text(); From 7817f4a74d7b1d95d71c487c95f71c25021bda53 Mon Sep 17 00:00:00 2001 From: Johannes Raggam Date: Tue, 14 Oct 2025 13:19:40 +0200 Subject: [PATCH 23/24] fixup pat-toolbar: Rename render-url to render-view, as URL was semantically incorrect wording. --- src/pat/toolbar/toolbar.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/pat/toolbar/toolbar.js b/src/pat/toolbar/toolbar.js index 8fb39e6d4a..2f4ebca4bd 100644 --- a/src/pat/toolbar/toolbar.js +++ b/src/pat/toolbar/toolbar.js @@ -10,7 +10,7 @@ import Cookies from "js-cookie"; const log = logging.getLogger("pat-toolbar"); export const parser = new Parser("toolbar"); -parser.addArgument("render-url", "@@render-toolbar"); +parser.addArgument("render-view", "@@render-toolbar"); class Pattern extends BasePattern { static name = "toolbar"; @@ -60,11 +60,11 @@ class Pattern extends BasePattern { } async reload_toolbar() { - const render_url = this.options["render-url"]; + const render_view = this.options["render-view"]; let url = document.body.dataset.baseUrl; // Ensure a trailing slash in the URL. url = url[url.length - 1] === "/" ? url : `${url}/` - url = `${url}${render_url}`; + url = `${url}${render_view}`; if (this.previous_toolbar_url === url) { // no need to reload same url From 0cd91d301bb0ce37d142ef16ecdfc89e82d11061 Mon Sep 17 00:00:00 2001 From: Johannes Raggam Date: Tue, 14 Oct 2025 13:23:31 +0200 Subject: [PATCH 24/24] fixup pat-structure: No need to set the base URL. Using history.pushState is enough to change the URL and to get pat-base-url active. --- src/pat/structure/js/views/app.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/pat/structure/js/views/app.js b/src/pat/structure/js/views/app.js index 12fe78f339..78d70886bd 100644 --- a/src/pat/structure/js/views/app.js +++ b/src/pat/structure/js/views/app.js @@ -188,9 +188,6 @@ export default BaseView.extend({ // specifying a path. path = ""; } - if (url && path !== "") { - document.body.dataset.baseUrl = url; - } $("body").trigger("structure-url-changed", [path]); this.loading.hide(); @@ -229,7 +226,6 @@ export default BaseView.extend({ path = "/"; } this.setCurrentPath(path); - document.body.dataset.baseUrl = `${document.body.dataset.portalUrl}${path}`; $("body").trigger("structure-url-changed", [path]); // since this next call causes state to be pushed... this.doNotPushState = true;