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