mock mode: removed subnav - keep navbar in sync with mock mode
This commit is contained in:
+50
-15
@@ -1,6 +1,11 @@
|
||||
{{- $loggedIn := and (and .Identity .Identity.AccessToken) true -}}
|
||||
{{- $hasAccount := and (and .Identity .Identity.Account) true -}}
|
||||
{{- $acctID := 0 }}
|
||||
{{- $mockMode := false }}
|
||||
{{- if $hasAccount }}
|
||||
{{- $acctID = .Identity.Account.AccountID }}
|
||||
{{- $mockMode = .Accounts.GetMockMode $acctID }}
|
||||
{{- end }}
|
||||
|
||||
|
||||
<!DOCTYPE html>
|
||||
@@ -84,7 +89,23 @@
|
||||
</li>
|
||||
{{ 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
|
||||
hx-swap="morph:innerHTML"
|
||||
{{ template "navbar-ul-class" }}
|
||||
@@ -99,29 +120,42 @@
|
||||
)}}
|
||||
|
||||
{{- else if $hasAccount }}
|
||||
{{- $acctID = .Identity.Account.AccountID }}
|
||||
|
||||
{{ template "navbar-link" (props
|
||||
"Href" (printf "/ui/accounts/%d" $acctID)
|
||||
"Selected" (eq $path (printf "/accounts/%d" $acctID))
|
||||
"Content" "Account"
|
||||
)}}
|
||||
|
||||
{{- $shopUIPath := printf "/accounts/%d/shops" $acctID }}
|
||||
{{- if $mockMode }}
|
||||
{{- $shopUIPath = printf "%s/mock" $shopUIPath }}
|
||||
{{- end }}
|
||||
|
||||
{{ template "navbar-link" (props
|
||||
"Href" (printf "/ui/accounts/%d/shops" $acctID)
|
||||
"Selected" (hasPrefix $path (printf "/accounts/%d/shops" $acctID))
|
||||
"Href" (printf "/ui%s" $shopUIPath)
|
||||
"Selected" (hasPrefix $path $shopUIPath)
|
||||
"Content" "Shops"
|
||||
)}}
|
||||
|
||||
{{- $inventoryUIPath := printf "/accounts/%d/inventory" $acctID }}
|
||||
{{- if $mockMode }}
|
||||
{{- $inventoryUIPath = printf "%s/mock" $inventoryUIPath }}
|
||||
{{- end }}
|
||||
|
||||
{{ template "navbar-link" (props
|
||||
"Href" (printf "/ui/accounts/%d/inventory" $acctID)
|
||||
"Selected" (hasPrefix $path (printf "/accounts/%d/inventory" $acctID))
|
||||
"Href" (printf "/ui%s" $inventoryUIPath)
|
||||
"Selected" (hasPrefix $path $inventoryUIPath)
|
||||
"Content" "Inventory"
|
||||
)}}
|
||||
|
||||
{{- $reportsUIPath := printf "/accounts/%d/reports" $acctID }}
|
||||
{{- if $mockMode }}
|
||||
{{- $reportsUIPath = printf "%s/mock" $reportsUIPath }}
|
||||
{{- end }}
|
||||
|
||||
{{ template "navbar-link" (props
|
||||
"Href" (printf "/ui/accounts/%d/reports" $acctID)
|
||||
"Selected" (hasPrefix $path (printf "/accounts/%d/reports" $acctID))
|
||||
"Href" (printf "/ui%s" $reportsUIPath)
|
||||
"Selected" (hasPrefix $path $reportsUIPath)
|
||||
"Content" "Reports"
|
||||
)}}
|
||||
|
||||
@@ -129,7 +163,8 @@
|
||||
</ul>
|
||||
</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" . }}>
|
||||
<ul
|
||||
hx-swap="morph:innerHTML"
|
||||
@@ -142,15 +177,15 @@
|
||||
)}}
|
||||
|
||||
{{ template "navbar-link" (props
|
||||
"Href" (printf "/ui/accounts/%d/shops/mocks" $acctID)
|
||||
"Selected" (eq $path (printf "/accounts/%d/shops/mocks" $acctID))
|
||||
"Href" (printf "/ui/accounts/%d/shops/mock" $acctID)
|
||||
"Selected" (eq $path (printf "/accounts/%d/shops/mock" $acctID))
|
||||
"Content" "Mock"
|
||||
)}}
|
||||
</ul>
|
||||
</nav>
|
||||
{{- end }}
|
||||
{{- end */}}
|
||||
|
||||
{{- if hasPrefix $path (printf "/accounts/%d/inventory" $acctID) }}
|
||||
{{/*- if hasPrefix $path (printf "/accounts/%d/inventory" $acctID) }}
|
||||
<nav {{ template "navbar-class" . }}>
|
||||
<ul
|
||||
hx-swap="morph:innerHTML"
|
||||
@@ -169,7 +204,7 @@
|
||||
)}}
|
||||
</ul>
|
||||
</nav>
|
||||
{{- end }}
|
||||
{{- end */}}
|
||||
</header>
|
||||
|
||||
<main class="basis-full grow max-w-full">
|
||||
|
||||
Reference in New Issue
Block a user