Advertisement
dredder

menu-view

May 17th, 2018
2,718
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (defn search-dish
  2.   []
  3.   (let [search-query (re-frame/subscribe [::subs/search-query])]
  4.     (fn []
  5.       [:div.search-dish-form
  6.        [:input.search-dish {:type "text"
  7.                             ;:auto-focus true
  8.                             :value @search-query
  9.                             :on-change #(re-frame/dispatch [::events/set-search-query (-> % .-target .-value)])}]
  10.        [:button.clear-search
  11.         {:on-click #(re-frame/dispatch [::events/set-search-query ""])}
  12.         [re-com/md-icon-button :md-icon-name "zmdi-close"]]])))
  13.  
  14. (defn menu-view
  15.   []
  16.   (let [filtered-dishes (re-frame/subscribe [::subs/filtered-dishes])]
  17.     (fn []
  18.       [:div.menu-wrapper
  19.        [search-dish]
  20.        [:div.menu-list
  21.         (for [dish @filtered-dishes]
  22.           ^{:key (:id dish)} [:div.menu-dish-buttons-wrapper
  23.                               [:button {:on-click #(re-frame/dispatch [::events/add-new-dish dish true])
  24.                                         :class "list-group-item product-button list-button"}
  25.                                (:short_name dish)]
  26.                               [:button.edit-menu-dish
  27.                                {:on-click #(re-frame/dispatch [::events/add-new-dish dish false])}
  28.                                [re-com/md-icon-button :md-icon-name "zmdi-edit"]]])]])))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement