-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use autoselect control for Providers (#725)
* Use autoselect control for Providers So it matches both the Region and Consumers pickers. See #724 * Move providers-set loading into dropdown component See #724 * Fix source code formatting
- Loading branch information
1 parent
ce906de
commit 3e3ee6c
Showing
3 changed files
with
14 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 11 additions & 28 deletions
39
client/src/planwise/client/providers_set/components/dropdown.cljs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,16 @@ | ||
(ns planwise.client.providers-set.components.dropdown | ||
(:require [re-frame.core :refer [subscribe dispatch]] | ||
[reagent.core :as r] | ||
[clojure.string :as string] | ||
(:require [re-frame.core :as rf] | ||
[planwise.client.asdf :as asdf] | ||
[planwise.client.utils :as utils] | ||
[planwise.client.components.common2 :as common2] | ||
[planwise.client.providers-set.db :as db] | ||
[planwise.client.ui.rmwc :as m] | ||
[re-frame.utils :as c])) | ||
|
||
(defn- providers-set-select-component | ||
[{:keys [label value options empty-label on-change]}] | ||
[m/Select {:label (if (empty? options) empty-label label) | ||
:disabled (empty? options) | ||
:value (str value) | ||
:options options | ||
:on-change #(on-change (js/parseInt (-> % .-target .-value)))}]) | ||
[planwise.client.ui.filter-select :as filter-select])) | ||
|
||
(defn providers-set-dropdown-component | ||
[{:keys [label value on-change disabled?]}] | ||
(let [list (subscribe [:providers-set/list]) | ||
options (subscribe [:providers-set/dropdown-options]) | ||
component (if (or disabled? (empty? @options)) | ||
common2/disabled-input-component | ||
providers-set-select-component)] | ||
[attrs] | ||
(let [list (rf/subscribe [:providers-set/list]) | ||
props (merge {:choices @(rf/subscribe [:providers-set/dropdown-options]) | ||
:label-fn :label | ||
:render-fn (fn [provider-set] [:div.option-row | ||
[:span (:label provider-set)]])} | ||
attrs)] | ||
(when (asdf/should-reload? @list) | ||
(dispatch [:providers-set/load-providers-set])) | ||
[component {:label label | ||
:value value | ||
:options @options | ||
:empty-label "There are no providers-set defined." | ||
:on-change on-change}])) | ||
(rf/dispatch [:providers-set/load-providers-set])) | ||
(into [filter-select/single-dropdown] (mapcat identity props)))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters