Minor cleanup tweaks
This commit is contained in:
@@ -1,12 +1,11 @@
|
||||
#_{:clj-kondo/ignore [:unused-namespace]}
|
||||
(ns auto-ap.core
|
||||
(:require [reagent.core :as reagent]
|
||||
[reagent.dom :as rdom]
|
||||
[re-frame.core :as re-frame]
|
||||
[auto-ap.events :as events]
|
||||
[auto-ap.views.main :refer [page active-page] ]
|
||||
[auto-ap.views.main :refer [active-page] ]
|
||||
[auto-ap.reload :as reload]
|
||||
[auto-ap.events :as events]
|
||||
|
||||
[auto-ap.config :as config]
|
||||
[auto-ap.effects :as effects]
|
||||
[pushy.core :as pushy]
|
||||
@@ -32,8 +31,7 @@
|
||||
(do
|
||||
(.setItem js/localStorage "jwt" jwt)
|
||||
(re-frame/dispatch-sync [::events/initialize-db jwt]))
|
||||
(do
|
||||
(re-frame/dispatch-sync [::events/initialize-db (.getItem js/localStorage "jwt")])))
|
||||
(re-frame/dispatch-sync [::events/initialize-db (.getItem js/localStorage "jwt")]))
|
||||
(pushy/start! p/history)
|
||||
(mount-root))
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#_{:clj-kondo/ignore [:unused-namespace]}
|
||||
(ns auto-ap.subs
|
||||
(:require [re-frame.core :as re-frame]
|
||||
[auto-ap.utils :refer [by]]
|
||||
@@ -6,6 +7,7 @@
|
||||
[minisearch :as ms]))
|
||||
(set! *warn-on-infer* true)
|
||||
|
||||
#_{:clj-kondo/ignore [:unresolved-symbol]}
|
||||
(def MiniSearch (if ms (aget ms "default")
|
||||
nil))
|
||||
|
||||
@@ -211,7 +213,7 @@
|
||||
all-vendors
|
||||
|
||||
client
|
||||
(filter (fn [{:keys [hidden usage name] :as vendor}]
|
||||
(filter (fn [{:keys [hidden usage]}]
|
||||
(or (not hidden)
|
||||
(-> (first (filter #(= (:client-id %)
|
||||
(:id client))
|
||||
|
||||
@@ -19,9 +19,9 @@
|
||||
[clojure.string :as str]
|
||||
[re-frame.core :as re-frame]
|
||||
[reagent.core :as r]
|
||||
[react-signature-canvas :as canvas]))
|
||||
[react-signature-canvas]))
|
||||
|
||||
(def signature-canvas (r/adapt-react-class (.-default canvas)))
|
||||
(def signature-canvas (r/adapt-react-class (.-default react-signature-canvas)))
|
||||
|
||||
(defn upload-replacement-button [{:keys [on-change]} text]
|
||||
(let [button (atom nil)]
|
||||
|
||||
@@ -2,21 +2,17 @@
|
||||
(:require [re-frame.core :as re-frame]
|
||||
[reagent.core :as reagent]
|
||||
[reagent.dom :as rdom]
|
||||
[auto-ap.events :as events]
|
||||
[auto-ap.subs :as subs]
|
||||
[auto-ap.entities.clients :as client]
|
||||
[auto-ap.views.components.layouts :refer [side-bar-layout]]
|
||||
[auto-ap.views.components.invoices.side-bar :refer [invoices-side-bar]]
|
||||
[auto-ap.views.utils :refer [dispatch-event bind-field with-user]]
|
||||
[auto-ap.views.utils :refer [dispatch-event with-user]]
|
||||
[auto-ap.utils :refer [by]]
|
||||
[auto-ap.entities.vendors :as vendor]
|
||||
[auto-ap.views.components.typeahead :refer [typeahead-v3]]
|
||||
[auto-ap.views.components.invoice-table :refer [invoice-table] :as invoice-table]
|
||||
[cljs.reader :as edn]
|
||||
[clojure.string :as str]
|
||||
[vimsical.re-frame.cofx.inject :as inject]
|
||||
[auto-ap.status :as status]
|
||||
[vimsical.re-frame.fx.track :as track]
|
||||
#_{:clj-kondo/ignore [:unused-namespace]}
|
||||
[dropzone :as dz]
|
||||
[auto-ap.views.pages.data-page :as data-page]
|
||||
[clojure.set :as set]
|
||||
@@ -37,7 +33,7 @@
|
||||
(fn []
|
||||
(re-frame/dispatch [::status/completed ::import])))
|
||||
|
||||
(.on t "success" (fn [_ files]
|
||||
(.on t "success" (fn [_ _]
|
||||
(re-frame/dispatch [::invalidated])))
|
||||
(.on t "error" (fn [_ error]
|
||||
(re-frame/dispatch [::status/error ::import [(edn/read-string error)]])))))
|
||||
@@ -49,7 +45,6 @@
|
||||
:previewsContainer "#dz-hidden"
|
||||
:previewTemplate "<div class='dz-hidden-preview'></div>"})))
|
||||
:reagent-render (fn []
|
||||
{:key batch}
|
||||
[:form.dz {:action "/api/invoices/upload"}
|
||||
[:div.field.has-addons
|
||||
[:p.control
|
||||
@@ -87,14 +82,14 @@
|
||||
|
||||
(re-frame/reg-event-fx
|
||||
::invalidated
|
||||
(fn [{:keys [db]} [_ params]]
|
||||
(fn [{:keys [db]} _]
|
||||
{:dispatch-n [[::params-change @(re-frame/subscribe [::data-page/params :import-invoices])]
|
||||
[::data-page/reset-checked :import-invoices]]
|
||||
:db (update db ::batch inc)}))
|
||||
|
||||
(re-frame/reg-event-fx
|
||||
::mounted
|
||||
(fn [cofx [_ params]]
|
||||
(fn [_ _]
|
||||
{::track/register [{:id ::params
|
||||
:subscription [::data-page/params :import-invoices]
|
||||
:event-fn (fn [params]
|
||||
@@ -107,7 +102,7 @@
|
||||
|
||||
(re-frame/reg-event-fx
|
||||
::unmounted
|
||||
(fn [cofx [_ params]]
|
||||
(fn [_ _]
|
||||
{::track/dispose {:id ::params}
|
||||
:dispatch [::data-page/dispose :import-invoices]}))
|
||||
|
||||
@@ -132,7 +127,7 @@
|
||||
|
||||
(re-frame/reg-event-fx
|
||||
::reject-invoices-clicked
|
||||
(fn [{:keys [db]} [_ invoices on-success]]
|
||||
(fn [{:keys [db]} [_ invoices]]
|
||||
{:graphql
|
||||
{:token (-> db :user)
|
||||
:owns-state {:single ::reject}
|
||||
@@ -145,7 +140,7 @@
|
||||
|
||||
(re-frame/reg-event-fx
|
||||
::approve-invoices-clicked
|
||||
(fn [{:keys [db]} [_ invoices on-success]]
|
||||
(fn [{:keys [db]} [_ invoices]]
|
||||
{:graphql
|
||||
{:token (-> db :user)
|
||||
:owns-state {:single ::approve}
|
||||
@@ -173,20 +168,18 @@
|
||||
:disabled (or (not (boolean (seq checked)))
|
||||
(status/disabled-for @(re-frame/subscribe [::status/single ::approve])))}
|
||||
"Approve "
|
||||
(when (> (count checked ))
|
||||
(str
|
||||
(count checked)
|
||||
" invoices"))
|
||||
(str
|
||||
(count checked)
|
||||
" invoices")
|
||||
[:span " "]]
|
||||
[:button.button.is-warning {:on-click (dispatch-event [::reject-invoices-clicked checked])
|
||||
:class (status/class-for @(re-frame/subscribe [::status/single ::reject]))
|
||||
:disabled (or (not (boolean (seq checked)))
|
||||
(status/disabled-for @(re-frame/subscribe [::status/single ::reject])))}
|
||||
"Reject "
|
||||
(when (> (count checked ))
|
||||
(str
|
||||
(count checked)
|
||||
" invoices"))
|
||||
(str
|
||||
(count checked)
|
||||
" invoices")
|
||||
[:span " "]]])
|
||||
|
||||
(def import-invoices-content
|
||||
|
||||
Reference in New Issue
Block a user