fixes a couple of dropdown-related bugs.
This commit is contained in:
@@ -98,7 +98,7 @@
|
||||
(= (:user/role id) "admin")
|
||||
nil
|
||||
|
||||
(#{"manager" "user" "power-user"} (:user/role id))
|
||||
(#{"manager" "user" "power-user" "read-only"} (:user/role id))
|
||||
(:user/clients id [])))
|
||||
|
||||
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
(ns auto-ap.ssr.components.navbar
|
||||
(:require
|
||||
[auto-ap.graphql.utils :refer [is-admin?]]
|
||||
[auto-ap.ssr-routes :as ssr-routes]
|
||||
[auto-ap.ssr.company-dropdown :as cd]
|
||||
[auto-ap.ssr.components.buttons :refer [icon-button-]]
|
||||
[auto-ap.ssr.components.user-dropdown :as user-dropdown]
|
||||
[auto-ap.ssr.svg :as svg]
|
||||
[bidi.bidi :as bidi]))
|
||||
(:require [auto-ap.graphql.utils :refer [is-admin? limited-clients]]
|
||||
[auto-ap.ssr-routes :as ssr-routes]
|
||||
[auto-ap.ssr.company-dropdown :as cd]
|
||||
[auto-ap.ssr.components.buttons :refer [icon-button-]]
|
||||
[auto-ap.ssr.components.user-dropdown :as user-dropdown]
|
||||
[auto-ap.ssr.svg :as svg]
|
||||
[bidi.bidi :as bidi]))
|
||||
|
||||
(defn navbar- [{:keys [client-selection client identity clients dd-env]}]
|
||||
[:nav {:class "fixed z-30 w-full bg-white border-b border-gray-200 dark:bg-gray-800 dark:border-gray-700"}
|
||||
@@ -39,7 +38,10 @@
|
||||
:hx-target "#modal-holder"
|
||||
:hx-swap "outerHTML"}
|
||||
svg/search)
|
||||
(cd/dropdown {:client-selection client-selection :client client :identity identity
|
||||
:clients clients})
|
||||
(let [limited-clients (limited-clients identity)]
|
||||
(when (or (nil? limited-clients)
|
||||
(> (count limited-clients) 1))
|
||||
(cd/dropdown {:client-selection client-selection :client client :identity identity
|
||||
:clients clients})))
|
||||
|
||||
(user-dropdown/dropdown {:identity identity})]]]])
|
||||
|
||||
@@ -77,12 +77,10 @@
|
||||
(and token
|
||||
last-client-id
|
||||
(not last-selected-clients))
|
||||
[(js/parseInt last-client-id)]
|
||||
{:selected [(js/parseInt last-client-id)]}
|
||||
|
||||
:else
|
||||
nil)]
|
||||
|
||||
|
||||
(cond
|
||||
(= :login handler)
|
||||
{:db (cond-> (assoc db/default-db
|
||||
@@ -135,11 +133,11 @@
|
||||
::received-initial
|
||||
(fn [{:keys [db]} [_ {clients :client}]]
|
||||
(let [only-one-client (when (= 1 (count clients))
|
||||
(->> clients first :id))]
|
||||
(->> clients first :id js/parseInt))]
|
||||
(when only-one-client
|
||||
(.setItem js/localStorage "last-client-id" only-one-client)
|
||||
(.setItem js/localStorage "last-selected-clients"
|
||||
(pr-str [(js/parseInt only-one-client)])))
|
||||
(.stringify js/JSON (clj->js {:selected [only-one-client]}))))
|
||||
{:db (cond-> (-> db
|
||||
(assoc :clients (by :id clients))
|
||||
(assoc :is-initial-loading? false)
|
||||
@@ -149,7 +147,7 @@
|
||||
(filter #(= % (:last-client-id db)))
|
||||
first))))
|
||||
only-one-client (assoc :last-client-id only-one-client
|
||||
:selected-clients [only-one-client]))
|
||||
:selected-clients {:selected [only-one-client]}))
|
||||
:interval {:action :start
|
||||
:id :refresh-clients
|
||||
:frequency 600000
|
||||
|
||||
Reference in New Issue
Block a user