fixed warnings.
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
(ns auto-ap.views.components.address
|
||||
(:require
|
||||
[auto-ap.entities.address :as address]
|
||||
[auto-ap.forms.builder :as form-builder]
|
||||
[auto-ap.views.components.level :as level]))
|
||||
|
||||
@@ -20,8 +19,7 @@
|
||||
[:p.help "City"]
|
||||
[:input.input.is-expanded {:type "text"
|
||||
:placeholder "Cupertino"
|
||||
:field [:city]
|
||||
:spec ::address/city}]]
|
||||
:field [:city]}]]
|
||||
[form-builder/field-v2 {:field :state}
|
||||
[:p.help "State"]
|
||||
[:input.input {:type "text"
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
[re-frame.core :as re-frame]
|
||||
[reagent.core :as r]))
|
||||
|
||||
(defn admin-side-bar [params ]
|
||||
(defn admin-side-bar []
|
||||
(let [ap @(re-frame/subscribe [::subs/active-page])]
|
||||
[:div
|
||||
[:p.menu-label "General"]
|
||||
@@ -45,12 +45,6 @@
|
||||
[:a {:href (bidi/path-for routes/routes :admin-rules), :class (str "item" (active-when ap = :admin-rules))}
|
||||
[:span {:class "icon icon-cog-play-1" :style {:font-size "25px"}}]
|
||||
[:span {:class "name"} "Rules"]]]
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
[:ul ]]
|
||||
[:p.menu-label "Import"]
|
||||
[:ul.menu-list
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
(:require [auto-ap.views.utils :refer [dispatch-event]]
|
||||
[reagent.core :as r]))
|
||||
|
||||
(defn fa-icon [{:keys [event icon class on-click] :as params}]
|
||||
(defn fa-icon [{:keys [event icon on-click] :as params}]
|
||||
[:a.button (cond-> params
|
||||
true (dissoc :event :icon)
|
||||
(and (not on-click)
|
||||
@@ -15,7 +15,7 @@
|
||||
|
||||
|
||||
|
||||
(defn sl-icon [{:keys [event icon class on-click] :as params}]
|
||||
(defn sl-icon [{:keys [event icon on-click] :as params}]
|
||||
[:a.button (cond-> params
|
||||
true (dissoc :event :icon)
|
||||
(and (not on-click)
|
||||
@@ -28,7 +28,7 @@
|
||||
[:span.icon [:i.fa.fa-plus]]
|
||||
[:span name]])
|
||||
|
||||
(defn dropdown [{:keys [event icon class on-click] :as params}]
|
||||
(defn dropdown [{:keys [event on-click] :as params}]
|
||||
[:a.button (cond-> params
|
||||
true (dissoc :event :icon)
|
||||
(and (not on-click)
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
[re-frame.core :as re-frame]
|
||||
[auto-ap.subs :as subs]))
|
||||
|
||||
(defn drop-down-contents [{:keys [id]} children ]
|
||||
(defn drop-down-contents [{:keys [id]}]
|
||||
(let [toggle-fn (fn [] (re-frame/dispatch [::events/toggle-menu id]))]
|
||||
(r/create-class {:component-did-mount (fn [] (.addEventListener js/document "click" toggle-fn))
|
||||
:component-will-unmount (fn [] (.removeEventListener js/document "click" toggle-fn))
|
||||
@@ -13,8 +13,8 @@
|
||||
(fn [children]
|
||||
children)})))
|
||||
|
||||
(defn drop-down [{:keys [ header id is-right? class]} child]
|
||||
(let [menu-active? (re-frame/subscribe [::subs/menu-active? id])]
|
||||
(defn drop-down [{:keys [ id ]} _]
|
||||
(let [_ (re-frame/subscribe [::subs/menu-active? id])]
|
||||
(r/create-class
|
||||
{:reagent-render (fn [{:keys [header id is-right? class] :or {is-right? true}} child]
|
||||
(let [menu-active? @(re-frame/subscribe [::subs/menu-active? id])]
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
(ns auto-ap.views.components.grid
|
||||
(:require [reagent.core :as r]
|
||||
[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.components.buttons :as buttons]
|
||||
[auto-ap.subs :as subs]
|
||||
[react-dom :as react-dom]))
|
||||
(:require
|
||||
[auto-ap.subs :as subs]
|
||||
[auto-ap.utils :refer [default-pagination-size]]
|
||||
[auto-ap.views.pages.data-page :as data-page]
|
||||
[auto-ap.views.utils :refer [copy-to-clipboard]]
|
||||
[re-frame.core :as re-frame]
|
||||
[react :as react]
|
||||
[reagent.core :as r]))
|
||||
|
||||
(set! *warn-on-infer* true)
|
||||
|
||||
(defonce ^js/React.Context grid-context ( react/createContext "default"))
|
||||
@@ -60,7 +60,7 @@
|
||||
:else
|
||||
y))
|
||||
|
||||
(defn paginator [{:keys [start per-page end count total on-change] :as g}]
|
||||
(defn paginator [{:keys [start per-page end total on-change]}]
|
||||
(let [per-page (or per-page default-pagination-size)
|
||||
max-buttons 5
|
||||
buttons-before (Math/floor (/ max-buttons 2))
|
||||
@@ -72,7 +72,7 @@
|
||||
[:li
|
||||
[:a.pagination-link {:class (when (= current-page x)
|
||||
"is-current")
|
||||
:on-click (fn [e] (on-change {:start (* x per-page)
|
||||
:on-click (fn [_] (on-change {:start (* x per-page)
|
||||
:per-page per-page}))}
|
||||
(inc x)]]))
|
||||
|
||||
@@ -117,11 +117,11 @@
|
||||
[:a.tag.is-medium.is-delete {:on-click (fn []
|
||||
(on-change {:sort (filter #(not= sort-key (:sort-key %)) sort)}))}]]])])
|
||||
|
||||
(defn controls [{:keys [start end count total per-page action-buttons] :as para}]
|
||||
(defn controls [{:keys [start end count total action-buttons]}]
|
||||
(let [children (r/children (r/current-component))]
|
||||
[:> Consumer {}
|
||||
(fn [consume]
|
||||
(let [{:strs [on-params-change params] :as consume} (js->clj consume)]
|
||||
(let [{:strs [on-params-change params]} (js->clj consume)]
|
||||
(r/as-element (into
|
||||
[:div {:style {:margin-bottom "1rem"}}
|
||||
[:div.level
|
||||
@@ -174,8 +174,8 @@
|
||||
:checked (if (get checked id)
|
||||
"checked"
|
||||
"")
|
||||
:on-change (fn [x e]
|
||||
(if id
|
||||
:on-change (fn [_ _]
|
||||
(when id
|
||||
(let [checked (or checked #{})]
|
||||
;; TODO only map once everything is moved over to data-page
|
||||
(if (map? checked)
|
||||
@@ -199,7 +199,7 @@
|
||||
]])))
|
||||
(map r/as-element children))))]))
|
||||
|
||||
(defn button-cell [params]
|
||||
(defn button-cell []
|
||||
(apply r/create-element "td" #js {"style" #js {"overflow" "visible"}}
|
||||
(map r/as-element (r/children (r/current-component)))))
|
||||
|
||||
@@ -244,13 +244,13 @@
|
||||
|
||||
children)))))]))
|
||||
|
||||
(defn sortable-header-cell [{:keys [style class sort-key sort-name asc]}]
|
||||
(defn sortable-header-cell [{:keys [style class sort-key sort-name]}]
|
||||
(let [children (r/children (r/current-component))]
|
||||
[:> Consumer {}
|
||||
(fn [consume]
|
||||
(let [{:strs [on-params-change params] :as consume} (js->clj consume)]
|
||||
(let [{:strs [on-params-change params]} (js->clj consume)]
|
||||
(r/as-element (conj (into
|
||||
[:th {:on-click (fn [e]
|
||||
[:th {:on-click (fn [_]
|
||||
(on-params-change
|
||||
(toggle-sort-by {:sort (:sort params)} sort-key sort-name)))
|
||||
:style (assoc style
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
:ref (fn [n]
|
||||
(reset! !child n))
|
||||
:tab-index 0
|
||||
:onBlur (fn [e]
|
||||
:onBlur (fn [_]
|
||||
(js/setTimeout (fn []
|
||||
(println @!child)
|
||||
(println (.-activeElement js/document))
|
||||
@@ -120,7 +120,7 @@
|
||||
(re-frame/dispatch [::events/swap-client client]))
|
||||
} name])]]))
|
||||
|
||||
(defn navbar [ap]
|
||||
(defn navbar []
|
||||
(let [navbar-menu-shown? (r/atom false)]
|
||||
(fn [ap]
|
||||
(let [user (re-frame/subscribe [::subs/user])
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
(ns auto-ap.views.components.modal
|
||||
(:require [re-frame.core :as re-frame]
|
||||
[reagent.core :as r]
|
||||
[auto-ap.events :as events]
|
||||
[auto-ap.subs :as subs]
|
||||
[auto-ap.status :as status]
|
||||
[auto-ap.views.utils :refer [with-keys appearing dispatch-event]]))
|
||||
(:require
|
||||
[auto-ap.status :as status]
|
||||
[auto-ap.views.utils :refer [appearing dispatch-event]]
|
||||
[re-frame.core :as re-frame]))
|
||||
|
||||
(re-frame/reg-sub
|
||||
::modal-state
|
||||
@@ -18,7 +16,7 @@
|
||||
|
||||
(re-frame/reg-event-fx
|
||||
::modal-closed
|
||||
(fn [{:keys [db]} [_ state]]
|
||||
(fn [{:keys [db]} [_ _]]
|
||||
(let [[_ status-id] (some-> db ::state :confirm :status-from )]
|
||||
(cond-> {:db (dissoc db ::state)}
|
||||
status-id (assoc :dispatch [::status/completed status-id])))))
|
||||
@@ -27,7 +25,7 @@
|
||||
(defn global-modal []
|
||||
(let [state (re-frame/subscribe [::modal-state])]
|
||||
(fn []
|
||||
(if (:visible? @state)
|
||||
(when (:visible? @state)
|
||||
(let [{:keys [title body status-from foot class cancel? confirm]} @state]
|
||||
[:div.modal.is-active (cond-> {}
|
||||
class (assoc :class class))
|
||||
|
||||
@@ -1,16 +1,13 @@
|
||||
(ns auto-ap.views.components.multi
|
||||
(:require
|
||||
[cemerick.url]
|
||||
#_{:clj-kondo/ignore [:unused-namespace]}
|
||||
[reagent.core :as reagent]
|
||||
[react :as react]
|
||||
[auto-ap.entities.shared :as shared]
|
||||
[auto-ap.views.utils :refer [appearing-group]]
|
||||
[auto-ap.forms.builder :as form-builder]))
|
||||
|
||||
|
||||
;; TODO just embrace the fact that it will need to be remounted, and use index based keys
|
||||
(defn multi-field-v2-internal [{:keys [template key-fn allow-change? disable-new? disable-remove? schema on-change disabled new-text] prop-value :value :as props} ]
|
||||
(defn multi-field-v2-internal [{:keys [template key-fn allow-change? disable-new? disable-remove? schema on-change disabled new-text] prop-value :value } ]
|
||||
(let [prop-value (if (seq prop-value)
|
||||
(vec prop-value)
|
||||
[])]
|
||||
|
||||
@@ -1,55 +0,0 @@
|
||||
(ns auto-ap.views.components.paginator
|
||||
(:require [re-frame.core :as re-frame]
|
||||
[auto-ap.subs :as subs]
|
||||
[auto-ap.views.utils :refer [date->str]]
|
||||
[reagent.core :as reagent]
|
||||
[clojure.string :as str]
|
||||
[cljs-time.format :as format]))
|
||||
|
||||
|
||||
(defn bound [x y z]
|
||||
(cond
|
||||
(< z x)
|
||||
x
|
||||
(< y x)
|
||||
x
|
||||
(> y z)
|
||||
z
|
||||
:else
|
||||
y))
|
||||
|
||||
(defn paginator [{:keys [start end count total on-change]}]
|
||||
(let [per-page 100
|
||||
max-buttons 5
|
||||
buttons-before (Math/floor (/ max-buttons 2))
|
||||
total-pages (Math/ceil (/ total per-page))
|
||||
current-page (Math/floor (/ start per-page))
|
||||
first-page-button (bound 0 (- current-page buttons-before) (- total-pages max-buttons))
|
||||
all-buttons (into [] (for [x (range total-pages)]
|
||||
^{:key x}
|
||||
[:li
|
||||
[:a.pagination-link {:class (when (= current-page x)
|
||||
"is-current")
|
||||
:on-click (fn [e] (on-change {:start (* x per-page)}))}
|
||||
(inc x)]]))
|
||||
|
||||
|
||||
last-page-button (Math/min total-pages (+ max-buttons first-page-button))
|
||||
|
||||
extended-last-page-button (when (not= last-page-button total-pages)
|
||||
(list
|
||||
^ {:key -1} [:li [:span.pagination-ellipsis "…"]]
|
||||
^ {:key -2} (last all-buttons)))
|
||||
|
||||
extended-first-page-button (when (not= first-page-button 0)
|
||||
(list
|
||||
^{:key -1} (first all-buttons)
|
||||
^{:key -2} [:li [:span.pagination-ellipsis "…"]]))]
|
||||
|
||||
|
||||
[:nav.pagination {:role "pagination"}
|
||||
[:ul.pagination-list
|
||||
extended-first-page-button
|
||||
(apply list (subvec all-buttons first-page-button last-page-button))
|
||||
extended-last-page-button
|
||||
"Showing " (Math/min (inc start) total) "-" end "/" total]]))
|
||||
@@ -1,6 +1,5 @@
|
||||
(ns auto-ap.views.components.percentage-field
|
||||
(:require [reagent.core :as r]
|
||||
[auto-ap.views.utils :refer [->short$]]
|
||||
[clojure.string :as str]
|
||||
[react :as react]))
|
||||
(def good-% #"^\d{1,3}$")
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
(ns auto-ap.views.components.sort-by-list
|
||||
(:require [re-frame.core :as re-frame]
|
||||
[auto-ap.subs :as subs]
|
||||
[auto-ap.views.utils :refer [date->str]]
|
||||
[reagent.core :as reagent]
|
||||
[clojure.string :as str]
|
||||
[cljs-time.format :as format]))
|
||||
|
||||
(defn sort-by-list [{:keys [sort on-change]}]
|
||||
[:div.field.is-grouped.is-grouped-multiline
|
||||
(for [{:keys [sort-key sort-name asc]} sort]
|
||||
^{:key sort-key}
|
||||
[:div.control
|
||||
[:div.tags.has-addons
|
||||
[:div.tag.is-medium [:span.icon (if asc
|
||||
[:i.fa.fa-sort-up]
|
||||
[:i.fa.fa-sort-down])]
|
||||
[:span sort-name] ]
|
||||
[:a.tag.is-medium.is-delete {:on-click (fn []
|
||||
(on-change {:sort (filter #(not= sort-key (:sort-key %)) sort)}))}]]])])
|
||||
|
||||
@@ -1,49 +0,0 @@
|
||||
(ns auto-ap.views.components.sorter
|
||||
(:require [re-frame.core :as re-frame]
|
||||
[auto-ap.subs :as subs]
|
||||
[auto-ap.views.utils :refer [date->str]]
|
||||
[reagent.core :as reagent]
|
||||
[clojure.string :as str]
|
||||
[cljs-time.format :as format]))
|
||||
(defn toggle-sort-by [params sort-key sort-name asc]
|
||||
(let [[found? sort] (reduce
|
||||
(fn [[found? sort] sort-item]
|
||||
(if (= sort-key (:sort-key sort-item))
|
||||
[true (conj sort
|
||||
(update sort-item :asc not))]
|
||||
[found? (conj sort sort-item)]))
|
||||
[false []]
|
||||
(:sort params))
|
||||
sort (if found?
|
||||
sort
|
||||
(conj sort {:sort-key sort-key
|
||||
:sort-name sort-name
|
||||
:asc true}))]
|
||||
|
||||
(-> params
|
||||
(assoc :sort sort))))
|
||||
|
||||
(defn sort-icon [which sort asc]
|
||||
(let [sort-item (first (filter #(= which (:sort-key %)) sort))]
|
||||
(cond
|
||||
(and sort-item (:asc sort-item))
|
||||
[:span.icon
|
||||
[:i.fa.fa-sort-up]]
|
||||
|
||||
(and sort-item (not (:asc sort-item)))
|
||||
[:span.icon
|
||||
[:i.fa.fa-sort-down]]
|
||||
|
||||
:else
|
||||
[:span.icon
|
||||
[:i.fa.fa-sort]])))
|
||||
|
||||
|
||||
(defn sorted-column [{:keys [on-sort sort-key sort sort-name asc style class]} & rest]
|
||||
[:th {:on-click (fn [e]
|
||||
(on-sort
|
||||
(toggle-sort-by {:sort sort} sort-key sort-name asc)))
|
||||
:style style
|
||||
:class class}
|
||||
rest
|
||||
(sort-icon sort-key sort asc)])
|
||||
@@ -166,7 +166,7 @@
|
||||
|
||||
|
||||
|
||||
(defn form-content [{:keys [data]}]
|
||||
(defn form-content []
|
||||
(let [is-admin? @(re-frame/subscribe [::subs/is-admin?])
|
||||
clients @(re-frame/subscribe [::subs/client-refs])]
|
||||
[form-builder/builder {:submit-event [::save]
|
||||
|
||||
Reference in New Issue
Block a user