diff --git a/lib/schema_web/controllers/page_controller.ex b/lib/schema_web/controllers/page_controller.ex index a00ef9e..1609961 100644 --- a/lib/schema_web/controllers/page_controller.ex +++ b/lib/schema_web/controllers/page_controller.ex @@ -32,6 +32,8 @@ defmodule SchemaWeb.PageController do @spec category_by_id(Plug.Conn.t(), map()) :: Plug.Conn.t() def category_by_id(conn, params) do + params = Map.put_new(params, "extensions", "") + case SchemaController.category_classes(params) do nil -> send_resp(conn, 404, "Not Found: #{SchemaController.params_to_uid(params)}") @@ -49,6 +51,7 @@ defmodule SchemaWeb.PageController do @spec profiles(Plug.Conn.t(), map) :: Plug.Conn.t() def profiles(conn, params) do + params = Map.put_new(params, "extensions", "") profiles = get_profiles(params) sorted_profiles = sort_by_descoped_key(profiles) @@ -81,7 +84,10 @@ defmodule SchemaWeb.PageController do @spec classes(Plug.Conn.t(), any) :: Plug.Conn.t() def classes(conn, params) do - data = SchemaController.classes(params) |> sort_by(:uid) + data = + Map.put_new(params, "extensions", "") + |> SchemaController.classes() + |> sort_by(:uid) render(conn, "classes.html", extensions: Schema.extensions(), @@ -137,6 +143,8 @@ defmodule SchemaWeb.PageController do @spec objects(Plug.Conn.t(), map()) :: Plug.Conn.t() def objects(conn, params) do + params = Map.put_new(params, "extensions", "") + data = SchemaController.parse_options(SchemaController.extensions(params)) |> Schema.objects_filter_extensions() @@ -190,6 +198,7 @@ defmodule SchemaWeb.PageController do @spec dictionary(Plug.Conn.t(), any) :: Plug.Conn.t() def dictionary(conn, params) do + params = Map.put_new(params, "extensions", "") schema = Schema.schema() data = diff --git a/lib/schema_web/templates/layout/app.html.eex b/lib/schema_web/templates/layout/app.html.eex index 38c3ccd..cbec0ee 100644 --- a/lib/schema_web/templates/layout/app.html.eex +++ b/lib/schema_web/templates/layout/app.html.eex @@ -46,11 +46,26 @@ limitations under the License. this.href = this.href + params; }); - // Also update main navigation links + // Also update main navigation links (skip dropdown toggles and hash-only links) $(".top-navbar-nav a.nav-link").each(function() { + if (this.getAttribute('href') === '#' || this.classList.contains('dropdown-toggle')) { + return; + } this.href = this.href + params; }); + // Update content links (class, object, category, profile links in page body) + $(".main-page a").each(function() { + const href = this.getAttribute('href'); + if (!href || href.startsWith('http') || href.startsWith('#') || href.startsWith('javascript:') || href.includes('?')) { + return; + } + // Only update internal schema navigation links + if (href.match(/^\/(classes|objects|categories|profiles|dictionary|data_types)/)) { + this.href = this.href + params; + } + }); + // set the profile checkboxes init_selected_profiles(); @@ -95,6 +110,9 @@ limitations under the License. case '/objects': $('#objects_id a.nav-link').addClass("active"); break; + case '/profiles': + $('#profiles_id a.nav-link').addClass("active"); + break; case '/objects/observable': $('#observable_id a.nav-link').addClass("active"); break; @@ -248,6 +266,9 @@ limitations under the License.