mock mode: removed subnav - keep navbar in sync with mock mode

This commit is contained in:
2026-02-26 23:44:11 -07:00
parent d34810555a
commit ee5557cca1
3 changed files with 51 additions and 16 deletions
@@ -9,7 +9,7 @@
{{- $mockMode := .Accounts.GetMockMode $acctID }} {{- $mockMode := .Accounts.GetMockMode $acctID }}
<form id="mock-mode-form"> <form id="mock-mode-form">
<label class="font-display text-[1.5em]"> <label class="flex items-center gap-[0.5em] font-display text-[1.5em]">
Mock Mode Mock Mode
<input <input
type="checkbox" type="checkbox"
+50 -15
View File
@@ -1,6 +1,11 @@
{{- $loggedIn := and (and .Identity .Identity.AccessToken) true -}} {{- $loggedIn := and (and .Identity .Identity.AccessToken) true -}}
{{- $hasAccount := and (and .Identity .Identity.Account) true -}} {{- $hasAccount := and (and .Identity .Identity.Account) true -}}
{{- $acctID := 0 }} {{- $acctID := 0 }}
{{- $mockMode := false }}
{{- if $hasAccount }}
{{- $acctID = .Identity.Account.AccountID }}
{{- $mockMode = .Accounts.GetMockMode $acctID }}
{{- end }}
<!DOCTYPE html> <!DOCTYPE html>
@@ -84,7 +89,23 @@
</li> </li>
{{ end }} {{ end }}
<nav {{ template "navbar-class" . }}> {{/* navbar updater */}}
{{- if $hasAccount }}
<div
hx-trigger="sse:accounts_{{$acctID}}_mock-mode"
hx-get="/ui{{$path}}"
hx-select="#header-navbar"
hx-target="#header-navbar"
hx-swap="outerHTML"
hidden
>
</div>
{{- end }}
<nav
{{ template "navbar-class" . }}
id="header-navbar"
>
<ul <ul
hx-swap="morph:innerHTML" hx-swap="morph:innerHTML"
{{ template "navbar-ul-class" }} {{ template "navbar-ul-class" }}
@@ -99,29 +120,42 @@
)}} )}}
{{- else if $hasAccount }} {{- else if $hasAccount }}
{{- $acctID = .Identity.Account.AccountID }}
{{ template "navbar-link" (props {{ template "navbar-link" (props
"Href" (printf "/ui/accounts/%d" $acctID) "Href" (printf "/ui/accounts/%d" $acctID)
"Selected" (eq $path (printf "/accounts/%d" $acctID)) "Selected" (eq $path (printf "/accounts/%d" $acctID))
"Content" "Account" "Content" "Account"
)}} )}}
{{- $shopUIPath := printf "/accounts/%d/shops" $acctID }}
{{- if $mockMode }}
{{- $shopUIPath = printf "%s/mock" $shopUIPath }}
{{- end }}
{{ template "navbar-link" (props {{ template "navbar-link" (props
"Href" (printf "/ui/accounts/%d/shops" $acctID) "Href" (printf "/ui%s" $shopUIPath)
"Selected" (hasPrefix $path (printf "/accounts/%d/shops" $acctID)) "Selected" (hasPrefix $path $shopUIPath)
"Content" "Shops" "Content" "Shops"
)}} )}}
{{- $inventoryUIPath := printf "/accounts/%d/inventory" $acctID }}
{{- if $mockMode }}
{{- $inventoryUIPath = printf "%s/mock" $inventoryUIPath }}
{{- end }}
{{ template "navbar-link" (props {{ template "navbar-link" (props
"Href" (printf "/ui/accounts/%d/inventory" $acctID) "Href" (printf "/ui%s" $inventoryUIPath)
"Selected" (hasPrefix $path (printf "/accounts/%d/inventory" $acctID)) "Selected" (hasPrefix $path $inventoryUIPath)
"Content" "Inventory" "Content" "Inventory"
)}} )}}
{{- $reportsUIPath := printf "/accounts/%d/reports" $acctID }}
{{- if $mockMode }}
{{- $reportsUIPath = printf "%s/mock" $reportsUIPath }}
{{- end }}
{{ template "navbar-link" (props {{ template "navbar-link" (props
"Href" (printf "/ui/accounts/%d/reports" $acctID) "Href" (printf "/ui%s" $reportsUIPath)
"Selected" (hasPrefix $path (printf "/accounts/%d/reports" $acctID)) "Selected" (hasPrefix $path $reportsUIPath)
"Content" "Reports" "Content" "Reports"
)}} )}}
@@ -129,7 +163,8 @@
</ul> </ul>
</nav> </nav>
{{- if hasPrefix $path (printf "/accounts/%d/shops" $acctID) }} {{/* TODO: delete this AFTER we're sure we don't need this anymore */}}
{{/*- if hasPrefix $path (printf "/accounts/%d/shops" $acctID) }}
<nav {{ template "navbar-class" . }}> <nav {{ template "navbar-class" . }}>
<ul <ul
hx-swap="morph:innerHTML" hx-swap="morph:innerHTML"
@@ -142,15 +177,15 @@
)}} )}}
{{ template "navbar-link" (props {{ template "navbar-link" (props
"Href" (printf "/ui/accounts/%d/shops/mocks" $acctID) "Href" (printf "/ui/accounts/%d/shops/mock" $acctID)
"Selected" (eq $path (printf "/accounts/%d/shops/mocks" $acctID)) "Selected" (eq $path (printf "/accounts/%d/shops/mock" $acctID))
"Content" "Mock" "Content" "Mock"
)}} )}}
</ul> </ul>
</nav> </nav>
{{- end }} {{- end */}}
{{- if hasPrefix $path (printf "/accounts/%d/inventory" $acctID) }} {{/*- if hasPrefix $path (printf "/accounts/%d/inventory" $acctID) }}
<nav {{ template "navbar-class" . }}> <nav {{ template "navbar-class" . }}>
<ul <ul
hx-swap="morph:innerHTML" hx-swap="morph:innerHTML"
@@ -169,7 +204,7 @@
)}} )}}
</ul> </ul>
</nav> </nav>
{{- end }} {{- end */}}
</header> </header>
<main class="basis-full grow max-w-full"> <main class="basis-full grow max-w-full">