action modal is gone.
This commit is contained in:
@@ -11,6 +11,8 @@
|
||||
(defn upsert-vendor [context {{:keys [id name hidden terms code print_as primary_contact secondary_contact address default_account_id invoice_reminder_schedule terms_overrides account_overrides] :as in} :vendor} value]
|
||||
(when id
|
||||
(assert-admin (:id context)))
|
||||
#_(Thread/sleep 3000)
|
||||
#_(throw (ex-info "" {:validation-error "can't do that."}))
|
||||
(let [hidden (if (is-admin? (:id context))
|
||||
hidden
|
||||
false)
|
||||
|
||||
@@ -8,14 +8,11 @@
|
||||
[auto-ap.subs :as subs]
|
||||
[auto-ap.events :as events]
|
||||
[auto-ap.views.utils :refer [active-when active-when= login-url dispatch-event appearing css-transition-group bind-field]]
|
||||
[auto-ap.views.components.vendor-dialog :refer [vendor-dialog]]
|
||||
|
||||
[auto-ap.views.components.vendor-dialog :refer [vendor-dialog]]
|
||||
[auto-ap.views.components.modal :as modal]
|
||||
[auto-ap.entities.vendors :as vendor]
|
||||
[auto-ap.views.components.vendor-dialog :as vendor-dialog]
|
||||
[clojure.string :as str]
|
||||
[reagent.core :as r]))
|
||||
[reagent.core :as r]
|
||||
[auto-ap.views.components.vendor-dialog :as vendor-dialog]))
|
||||
|
||||
|
||||
(defn navbar-drop-down-contents [{:keys [id]} children ]
|
||||
@@ -203,8 +200,6 @@
|
||||
]
|
||||
#_[footer]
|
||||
[:div
|
||||
(when-not is-initial-loading
|
||||
[vendor-dialog {}])
|
||||
bottom]
|
||||
[:div#dz-hidden]]))
|
||||
|
||||
|
||||
@@ -23,39 +23,6 @@
|
||||
[:footer.modal-card-foot
|
||||
foot])]])
|
||||
|
||||
(defn action-modal [{:keys [title class warning action-text id save-event can-submit? status-from] :or {can-submit? true}} & rest]
|
||||
(let [{:keys [visible? saving? error-message]} @(re-frame/subscribe [::subs/modal-state id status-from])]
|
||||
(when visible?
|
||||
[:form {:id id
|
||||
:on-submit (fn [e]
|
||||
(.preventDefault e)
|
||||
(re-frame/dispatch [::events/modal-status id {:saving? true :error-message nil}])
|
||||
(re-frame/dispatch save-event))}
|
||||
(-> [modal {:title [:span title]
|
||||
:class class
|
||||
:foot [:input.button.is-primary (cond-> {:type "submit"
|
||||
:form id
|
||||
:class (when saving?
|
||||
"is-loading")
|
||||
:value action-text}
|
||||
saving? (assoc :disabled "disabled")
|
||||
(not can-submit?) (assoc :disabled "disabled"))
|
||||
]
|
||||
:id id
|
||||
:hide-event [::events/modal-status id {:visible? false :error-message nil}]}
|
||||
[appearing {:visible? error-message
|
||||
:timeout 200
|
||||
:enter-class "appear"
|
||||
:exit-class "disappear"}
|
||||
[:div.notification.is-warning error-message]]
|
||||
[appearing {:visible? warning
|
||||
:timeout 200
|
||||
:enter-class "appear"
|
||||
:exit-class "disappear"}
|
||||
[:div.notification.is-info warning]]]
|
||||
(into (r/children (r/current-component)))
|
||||
(into [(when saving? [:div.is-overlay {:style {"backgroundColor" "rgba(150,150,150, 0.5)"}}])]))])))
|
||||
|
||||
|
||||
(defn simple-modal [{:keys [title foot class warning action-text id save-event can-submit? status-from] :or {can-submit? true}} & rest]
|
||||
(let [{:keys [visible? saving? error-message]} @(re-frame/subscribe [::subs/modal-state id status-from])]
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
(ns auto-ap.views.components.vendor-dialog
|
||||
(:require [re-frame.core :as re-frame]
|
||||
[auto-ap.views.utils :refer [dispatch-event horizontal-field bind-field with-user with-is-admin? active-when]]
|
||||
[auto-ap.views.components.modal :refer [action-modal]]
|
||||
[auto-ap.views.components.address :refer [address-field]]
|
||||
[auto-ap.views.components.typeahead :refer [typeahead-entity]]
|
||||
[auto-ap.views.components.dropdown :refer [drop-down drop-down-contents]]
|
||||
@@ -12,7 +11,15 @@
|
||||
[auto-ap.entities.vendors :as entity]
|
||||
[auto-ap.entities.contact :as contact]
|
||||
[auto-ap.subs :as subs]
|
||||
[auto-ap.forms :as forms]))
|
||||
[auto-ap.forms :as forms]
|
||||
[auto-ap.views.components.modal :as modal]
|
||||
[auto-ap.status :as status]))
|
||||
|
||||
(re-frame/reg-sub
|
||||
::can-submit
|
||||
:<- [::forms/form ::vendor-form]
|
||||
(fn [form]
|
||||
(s/valid? ::entity/vendor (:data form))))
|
||||
|
||||
(defn ngrams [text len]
|
||||
(mapv #(.toLowerCase (str/join "" %))
|
||||
@@ -56,30 +63,7 @@
|
||||
(map vector (range) overrides))))))
|
||||
|
||||
|
||||
(re-frame/reg-event-fx
|
||||
::started
|
||||
(fn [{:keys [db]} [_ vendor]]
|
||||
{:db (-> db (forms/start-form ::vendor-form (-> vendor
|
||||
(update :account-overrides #(mapv
|
||||
(fn [ao]
|
||||
{:id (:id ao)
|
||||
:client (:client ao)
|
||||
:override (:account ao)})
|
||||
%))
|
||||
|
||||
(update :terms-overrides #(mapv
|
||||
(fn [to]
|
||||
{:id (:id to)
|
||||
:client (:client to)
|
||||
:override (:terms to)})
|
||||
%))
|
||||
(update :hidden #(if (nil? %)
|
||||
false
|
||||
%))
|
||||
(update :default-account
|
||||
(fn [da]
|
||||
@(re-frame/subscribe [::subs/account nil (:id da)]))))))
|
||||
:dispatch [::events/modal-status ::dialog {:visible? true}]}))
|
||||
|
||||
(re-frame/reg-event-db
|
||||
::changed
|
||||
@@ -99,9 +83,8 @@
|
||||
::save-complete
|
||||
[(forms/triggers-stop ::vendor-form)]
|
||||
(fn [{:keys [db]} [_ {vendor :upsert-vendor} ]]
|
||||
{:dispatch [::events/modal-completed ::dialog ]
|
||||
:db (-> db
|
||||
(assoc-in [:vendors (:id vendor)] vendor))}))
|
||||
{:dispatch [::modal/modal-closed ]
|
||||
:db (-> db (assoc-in [:vendors (:id vendor)] vendor))}))
|
||||
|
||||
(re-frame/reg-event-fx
|
||||
::save
|
||||
@@ -110,9 +93,9 @@
|
||||
(when (s/valid? ::entity/vendor data)
|
||||
{ :graphql
|
||||
{:token user
|
||||
:owns-state {:single ::vendor-form}
|
||||
:query-obj {:venia/operation {:operation/type :mutation
|
||||
:operation/name "UpsertVendor"}
|
||||
:venia/queries [{:query/data [:upsert-vendor
|
||||
:operation/name "UpsertVendor"} :venia/queries [{:query/data [:upsert-vendor
|
||||
{:vendor (cond-> {:id id
|
||||
:name name
|
||||
:print-as print-as
|
||||
@@ -139,8 +122,7 @@
|
||||
:id
|
||||
automatically-paid-when-due)))}
|
||||
events/vendor-query]}]}
|
||||
:on-success [::save-complete]
|
||||
:on-error [::forms/save-error ::vendor-form]}})))
|
||||
:on-success [::save-complete]}})))
|
||||
|
||||
(defn client-list [{:keys [override-key override-value-key change-event default-key data]} template]
|
||||
(let [clients @(re-frame/subscribe [::subs/clients])
|
||||
@@ -368,19 +350,39 @@
|
||||
all-vendors @(re-frame/subscribe [::subs/vendors])
|
||||
{:keys [data error warning] :as f} @(re-frame/subscribe [::forms/form ::vendor-form])
|
||||
change-event [::changed]]
|
||||
[action-modal {:id ::dialog
|
||||
:class ["wide"]
|
||||
:title [:span (if (:id data)
|
||||
(str "Edit " (or (:name data) "<vendor>"))
|
||||
(str "Add " (or (:name data) "<new vendor>")))
|
||||
(when error
|
||||
[:span.icon.has-text-danger
|
||||
[:i.fa.fa-exclamation-triangle]])]
|
||||
:status-from ::vendor-form
|
||||
:warning warning
|
||||
:action-text "Save"
|
||||
:save-event [::save]
|
||||
:can-submit? (s/valid? ::entity/vendor data)}
|
||||
[:div
|
||||
[form-content {:data data :change-event change-event}]]]))
|
||||
[:div
|
||||
[form-content {:data data :change-event change-event}]]))
|
||||
|
||||
(re-frame/reg-event-fx
|
||||
::started
|
||||
(fn [{:keys [db]} [_ vendor]]
|
||||
{:db (-> db (forms/start-form ::vendor-form (-> vendor
|
||||
(update :account-overrides #(mapv
|
||||
(fn [ao]
|
||||
{:id (:id ao)
|
||||
:client (:client ao)
|
||||
:override (:account ao)})
|
||||
%))
|
||||
|
||||
(update :terms-overrides #(mapv
|
||||
(fn [to]
|
||||
{:id (:id to)
|
||||
:client (:client to)
|
||||
:override (:terms to)})
|
||||
%))
|
||||
(update :hidden #(if (nil? %)
|
||||
false
|
||||
%))
|
||||
(update :default-account
|
||||
(fn [da]
|
||||
@(re-frame/subscribe [::subs/account nil (:id da)]))))))
|
||||
:dispatch [::modal/modal-requested
|
||||
{:title "Vendor"
|
||||
:class "is-wide"
|
||||
:body [vendor-dialog]
|
||||
:confirm {:value "Save Vendor"
|
||||
:status-from [::status/single ::vendor-form]
|
||||
:class "is-primary"
|
||||
:on-click (dispatch-event [::save])
|
||||
:can-submit [::can-submit]
|
||||
:close-event [::status/completed ::vendor-form]}}]}))
|
||||
|
||||
@@ -27,8 +27,7 @@
|
||||
[auto-ap.views.pages.admin.excel-import :refer [admin-excel-import-page]]
|
||||
[auto-ap.views.pages.admin.users :refer [admin-users-page]]
|
||||
[auto-ap.views.pages.admin.yodlee :refer [admin-yodlee-page]]
|
||||
[auto-ap.entities.clients :as clients]
|
||||
[auto-ap.views.components.vendor-dialog :refer [vendor-dialog]]))
|
||||
[auto-ap.entities.clients :as clients]))
|
||||
|
||||
(defmulti page (fn [active-page] active-page))
|
||||
(defmethod page :unpaid-invoices [_]
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
[auto-ap.views.components.layouts :refer [side-bar-layout appearing-side-bar side-bar] ]
|
||||
[auto-ap.views.components.admin.side-bar :refer [admin-side-bar]]
|
||||
[auto-ap.views.utils :refer [login-url dispatch-event dispatch-value-change bind-field horizontal-field nf]]
|
||||
[auto-ap.views.components.modal :refer [action-modal]]
|
||||
[auto-ap.views.pages.admin.clients.table :as table]
|
||||
[auto-ap.views.pages.admin.clients.form :as form]
|
||||
[cljs.reader :as edn]
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
[auto-ap.views.pages.admin.users.table :as table]
|
||||
[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]]
|
||||
[auto-ap.views.components.modal :refer [modal action-modal]]
|
||||
[auto-ap.views.components.grid :as grid]
|
||||
[auto-ap.utils :refer [by replace-by]]
|
||||
[cljs.reader :as edn]
|
||||
|
||||
@@ -9,14 +9,14 @@
|
||||
[auto-ap.views.components.admin.side-bar :refer [admin-side-bar]]
|
||||
[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.components.modal :refer [modal action-modal] :as modal]
|
||||
[auto-ap.views.components.grid :as grid]
|
||||
[auto-ap.utils :refer [by replace-if]]
|
||||
[cljs.reader :as edn]
|
||||
[auto-ap.routes :as routes]
|
||||
[bidi.bidi :as bidi]
|
||||
[auto-ap.status :as status]
|
||||
[auto-ap.forms :as forms]))
|
||||
[auto-ap.forms :as forms]
|
||||
[auto-ap.views.components.modal :as modal]))
|
||||
|
||||
(re-frame/reg-sub
|
||||
::can-submit
|
||||
|
||||
@@ -10,9 +10,7 @@
|
||||
[auto-ap.utils :refer [by]]
|
||||
[auto-ap.entities.vendors :as entity]
|
||||
[auto-ap.views.components.address :refer [address-field]]
|
||||
[auto-ap.views.components.vendor-dialog :refer [vendor-dialog] :as vendor-dialog]
|
||||
[auto-ap.views.components.grid :as grid]
|
||||
[auto-ap.views.components.modal :refer [modal action-modal]]
|
||||
[auto-ap.views.components.admin.side-bar :refer [admin-side-bar]]
|
||||
[auto-ap.views.components.layouts :refer [side-bar-layout]]
|
||||
[clojure.spec.alpha :as s]
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
[auto-ap.views.components.bank-account-filter :refer [bank-account-filter]]
|
||||
[auto-ap.views.components.layouts :refer [appearing-side-bar side-bar-layout]]
|
||||
[auto-ap.routes :as routes]
|
||||
[auto-ap.views.components.modal :refer [action-modal]]
|
||||
[bidi.bidi :as bidi]
|
||||
[auto-ap.views.components.paginator :refer [paginator]]
|
||||
[auto-ap.views.components.sorter :refer [sorted-column]]
|
||||
|
||||
Reference in New Issue
Block a user