diff --git a/src/cljs/auto_ap/events.cljs b/src/cljs/auto_ap/events.cljs index 6fcd2681..7a566e01 100644 --- a/src/cljs/auto_ap/events.cljs +++ b/src/cljs/auto_ap/events.cljs @@ -61,7 +61,8 @@ [:vendor vendor-query] [:accounts [:numeric-code :location :name :type :account_set :applicability :id [:client-overrides [:name :id [:client [:name :id]]]]]]]} - :on-success [::received-initial]}})))) + :on-success [::received-initial] + :on-error [::failed-initial]}})))) (re-frame/reg-event-db @@ -82,7 +83,8 @@ vendor-query] [:accounts [:numeric-code :name :location :type :account_set :applicability :id [:client-overrides [:name [:client [:name :id]]]]]]]} - :on-success [::received-initial]} + :on-success [::received-initial] + :on-error [::failed-initial]} :db (assoc db :user (assoc user :token token) :is-initial-loading? true)})) @@ -102,6 +104,14 @@ (filter #(= % (:last-client-id db))) first)))))) +(re-frame/reg-event-db + ::failed-initial + (fn [db [_ e]] + (assoc db :initial-error e + + :is-initial-loading? false + :active-page :initial-error))) + (re-frame/reg-event-db ::swap-client (fn [db [_ client]] diff --git a/src/cljs/auto_ap/views/main.cljs b/src/cljs/auto_ap/views/main.cljs index d210d302..5d178554 100644 --- a/src/cljs/auto_ap/views/main.cljs +++ b/src/cljs/auto_ap/views/main.cljs @@ -12,6 +12,7 @@ [auto-ap.views.pages.needs-activation :refer [needs-activation-page]] [auto-ap.views.pages.transactions :refer [transactions-page]] [auto-ap.views.pages.ledger :refer [ledger-page]] + [auto-ap.views.pages.error :refer [error-page]] [auto-ap.views.pages.ledger.balance-sheet :refer [balance-sheet-page]] [auto-ap.views.pages.ledger.external-import :refer [external-import-page]] [auto-ap.views.pages.ledger.profit-and-loss :refer [profit-and-loss-page]] @@ -120,6 +121,9 @@ (defmethod page :admin-excel-import [_] [admin-excel-import-page]) +(defmethod page :initial-error [_] + [error-page]) + (defn active-page [] (let [ap (re-frame/subscribe [::subs/active-page]) current-client @(re-frame/subscribe [::subs/client]) diff --git a/src/cljs/auto_ap/views/pages/error.cljs b/src/cljs/auto_ap/views/pages/error.cljs new file mode 100644 index 00000000..2fbb886a --- /dev/null +++ b/src/cljs/auto_ap/views/pages/error.cljs @@ -0,0 +1,24 @@ +(ns auto-ap.views.pages.error + (:require [re-frame.core :as re-frame] + [auto-ap.views.components.layouts :refer [side-bar-layout]])) + +(re-frame/reg-sub + ::error + (fn [db] + (:initial-error db))) + +(defn error-page [] + [:div.container + [:section.is-fullheight.hero + [:div.hero-body + [:div.container + [:div.column.is-8.is-offset-2.has-text-centered + + [:div.box.slideInFromBelow + [:img {:src "http://www.integreatconsult.com/wp-content/uploads/2016/11/logo.png"}] + [:div.notification.is-danger.is-light "An unexpected error has occured. " + [:a {:on-click #(.reload (.-location js/document )) } "Click here"] + " to try again."]] + [:p.has-text-gray + "Copyright Integreat 2020"]]]]]] + ) diff --git a/src/cljs/auto_ap/views/pages/invoices/form.cljs b/src/cljs/auto_ap/views/pages/invoices/form.cljs index c36b0cd3..9ac99e30 100644 --- a/src/cljs/auto_ap/views/pages/invoices/form.cljs +++ b/src/cljs/auto_ap/views/pages/invoices/form.cljs @@ -15,7 +15,9 @@ [cljs-time.core :as c] [clojure.spec.alpha :as s] [clojure.string :as str] - [re-frame.core :as re-frame])) + [re-frame.core :as re-frame] + [vimsical.re-frame.fx.track :as track] + [reagent.core :as r])) ;; SUBS (re-frame/reg-sub @@ -228,7 +230,20 @@ :submit-event [::saving ] :id ::form})) -(defn form [{:keys [can-change-amount?] :as params}] +(re-frame/reg-event-fx + ::mounted + (fn [] + {::track/register [{:id ::client + :subscription [::subs/client] + :event-fn (fn [c] + [::changed [:client] c])}]})) + +(re-frame/reg-event-fx + ::unmounted + (fn [] + {::track/dispose [{:id ::client}]})) + +(defn form-content [{:keys [can-change-amount?] :as params}] [layouts/side-bar {:on-close (dispatch-event [::forms/form-closing ::form ])} (let [{:keys [data active? error id]} @(re-frame/subscribe [::forms/form ::form]) {:keys [form-inline field raw-field error-notification submit-button ]} invoice-form @@ -349,3 +364,12 @@ (submit-button "Save")]]]) {:key id}))]) + + +(defn form [p] + (r/create-class + {:display-name "invoice-form" + :component-did-mount #(re-frame/dispatch [::mounted]) + :component-will-unmount #(re-frame/dispatch [::unmounted]) + :reagent-render (fn [p] + [form-content p])})) diff --git a/src/cljs/auto_ap/views/pages/ledger/profit_and_loss.cljs b/src/cljs/auto_ap/views/pages/ledger/profit_and_loss.cljs index 42ee1acc..ce9540f9 100644 --- a/src/cljs/auto_ap/views/pages/ledger/profit_and_loss.cljs +++ b/src/cljs/auto_ap/views/pages/ledger/profit_and_loss.cljs @@ -40,7 +40,6 @@ (mapcat second) (map :location) (map not-empty) - (filter #(not= "A" %)) (filter identity) (set)