add cards listing to list details page
the filter to turn on/off the option to restrict shown cards to those that are in the list being viewed is implemented in kind of a hacky way that likely is a good indication that the search/filtering code probably needs to be redesigned... ugh.
This commit is contained in:
parent
a669221ad7
commit
3dbc417885
|
@ -145,7 +145,7 @@ div.card-title > h1 > small {
|
|||
margin-left: 20px;
|
||||
}
|
||||
|
||||
.set-details {
|
||||
.set-details, .list-details {
|
||||
padding-bottom: 15px;
|
||||
margin-bottom: 15px;
|
||||
border-bottom: 1px solid #eee;
|
||||
|
|
|
@ -178,7 +178,7 @@
|
|||
:value value)))
|
||||
|
||||
(defn search-field
|
||||
[filter existing-search-fields remove-button on-enter]
|
||||
[filter existing-search-fields remove-button on-enter exclude-filters]
|
||||
(let [field (:field @filter)
|
||||
field-type (:type @filter)
|
||||
invalid? (:invalid? @filter)
|
||||
|
@ -195,6 +195,9 @@
|
|||
(remove
|
||||
#(and (contains? existing-search-fields (first %))
|
||||
(not= (:field @filter) (first %))))
|
||||
(remove
|
||||
(fn [[k _]]
|
||||
(some #{k} exclude-filters)))
|
||||
(map (fn [[k v]] [k (:label v)]))
|
||||
(sort-by second)
|
||||
(map
|
||||
|
@ -293,7 +296,7 @@
|
|||
(doall)))
|
||||
|
||||
(defn search-filter-selector
|
||||
[search-filters & [{:keys [fixed-active-filters no-filters-message?] :as options}]]
|
||||
[search-filters & [{:keys [fixed-active-filters exclude-filters no-filters-message? extra] :as options}]]
|
||||
(let [fixed-filter-fields (mapv :field fixed-active-filters)
|
||||
selected-search-fields (-> (get-selected-search-fields @search-filters)
|
||||
(into fixed-filter-fields))
|
||||
|
@ -315,7 +318,8 @@
|
|||
:bsStyle "danger"
|
||||
:on-click #(remove-filter! filter search-filters)}
|
||||
[bs/Glyphicon {:glyph "minus"}] " Remove Filter"]
|
||||
#(apply-search-filters! search-filters fixed-active-filters)])
|
||||
#(apply-search-filters! search-filters fixed-active-filters)
|
||||
exclude-filters])
|
||||
filters)
|
||||
[bs/Row
|
||||
[bs/Col {:sm 2}
|
||||
|
@ -323,7 +327,7 @@
|
|||
{:block true
|
||||
:on-click #(add-filter! search-filters)}
|
||||
[bs/Glyphicon {:glyph "plus"}] " Add Filter"]]
|
||||
[bs/Col {:sm 6}
|
||||
[bs/Col {:sm 10}
|
||||
[bs/Button
|
||||
{:bsStyle "primary"
|
||||
:on-click #(apply-search-filters! search-filters fixed-active-filters)}
|
||||
|
@ -332,4 +336,6 @@
|
|||
[bs/Button
|
||||
{:bsStyle "warning"
|
||||
:on-click #(reset-search-filters! search-filters fixed-active-filters)}
|
||||
"Reset"]]]]))
|
||||
"Reset"]
|
||||
" "
|
||||
extra]]]))
|
|
@ -6,9 +6,12 @@
|
|||
[webtools.reagent.bootstrap :as bs]
|
||||
[webtools.cljs.ajax :as ajax]
|
||||
[webtools.cljs.utils :refer [->url redirect!]]
|
||||
[mtgcoll.common :as c]
|
||||
[mtgcoll.client.auth :as auth]
|
||||
[mtgcoll.client.page :refer [set-active-breadcrumb! set-error!]]
|
||||
[mtgcoll.client.utils :refer [get-field-value]]
|
||||
[mtgcoll.client.components.cards :refer [card-list-table ->card-list-pager]]
|
||||
[mtgcoll.client.components.search :as s]
|
||||
[mtgcoll.client.components.utils :refer [click-to-edit-textarea markdown confirm-modal]]))
|
||||
|
||||
(defn create-list-form
|
||||
|
@ -122,6 +125,41 @@
|
|||
:on-error #(set-error! "Server error while deleting the list.")
|
||||
:on-success #(redirect! "#/lists")))
|
||||
|
||||
(defonce list-cards-search-filters
|
||||
(r/atom (s/->search-filters)))
|
||||
|
||||
(defn list-cards-list
|
||||
[list-id]
|
||||
(let [limit-to-list? (r/atom true)
|
||||
fixed-filters [{:field :owned? :value true :comparison :=}]
|
||||
active-search-filters (r/cursor list-cards-search-filters [:active-filters])
|
||||
pager (r/cursor list-cards-search-filters [:pager])]
|
||||
(s/apply-search-filters! list-cards-search-filters fixed-filters)
|
||||
(fn [list-id]
|
||||
(let [fixed-filters (if @limit-to-list? [{:field :owned? :value true :comparison :=}] [])]
|
||||
[:div.list-cards-list
|
||||
[s/search-filter-selector list-cards-search-filters
|
||||
{:fixed-active-filters fixed-filters
|
||||
:exclude-filters [:owned? :owned-foil?]
|
||||
:extra [:span {:style {:margin-left "40px"}}
|
||||
[bs/Checkbox
|
||||
(merge
|
||||
(if @limit-to-list? {:checked true})
|
||||
{:inline true
|
||||
:value true
|
||||
:on-change (fn [e]
|
||||
(let [value (boolean (get-field-value e))]
|
||||
(reset! limit-to-list? value)
|
||||
(swap! active-search-filters
|
||||
(fn [active-filters]
|
||||
(->> active-filters
|
||||
(remove #(= :owned? (:field %)))
|
||||
(into (if value
|
||||
[{:field :owned? :value true :comparison :=}]
|
||||
[])))))))})
|
||||
"Limit To List Cards Only?"]]}]
|
||||
[card-list-table list-id @active-search-filters pager #_{:no-owned-highlight? @limit-to-list?}]]))))
|
||||
|
||||
(defvc list-details
|
||||
[list-id]
|
||||
(let [show-delete-confirm? (r/atom false)]
|
||||
|
@ -147,6 +185,12 @@
|
|||
[bs/MenuItem {:on-click #(change-list-visibility! list-id (not (:is_public @list)))} (if (:is_public @list) "Make Private" "Make Public")]
|
||||
[bs/MenuItem {:on-click #(reset! show-delete-confirm? true)} "Delete"]]])
|
||||
[bs/PageHeader (:name @list)]
|
||||
[confirm-modal
|
||||
show-delete-confirm?
|
||||
{:title "Confirm Delete"
|
||||
:body [:p "Are you sure you want to delete the " [:strong (:name @list)] " list? This cannot be undone."]
|
||||
:on-yes #(delete-list! list-id)}]
|
||||
[:div.list-details
|
||||
(if (auth/can-modify-data?)
|
||||
[click-to-edit-textarea
|
||||
(:notes @list)
|
||||
|
@ -154,9 +198,5 @@
|
|||
:rows 10
|
||||
:on-update #(on-update-list-notes! list-id %)
|
||||
:render markdown}]
|
||||
[markdown (:notes @list)])
|
||||
[confirm-modal
|
||||
show-delete-confirm?
|
||||
{:title "Confirm Delete"
|
||||
:body [:p "Are you sure you want to delete the " [:strong (:name @list)] " list? This cannot be undone."]
|
||||
:on-yes #(delete-list! list-id)}]])))))
|
||||
[markdown (:notes @list)])]
|
||||
[list-cards-list list-id]])))))
|
|
@ -65,7 +65,7 @@
|
|||
pager (r/cursor set-cards-search-filters [:pager])
|
||||
list-id c/owned-list-id]
|
||||
(s/apply-search-filters! set-cards-search-filters fixed-filters)
|
||||
(fn []
|
||||
(fn [set-code]
|
||||
[:div.set-cards-list
|
||||
[s/search-filter-selector set-cards-search-filters {:fixed-active-filters fixed-filters}]
|
||||
[card-list-table list-id @active-search-filters pager]])))
|
||||
|
|
Loading…
Reference in a new issue