diff --git a/ui/src/ethlance/ui/component/table.cljs b/ui/src/ethlance/ui/component/table.cljs index 7e170f81..1c2b65ba 100644 --- a/ui/src/ethlance/ui/component/table.cljs +++ b/ui/src/ethlance/ui/component/table.cljs @@ -41,7 +41,7 @@ :row-cells [[:span \"First cell\" \"Second cell\" etc]]} ] " - [{:keys [headers]} & rows] + [{:keys [headers empty-message] :or {empty-message "No data yet to show"}} & rows] [:div.ethlance-table [:table [:tbody @@ -50,18 +50,21 @@ (for [[i header] (map-indexed vector headers)] ^{:key (str "header-" i)} [:th header]))] - (doall - (for [[i row] (map-indexed vector rows)] - (if (map? row) + (if (empty? rows) + [:tr + [:td {:style {:text-align "center"} :col-span (count headers)} empty-message]] + (doall + (for [[i row] (map-indexed vector rows)] + (if (map? row) - ^{:key (str "row-" i)} - [:tr.clickable (:row-link row) - (for [[i elem] (map-indexed vector (:row-cells row))] - ^{:key (str "elem-" i)} - [:td elem])] + ^{:key (str "row-" i)} + [:tr.clickable (:row-link row) + (for [[i elem] (map-indexed vector (:row-cells row))] + ^{:key (str "elem-" i)} + [:td elem])] - ^{:key (str "row-" i)} - [:tr - (for [[i elem] (map-indexed vector row)] - ^{:key (str "elem-" i)} - [:td elem])])))]]]) + ^{:key (str "row-" i)} + [:tr + (for [[i elem] (map-indexed vector row)] + ^{:key (str "elem-" i)} + [:td elem])]))))]]]) diff --git a/ui/src/ethlance/ui/component/token_amount_input.cljs b/ui/src/ethlance/ui/component/token_amount_input.cljs index 964d9c49..6c7b1fba 100644 --- a/ui/src/ethlance/ui/component/token_amount_input.cljs +++ b/ui/src/ethlance/ui/component/token_amount_input.cljs @@ -12,7 +12,7 @@ "Returns original value if the val is zero expressing string (e.g. 0 or 0.0) When it becomes non-zero (e.g. 0.01) then returns the result (transform-fn val)" [val transform-fn] - (if (non-zero-fraction? val) + (if (non-zero-fraction? (str val)) (transform-fn val) val)) diff --git a/ui/src/ethlance/ui/component/token_info.cljs b/ui/src/ethlance/ui/component/token_info.cljs index 8aba3df0..63785bd8 100644 --- a/ui/src/ethlance/ui/component/token_info.cljs +++ b/ui/src/ethlance/ui/component/token_info.cljs @@ -37,7 +37,7 @@ (clojure.string/upper-case (name (or token-type "")))) address (:token-detail/id token-detail) short-address (str (subs address 0 5) "...") - token-link-parts (if show-address? + token-link-parts (if (and show-address? (not (= :eth token-type))) [display-type short-address] [display-type])] [:div (str display-amount " " token-symbol) diff --git a/ui/src/ethlance/ui/events.cljs b/ui/src/ethlance/ui/events.cljs index 2fc814e2..c449916f 100644 --- a/ui/src/ethlance/ui/events.cljs +++ b/ui/src/ethlance/ui/events.cljs @@ -2,7 +2,7 @@ (:require [akiroz.re-frame.storage] [day8.re-frame.forward-events-fx] - [district.ui.web3-accounts.events] + [district.ui.web3-accounts.events :as accounts-events] [ethlance.ui.page.arbiters.events] [ethlance.ui.page.candidates.events] [ethlance.ui.page.home.events] @@ -19,6 +19,16 @@ [re-frame.core :as re])) +(re/reg-event-fx + ::accounts-changed + (fn [_cofx [_event-name [new-active-account]]] + {:fx [[:dispatch [::accounts-events/set-active-account new-active-account]]]})) + +(re/reg-event-fx + ::listen-account-changes + (fn [_cofx _event] + {:fx [[:district.ui.web3-accounts.effects/watch-accounts {:on-change [::accounts-changed]}]]})) + (re/reg-event-fx :ethlance/initialize [(re/inject-cofx :store)] @@ -40,4 +50,5 @@ [:page.job-detail/initialize-page] [:page.new-job/initialize-page] [:page.invoices/initialize-page] - [:page.new-invoice/initialize-page]]}))) + [:page.new-invoice/initialize-page]] + :dispatch-later [{:ms 1000 :dispatch [::listen-account-changes]}]}))) diff --git a/ui/src/ethlance/ui/page/job_detail.cljs b/ui/src/ethlance/ui/page/job_detail.cljs index 3fd85b75..0f3f1d5f 100644 --- a/ui/src/ethlance/ui/page/job_detail.cljs +++ b/ui/src/ethlance/ui/page/job_detail.cljs @@ -276,12 +276,13 @@ arbiter-fields]]] search-result @(re/subscribe [::gql/query {:queries [arbiters-query job-query]} {:refetch-on #{:page.job-detail/arbitrations-updated}}]) - + employer-address (get-in search-result [:job :job/employer-address]) all-arbiters (get-in search-result [:arbiter-search :items]) + not-employer (fn [arbiter] (ilike!= employer-address (get-in arbiter [:user :user/id]))) + arbiters-without-current-employer (filter not-employer all-arbiters) already-added (map #(get % :arbiter) (get-in search-result [:job :arbitrations :items])) - uninvited-arbiters (clojure.set/difference (set all-arbiters) (set already-added)) + uninvited-arbiters (clojure.set/difference (set arbiters-without-current-employer) (set already-added)) - employer-address (get-in search-result [:job :job/employer-address]) nothing-added? (empty? @selected-arbiters) arbiter-info-fn (fn [arbiter] (clojure.string/join @@ -327,7 +328,6 @@ invited? (= "invited" (:arbitration/status arbitration-by-current-user)) job-address (get arbitration-by-current-user :job/id) active-user (get-in arbitration-by-current-user [:arbiter :user/id])] - (println ">>> c-set-arbiter-quote token-amount" @token-amount) (if invited? [:div.proposal-form [:div.label "Set quote to be arbiter"] diff --git a/ui/src/ethlance/ui/page/profile.cljs b/ui/src/ethlance/ui/page/profile.cljs index 248eb465..1dff30b7 100644 --- a/ui/src/ethlance/ui/page/profile.cljs +++ b/ui/src/ethlance/ui/page/profile.cljs @@ -179,28 +179,29 @@ invitation-text (re/subscribe [:page.profile/invitation-text]) preselected-job (or @job-for-invitation (first jobs)) job-story-exists? (:job-story-exists? preselected-job)] - [:div.job-listing - [:div.title "Invite to a job"] - [c-select-input - {:selections jobs - :value-fn :job/id - :label-fn #(str (:job/title %) (:comment %)) - :selection preselected-job - :on-select #(re/dispatch [:page.profile/set-job-for-invitation %])}] - [c-textarea-input {:value @invitation-text - :disabled job-story-exists? - :placeholder "Briefly describe to what and why you're inviting the candidate" - :on-change #(re/dispatch [:page.profile/set-invitation-text %])}] - [c-button {:color :primary - :disabled? job-story-exists? - :on-click (fn [] - (when-not job-story-exists? - (re/dispatch [:page.profile/invite-candidate - {:candidate candidate-address - :text @invitation-text - :job preselected-job - :employer active-user}])))} - [c-button-label "Invite"]]])) + (when (seq jobs) + [:div.job-listing + [:div.title "Invite to a job"] + [c-select-input + {:selections jobs + :value-fn :job/id + :label-fn #(str (:job/title %) (:comment %)) + :selection preselected-job + :on-select #(re/dispatch [:page.profile/set-job-for-invitation %])}] + [c-textarea-input {:value @invitation-text + :disabled job-story-exists? + :placeholder "Briefly describe to what and why you're inviting the candidate" + :on-change #(re/dispatch [:page.profile/set-invitation-text %])}] + [c-button {:color :primary + :disabled? job-story-exists? + :on-click (fn [] + (when-not job-story-exists? + (re/dispatch [:page.profile/invite-candidate + {:candidate candidate-address + :text @invitation-text + :job preselected-job + :employer active-user}])))} + [c-button-label "Invite"]]]))) (defn c-rating-box