Remove paths on click

This commit is contained in:
Daniel Compton 2017-11-07 14:03:18 +13:00
parent 5f6ff4fe9d
commit b21b83c182
2 changed files with 8 additions and 1 deletions

View File

@ -81,3 +81,10 @@
(fn [db [_ paths]]
(localstorage/save! "app-db-paths" paths)
(assoc-in db [:app-db :paths] paths)))
(rf/reg-event-db
:app-db/remove-path
(fn [db [_ path]]
(let [new-db (update-in db [:app-db :paths] disj path)]
(localstorage/save! "app-db-paths" (get-in new-db [:app-db :paths]))
new-db)))

View File

@ -144,7 +144,7 @@
[:div.subtree
[subtree
(get-in @data path)
[:button.subtree-button {:on-click #(swap! subtree-paths disj path)}
[:button.subtree-button {:on-click #(rf/dispatch [:app-db/remove-path path])}
[:span.subtree-button-string
(str path)]]]]])
@subtree-paths))]