diff --git a/src/cljs/grub/view/app.cljs b/src/cljs/grub/view/app.cljs index 9e7f453..a317e40 100644 --- a/src/cljs/grub/view/app.cljs +++ b/src/cljs/grub/view/app.cljs @@ -4,7 +4,7 @@ [cljs.core.async :as a :refer [events (om/get-shared owner :>events)] diff --git a/src/cljs/grub/view/recipe.cljs b/src/cljs/grub/view/recipe.cljs index 92f3b5f..2be116c 100644 --- a/src/cljs/grub/view/recipe.cljs +++ b/src/cljs/grub/view/recipe.cljs @@ -37,7 +37,7 @@ (om/set-state! owner :editing false) (put! ch (update-event id name grubs)))) -(defn recipe-view [{:keys [id] :as props} owner] +(defn view [{:keys [id] :as props} owner] (reify om/IInitState (init-state [_] @@ -103,92 +103,3 @@ (a/close! subscriber)) (om/set-state! owner :editing false) (recur)))))) - -(defn add-recipe [ch name grubs owner] - (when (and (not (empty? name)) - (not (empty? grubs))) - (om/set-state! owner :new-recipe-name "") - (om/set-state! owner :new-recipe-grubs "") - (om/set-state! owner :editing false) - (put! ch (add-event name grubs)))) - -(defn new-recipe-view [_ owner] - (reify - om/IInitState - (init-state [_] - (let [publisher (chan)] - {:editing false - :>local-events publisher - :local-events new-recipe-name new-recipe-grubs]}] - (let [add (om/get-shared owner :recipe-add)] - (html - [:div.panel.panel-default.recipe-panel - {:on-click #(put! >local-events :click)} - [:div.panel-heading.recipe-header - [:input.form-control.recipe-header-input - {:id "new-recipe-name" - :type "text" - :placeholder "New recipe" - :value new-recipe-name - :on-change #(om/set-state! owner :new-recipe-name (dom/event-val %))}]] - [:div.panel-body.recipe-grubs - {:class (when (not editing) "hidden")} - [:textarea.form-control.recipe-grubs-input - {:id "new-recipe-grubs" - :rows 3 - :placeholder "Recipe ingredients" - :value new-recipe-grubs - :on-change #(om/set-state! owner :new-recipe-grubs (dom/event-val %))}] - [:button.btn.btn-primary.pull-right.recipe-btn.recipe-done-btn - {:type "button" - :on-click #(put! >local-events :done)} - "Done"]]]))) - - om/IWillMount - (will-mount [_] - (let [local-events publisher + :local-events new-recipe-name new-recipe-grubs]}] + (let [add (om/get-shared owner :recipe-add)] + (html + [:div.panel.panel-default.recipe-panel + {:on-click #(put! >local-events :click)} + [:div.panel-heading.recipe-header + [:input.form-control.recipe-header-input + {:id "new-recipe-name" + :type "text" + :placeholder "New recipe" + :value new-recipe-name + :on-change #(om/set-state! owner :new-recipe-name (dom/event-val %))}]] + [:div.panel-body.recipe-grubs + {:class (when (not editing) "hidden")} + [:textarea.form-control.recipe-grubs-input + {:id "new-recipe-grubs" + :rows 3 + :placeholder "Recipe ingredients" + :value new-recipe-grubs + :on-change #(om/set-state! owner :new-recipe-grubs (dom/event-val %))}] + [:button.btn.btn-primary.pull-right.recipe-btn.recipe-done-btn + {:type "button" + :on-click #(put! >local-events :done)} + "Done"]]]))) + + om/IWillMount + (will-mount [_] + (let [