Skip to content

Commit

Permalink
Issue #63. Fix cross reference logic on dictionary and objects pages.…
Browse files Browse the repository at this point in the history
… Before this, classes were ignored when Base Event was one of the references.
  • Loading branch information
rmouritzen-splunk committed Jan 24, 2024
1 parent 8d3bcee commit 89cd150
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 18 deletions.
2 changes: 1 addition & 1 deletion lib/schema_web/templates/layout/app.html.eex
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ limitations under the License.
<a class="navbar-brand" href="#">OCSF Schema</a>

<nav class="navbar navbar-bg collapse navbar-collapse navbar-expand-md navbar-light fixed-left">
<a href=<%= Routes.static_path(@conn, "/?extensions=") %> onclick="reset_home_page()" class="navbar-brand ocsf-logo">
<a href="<%= Routes.static_path(@conn, "/?extensions=") %>" onclick="reset_home_page()" class="navbar-brand ocsf-logo">
<img src='<%= Routes.static_path(@conn, "/images/ocsf-logo.png") %>' alt="OCSF"/>
</a>
<h6 class="container-fluid version">
Expand Down
34 changes: 18 additions & 16 deletions lib/schema_web/views/page_view.ex
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,15 @@ defmodule SchemaWeb.PageView do
end

def class_profiles(conn, class, profiles) do
case (class[:profiles] || []) do
case class[:profiles] || [] do
[] ->
""

list ->
[
"<h5 class='mt-3'>Profiles</h5>",
"Applicable profiles: ",
Stream.filter(list, fn profile -> Map.has_key?(profiles, profile) end)
Stream.filter(list, fn profile -> Map.has_key?(profiles, profile) end)
|> Enum.map_join(", ", fn name ->
profile_link(conn, get_in(profiles, [name, :caption]), name)
end),
Expand Down Expand Up @@ -251,7 +252,7 @@ defmodule SchemaWeb.PageView do
end

r ->
max_len <> "</br>" <> r
max_len <> "<br>" <> r
end
end

Expand Down Expand Up @@ -372,16 +373,16 @@ defmodule SchemaWeb.PageView do
[
"At least one attribute must be present: <strong>",
Enum.join(list, ", "),
"</strong><br/>" | acc
"</strong><br>" | acc
]
end

def constraints(:just_one, list, acc) do
["Only one attribute can be present: <strong>", Enum.join(list, ", "), "</strong><br/>" | acc]
["Only one attribute can be present: <strong>", Enum.join(list, ", "), "</strong><br>" | acc]
end

def constraints(name, list, acc) do
[Atom.to_string(name), ": <strong>", Enum.join(list, ", "), "</strong><br/>" | acc]
[Atom.to_string(name), ": <strong>", Enum.join(list, ", "), "</strong><br>" | acc]
end

def associations(rules) do
Expand All @@ -391,7 +392,7 @@ defmodule SchemaWeb.PageView do
end

def associations(name, list, acc) do
[Atom.to_string(name), ": ", Enum.join(list, ", "), "<br/>" | acc]
[Atom.to_string(name), ": ", Enum.join(list, ", "), "<br>" | acc]
end

def links(_, _, nil), do: ""
Expand All @@ -418,12 +419,14 @@ defmodule SchemaWeb.PageView do
)
end

defp join_html([], [], []), do: []
defp join_html(commons, [], []), do: commons
defp join_html([], classes, []), do: classes
defp join_html(commons, _classes, []), do: commons
defp join_html(_, [], objects), do: objects
defp join_html([], classes, objects), do: [classes, "<hr/>", objects]
defp join_html(commons, _classes, objects), do: [commons, "<hr/>", objects]
defp join_html([], [], objects), do: objects
defp join_html(commons, classes, []), do: [commons, "<hr>", classes]
defp join_html(commons, [], objects), do: [commons, "<hr>", objects]
defp join_html([], classes, objects), do: [classes, "<hr>", objects]
defp join_html(commons, classes, objects), do: [commons, "<hr>", classes, "<hr>", objects]

defp to_html(_, _, nil), do: []

Expand All @@ -438,7 +441,7 @@ defmodule SchemaWeb.PageView do
[],
fn _, acc ->
type_path = SchemaWeb.Router.Helpers.static_path(conn, "/base_event")
["<a href='", type_path, "'>", " Base Event</a>", ", " | acc]
["<a href='", type_path, "'>", "Base Event Class</a>", ", " | acc]
end
)
|> List.delete_at(-1)
Expand All @@ -455,7 +458,7 @@ defmodule SchemaWeb.PageView do
[],
fn {_type, link, name}, acc ->
type_path = SchemaWeb.Router.Helpers.static_path(conn, "/classes/" <> link)
["<a href='", type_path, "'>", name, " Event</a>", ", " | acc]
["<a href='", type_path, "'>", name, " Class</a>", ", " | acc]
end
)
|> List.delete_at(-1)
Expand Down Expand Up @@ -493,11 +496,10 @@ defmodule SchemaWeb.PageView do
defp deprecated(map, deprecated) do
[
Map.get(map, :description),
"<div class='text-dark mt-2'><span class='bg-warning'>DEPRECATED since v",
"<div class='text-dark mt-2 bg-warning'>DEPRECATED since v",
Map.get(deprecated, :since),
"</span></div>",
"</div>",
Map.get(deprecated, :message)
]
end

end
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
defmodule Schema.MixProject do
use Mix.Project

@version "2.67.0"
@version "2.68.0"

def project do
build = System.get_env("GITHUB_RUN_NUMBER") || "SNAPSHOT"
Expand Down

0 comments on commit 89cd150

Please sign in to comment.