Skip to content

Commit

Permalink
Merge pull request #493 from datdamnzotz/#151-Delete-All-Content-Button
Browse files Browse the repository at this point in the history
#151 delete all content button
  • Loading branch information
datdamnzotz authored Dec 29, 2020
2 parents d7aecc8 + 4dae511 commit fc73c5f
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/cljs/orcpub/dnd/e5/events.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -3816,6 +3816,23 @@
(fn [db [_ id]]
(assoc-in db [::char5e/delete-confirmation-shown? id] false)))

(reg-event-db
::char5e/show-delete-plugin-confirmation
(fn [db _]
(assoc-in db [::char5e/delete-plugin-confirmation-shown?] true)))

(reg-event-db
::char5e/hide-delete-plugin-confirmation
(fn [db _]
(assoc-in db [::char5e/delete-plugin-confirmation-shown?] false)))

;to-do probably should reach into plugins and delete one at the time instead of brute forcing it.
(reg-event-db
::char5e/delete-all-plugins
(fn [db _]
(js/localStorage.removeItem "plugins")
(js/location.reload)))

(reg-event-fx
::char5e/don-armor
(fn [{:keys [db]} [_ id armor-kw]]
Expand Down
5 changes: 5 additions & 0 deletions src/cljs/orcpub/dnd/e5/subs.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -1221,6 +1221,11 @@
(fn [db [_ id]]
(get-in db [::char5e/delete-confirmation-shown? id])))

(reg-sub
::char5e/delete-plugin-confirmation-shown?
(fn [db _]
(get-in db [::char5e/delete-plugin-confirmation-shown?])))

(reg-sub
::char5e/newb-char-data
(fn [db _]
Expand Down
15 changes: 15 additions & 0 deletions src/cljs/orcpub/dnd/e5/views.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -7338,9 +7338,24 @@
(defn my-content []
[:div.main-text-color
[:div.flex.justify-cont-end
[:button.form-button.m-r-10.m-b-10
{:on-click (make-event-handler ::char/show-delete-plugin-confirmation)}
"Delete All"]
[:button.form-button.m-r-10.m-b-10
{:on-click (make-event-handler ::e5/export-all-plugins)}
"Export All"]]
[:div.flex.justify-cont-end
(if @(subscribe [::char/delete-plugin-confirmation-shown?])
[:div.p-20.flex.justify-cont-end
[:div
[:div.m-b-10 "Are you sure you want to delete ALL Option sources?"]
[:div.flex
[:button.form-button
{:on-click (make-event-handler ::char/hide-delete-plugin-confirmation)}
"cancel"]
[:span.link-button
{:on-click (make-event-handler ::char/delete-all-plugins)}
"delete"]]]])]
[:div.item-list
(let [plugins (sort @(subscribe [::e5/plugins]))]
(doall
Expand Down

0 comments on commit fc73c5f

Please sign in to comment.