Revert "Revert "Enabling signature editing.""

This reverts commit b52f3231e8.
This commit is contained in:
Bryce Covert
2020-12-21 08:47:53 -08:00
parent b52f3231e8
commit 3d0b190702
17 changed files with 1917 additions and 140 deletions

View File

@@ -5,6 +5,7 @@ phases:
runtime-versions: runtime-versions:
docker: 19 docker: 19
java: corretto8 java: corretto8
nodejs: 12
pre_build: pre_build:
commands: commands:
@@ -18,6 +19,7 @@ phases:
- chmod +x lein - chmod +x lein
build: build:
commands: commands:
- npm install
- ./lein build - ./lein build
- cp imagedefinitions.json target/ - cp imagedefinitions.json target/
- echo Build started on `date` - echo Build started on `date`

View File

@@ -1,2 +1,8 @@
{:main auto-ap.core {:main auto-ap.core
:output-to "resources/public/js/compiled/app.js"} :target :bundle
:output-to "resources/public/js/compiled/app.js"
:output-dir "resources/public/js/compiled/"
:infer-externs true
:bundle-cmd {:none ["npx" "webpack" "--mode=production" :output-to
"--output-path" :final-output-dir
"--output-filename" :final-output-filename]}}

1667
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

36
package.json Normal file
View File

@@ -0,0 +1,36 @@
{
"name": "integreat",
"version": "1.0.0",
"description": "",
"main": "index.js",
"directories": {
"test": "test"
},
"dependencies": {
"dropzone": "^4.3.0",
"prop-types": "^15.7.2",
"react": "^17.0.1",
"react-datepicker": "^2.1.0",
"react-dom": "^17.0.1",
"react-prop-types": "^0.4.0",
"react-signature-canvas": "^1.0.3",
"react-signature-pad": "0.0.6",
"react-transition-group": "^2.4.0",
"recharts": "^1.4.2"
},
"devDependencies": {
"webpack": "^5.11.0",
"webpack-cli": "^4.2.0"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git+ssh://git@bitbucket.org/brycecovertoperations/integreat.git"
},
"keywords": [],
"author": "",
"license": "ISC",
"homepage": "https://bitbucket.org/brycecovertoperations/integreat#readme"
}

View File

@@ -6,7 +6,7 @@
:username "datomic@brycecovertoperations.com" :username "datomic@brycecovertoperations.com"
:password "9a382afc-d119-44db-83c2-98d8057d7666"}} :password "9a382afc-d119-44db-83c2-98d8057d7666"}}
:dependencies [[org.clojure/clojure "1.9.0"] :dependencies [[org.clojure/clojure "1.9.0"]
[org.clojure/clojurescript "1.10.339"] [org.clojure/clojurescript "1.10.764"]
[postgresql/postgresql "9.3-1102.jdbc41"] [postgresql/postgresql "9.3-1102.jdbc41"]
[com.datomic/datomic-pro "0.9.5703" :exclusions [com.google.guava/guava org.apache.httpcomponents/httpclient]] [com.datomic/datomic-pro "0.9.5703" :exclusions [com.google.guava/guava org.apache.httpcomponents/httpclient]]
[compojure "1.6.1" :exclusions [ring]] [compojure "1.6.1" :exclusions [ring]]
@@ -26,8 +26,7 @@
[yogthos/config "0.8"] [yogthos/config "0.8"]
[dk.ative/docjure "1.12.0"] [dk.ative/docjure "1.12.0"]
[org.clojure/java.jdbc "0.7.3"] [org.clojure/java.jdbc "0.7.3"]
[cljsjs/dropzone "4.3.0-0"]
[cljsjs/recharts "1.4.2-0" :exclusions [cljsjs/react cljsjs/react-dom]]
[clj-fuzzy "0.4.1"] [clj-fuzzy "0.4.1"]
[honeysql "0.9.2"] [honeysql "0.9.2"]
[com.walmartlabs/lacinia "0.25.0"] [com.walmartlabs/lacinia "0.25.0"]
@@ -81,7 +80,8 @@
:source-paths ["src/clj" "src/cljc" "src/cljs"] :source-paths ["src/clj" "src/cljc" "src/cljs"]
:resource-paths ["resources"] :resource-paths ["resources"]
:aliases {"build" ["do" "clean" ["uberjar"]] :aliases {"build" ["do" "clean" ["uberjar"]]
"fig:min" ["run" "-m" "figwheel.main" "-bo" "min"]} "fig:dev" ["run" "-m" "figwheel.main" "-b" "dev" "-r"]
"fig:min" ["run" "-m" "figwheel.main" "-O" "advanced" "-bo" "dev"]}
:profiles :profiles
{:dev {:dev
@@ -90,56 +90,42 @@
{:resource-paths ["resources" "target"] {:resource-paths ["resources" "target"]
:dependencies [[binaryage/devtools "0.9.4"] :dependencies [[binaryage/devtools "0.9.4"]
#_[refactor-nrepl "2.5.0"] #_[refactor-nrepl "2.5.0"]
[com.bhauman/figwheel-main "0.2.3" :exclusions [org.clojure/clojurescript [com.bhauman/figwheel-main "0.2.12" :exclusions [org.clojure/clojurescript
ring/ring-core ring/ring-core
ring/ring-codec ring/ring-codec
ring.adapter.jetty ring.adapter.jetty
binaryage/devtools binaryage/devtools
commons-io commons-io
commons-codec commons-codec
com.fasterxml.jackson.core/jackson-core com.fasterxml.jackson.core/jackson-core
org.clojure/tools.namespace org.clojure/tools.namespace
org.eclipse.jetty.websocket/websocket-server org.eclipse.jetty.websocket/websocket-server
org.eclipse.jetty.websocket/websocket-servlet org.eclipse.jetty.websocket/websocket-servlet
args4j]] args4j]]
[com.bhauman/rebel-readline-cljs "0.1.4"] [com.bhauman/rebel-readline-cljs "0.1.4"]
[javax.servlet/servlet-api "2.5"]] [javax.servlet/servlet-api "2.5"]]
:plugins [ :plugins [
[lein-pdo "0.1.1"]] [lein-pdo "0.1.1"]]
:jvm-opts ["-Dconfig=config/dev.edn" "--add-modules" "java.xml.bind"]} :jvm-opts ["-Dconfig=config/dev.edn" "--add-modules" "java.xml.bind"]}
:uberjar {:prep-tasks ["fig:min" ] :uberjar {:prep-tasks ["fig:min" ]
:dependencies [[com.bhauman/figwheel-main "0.2.3" :exclusions [org.clojure/clojurescript :dependencies [[com.bhauman/figwheel-main "0.2.12" :exclusions [org.clojure/clojurescript
ring/ring-core ring/ring-core
ring/ring-codec ring/ring-codec
ring.adapter.jetty ring.adapter.jetty
binaryage/devtools binaryage/devtools
commons-io commons-io
commons-codec commons-codec
com.fasterxml.jackson.core/jackson-core com.fasterxml.jackson.core/jackson-core
org.clojure/tools.namespace org.clojure/tools.namespace
org.eclipse.jetty.websocket/websocket-server org.eclipse.jetty.websocket/websocket-server
org.eclipse.jetty.websocket/websocket-servlet org.eclipse.jetty.websocket/websocket-servlet
args4j]]]} args4j]]]}
:provided {:dependencies [[org.clojure/clojurescript "1.10.339"] :provided {:dependencies [[org.clojure/clojurescript "1.10.764"]
[reagent "1.0.0-alpha2" ] [reagent "1.0.0-alpha2" :exclusions [cljsjs/react cljsjs/react-dom cljsjs/react-dom-server] ]
[cljsjs/react-datepicker "2.1.0-0" :exclusions [cljsjs/react cljsjs/react-dom]]
[cljsjs/react-transition-group "2.4.0-0" :exclusions [cljsjs/react cljsjs/react-dom]]
[re-frame "0.10.2"] [re-frame "0.10.2"]
[re-frame-utils "0.1.0"] [re-frame-utils "0.1.0"]
[com.andrewmcveigh/cljs-time "0.5.2"]]}} [com.andrewmcveigh/cljs-time "0.5.2"]]}}
:cljsbuild
{:builds
[{:id "dev"
:source-paths ["src/cljs" "src/cljc"]
:compiler {:main auto-ap.core
:output-to "resources/public/js/compiled/app.js"
:output-dir "resources/public/js/compiled/out"
:asset-path "/js/compiled/out"
:source-map-timestamp true
:preloads [devtools.preload]
:external-config {:devtools/config {:features-to-install :all}}}}]}
:main auto-ap.server :main auto-ap.server
:aot [auto-ap.server auto-ap.datomic.migrate auto-ap.time clj-time.core clj-time.coerce clj-time.format clojure.tools.logging.impl] :aot [auto-ap.server auto-ap.datomic.migrate auto-ap.time clj-time.core clj-time.coerce clj-time.format clojure.tools.logging.impl]

View File

@@ -18,7 +18,7 @@
</head> </head>
<body> <body>
<div id="app"><div><nav class="navbar has-shadow is-fixed-top"><div class="container"><div class="navbar-brand"><a class="navbar-item" href="../"><img src="/img/logo.png"></a></div><div class="navbar-menu"><div class="navbar-burger burger" data-target="navMenu"><span></span><span></span><span></span></div></div></div></nav><div class="columns has-shadow" id="mail-app" style="margin-bottom: 0px; height: calc(100vh - 46px);"><aside class="column aside menu is-2 "><div class="main left-nav"><div></div></div></aside><div class="column messages hero " id="message-feed" style="overflow: auto;"><div class="inbox-messages"><div class="has-text-centered hero is-fullheight is-vertically-centered is-centered"><div class="hero-body"><div class="container"><div class="column is-4 is-offset-4 has-text-centered"><div class="loader is-loading is-active big is-centered"></div></div></div></div></div></div></div></div><div></div><div id="dz-hidden"></div></div></div> <div id="app"><div><nav class="navbar has-shadow is-fixed-top"><div class="container"><div class="navbar-brand"><a class="navbar-item" href="../"><img src="/img/logo.png"></a></div><div class="navbar-menu"><div class="navbar-burger burger" data-target="navMenu"><span></span><span></span><span></span></div></div></div></nav><div class="columns has-shadow" id="mail-app" style="margin-bottom: 0px; height: calc(100vh - 46px);"><aside class="column aside menu is-2 "><div class="main left-nav"><div></div></div></aside><div class="column messages hero " id="message-feed" style="overflow: auto;"><div class="inbox-messages"><div class="has-text-centered hero is-fullheight is-vertically-centered is-centered"><div class="hero-body"><div class="container"><div class="column is-4 is-offset-4 has-text-centered"><div class="loader is-loading is-active big is-centered"></div></div></div></div></div></div></div></div><div></div><div id="dz-hidden"></div></div></div>
<script src="/js/compiled/app.js"></script> <script src="/js/compiled/app_bundle.js"></script>
<script>auto_ap.core.init();</script> <script>auto_ap.core.init();</script>
</body> </body>
</html> </html>

View File

@@ -67,6 +67,7 @@
{:fields {:id {:type :id} {:fields {:id {:type :id}
:name {:type 'String} :name {:type 'String}
:code {:type 'String} :code {:type 'String}
:signature_file {:type 'String}
:week_a_debits {:type :money} :week_a_debits {:type :money}
:week_a_credits {:type :money} :week_a_credits {:type :money}
:week_b_debits {:type :money} :week_b_debits {:type :money}
@@ -651,6 +652,7 @@
:edit_client {:fields {:id {:type :id} :edit_client {:fields {:id {:type :id}
:name {:type 'String} :name {:type 'String}
:code {:type 'String} :code {:type 'String}
:signature_data {:type 'String}
:email {:type 'String} :email {:type 'String}
:week_a_credits {:type :money} :week_a_credits {:type :money}
:week_a_debits {:type :money} :week_a_debits {:type :money}

View File

@@ -3,9 +3,14 @@
[auto-ap.datomic.clients :as d-clients] [auto-ap.datomic.clients :as d-clients]
[auto-ap.graphql.utils :refer [->graphql assert-admin can-see-client?]] [auto-ap.graphql.utils :refer [->graphql assert-admin can-see-client?]]
[clj-time.coerce :as coerce] [clj-time.coerce :as coerce]
[config.core :refer [env]]
[clojure.string :as str] [clojure.string :as str]
[clojure.tools.logging :as log] [clojure.tools.logging :as log]
[datomic.api :as d])) [datomic.api :as d]
[clojure.java.io :as io]
[amazonica.aws.s3 :as s3])
(:import [org.apache.commons.codec.binary Base64]
java.util.UUID))
(defn assert-client-code-is-unique [code] (defn assert-client-code-is-unique [code]
(when (seq (d/query {:query {:find '[?id] (when (seq (d/query {:query {:find '[?id]
@@ -14,6 +19,21 @@
:args [(d/db conn) code]})) :args [(d/db conn) code]}))
(throw (ex-info "Client is not unique" {:validation-error (str "Client code '" code "' is not unique.")})))) (throw (ex-info "Client is not unique" {:validation-error (str "Client code '" code "' is not unique.")}))))
(defn upload-signature-data [signature-data]
(let [prefix "data:image/jpeg;base64,"]
(when signature-data
(when-not (str/starts-with? signature-data prefix)
(throw (ex-info "Invalid signature image" {:validation-error (str "Invalid signature image.")})))
(let [signature-id (str (UUID/randomUUID))
raw-bytes (Base64/decodeBase64 (subs signature-data (count prefix)))]
(s3/put-object :bucket-name "integreat-signature-images" #_(:data-bucket env)
:key (str signature-id ".jpg")
:input-stream (io/make-input-stream raw-bytes {})
:metadata {:content-type "image/jpeg"}
:canned-acl "public-read")
(str "https://integreat-signature-images.s3.amazonaws.com/" signature-id ".jpg")
))))
(defn edit-client [context {:keys [edit_client new_bank_accounts] :as args} value] (defn edit-client [context {:keys [edit_client new_bank_accounts] :as args} value]
(assert-admin (:id context)) (assert-admin (:id context))
(when-not (:id edit_client) (when-not (:id edit_client)
@@ -21,6 +41,7 @@
(let [client (when (:id edit_client) (d-clients/get-by-id (:id edit_client))) (let [client (when (:id edit_client) (d-clients/get-by-id (:id edit_client)))
id (or (:db/id client) "new-client") id (or (:db/id client) "new-client")
signature-file (upload-signature-data (:signature_data edit_client))
_ (when client _ (when client
(audit-transact (into (audit-transact (into
(mapv (fn [lm] [:db/retractEntity (:db/id lm)]) (:client/location-matches client)) (mapv (fn [lm] [:db/retractEntity (:db/id lm)]) (:client/location-matches client))
@@ -36,6 +57,7 @@
(:client/code client)) (:client/code client))
:client/name (:name edit_client) :client/name (:name edit_client)
:client/matches (:matches edit_client) :client/matches (:matches edit_client)
:client/signature-file signature-file
:client/email (:email edit_client) :client/email (:email edit_client)
:client/locations (filter identity (:locations edit_client)) :client/locations (filter identity (:locations edit_client))
:client/week-a-debits (:week_a_debits edit_client) :client/week-a-debits (:week_a_debits edit_client)

View File

@@ -11,8 +11,7 @@
[auto-ap.effects :as effects] [auto-ap.effects :as effects]
[pushy.core :as pushy] [pushy.core :as pushy]
[auto-ap.history :as p] [auto-ap.history :as p]
[bidi.bidi :as bidi] [bidi.bidi :as bidi]))
[cljsjs.recharts]))
(defn dev-setup [] (defn dev-setup []
(when true (when true

View File

@@ -56,7 +56,7 @@
:graphql {:token token :graphql {:token token
:query-obj {:venia/queries [[:client :query-obj {:venia/queries [[:client
[:id :name :code :email :matches :week-a-debits :week-a-credits :week-b-debits :week-b-credits :locations [:location-matches [:id :location :match]] [:bank-accounts [:id :start-date :code :number :bank-name :bank-code :check-number :name :routing :type :sort-order :visible :yodlee-account-id :locations :include-in-reports] ] [:id :name :signature-file :code :email :matches :week-a-debits :week-a-credits :week-b-debits :week-b-credits :locations [:location-matches [:id :location :match]] [:bank-accounts [:id :start-date :code :number :bank-name :bank-code :check-number :name :routing :type :sort-order :visible :yodlee-account-id :locations :include-in-reports] ]
[:address [:street1 :street2 :city :state :zip]] [:address [:street1 :street2 :city :state :zip]]
[:forecasted-transactions [:id :amount :identifier :day-of-month]]]] [:forecasted-transactions [:id :amount :identifier :day-of-month]]]]
[:vendor [:vendor

View File

@@ -119,7 +119,7 @@
(defn settles [{:keys [event time key]}] (defn settles [{:keys [event time key]}]
(i/->interceptor (i/->interceptor
:id :settles :id :settles
:befor (fn [context] :before (fn [context]
context) context)
:after (fn [context] :after (fn [context]
(i/assoc-effect context :dispatch-debounce {:event event (i/assoc-effect context :dispatch-debounce {:event event

View File

@@ -1,6 +1,5 @@
(ns auto-ap.views.components.layouts (ns auto-ap.views.components.layouts
(:require (:require
[cljsjs.react-transition-group]
[reagent.core :as reagent] [reagent.core :as reagent]
[re-frame.core :as re-frame] [re-frame.core :as re-frame]
[bidi.bidi :as bidi] [bidi.bidi :as bidi]

View File

@@ -9,7 +9,58 @@
[cljs-time.core :as t] [cljs-time.core :as t]
[clojure.spec.alpha :as s] [clojure.spec.alpha :as s]
[re-frame.core :as re-frame] [re-frame.core :as re-frame]
[clojure.string :as str])) [reagent.core :as r]
[clojure.string :as str]
[react-signature-canvas :as canvas]
[auto-ap.views.components.buttons :as buttons]))
(def signature-canvas (r/adapt-react-class (.-default canvas)))
(defn signature [{:keys [signature-file signature-data on-change]}]
(let [canvas (atom nil)
edit-mode? (r/atom false)
w (* 1.5 464)
h (* 1.5 174)]
(fn [{:keys [signature-file signature-data on-change]}]
[:div
(if @edit-mode?
[:div
[signature-canvas {"canvasProps" {"width" w
"height" h
"style" #js {"border" "1px solid rgb(219,219,219)"
"border-radius" "4px"}}
"backgroundColor" "#FFF"
:ref (fn [el]
(reset! canvas el))}]
[:div.buttons
[:a.button.is-primary.is-outlined {:on-click (fn []
(on-change (.toDataURL @canvas "image/jpeg"))
(reset! edit-mode? false))}
"Accept"]
[:a.button.is-warning.is-outlined {:on-click (fn []
(.clear @canvas)
(reset! edit-mode? false))}
"Cancel"]]]
(if (or signature-data signature-file)
[:div
[:img {:src (or signature-data signature-file)
:style {:width w
:height h}}]
[:div.buttons
[:a.button {:on-click (fn []
(reset! edit-mode? true))}
"Replace Signature"]]]
[:div
[:div.has-text-centered.is-vcentered {:style {:width w
:height h
:margin-bottom "8px"
:background "#EEE"}}
"No signature"]
[:div.buttons
[:a.button.is-primary.is-outlined {:on-click (fn []
(reset! edit-mode? true))}
"New Signature"]]]))
])))
(re-frame/reg-sub (re-frame/reg-sub
::can-submit ::can-submit
@@ -23,56 +74,58 @@
::new-client-request ::new-client-request
:<- [::forms/form ::form] :<- [::forms/form ::form]
(fn [{new-client-data :data} _] (fn [{new-client-data :data} _]
{:id (:id new-client-data), (cond->
:name (:name new-client-data) {:id (:id new-client-data),
:code (:code new-client-data) ;; TODO add validation can't change :name (:name new-client-data)
:email (:email new-client-data) :code (:code new-client-data) ;; TODO add validation can't change
:locations (mapv :location (:locations new-client-data)) :email (:email new-client-data)
:matches (mapv :match (:matches new-client-data)) :locations (mapv :location (:locations new-client-data))
:location-matches (:location-matches new-client-data) :matches (mapv :match (:matches new-client-data))
:week-a-credits (:week-a-credits new-client-data) :location-matches (:location-matches new-client-data)
:week-a-debits (:week-a-debits new-client-data) :week-a-credits (:week-a-credits new-client-data)
:week-b-credits (:week-b-credits new-client-data) :week-a-debits (:week-a-debits new-client-data)
:week-b-debits (:week-b-debits new-client-data) :week-b-credits (:week-b-credits new-client-data)
:address {:street1 (:street1 (:address new-client-data)) :week-b-debits (:week-b-debits new-client-data)
:street2 (:street2 (:address new-client-data)), :address {:street1 (:street1 (:address new-client-data))
:city (:city (:address new-client-data)) :street2 (:street2 (:address new-client-data)),
:state (:state (:address new-client-data)) :city (:city (:address new-client-data))
:zip (:zip (:address new-client-data))} :state (:state (:address new-client-data))
:forecasted-transactions (map (fn [{:keys [id day-of-month identifier amount]}] :zip (:zip (:address new-client-data))}
{:id id :signature-data (:signature-data new-client-data)
:day-of-month day-of-month :forecasted-transactions (map (fn [{:keys [id day-of-month identifier amount]}]
:identifier identifier {:id id
:amount amount}) :day-of-month day-of-month
(:forecasted-transactions new-client-data)) :identifier identifier
:bank-accounts (map (fn [{:keys [number name check-number include-in-reports type id code start-date bank-name routing bank-code new? sort-order visible yodlee-account-id locations]}] :amount amount})
{:number number (:forecasted-transactions new-client-data))
:name name :bank-accounts (map (fn [{:keys [number name check-number include-in-reports type id code start-date bank-name routing bank-code new? sort-order visible yodlee-account-id locations]}]
:check-number check-number {:number number
:include-in-reports include-in-reports :name name
:start-date (cond (not start-date) :check-number check-number
nil :include-in-reports include-in-reports
:start-date (cond (not start-date)
nil
(instance? goog.date.Date start-date) (instance? goog.date.Date start-date)
(date->str start-date standard) (date->str start-date standard)
:else :else
start-date start-date
) )
:type type :type type
:id id :id id
:sort-order sort-order :sort-order sort-order
:visible visible :visible visible
:locations (mapv :location locations) :locations (mapv :location locations)
:yodlee-account-id (when-not (str/blank? yodlee-account-id) :yodlee-account-id (when-not (str/blank? yodlee-account-id)
(js/parseInt yodlee-account-id)) (js/parseInt yodlee-account-id))
:code (if new? :code (if new?
(str (:code new-client-data) "-" code) (str (:code new-client-data) "-" code)
code) code)
:bank-name bank-name :bank-name bank-name
:routing routing :routing routing
:bank-code bank-code}) :bank-code bank-code})
(:bank-accounts new-client-data))})) (:bank-accounts new-client-data))})))
(re-frame/reg-event-fx (re-frame/reg-event-fx
::editing ::editing
@@ -107,7 +160,7 @@
:operation/name "EditClient"} :operation/name "EditClient"}
:venia/queries [{:query/data [:edit-client :venia/queries [{:query/data [:edit-client
{:edit-client new-client-req} {:edit-client new-client-req}
[:id :name :code :email :locations :matches :week-a-debits :week-a-credits :week-b-debits :week-b-credits [:id :name :signature-file :code :email :locations :matches :week-a-debits :week-a-credits :week-b-debits :week-b-credits
[:location-matches [:location :match :id]] [:location-matches [:location :match :id]]
[:address [:street1 :street2 :city :state :zip]] [:address [:street1 :street2 :city :state :zip]]
[:forecasted-transactions [:id :amount :identifier :day-of-month]] [:forecasted-transactions [:id :amount :identifier :day-of-month]]
@@ -362,6 +415,7 @@
:spec ::entity/name :spec ::entity/name
}]) }])
[:div.field [:div.field
[:p.help "Client code" [:p.help "Client code"
] ]
@@ -380,7 +434,12 @@
:field :email :field :email
:spec ::entity/email}]) :spec ::entity/email}])
[:div.field
[:p.help "Signature"]
[signature {:signature-file (:signature-file new-client)
:signature-data (:signature-data new-client)
:on-change (fn [uri]
(re-frame/dispatch [::forms/change ::form [:signature-data] uri]))}]]
[:h2.subtitle.is-5 "Name matches"] [:h2.subtitle.is-5 "Name matches"]
[:div.control [:div.control

View File

@@ -11,17 +11,18 @@
[cljs-time.core :as t] [cljs-time.core :as t]
[pushy.core :as pushy] [pushy.core :as pushy]
[re-frame.core :as re-frame] [re-frame.core :as re-frame]
[recharts]
[reagent.core :as r])) [reagent.core :as r]))
(def pie-chart (r/adapt-react-class js/Recharts.PieChart)) (def pie-chart (r/adapt-react-class recharts/PieChart))
(def pie (r/adapt-react-class js/Recharts.Pie)) (def pie (r/adapt-react-class recharts/Pie))
(def bar-chart (r/adapt-react-class js/Recharts.BarChart)) (def bar-chart (r/adapt-react-class recharts/BarChart))
(def x-axis (r/adapt-react-class js/Recharts.XAxis)) (def x-axis (r/adapt-react-class recharts/XAxis))
(def y-axis (r/adapt-react-class js/Recharts.YAxis)) (def y-axis (r/adapt-react-class recharts/YAxis))
(def bar (r/adapt-react-class js/Recharts.Bar)) (def bar (r/adapt-react-class recharts/Bar))
(def legend (r/adapt-react-class js/Recharts.Legend)) (def legend (r/adapt-react-class recharts/Legend))
(def cell (r/adapt-react-class js/Recharts.Cell)) (def cell (r/adapt-react-class recharts/Cell))
(def tool-tip (r/adapt-react-class js/Recharts.Tooltip)) (def tool-tip (r/adapt-react-class recharts/Tooltip))
(def colors ["#79b52e" "#009cea" "#209b1c" "#f48017" " #ff0303" "hsl(217, 71%, 53%)" "hsl(141, 53%, 53%)"]) (def colors ["#79b52e" "#009cea" "#209b1c" "#f48017" " #ff0303" "hsl(217, 71%, 53%)" "hsl(141, 53%, 53%)"])
(def light-colors ["#a6d869" "#8ad8ff" "#2cd327" "#fac899" "#ff6b6b" "hsl(217, 71%, 53%)"]) (def light-colors ["#a6d869" "#8ad8ff" "#2cd327" "#fac899" "#ff6b6b" "hsl(217, 71%, 53%)"])
@@ -46,11 +47,9 @@
[tool-tip] [tool-tip]
[bar {:dataKey "paid" :fill (get colors 0) :stackId "a" :name "Paid"}] [bar {:dataKey "paid" :fill (get colors 0) :stackId "a" :name "Paid"}]
[bar {:dataKey "unpaid" :fill (get light-colors 0) :stackId "a" :name "Unpaid"}] [bar {:dataKey "unpaid" :fill (get light-colors 0) :stackId "a" :name "Unpaid"}]
[x-axis {:dataKey "name"}] [x-axis {:dataKey "name"}]
[y-axis] [y-axis]
[legend]] [legend]])
)
(defn make-cash-flow-chart [{:keys [width height data] }] (defn make-cash-flow-chart [{:keys [width height data] }]
(let [redirect-fn (fn [x] (let [redirect-fn (fn [x]

View File

@@ -12,12 +12,12 @@
[auto-ap.entities.vendors :as vendor] [auto-ap.entities.vendors :as vendor]
[auto-ap.views.components.typeahead :refer [typeahead-entity]] [auto-ap.views.components.typeahead :refer [typeahead-entity]]
[auto-ap.views.components.invoice-table :refer [invoice-table] :as invoice-table] [auto-ap.views.components.invoice-table :refer [invoice-table] :as invoice-table]
[cljsjs.dropzone :as dropzone]
[cljs.reader :as edn] [cljs.reader :as edn]
[clojure.string :as str] [clojure.string :as str]
[vimsical.re-frame.cofx.inject :as inject] [vimsical.re-frame.cofx.inject :as inject]
[auto-ap.status :as status] [auto-ap.status :as status]
[vimsical.re-frame.fx.track :as track] [vimsical.re-frame.fx.track :as track]
[dropzone :as dz]
[auto-ap.views.pages.data-page :as data-page] [auto-ap.views.pages.data-page :as data-page]
[clojure.set :as set] [clojure.set :as set]
[auto-ap.effects.forward :as forward])) [auto-ap.effects.forward :as forward]))
@@ -29,23 +29,23 @@
(reagent/create-class (reagent/create-class
{:display-name "dropzone" {:display-name "dropzone"
:component-did-mount (fn [this] :component-did-mount (fn [this]
(js/Dropzone. (rdom/dom-node this) (dz. (rdom/dom-node this)
(clj->js {:init (fn [] (clj->js {:init (fn []
(.on (js-this) "addedfiles" (.on (js-this) "addedfiles"
(fn [] (fn []
(re-frame/dispatch [::status/completed ::import]))) (re-frame/dispatch [::status/completed ::import])))
(.on (js-this) "success" (fn [_ files] (.on (js-this) "success" (fn [_ files]
(re-frame/dispatch [::invalidated]))) (re-frame/dispatch [::invalidated])))
(.on (js-this) "error" (fn [_ error] (.on (js-this) "error" (fn [_ error]
(re-frame/dispatch [::status/error ::import [(edn/read-string error)]])))) (re-frame/dispatch [::status/error ::import [(edn/read-string error)]]))))
:paramName "file" :paramName "file"
:headers {"Authorization" (str "Token " @token)} :headers {"Authorization" (str "Token " @token)}
:url (str "/api/invoices/upload" :url (str "/api/invoices/upload"
(when-let [client-name (-> @client :id)] (when-let [client-name (-> @client :id)]
(str "?client=" client-name))) (str "?client=" client-name)))
:previewsContainer "#dz-hidden" :previewsContainer "#dz-hidden"
:previewTemplate "<div class='dz-hidden-preview'></div>"}))) :previewTemplate "<div class='dz-hidden-preview'></div>"})))
:reagent-render (fn [] :reagent-render (fn []
{:key batch} {:key batch}
[:form.dz {:action "/api/invoices/upload"} [:form.dz {:action "/api/invoices/upload"}

View File

@@ -1,8 +1,8 @@
(ns auto-ap.views.utils (ns auto-ap.views.utils
(:require [re-frame.core :as re-frame] (:require [re-frame.core :as re-frame]
[cljsjs.react-transition-group]
[cljsjs.react-datepicker]
[reagent.core :as reagent] [reagent.core :as reagent]
[react-transition-group :as react-transition-group]
[react-datepicker]
[clojure.spec.alpha :as s] [clojure.spec.alpha :as s]
[cljs-time.coerce :as c] [cljs-time.coerce :as c]
[cljs-time.core :as time] [cljs-time.core :as time]
@@ -20,7 +20,7 @@
(def nff (def nff
(NumberFormat. Format/CURRENCY)) (NumberFormat. Format/CURRENCY))
(defn- nf (defn nf
[num] [num]
(.format nff (str num))) (.format nff (str num)))
@@ -60,9 +60,10 @@
(defn delayed-dispatch [e] (defn delayed-dispatch [e]
(fn [x] (fn [x]
(js/setTimeout #(re-frame/dispatch e) 150) (js/setTimeout #(re-frame/dispatch e) 151)
false)) false))
(defn dispatch-event [event] (defn dispatch-event [event]
(fn [e] (fn [e]
(when (.-stopPropagation e) (when (.-stopPropagation e)
@@ -103,7 +104,7 @@
(def css-transition-group (def css-transition-group
(reagent/adapt-react-class js/ReactTransitionGroup.CSSTransition)) (reagent/adapt-react-class react-transition-group/CSSTransition))
(defn appearing [{:keys [visible? enter-class exit-class timeout]} & children ] (defn appearing [{:keys [visible? enter-class exit-class timeout]} & children ]
@@ -410,8 +411,7 @@
(def date-picker (def date-picker
(do (do
(reagent/adapt-react-class (aget js/DatePicker "default")))) (reagent/adapt-react-class (.-default react-datepicker))))
(defn local-now [] (defn local-now []