mirror of
https://github.com/status-im/open-bounty.git
synced 2025-02-17 03:47:58 +00:00
Merge pull request #245 from pablodip/sort-and-filter-fixes
Sorting and filtering fixes
This commit is contained in:
commit
ce77b6a9ba
@ -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,
|
||||
|
@ -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)
|
||||
|
@ -83,8 +83,8 @@
|
||||
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
|
||||
"$0 - $1000+"
|
||||
[: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
|
||||
:on-change-val on-min-change-fn})]
|
||||
@ -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])])
|
||||
|
@ -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))))
|
||||
|
@ -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]
|
||||
|
@ -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]
|
||||
(:created-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,11 +59,11 @@
|
||||
(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 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 "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)})
|
||||
|
@ -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 {
|
||||
|
Loading…
x
Reference in New Issue
Block a user