mirror of
https://github.com/status-im/open-bounty.git
synced 2025-02-27 00:20:46 +00:00
[FIX #187] Add dummy value to Metamask dropdown;
do not automatically preselect first item in the list; convert addresses to lower-case
This commit is contained in:
parent
3f883a36c1
commit
3c4413b160
@ -10,18 +10,19 @@
|
|||||||
(merge props {:type "text"
|
(merge props {:type "text"
|
||||||
:value @val-ratom
|
:value @val-ratom
|
||||||
:on-change #(reset! val-ratom (-> % .-target .-value))})]))
|
:on-change #(reset! val-ratom (-> % .-target .-value))})]))
|
||||||
|
|
||||||
(defn dropdown [props title val-ratom items]
|
(defn dropdown [props title val-ratom items]
|
||||||
(fn []
|
(fn []
|
||||||
(if (= 1 (count items))
|
|
||||||
(reset! val-ratom (first items)))
|
|
||||||
[:select.ui.basic.selection.dropdown
|
[:select.ui.basic.selection.dropdown
|
||||||
(merge props {:on-change
|
(merge props {:on-change
|
||||||
#(reset! val-ratom (-> % .-target .-value))})
|
#(let [selected-value (-> % .-target .-value)]
|
||||||
(doall (for [item items]
|
(when (not= selected-value title)
|
||||||
^{:key item} [:option
|
(reset! val-ratom selected-value)))
|
||||||
{:value item}
|
:default-value (if (contains? (set items) @val-ratom)
|
||||||
item]))]))
|
@val-ratom
|
||||||
|
title)})
|
||||||
|
(conj (doall (for [item items]
|
||||||
|
^{:key item} [:option {:value item} item]))
|
||||||
|
^{:key title} [:option {:value title :disabled true} title])]))
|
||||||
|
|
||||||
(defn moment-timestamp [time]
|
(defn moment-timestamp [time]
|
||||||
(let [now (.now js/Date.)
|
(let [now (.now js/Date.)
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
[commiteth.common :refer [input dropdown]]
|
[commiteth.common :refer [input dropdown]]
|
||||||
[reagent.core :as r]
|
[reagent.core :as r]
|
||||||
[reagent.crypt :as crypt]
|
[reagent.crypt :as crypt]
|
||||||
|
[clojure.string :as str]
|
||||||
[cljs-web3.eth :as web3-eth]))
|
[cljs-web3.eth :as web3-eth]))
|
||||||
|
|
||||||
|
|
||||||
@ -10,7 +11,9 @@
|
|||||||
(let [db (rf/subscribe [:db])
|
(let [db (rf/subscribe [:db])
|
||||||
user (rf/subscribe [:user])
|
user (rf/subscribe [:user])
|
||||||
updating-address (rf/subscribe [:get-in [:updating-address]])
|
updating-address (rf/subscribe [:get-in [:updating-address]])
|
||||||
address (r/atom @(rf/subscribe [:get-in [:user :address]]))]
|
address (-> @(rf/subscribe [:get-in [:user :address]])
|
||||||
|
str/lower-case
|
||||||
|
r/atom)]
|
||||||
(fn []
|
(fn []
|
||||||
(let [web3 (:web3 @db)
|
(let [web3 (:web3 @db)
|
||||||
web3-accounts (when web3
|
web3-accounts (when web3
|
||||||
@ -22,13 +25,12 @@
|
|||||||
[:p "Insert your Ethereum address in hex format."]
|
[:p "Insert your Ethereum address in hex format."]
|
||||||
[:div.field
|
[:div.field
|
||||||
(if-not (empty? web3-accounts)
|
(if-not (empty? web3-accounts)
|
||||||
[dropdown {:class "address-input"} "Select address"
|
[dropdown {:class "address-input"}
|
||||||
|
"Select address"
|
||||||
address
|
address
|
||||||
(vec
|
(map str/lower-case web3-accounts)]
|
||||||
(for [acc web3-accounts]
|
|
||||||
acc))]
|
|
||||||
[:div.ui.input.address-input
|
[:div.ui.input.address-input
|
||||||
[input address {:placeholder "0x0000000000000000000000000000000000000000"
|
[input address {:placeholder "0x0000000000000000000000000000000000000000"
|
||||||
:auto-complete "off"
|
:auto-complete "off"
|
||||||
:auto-correct "off"
|
:auto-correct "off"
|
||||||
:spell-check "false"
|
:spell-check "false"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user