Skip to content

Commit

Permalink
Add pagination to results, disable buttons appropriately
Browse files Browse the repository at this point in the history
  • Loading branch information
joshkh committed Oct 26, 2016
1 parent bf3f9ce commit faf8ae1
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 10 deletions.
1 change: 0 additions & 1 deletion src/cljs/redgenes/sections/regions/events.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@
(search/build-feature-query to-search)
(map name (keys (filter (fn [[name enabled?]] enabled?) feature-types))))
(add-organism-constraint selected-organism))]
(println "ORGANISM" selected-organism)
{:db (assoc-in db [:regions :regions-searched] (map parse-region to-search))
:im-operation {:op (partial search/raw-query-rows
{:root @(subscribe [:mine-url])}
Expand Down
33 changes: 24 additions & 9 deletions src/cljs/redgenes/sections/regions/views.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -62,22 +62,33 @@
(fn []
[:div
[:textarea.form-control
{:rows 8
{:rows 8
:placeholder (str "example:\n" example-regions)
:value @to-search
:on-change (fn [e]
(dispatch [:regions/set-to-search (oget e "target" "value")]))}]])))
:value @to-search
:on-change (fn [e]
(dispatch [:regions/set-to-search (oget e "target" "value")]))}]])))

; Results table
(defn result-table []
(let [model (subscribe [:model])]
(let [pager (reagent/atom {:show 20
:page 0})
model (subscribe [:model])]
(fn [{:keys [chromosome from to results] :as feature}]
[:div.grid-2_xs-1
{:style {:font-size "0.8em"}}
[:div.col-3
[:h4 (str chromosome " " from ".." to)]
[graphs/main feature]]
[:div.col-9
[:div.row
[:div.btn-toolbar.pull-right
[:button.btn.btn-primary
{:disabled (< (:page @pager) 1)
:on-click (fn [] (swap! pager update :page dec))}
"Previous"]
[:button.btn.btn-primary
{:disabled (< (count results) (* (:show @pager) (inc (:page @pager))))
:on-click (fn [] (swap! pager update :page inc))} "Next"]]]
[:div.grid-3_xs-3
[:div.col [:h4 "Feature"]]
[:div.col [:h4 "Feature Type"]]
Expand All @@ -91,11 +102,12 @@
":"
(:start chromosomeLocation)
".."
(:end chromosomeLocation))]]) results)]])))
(:end chromosomeLocation))]])
(take (:show @pager) (drop (* (:show @pager) (:page @pager)) results)))]])))

(defn main []
(let [results (subscribe [:regions/results])
settings (subscribe [:regions/settings])
(let [results (subscribe [:regions/results])
settings (subscribe [:regions/settings])
to-search (subscribe [:regions/to-search])]
(fn []
[:div.container
Expand Down Expand Up @@ -150,7 +162,10 @@
{:on-click (fn [] (dispatch [:regions/deselect-all-feature-types]))}
[:span [:i.fa.fa-square-o] " Deselect All"]]
[:button.btn.btn-primary.btn-raised.pull-right
{:class (if (or (= "" @to-search) (= nil @to-search) ) "disabled")
{:disabled (or
(= "" @to-search)
(= nil @to-search)
(empty? (filter (fn [[name enabled?]] enabled?) (:feature-types @settings))))
:on-click (fn [] (dispatch [:regions/run-query]))}
[:span "Search"]]]]]]]]]]]
[:div.row
Expand Down

0 comments on commit faf8ae1

Please sign in to comment.