One modal to rule them all.
This commit is contained in:
@@ -1,6 +1,4 @@
|
||||
(ns auto-ap.views.pages.admin.yodlee
|
||||
(:require-macros [cljs.core.async.macros :refer [go]]
|
||||
)
|
||||
(:require [re-frame.core :as re-frame]
|
||||
[auto-ap.forms :as forms]
|
||||
[reagent.core :as reagent]
|
||||
@@ -14,7 +12,8 @@
|
||||
[auto-ap.views.components.admin.side-bar :refer [admin-side-bar]]
|
||||
[auto-ap.views.components.address :refer [address-field]]
|
||||
[auto-ap.views.utils :refer [login-url dispatch-event dispatch-value-change bind-field horizontal-field str->date date->str with-user]]
|
||||
[auto-ap.views.components.modal :refer [simple-modal modal]]
|
||||
[auto-ap.views.components.modal :as modal]
|
||||
[auto-ap.status :as status]
|
||||
[cljs.reader :as edn]
|
||||
[auto-ap.routes :as routes]
|
||||
[bidi.bidi :as bidi]))
|
||||
@@ -248,18 +247,17 @@
|
||||
(re-frame/reg-event-fx
|
||||
::provider-account-deleted
|
||||
(fn [{:keys [db]} [_ i result]]
|
||||
|
||||
{:db (assoc-in db [::provider-accounts] result)
|
||||
:dispatch [::forms/form-closing [::refresh-provider-account i]]}))
|
||||
:dispatch-n [[::forms/form-closing [::refresh-provider-account i]]
|
||||
[::modal/modal-closed ]]}))
|
||||
|
||||
(re-frame/reg-event-fx
|
||||
::delete-provider-account
|
||||
[with-user ]
|
||||
(fn [{:keys [user db]} [_ provider-account-id ]]
|
||||
{:db (forms/loading db [::delete-provider-account provider-account-id])
|
||||
:dispatch (dispatch-event [::events/modal-status [::delete provider-account-id] {:visible? false}] )
|
||||
:http {:token user
|
||||
{:http {:token user
|
||||
:method :post
|
||||
:owns-state {:single ::delete-provider-account}
|
||||
:headers {"Content-Type" "application/edn"}
|
||||
:uri (str "/api/yodlee/provider-accounts/delete/" provider-account-id )
|
||||
:body {}
|
||||
@@ -267,24 +265,26 @@
|
||||
:on-error [::forms/save-error [::delete-provider-account provider-account-id] ]}}))
|
||||
|
||||
|
||||
|
||||
(re-frame/reg-event-fx
|
||||
::delete-requested
|
||||
[with-user]
|
||||
(fn [{:keys [user db]} [_ account-id]]
|
||||
{:dispatch
|
||||
[::modal/modal-requested {:title "Delete Provider account "
|
||||
:body [:div "Are you sure you want to delete provider account " account-id "?"]
|
||||
:confirm {:value "Delete provider account"
|
||||
:status-from [::status/single ::delete-provider-account]
|
||||
:class "is-danger"
|
||||
:on-click (dispatch-event [::delete-provider-account account-id])
|
||||
:close-event [::status/completed ::delete-provider-account]}
|
||||
:cancel? true}]}))
|
||||
|
||||
|
||||
(defn delete-button [account-id]
|
||||
(let [confirmed? (reagent/atom false)]
|
||||
(fn []
|
||||
(let [delete-form @(re-frame/subscribe [::forms/form [::delete-provider-account account-id]])]
|
||||
[:div
|
||||
(cond
|
||||
(= :loading (:status delete-form)) [:button.button.is-disabled.is-loading [:i.fa.fa-times]]
|
||||
(:error delete-form) [:button.button.is-disabled [:span.icon [:i.fa.fa-exclamation-triangle]]]
|
||||
:else
|
||||
[:button.button
|
||||
{:on-click (dispatch-event [::events/modal-status [::delete account-id] {:visible? true}])}
|
||||
[:span.icon [:i.fa.fa-times]]])
|
||||
[simple-modal {:id [::delete account-id]
|
||||
:title "Confirmation"
|
||||
:foot [:div
|
||||
[:button.button.is-danger {:on-click (dispatch-event [::delete-provider-account account-id] )} "Delete provider account"]
|
||||
[:button.button {:on-click (dispatch-event [::events/modal-status [::delete account-id] {:visible? false}] )}"Cancel"]]}
|
||||
"Are you sure you want to delete provider account " account-id "?"]]))))
|
||||
[:button.button
|
||||
{:on-click (dispatch-event [::delete-requested account-id])}
|
||||
[:span.icon [:i.fa.fa-times]]])
|
||||
|
||||
(defn yodlee-provider-accounts-table []
|
||||
|
||||
|
||||
Reference in New Issue
Block a user