Merge branch 'try-tailwind'
This commit is contained in:
@@ -1,23 +1,21 @@
|
||||
(ns auto-ap.views.components.layouts
|
||||
(:require
|
||||
[auto-ap.events :as events]
|
||||
[auto-ap.forms :as forms]
|
||||
[auto-ap.forms.builder :as form-builder]
|
||||
[auto-ap.routes :as routes]
|
||||
[auto-ap.ssr-routes :as ssr-routes]
|
||||
[auto-ap.subs :as subs]
|
||||
[auto-ap.views.components.modal :as modal]
|
||||
[auto-ap.views.components.search :as search]
|
||||
[auto-ap.views.components.vendor-dialog :as vendor-dialog]
|
||||
[auto-ap.views.utils
|
||||
:refer [active-when
|
||||
appearing
|
||||
dispatch-event-with-propagation
|
||||
login-url]]
|
||||
:refer [active-when appearing dispatch-event-with-propagation login-url]]
|
||||
[bidi.bidi :as bidi]
|
||||
[clojure.string :as str]
|
||||
[re-frame.core :as re-frame]
|
||||
[reagent.core :as r]
|
||||
[auto-ap.forms.builder :as form-builder]
|
||||
[vimsical.re-frame.cofx.inject :as inject]
|
||||
[auto-ap.forms :as forms]))
|
||||
[vimsical.re-frame.cofx.inject :as inject]))
|
||||
|
||||
(defn navbar-drop-down [{:keys [ class]} _]
|
||||
(let [!child (r/atom nil)]
|
||||
@@ -47,19 +45,19 @@
|
||||
(defn login-dropdown []
|
||||
(let [user (re-frame/subscribe [::subs/user])]
|
||||
(if @user
|
||||
[navbar-drop-down {:header [:span [:span.icon [:i.fa.fa-user] ]
|
||||
[navbar-drop-down {:header [:span [:span.icon [:i.fa.fa-user]]
|
||||
[:span (:user/name @user)]]
|
||||
:id ::account}
|
||||
[:div
|
||||
[:a {:class "navbar-item"
|
||||
:href (bidi/path-for routes/routes :reports)} "My company"]
|
||||
:href (bidi/path-for auto-ap.ssr-routes/only-routes :company)} "My company"]
|
||||
[:a.dropdown-item {:on-click (dispatch-event-with-propagation [::vendor-dialog/started {}])} "New Vendor"]
|
||||
[:a.dropdown-item {:on-click (dispatch-event-with-propagation [::vendor-dialog/edit {}])} "Edit Vendor"]
|
||||
(when (= "admin" (:user/role @user))
|
||||
[:a {:class "navbar-item" :href (bidi/path-for routes/routes :admin)} "Administration"])
|
||||
[:hr {:class "navbar-divider"}]
|
||||
[:a.navbar-item {:on-click (fn [e] (.preventDefault e) (re-frame/dispatch [::events/logout]))} "Logout"]]]
|
||||
[:a.navbar-item {:href login-url} "Login"])))
|
||||
[:a.navbar-item {:on-click (fn [e] (.preventDefault e) (re-frame/dispatch [::events/logout]))} "Logout"]]]
|
||||
[:a.navbar-item {:href (login-url)} "Login"])))
|
||||
|
||||
(re-frame/reg-sub
|
||||
::client-search
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
(ns auto-ap.views.pages.login
|
||||
(:require
|
||||
[auto-ap.views.utils :refer [login-url]]
|
||||
[re-frame.core :as re-frame]))
|
||||
[re-frame.core :as re-frame]
|
||||
[cemerick.url :as url]))
|
||||
|
||||
(re-frame/reg-sub
|
||||
::logout-reason
|
||||
@@ -17,9 +18,9 @@
|
||||
[:div.notification.is-warning reason])
|
||||
[:h1.title "Login"]
|
||||
[:div.box.slideInFromBelow
|
||||
|
||||
|
||||
[:img {:src "/img/logo-big.png"}]
|
||||
[:div
|
||||
[:a.button.is-large.is-primary {:href login-url} "Login with Google"]]]
|
||||
[:a.button.is-large.is-primary {:href (doto (login-url (get (:query (url/url (.-location js/window))) "redirect-to")) println)} "Login with Google"]]]
|
||||
[:p.has-text-gray
|
||||
"Copyright Integreat 2018"]]]]]])
|
||||
|
||||
@@ -12,11 +12,11 @@
|
||||
|
||||
|
||||
(defn needs-activation-page []
|
||||
[:div
|
||||
[:div
|
||||
[:h2 "Sorry, your user is not activated yet. Please have Ben Skinner enable your account. Click "
|
||||
[:a {:on-click (fn []
|
||||
(re-frame/dispatch-sync [::relogin])
|
||||
true)
|
||||
:href login-url}
|
||||
:href (login-url)}
|
||||
"here"]
|
||||
" to try again."]])
|
||||
|
||||
@@ -21,56 +21,55 @@
|
||||
user @(re-frame/subscribe [::subs/user])
|
||||
client @(re-frame/subscribe [::subs/client])]
|
||||
[:div
|
||||
[:div [:p.menu-label "Type"]
|
||||
[:ul.menu-list
|
||||
[:li.menu-item
|
||||
[:a.item {:href (bidi/path-for routes/routes :transactions)
|
||||
:class [(active-when ap = :transactions)]}
|
||||
[:span {:class "icon" :style {:font-size "25px"}}]
|
||||
[:span {:class "name"} "All"]]]
|
||||
[:li.menu-item
|
||||
[:a.item {:href (bidi/path-for routes/routes :unapproved-transactions)
|
||||
:class [(active-when ap = :unapproved-transactions)]}
|
||||
[:span {:class "icon icon-task-list-text-1" :style {:font-size "25px"}}]
|
||||
[:span {:class "name"} "Unapproved"]]]
|
||||
[:li.menu-item
|
||||
[:a.item {:href (bidi/path-for routes/routes :requires-feedback-transactions)
|
||||
:class [(active-when ap = :requires-feedback-transactions)]}
|
||||
[:div [:p.menu-label "Type"]
|
||||
[:ul.menu-list
|
||||
[:li.menu-item
|
||||
[:a.item {:href (bidi/path-for routes/routes :transactions)
|
||||
:class [(active-when ap = :transactions)]}
|
||||
[:span {:class "icon" :style {:font-size "25px"}}]
|
||||
[:span {:class "name"} "All"]]]
|
||||
[:li.menu-item
|
||||
[:a.item {:href (bidi/path-for routes/routes :unapproved-transactions)
|
||||
:class [(active-when ap = :unapproved-transactions)]}
|
||||
[:span {:class "icon icon-task-list-text-1" :style {:font-size "25px"}}]
|
||||
[:span {:class "name"} "Unapproved"]]]
|
||||
[:li.menu-item
|
||||
[:a.item {:href (bidi/path-for routes/routes :requires-feedback-transactions)
|
||||
:class [(active-when ap = :requires-feedback-transactions)]}
|
||||
|
||||
[:span {:class "icon icon-task-list-question" :style {:font-size "25px"}}]
|
||||
|
||||
[:span {:class "name"} "Client Review"]]]
|
||||
[:li.menu-item
|
||||
[:a.item {:href (bidi/path-for routes/routes :approved-transactions)
|
||||
:class [(active-when ap = :approved-transactions)]}
|
||||
[:span {:class "icon icon-task-list-question" :style {:font-size "25px"}}]
|
||||
|
||||
[:span {:class "icon icon-task-list-check-1" :style {:font-size "25px"}}]
|
||||
|
||||
[:span {:class "name"} "Approved"]]]
|
||||
[:li.menu-item
|
||||
[:a.item {:href (bidi/path-for routes/routes :excluded-transactions)
|
||||
:class [(active-when ap = :excluded-transactions)]}
|
||||
[:span {:class "name"} "Client Review"]]]
|
||||
[:li.menu-item
|
||||
[:a.item {:href (bidi/path-for routes/routes :approved-transactions)
|
||||
:class [(active-when ap = :approved-transactions)]}
|
||||
|
||||
[:span {:class "icon icon-task-list-disable" :style {:font-size "25px"}}]
|
||||
|
||||
[:span {:class "name"} "Excluded"]]]
|
||||
[:span {:class "icon icon-task-list-check-1" :style {:font-size "25px"}}]
|
||||
|
||||
[:span {:class "name"} "Approved"]]]
|
||||
[:li.menu-item
|
||||
[:a.item {:href (bidi/path-for routes/routes :excluded-transactions)
|
||||
:class [(active-when ap = :excluded-transactions)]}
|
||||
|
||||
[:span {:class "icon icon-task-list-disable" :style {:font-size "25px"}}]
|
||||
|
||||
[:span {:class "name"} "Excluded"]]]
|
||||
(when @(re-frame/subscribe [::subs/is-admin?])
|
||||
[:li.menu-item
|
||||
[:a.item {:href (bidi/path-for ssr-routes/only-routes :transaction-insights)
|
||||
:class [(active-when ap = :transaction-insights)]}
|
||||
|
||||
[:span {:class "icon icon-task-list-disable" :style {:font-size "25px"}}]
|
||||
|
||||
[:span {:class "name"} "Insights"]]]
|
||||
]]
|
||||
(when client
|
||||
[:<>
|
||||
|
||||
[:span {:class "name"} "Insights"]]])]]
|
||||
(when client
|
||||
[:<>
|
||||
[:p.menu-label "Bank Account"]
|
||||
[:div
|
||||
[:div
|
||||
[bank-account-filter
|
||||
{:on-change-event [::data-page/filter-changed data-page :bank-account]
|
||||
:value @(re-frame/subscribe [::data-page/filter data-page :bank-account])
|
||||
:bank-accounts @(re-frame/subscribe [::subs/bank-accounts])}]]])
|
||||
|
||||
|
||||
[:p.menu-label "Financial Account"]
|
||||
[:div
|
||||
@@ -79,7 +78,7 @@
|
||||
{:query i
|
||||
:client-id (:id client)}
|
||||
[:name :id]])
|
||||
:entity->text (fn [x ] (str (:numeric-code x) " - " (:name x)))
|
||||
:entity->text (fn [x] (str (:numeric-code x) " - " (:name x)))
|
||||
:type "typeahead-v3"
|
||||
:on-change #(re-frame/dispatch [::data-page/filter-changed data-page :account (some-> % (select-keys [:name :id :numeric-code]))])
|
||||
:value @(re-frame/subscribe [::data-page/filter data-page :account])}]]
|
||||
@@ -94,13 +93,11 @@
|
||||
:on-change #(re-frame/dispatch [::data-page/filter-changed data-page :vendor %])
|
||||
:value @(re-frame/subscribe [::data-page/filter data-page :vendor])}]]
|
||||
|
||||
|
||||
|
||||
[:p.menu-label "Amount"]
|
||||
[:div
|
||||
[number-filter
|
||||
{:on-change-event [::data-page/filter-changed data-page :amount-range]
|
||||
:value @(re-frame/subscribe [::data-page/filter data-page :amount-range])}]]
|
||||
[:div
|
||||
[number-filter
|
||||
{:on-change-event [::data-page/filter-changed data-page :amount-range]
|
||||
:value @(re-frame/subscribe [::data-page/filter data-page :amount-range])}]]
|
||||
|
||||
[:p.menu-label "Date Range"]
|
||||
[:div
|
||||
@@ -108,33 +105,31 @@
|
||||
{:on-change-event [::data-page/filter-changed data-page :date-range]
|
||||
:value @(re-frame/subscribe [::data-page/filter data-page :date-range])}]]
|
||||
|
||||
|
||||
[:p.menu-label "Location"]
|
||||
[:div.field
|
||||
[:div.control [:input.input {:placeholder "SC"
|
||||
:style {:width "3em"}
|
||||
:value @(re-frame/subscribe [::data-page/filter data-page :location])
|
||||
:on-change (dispatch-value-change [::data-page/filter-changed data-page :location ])} ]]]
|
||||
:on-change (dispatch-value-change [::data-page/filter-changed data-page :location])}]]]
|
||||
|
||||
[:p.menu-label "Description"]
|
||||
[:div
|
||||
[:div.field
|
||||
[:div.control [:input.input {:placeholder "CHECK 123 ABC"
|
||||
:value @(re-frame/subscribe [::data-page/filter data-page :description])
|
||||
:on-change (dispatch-value-change [::data-page/filter-changed data-page :description])} ]]]]
|
||||
[:p.menu-label "Description"]
|
||||
[:div
|
||||
[:div.field
|
||||
[:div.control [:input.input {:placeholder "CHECK 123 ABC"
|
||||
:value @(re-frame/subscribe [::data-page/filter data-page :description])
|
||||
:on-change (dispatch-value-change [::data-page/filter-changed data-page :description])}]]]]
|
||||
(when-let [exact-match-id @(re-frame/subscribe [::data-page/filter data-page :exact-match-id])]
|
||||
[:div
|
||||
[:p.menu-label "Specific Transaction"]
|
||||
[:span.tag.is-medium exact-match-id " "
|
||||
[:button.delete.is-small {:on-click
|
||||
(dispatch-event [::data-page/filter-changed data-page :exact-match-id nil])}]]])
|
||||
|
||||
|
||||
(when (= "admin" (:user/role user))
|
||||
[:<>
|
||||
|
||||
|
||||
[:p.menu-label "Admin only"]
|
||||
[:div
|
||||
[:div
|
||||
[switch-field {:id "unresolved-only"
|
||||
:checked (boolean @(re-frame/subscribe [::data-page/filter data-page :unresolved]))
|
||||
:on-change (fn [e]
|
||||
@@ -149,7 +144,7 @@
|
||||
[:button.delete.is-small {:on-click
|
||||
(dispatch-event [::data-page/filter-changed data-page :import-batch-id nil])}]]])
|
||||
|
||||
[:div
|
||||
[:div
|
||||
[switch-field {:id "potentially-duplicate"
|
||||
:checked (boolean @(re-frame/subscribe [::data-page/filter data-page :potential-duplicates]))
|
||||
:on-change (fn [e]
|
||||
|
||||
@@ -57,10 +57,16 @@
|
||||
|
||||
(when (apply f (into [active-page] rest)) " is-active"))
|
||||
|
||||
(def login-url
|
||||
(let [client-id "264081895820-0nndcfo3pbtqf30sro82vgq5r27h8736.apps.googleusercontent.com"
|
||||
redirect-uri (js/encodeURI (str (.-origin (.-location js/window)) "/api/oauth"))]
|
||||
(str "https://accounts.google.com/o/oauth2/auth?access_type=online&client_id=" client-id "&redirect_uri=" redirect-uri "&response_type=code&max_auth_age=0&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.email+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.profile")))
|
||||
(defn login-url
|
||||
([] (login-url nil))
|
||||
([next]
|
||||
|
||||
(let [client-id "264081895820-0nndcfo3pbtqf30sro82vgq5r27h8736.apps.googleusercontent.com"
|
||||
redirect-uri (js/encodeURI (str (.-origin (.-location js/window)) "/api/oauth"
|
||||
))]
|
||||
(str "https://accounts.google.com/o/oauth2/auth?access_type=online&client_id=" client-id "&redirect_uri=" redirect-uri "&response_type=code&max_auth_age=0&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.email+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.profile"
|
||||
(when next
|
||||
(str "&state=" (js/encodeURIComponent next)))))))
|
||||
|
||||
(defn dispatch-value-change [event]
|
||||
(fn [e]
|
||||
@@ -249,9 +255,9 @@
|
||||
:user/role)))))))
|
||||
|
||||
(defn query-params []
|
||||
(reduce-kv
|
||||
(reduce-kv
|
||||
(fn [result k v]
|
||||
(assoc result (keyword k) (edn/read-string v)))
|
||||
(assoc result (keyword k) (try (edn/read-string v) (catch js/Error e v))))
|
||||
{}
|
||||
(:query (cemerick.url/url (.-location js/window)))))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user