simplified form works, too.
This commit is contained in:
@@ -106,6 +106,8 @@
|
|||||||
(defn ^:deprecated side-bar-form [{:keys [form]} children]
|
(defn ^:deprecated side-bar-form [{:keys [form]} children]
|
||||||
[:div [:a.delete.is-pulled-right {:on-click (dispatch-event [::form-closing form])}] [:div children]])
|
[:div [:a.delete.is-pulled-right {:on-click (dispatch-event [::form-closing form])}] [:div children]])
|
||||||
|
|
||||||
|
|
||||||
|
;; TODO ^:deprecated
|
||||||
(defn loading [db id]
|
(defn loading [db id]
|
||||||
(-> db
|
(-> db
|
||||||
(assoc-in [::forms id :status] :loading)
|
(assoc-in [::forms id :status] :loading)
|
||||||
|
|||||||
@@ -121,8 +121,8 @@
|
|||||||
|
|
||||||
[:div.buttons
|
[:div.buttons
|
||||||
(when confirm
|
(when confirm
|
||||||
[:button.button.is-danger {:class (status/class-for status)
|
[:button.button {:class (conj (status/class-for status) (:class confirm) )
|
||||||
:on-click (:on-click confirm)}
|
:on-click (:on-click confirm)}
|
||||||
(:value confirm)])
|
(:value confirm)])
|
||||||
(when cancel?
|
(when cancel?
|
||||||
[:button.button {:on-click (dispatch-event [::modal-closed] )} "Cancel"])]]]))]])))))
|
[:button.button {:on-click (dispatch-event [::modal-closed] )} "Cancel"])]]]))]])))))
|
||||||
|
|||||||
@@ -93,6 +93,7 @@
|
|||||||
:body [:div "Are you sure you want to delete transaction rule '" (:description which) "'? Any previously transactions will remain updated, but the rule association will be lost."]
|
:body [:div "Are you sure you want to delete transaction rule '" (:description which) "'? Any previously transactions will remain updated, but the rule association will be lost."]
|
||||||
:cancel? true
|
:cancel? true
|
||||||
:confirm {:value "Delete Transaction Rule"
|
:confirm {:value "Delete Transaction Rule"
|
||||||
|
:class "is-danger"
|
||||||
:status-from [::status/single ::delete-transaction-rule]
|
:status-from [::status/single ::delete-transaction-rule]
|
||||||
:on-click (dispatch-event [::delete-transaction-rule (:id which)] )}
|
:on-click (dispatch-event [::delete-transaction-rule (:id which)] )}
|
||||||
:close-event [::status/completed ::delete-transaction-rule]}]}))
|
:close-event [::status/completed ::delete-transaction-rule]}]}))
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
[auto-ap.views.components.admin.side-bar :refer [admin-side-bar]]
|
[auto-ap.views.components.admin.side-bar :refer [admin-side-bar]]
|
||||||
[auto-ap.views.components.layouts :refer [side-bar-layout]]
|
[auto-ap.views.components.layouts :refer [side-bar-layout]]
|
||||||
[auto-ap.views.utils :refer [login-url dispatch-value-change bind-field horizontal-field dispatch-event with-user]]
|
[auto-ap.views.utils :refer [login-url dispatch-value-change bind-field horizontal-field dispatch-event with-user]]
|
||||||
[auto-ap.views.components.modal :refer [modal action-modal]]
|
[auto-ap.views.components.modal :refer [modal action-modal] :as modal]
|
||||||
[auto-ap.views.components.grid :as grid]
|
[auto-ap.views.components.grid :as grid]
|
||||||
[auto-ap.utils :refer [by replace-if]]
|
[auto-ap.utils :refer [by replace-if]]
|
||||||
[cljs.reader :as edn]
|
[cljs.reader :as edn]
|
||||||
@@ -29,12 +29,7 @@
|
|||||||
(fn [data field value]
|
(fn [data field value]
|
||||||
[])))
|
[])))
|
||||||
|
|
||||||
(re-frame/reg-event-db
|
|
||||||
::editing
|
|
||||||
(fn [db [_ d]]
|
|
||||||
(re-frame/dispatch [::events/modal-status ::edit-user {:visible? true}])
|
|
||||||
(-> db
|
|
||||||
(forms/start-form ::form d))))
|
|
||||||
|
|
||||||
(re-frame/reg-event-db
|
(re-frame/reg-event-db
|
||||||
::add-client
|
::add-client
|
||||||
@@ -52,10 +47,11 @@
|
|||||||
|
|
||||||
(re-frame/reg-event-fx
|
(re-frame/reg-event-fx
|
||||||
::saving
|
::saving
|
||||||
[with-user (forms/triggers-loading ::form) (forms/in-form ::form)]
|
[with-user (forms/in-form ::form)]
|
||||||
(fn [{:keys [db user]} [_]]
|
(fn [{:keys [db user]} [_]]
|
||||||
{:graphql
|
{:graphql
|
||||||
{:token user
|
{:token user
|
||||||
|
:owns-state {:single ::form}
|
||||||
:query-obj {:venia/operation {:operation/type :mutation
|
:query-obj {:venia/operation {:operation/type :mutation
|
||||||
:operation/name "EditUser"}
|
:operation/name "EditUser"}
|
||||||
:venia/queries [{:query/data [:edit-user
|
:venia/queries [{:query/data [:edit-user
|
||||||
@@ -69,7 +65,7 @@
|
|||||||
::saved
|
::saved
|
||||||
(forms/triggers-stop ::form)
|
(forms/triggers-stop ::form)
|
||||||
(fn [{:keys [db]} [_ {:keys [edit-user]}]]
|
(fn [{:keys [db]} [_ {:keys [edit-user]}]]
|
||||||
(re-frame/dispatch [::events/modal-completed ::edit-user])))
|
{:dispatch [::modal/modal-closed]}))
|
||||||
|
|
||||||
(def user-form (forms/vertical-form {:submit-event [::saving]
|
(def user-form (forms/vertical-form {:submit-event [::saving]
|
||||||
:change-event [::changed]
|
:change-event [::changed]
|
||||||
@@ -79,52 +75,54 @@
|
|||||||
(defn form []
|
(defn form []
|
||||||
(let [{:keys [data active? error id]} @(re-frame/subscribe [::forms/form ::form])
|
(let [{:keys [data active? error id]} @(re-frame/subscribe [::forms/form ::form])
|
||||||
{:keys [form-inline field raw-field error-notification submit-button]} user-form]
|
{:keys [form-inline field raw-field error-notification submit-button]} user-form]
|
||||||
[action-modal {:title (str "Edit " (:name data))
|
(form-inline {}
|
||||||
:id ::edit-user
|
[:<>
|
||||||
:action-text "Save"
|
(field "Name"
|
||||||
:save-event [::saving]
|
[:input.input {:type "text"
|
||||||
:status-from ::form}
|
:field [:name]
|
||||||
(form-inline {}
|
:spec ::entity/name}])
|
||||||
[:<>
|
[:div.field
|
||||||
(field "Name"
|
[:p.help "Role"]
|
||||||
[:input.input {:type "text"
|
[:div.control
|
||||||
:field [:name]
|
[:div.select
|
||||||
:spec ::entity/name}])
|
[raw-field
|
||||||
|
[:select {:type "select"
|
||||||
|
:field [:role]}
|
||||||
|
[:option {:value ":none"} "None"]
|
||||||
|
[:option {:value ":user"} "User"]
|
||||||
|
[:option {:value ":manager"} "Manager"]
|
||||||
|
[:option {:value ":admin"} "Admin"]]]]]]
|
||||||
|
(when (#{":user" ":manager"} (:role data))
|
||||||
|
[:div.field
|
||||||
|
[:p.help "Clients"]
|
||||||
|
[:div.control
|
||||||
|
[:div.field.has-addons
|
||||||
|
[:div.control
|
||||||
|
[:div.select
|
||||||
|
[raw-field
|
||||||
|
[:select {:type "select"
|
||||||
|
:field [:adding-client]}
|
||||||
|
[:option]
|
||||||
|
(let [used-clients (set (map :id (:clients data)))]
|
||||||
|
(for [{:keys [id name] :as client} @(re-frame/subscribe [::subs/clients])
|
||||||
|
:when (not (used-clients id))]
|
||||||
|
^{:key id} [:option {:value id} name]))]]]]
|
||||||
|
[:p.control
|
||||||
|
[:button.button.is-primary {:on-click (dispatch-event [::add-client])} "Add"]]]
|
||||||
|
|
||||||
|
[:ul
|
||||||
[:div.field
|
(for [{:keys [id name]} (:clients data)]
|
||||||
[:p.help "Role"]
|
^{:key id} [:li name [:a.icon {:on-click (dispatch-event [::remove-client id])} [:i.fa.fa-times ]]])]]])])))
|
||||||
[:div.control
|
(re-frame/reg-event-fx
|
||||||
[:div.select
|
::editing
|
||||||
[raw-field
|
(fn [{:keys [db]} [_ d]]
|
||||||
[:select {:type "select"
|
{:db (-> db
|
||||||
:field [:role]}
|
(forms/start-form ::form d))
|
||||||
[:option {:value ":none"} "None"]
|
:dispatch [::modal/modal-requested {:title (str "Edit user " (:name d))
|
||||||
[:option {:value ":user"} "User"]
|
:body [form]
|
||||||
[:option {:value ":manager"} "Manager"]
|
:cancel? false
|
||||||
[:option {:value ":admin"} "Admin"]]]]]]])
|
:confirm {:value "Save"
|
||||||
|
:status-from [::status/single ::form]
|
||||||
|
:class "is-primary"
|
||||||
|
:on-click (dispatch-event [::saving])
|
||||||
|
:close-event [::status/completed ::form]}}]}))
|
||||||
(when (#{":user" ":manager"} (:role data))
|
|
||||||
[:div.field
|
|
||||||
[:p.help "Clients"]
|
|
||||||
[:div.control
|
|
||||||
[:div.field.has-addons
|
|
||||||
[:div.control
|
|
||||||
[:div.select
|
|
||||||
[raw-field
|
|
||||||
[:select {:type "select"
|
|
||||||
:field [:adding-client]}
|
|
||||||
[:option]
|
|
||||||
(let [used-clients (set (map :id (:clients data)))]
|
|
||||||
(for [{:keys [id name] :as client} @(re-frame/subscribe [::subs/clients])
|
|
||||||
:when (not (used-clients id))]
|
|
||||||
^{:key id} [:option {:value id} name]))]]]]
|
|
||||||
[:p.control
|
|
||||||
[:button.button.is-primary {:on-click (dispatch-event [::add-client])} "Add"]]]
|
|
||||||
|
|
||||||
[:ul
|
|
||||||
(for [{:keys [id name]} (:clients data)]
|
|
||||||
^{:key id} [:li name [:a.icon {:on-click (dispatch-event [::remove-client id])} [:i.fa.fa-times ]]])]]])]))
|
|
||||||
|
|||||||
Reference in New Issue
Block a user