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;
|
margin-left: 20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.set-details {
|
.set-details, .list-details {
|
||||||
padding-bottom: 15px;
|
padding-bottom: 15px;
|
||||||
margin-bottom: 15px;
|
margin-bottom: 15px;
|
||||||
border-bottom: 1px solid #eee;
|
border-bottom: 1px solid #eee;
|
||||||
|
|
|
@ -178,7 +178,7 @@
|
||||||
:value value)))
|
:value value)))
|
||||||
|
|
||||||
(defn search-field
|
(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)
|
(let [field (:field @filter)
|
||||||
field-type (:type @filter)
|
field-type (:type @filter)
|
||||||
invalid? (:invalid? @filter)
|
invalid? (:invalid? @filter)
|
||||||
|
@ -195,6 +195,9 @@
|
||||||
(remove
|
(remove
|
||||||
#(and (contains? existing-search-fields (first %))
|
#(and (contains? existing-search-fields (first %))
|
||||||
(not= (:field @filter) (first %))))
|
(not= (:field @filter) (first %))))
|
||||||
|
(remove
|
||||||
|
(fn [[k _]]
|
||||||
|
(some #{k} exclude-filters)))
|
||||||
(map (fn [[k v]] [k (:label v)]))
|
(map (fn [[k v]] [k (:label v)]))
|
||||||
(sort-by second)
|
(sort-by second)
|
||||||
(map
|
(map
|
||||||
|
@ -293,7 +296,7 @@
|
||||||
(doall)))
|
(doall)))
|
||||||
|
|
||||||
(defn search-filter-selector
|
(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)
|
(let [fixed-filter-fields (mapv :field fixed-active-filters)
|
||||||
selected-search-fields (-> (get-selected-search-fields @search-filters)
|
selected-search-fields (-> (get-selected-search-fields @search-filters)
|
||||||
(into fixed-filter-fields))
|
(into fixed-filter-fields))
|
||||||
|
@ -315,7 +318,8 @@
|
||||||
:bsStyle "danger"
|
:bsStyle "danger"
|
||||||
:on-click #(remove-filter! filter search-filters)}
|
:on-click #(remove-filter! filter search-filters)}
|
||||||
[bs/Glyphicon {:glyph "minus"}] " Remove Filter"]
|
[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)
|
filters)
|
||||||
[bs/Row
|
[bs/Row
|
||||||
[bs/Col {:sm 2}
|
[bs/Col {:sm 2}
|
||||||
|
@ -323,7 +327,7 @@
|
||||||
{:block true
|
{:block true
|
||||||
:on-click #(add-filter! search-filters)}
|
:on-click #(add-filter! search-filters)}
|
||||||
[bs/Glyphicon {:glyph "plus"}] " Add Filter"]]
|
[bs/Glyphicon {:glyph "plus"}] " Add Filter"]]
|
||||||
[bs/Col {:sm 6}
|
[bs/Col {:sm 10}
|
||||||
[bs/Button
|
[bs/Button
|
||||||
{:bsStyle "primary"
|
{:bsStyle "primary"
|
||||||
:on-click #(apply-search-filters! search-filters fixed-active-filters)}
|
:on-click #(apply-search-filters! search-filters fixed-active-filters)}
|
||||||
|
@ -332,4 +336,6 @@
|
||||||
[bs/Button
|
[bs/Button
|
||||||
{:bsStyle "warning"
|
{:bsStyle "warning"
|
||||||
:on-click #(reset-search-filters! search-filters fixed-active-filters)}
|
:on-click #(reset-search-filters! search-filters fixed-active-filters)}
|
||||||
"Reset"]]]]))
|
"Reset"]
|
||||||
|
" "
|
||||||
|
extra]]]))
|
|
@ -6,9 +6,12 @@
|
||||||
[webtools.reagent.bootstrap :as bs]
|
[webtools.reagent.bootstrap :as bs]
|
||||||
[webtools.cljs.ajax :as ajax]
|
[webtools.cljs.ajax :as ajax]
|
||||||
[webtools.cljs.utils :refer [->url redirect!]]
|
[webtools.cljs.utils :refer [->url redirect!]]
|
||||||
|
[mtgcoll.common :as c]
|
||||||
[mtgcoll.client.auth :as auth]
|
[mtgcoll.client.auth :as auth]
|
||||||
[mtgcoll.client.page :refer [set-active-breadcrumb! set-error!]]
|
[mtgcoll.client.page :refer [set-active-breadcrumb! set-error!]]
|
||||||
[mtgcoll.client.utils :refer [get-field-value]]
|
[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]]))
|
[mtgcoll.client.components.utils :refer [click-to-edit-textarea markdown confirm-modal]]))
|
||||||
|
|
||||||
(defn create-list-form
|
(defn create-list-form
|
||||||
|
@ -122,6 +125,41 @@
|
||||||
:on-error #(set-error! "Server error while deleting the list.")
|
:on-error #(set-error! "Server error while deleting the list.")
|
||||||
:on-success #(redirect! "#/lists")))
|
: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
|
(defvc list-details
|
||||||
[list-id]
|
[list-id]
|
||||||
(let [show-delete-confirm? (r/atom false)]
|
(let [show-delete-confirm? (r/atom false)]
|
||||||
|
@ -147,16 +185,18 @@
|
||||||
[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 #(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/MenuItem {:on-click #(reset! show-delete-confirm? true)} "Delete"]]])
|
||||||
[bs/PageHeader (:name @list)]
|
[bs/PageHeader (:name @list)]
|
||||||
(if (auth/can-modify-data?)
|
|
||||||
[click-to-edit-textarea
|
|
||||||
(:notes @list)
|
|
||||||
{:placeholder "List Notes"
|
|
||||||
:rows 10
|
|
||||||
:on-update #(on-update-list-notes! list-id %)
|
|
||||||
:render markdown}]
|
|
||||||
[markdown (:notes @list)])
|
|
||||||
[confirm-modal
|
[confirm-modal
|
||||||
show-delete-confirm?
|
show-delete-confirm?
|
||||||
{:title "Confirm Delete"
|
{:title "Confirm Delete"
|
||||||
:body [:p "Are you sure you want to delete the " [:strong (:name @list)] " list? This cannot be undone."]
|
:body [:p "Are you sure you want to delete the " [:strong (:name @list)] " list? This cannot be undone."]
|
||||||
:on-yes #(delete-list! list-id)}]])))))
|
:on-yes #(delete-list! list-id)}]
|
||||||
|
[:div.list-details
|
||||||
|
(if (auth/can-modify-data?)
|
||||||
|
[click-to-edit-textarea
|
||||||
|
(:notes @list)
|
||||||
|
{:placeholder "List Notes"
|
||||||
|
:rows 10
|
||||||
|
:on-update #(on-update-list-notes! list-id %)
|
||||||
|
:render markdown}]
|
||||||
|
[markdown (:notes @list)])]
|
||||||
|
[list-cards-list list-id]])))))
|
|
@ -65,7 +65,7 @@
|
||||||
pager (r/cursor set-cards-search-filters [:pager])
|
pager (r/cursor set-cards-search-filters [:pager])
|
||||||
list-id c/owned-list-id]
|
list-id c/owned-list-id]
|
||||||
(s/apply-search-filters! set-cards-search-filters fixed-filters)
|
(s/apply-search-filters! set-cards-search-filters fixed-filters)
|
||||||
(fn []
|
(fn [set-code]
|
||||||
[:div.set-cards-list
|
[:div.set-cards-list
|
||||||
[s/search-filter-selector set-cards-search-filters {:fixed-active-filters fixed-filters}]
|
[s/search-filter-selector set-cards-search-filters {:fixed-active-filters fixed-filters}]
|
||||||
[card-list-table list-id @active-search-filters pager]])))
|
[card-list-table list-id @active-search-filters pager]])))
|
||||||
|
|
Loading…
Reference in a new issue