admins copy IDs
This commit is contained in:
@@ -1,10 +1,12 @@
|
||||
(ns auto-ap.views.components.grid
|
||||
(:require [reagent.core :as r]
|
||||
[auto-ap.views.utils :refer [appearing]]
|
||||
[auto-ap.views.utils :refer [appearing copy-to-clipboard]]
|
||||
[auto-ap.utils :refer [default-pagination-size]]
|
||||
[react :as react]
|
||||
[re-frame.core :as re-frame]
|
||||
[auto-ap.views.pages.data-page :as data-page]))
|
||||
[auto-ap.views.pages.data-page :as data-page]
|
||||
[auto-ap.views.components.buttons :as buttons]
|
||||
[auto-ap.subs :as subs]))
|
||||
|
||||
(defonce grid-context (react/createContext "default"))
|
||||
(def Provider (.-Provider grid-context))
|
||||
@@ -151,7 +153,10 @@
|
||||
(r/children (r/current-component))))
|
||||
|
||||
(defn row [{:keys [class id checkable? entity] }]
|
||||
(let [children (r/children (r/current-component))]
|
||||
(let [children (r/children (r/current-component))
|
||||
is-admin? @(re-frame/subscribe [::subs/is-admin?])
|
||||
|
||||
]
|
||||
[:> Consumer {}
|
||||
(fn [consume]
|
||||
(let [on-check-changed (aget consume "on-check-changed")
|
||||
@@ -178,6 +183,15 @@
|
||||
(on-check-changed (conj checked id)))))))}
|
||||
(boolean? checkable?) (assoc :disabled (not checkable?))) ]]))
|
||||
|
||||
(when is-admin?
|
||||
(r/as-element
|
||||
(cond
|
||||
(not id) [:th {:style {:width "4em"}}]
|
||||
id [:th {:style {:width "4em"}} [:button.button.is-link.is-light
|
||||
{:on-click (fn []
|
||||
(copy-to-clipboard id))}
|
||||
[:span.icon [:i.fa.fa-files-o]]
|
||||
]])))
|
||||
(map r/as-element children))))]))
|
||||
|
||||
(defn button-cell [params]
|
||||
@@ -190,12 +204,14 @@
|
||||
)
|
||||
|
||||
(defn body []
|
||||
(let [children (r/children (r/current-component))]
|
||||
(let [children (r/children (r/current-component))
|
||||
is-admin? @(re-frame/subscribe [::subs/is-admin?])]
|
||||
[:> Consumer {}
|
||||
(fn [consume]
|
||||
(let [{:strs [column-count status check-boxes?]} (js->clj consume)
|
||||
column-count (cond-> column-count
|
||||
check-boxes? inc)]
|
||||
check-boxes? inc
|
||||
is-admin? inc)]
|
||||
(r/as-element
|
||||
(cond (= :loading (:state status))
|
||||
^{:key "loading-body"}
|
||||
|
||||
Reference in New Issue
Block a user