From a3e42fe61f81f1722de092a80f109af57e6426bf Mon Sep 17 00:00:00 2001 From: pablodip Date: Thu, 1 Feb 2018 15:56:15 +0100 Subject: [PATCH 1/5] some filtering and sorting fixes --- src/cljs/commiteth/bounties.cljs | 2 +- src/cljs/commiteth/handlers.cljs | 4 ++-- src/cljs/commiteth/subscriptions.cljs | 9 ++++++++- src/cljs/commiteth/ui_model.cljs | 7 ++++--- 4 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/cljs/commiteth/bounties.cljs b/src/cljs/commiteth/bounties.cljs index 55e2c29..5d7600c 100644 --- a/src/cljs/commiteth/bounties.cljs +++ b/src/cljs/commiteth/bounties.cljs @@ -84,7 +84,7 @@ (let [new-min (min current-min (max default-min new-max))] (on-change-fn new-min new-max)))] [:div - "$0 - $1000+" + (::ui-model/bounty-filter.type.header filter-type-def) [bounties-filter-tooltip-value-input-view "Min" tooltip-open? (merge common-range-opts {:current-val current-min :on-change-val on-min-change-fn})] diff --git a/src/cljs/commiteth/handlers.cljs b/src/cljs/commiteth/handlers.cljs index da58177..eb61374 100644 --- a/src/cljs/commiteth/handlers.cljs +++ b/src/cljs/commiteth/handlers.cljs @@ -465,11 +465,11 @@ ::set-open-bounties-sorting-type (fn [db [_ sorting-type]] (merge db {::db/open-bounties-sorting-type sorting-type - :bounty-page-number 1}))) + :page-number 1}))) (reg-event-db ::set-open-bounty-filter-type (fn [db [_ filter-type filter-value]] (-> db (assoc-in [::db/open-bounties-filters filter-type] filter-value) - (assoc :bounty-page-number 1)))) + (assoc :page-number 1)))) diff --git a/src/cljs/commiteth/subscriptions.cljs b/src/cljs/commiteth/subscriptions.cljs index 5598142..bb2a82a 100644 --- a/src/cljs/commiteth/subscriptions.cljs +++ b/src/cljs/commiteth/subscriptions.cljs @@ -2,7 +2,8 @@ (:require [re-frame.core :refer [reg-sub]] [commiteth.db :as db] [commiteth.ui-model :as ui-model] - [commiteth.common :refer [items-per-page]])) + [commiteth.common :refer [items-per-page]] + [clojure.string :as string])) (reg-sub :db @@ -139,6 +140,12 @@ (map :repo-owner) set))) +(reg-sub + ::open-bounties-owners-sorted + :<- [::open-bounties-owners] + (fn [owners _] + (sort-by string/lower-case owners))) + (reg-sub ::open-bounties-currencies :<- [:open-bounties] diff --git a/src/cljs/commiteth/ui_model.cljs b/src/cljs/commiteth/ui_model.cljs index db3234d..2b4a3f3 100644 --- a/src/cljs/commiteth/ui_model.cljs +++ b/src/cljs/commiteth/ui_model.cljs @@ -63,7 +63,7 @@ (let [created-at-date (-> created-at-inst inst-ms t-coerce/from-long)] (t/within? filter-value-interval created-at-date))))) -(def bounty-filter-type-claims-options-def {::bounty-filter-type-claims-option|no-claims "With no claims"}) +(def bounty-filter-type-claims-options-def {::bounty-filter-type-claims-option|no-claims "Not claimed yet"}) (def bounty-filter-type-claims-options (keys bounty-filter-type-claims-options-def)) @@ -75,7 +75,8 @@ {::bounty-filter-type.name "Value" ::bounty-filter-type.category ::bounty-filter-type-category|range ::bounty-filter-type.min-val 0 - ::bounty-filter-type.max-val 1000 + ::bounty-filter-type.max-val 10000 + ::bounty-filter.type.header "$0 - $10000+" ::bounty-filter-type.predicate (fn [filter-value bounty] (let [min-val (first filter-value) max-val (second filter-value)] @@ -101,7 +102,7 @@ ::bounty-filter-type|owner {::bounty-filter-type.name "Owner" ::bounty-filter-type.category ::bounty-filter-type-category|multiple-dynamic-options - ::bounty-filter-type.re-frame-subs-key-for-options :commiteth.subscriptions/open-bounties-owners + ::bounty-filter-type.re-frame-subs-key-for-options :commiteth.subscriptions/open-bounties-owners-sorted ::bounty-filter-type.predicate (fn [filter-value bounty] (->> filter-value (some #{(:repo-owner bounty)}) From e3a9d07add7ce132a0cc05781a12e17f28f3d60f Mon Sep 17 00:00:00 2001 From: pablodip Date: Fri, 2 Feb 2018 23:39:49 +0100 Subject: [PATCH 2/5] fix filter single-static-option when clicking with touchpad in mac --- src/cljs/commiteth/bounties.cljs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/cljs/commiteth/bounties.cljs b/src/cljs/commiteth/bounties.cljs index 5d7600c..af1b2c7 100644 --- a/src/cljs/commiteth/bounties.cljs +++ b/src/cljs/commiteth/bounties.cljs @@ -98,10 +98,12 @@ (for [[option-type option-text] (::ui-model/bounty-filter-type.options filter-type-def)] ^{:key (str option-type)} [:div.open-bounties-filter-list-option - (merge {:on-click #(do (rf/dispatch [::handlers/set-open-bounty-filter-type - filter-type - option-type]) - (reset! tooltip-open? false))} + (merge {:on-click #(do (rf/dispatch [::handlers/set-open-bounty-filter-type + filter-type + option-type]) + (reset! tooltip-open? false)) + :tab-index 0 + :on-focus #(reset! tooltip-open? true)} (when (= option-type current-filter-value) {:class "active"})) option-text])]) From 1b9151e1e1a38b08dc70d40a3483a7847fa84497 Mon Sep 17 00:00:00 2001 From: pablodip Date: Fri, 2 Feb 2018 23:46:09 +0100 Subject: [PATCH 3/5] use updated-at in filtering and sorting --- resources/sql/queries.sql | 1 - src/clj/commiteth/routes/services.clj | 3 +-- src/cljs/commiteth/ui_model.cljs | 8 ++++---- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/resources/sql/queries.sql b/resources/sql/queries.sql index 1fa529c..e8a3115 100644 --- a/resources/sql/queries.sql +++ b/resources/sql/queries.sql @@ -422,7 +422,6 @@ SELECT i.payout_hash AS payout_hash, i.payout_receipt AS payout_receipt, i.updated AS updated, - i.created_at AS created_at, r.owner AS repo_owner, r.owner_avatar_url AS repo_owner_avatar_url, r.repo AS repo_name, diff --git a/src/clj/commiteth/routes/services.clj b/src/clj/commiteth/routes/services.clj index 6a60fec..82c5633 100644 --- a/src/clj/commiteth/routes/services.clj +++ b/src/clj/commiteth/routes/services.clj @@ -155,8 +155,7 @@ :value_usd :value-usd :claim_count :claim-count :balance_eth :balance-eth - :user_has_address :user-has-address - :created_at :created-at}] + :user_has_address :user-has-address}] (map #(-> % (rename-keys renames) (update :value-usd usd-decimal->str) diff --git a/src/cljs/commiteth/ui_model.cljs b/src/cljs/commiteth/ui_model.cljs index 2b4a3f3..46824a1 100644 --- a/src/cljs/commiteth/ui_model.cljs +++ b/src/cljs/commiteth/ui_model.cljs @@ -9,7 +9,7 @@ (def bounty-sorting-types-def {::bounty-sorting-type|most-recent {::bounty-sorting-type.name "Most recent" ::bounty-sorting-type.sort-key-fn (fn [bounty] - (:created-at bounty)) + (:updated-at bounty)) ::bounty-sorting-type.sort-comparator-fn compare} ::bounty-sorting-type|lowest-value {::bounty-sorting-type.name "Lowest value" ::bounty-sorting-type.sort-key-fn (fn [bounty] @@ -59,9 +59,9 @@ (t/interval filter-from (t/now))))) (def bounty-filter-type-date-predicate (fn [filter-value-interval bounty] - (when-let [created-at-inst (:created-at bounty)] - (let [created-at-date (-> created-at-inst inst-ms t-coerce/from-long)] - (t/within? filter-value-interval created-at-date))))) + (when-let [date-inst (:updated-at bounty)] + (let [date (-> date-inst inst-ms t-coerce/from-long)] + (t/within? filter-value-interval date))))) (def bounty-filter-type-claims-options-def {::bounty-filter-type-claims-option|no-claims "Not claimed yet"}) From bc72fd165d0b98dcb8a7a0c9eca4ab58a1d058fb Mon Sep 17 00:00:00 2001 From: pablodip Date: Sat, 3 Feb 2018 00:07:23 +0100 Subject: [PATCH 4/5] limit height of filter tooltips and add scroll to them if exceeded --- src/cljs/commiteth/bounties.cljs | 2 +- src/less/style.less | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/cljs/commiteth/bounties.cljs b/src/cljs/commiteth/bounties.cljs index af1b2c7..34137bb 100644 --- a/src/cljs/commiteth/bounties.cljs +++ b/src/cljs/commiteth/bounties.cljs @@ -83,7 +83,7 @@ on-max-change-fn (fn [new-max] (let [new-min (min current-min (max default-min new-max))] (on-change-fn new-min new-max)))] - [:div + [:div.open-bounties-filter-list (::ui-model/bounty-filter.type.header filter-type-def) [bounties-filter-tooltip-value-input-view "Min" tooltip-open? (merge common-range-opts {:current-val current-min diff --git a/src/less/style.less b/src/less/style.less index 0827245..6fb2407 100644 --- a/src/less/style.less +++ b/src/less/style.less @@ -475,7 +475,6 @@ position: absolute; min-width: 227px; margin-top: 12px; - padding: 24px 16px; border-radius: 10px; background-color: #ffffff; box-shadow: 0 15px 12px 0 rgba(161, 174, 182, 0.53), 0 0 38px 0 rgba(0, 0, 0, 0.05); @@ -483,6 +482,8 @@ font-size: 16px; line-height: 1.5; z-index: 999; + max-height: 300px; + overflow: scroll; .open-bounties-filter-element-tooltip-value-input-container { display: flex; @@ -591,6 +592,7 @@ display: flex; flex-direction: column; align-items: flex-start; + margin: 24px 16px; } .open-bounties-filter-list-option { From 0df0ef6ef2de35393b6801d6f5a6681e422dff31 Mon Sep 17 00:00:00 2001 From: pablodip Date: Mon, 5 Feb 2018 16:26:48 +0100 Subject: [PATCH 5/5] change :update-at by :update and sort direction fixing --- src/cljs/commiteth/ui_model.cljs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cljs/commiteth/ui_model.cljs b/src/cljs/commiteth/ui_model.cljs index 46824a1..fd7d41c 100644 --- a/src/cljs/commiteth/ui_model.cljs +++ b/src/cljs/commiteth/ui_model.cljs @@ -9,8 +9,8 @@ (def bounty-sorting-types-def {::bounty-sorting-type|most-recent {::bounty-sorting-type.name "Most recent" ::bounty-sorting-type.sort-key-fn (fn [bounty] - (:updated-at bounty)) - ::bounty-sorting-type.sort-comparator-fn compare} + (:updated bounty)) + ::bounty-sorting-type.sort-comparator-fn (comp - compare)} ::bounty-sorting-type|lowest-value {::bounty-sorting-type.name "Lowest value" ::bounty-sorting-type.sort-key-fn (fn [bounty] (js/parseFloat (:value-usd bounty))) @@ -59,7 +59,7 @@ (t/interval filter-from (t/now))))) (def bounty-filter-type-date-predicate (fn [filter-value-interval bounty] - (when-let [date-inst (:updated-at bounty)] + (when-let [date-inst (:updated bounty)] (let [date (-> date-inst inst-ms t-coerce/from-long)] (t/within? filter-value-interval date)))))