Builds client SSR approach, sunsets old cljs.
This commit is contained in:
@@ -6,10 +6,7 @@
|
||||
"needs-activation/" :needs-activation
|
||||
"needs-activation" :needs-activation
|
||||
"payments/" :payments
|
||||
"admin/" {"clients/" {"" :admin-clients
|
||||
[:id] {"" :admin-specific-client
|
||||
"/bank-accounts/" {[:bank-account] :admin-specific-bank-account}}}
|
||||
"vendors" :admin-vendors}
|
||||
"admin/" { "vendors" :admin-vendors}
|
||||
"invoices/" {"" :invoices
|
||||
"import" :import-invoices
|
||||
"unpaid" :unpaid-invoices
|
||||
@@ -22,8 +19,6 @@
|
||||
"requires-feedback" :requires-feedback-transactions
|
||||
"excluded" :excluded-transactions}
|
||||
"reports/" {"" :reports}
|
||||
"plaid" :plaid
|
||||
"yodlee2" :yodlee2
|
||||
"ledger/" {"" :ledger
|
||||
"profit-and-loss" :profit-and-loss
|
||||
"cash-flows" :cash-flows
|
||||
|
||||
@@ -1,11 +1,25 @@
|
||||
(ns auto-ap.permissions)
|
||||
|
||||
;; TODO after getting rid of cljs, use malli schemas to decode this
|
||||
(defn get-client-id [client]
|
||||
(cond (nat-int? client)
|
||||
client
|
||||
|
||||
(:db/id client)
|
||||
(:db/id client)
|
||||
|
||||
:else
|
||||
nil))
|
||||
|
||||
(defn can? [user {:keys [client subject activity]}]
|
||||
(let [role (or (:user/role user) (:role user) user)]
|
||||
(println "ROLE IS" role)
|
||||
(let [role (or (:user/role user) (:role user) user)
|
||||
client-id (get-client-id client)]
|
||||
(cond (#{:user-role/admin "admin"} role)
|
||||
true
|
||||
|
||||
(and client-id (not (get (into #{} (map :db/id (:clients user))) client-id)))
|
||||
false
|
||||
|
||||
(#{:user-role/power-user "power-user"} role)
|
||||
(cond
|
||||
(#{:invoice-page :payment-page :my-company-page :transaction-page :ledger-page} subject)
|
||||
@@ -49,6 +63,9 @@
|
||||
(= [:vendor :edit] [subject activity])
|
||||
true
|
||||
|
||||
(= [:signature :edit] [subject activity])
|
||||
true
|
||||
|
||||
:else false)
|
||||
|
||||
:else
|
||||
|
||||
19
src/cljc/auto_ap/routes/admin/clients.cljc
Normal file
19
src/cljc/auto_ap/routes/admin/clients.cljc
Normal file
@@ -0,0 +1,19 @@
|
||||
(ns auto-ap.routes.admin.clients)
|
||||
(def routes {"" {:get ::page
|
||||
:put ::save
|
||||
:post ::save}
|
||||
"/table" ::table
|
||||
|
||||
"/navigate" ::navigate
|
||||
"/bank-accounts/sort" ::sort-bank-accounts
|
||||
"/discard" ::discard
|
||||
"/square-locations" ::refresh-square-locations
|
||||
|
||||
"/location/new" ::new-location
|
||||
"/match/new" ::new-match
|
||||
"/location-match/new" ::new-location-match
|
||||
"/email-contact/new" ::new-email-contact
|
||||
"/feature-flag/new" ::new-feature-flag
|
||||
"/new" {:get ::new-dialog}
|
||||
["/" [#"\d+" :db/id] "/sales-powerquery"] ::biweekly-sales-powerquery
|
||||
["/" [#"\d+" :db/id] "/edit"] ::edit-dialog})
|
||||
@@ -10,9 +10,10 @@
|
||||
"/account/typeahead" ::account-typeahead
|
||||
"/test" ::test
|
||||
"/new" {:get ::new-dialog}
|
||||
"/navigate" ::navigate
|
||||
["/" [#"\d+" :db/id] "/edit"] ::edit-dialog
|
||||
["/" [#"\d+" :db/id] "/delete"] ::delete
|
||||
["/" [#"\d+" :db/id] "/run"] {:get ::execute-dialog
|
||||
:post ::execute}
|
||||
:post ::execute}
|
||||
"/check-badges" ::check-badges
|
||||
})
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
"/account-override" ::new-account-override
|
||||
"/account-typeahead" ::account-typeahead
|
||||
"/validate" ::validate
|
||||
"/navigat" ::navigate
|
||||
"/new" {:get ::new}
|
||||
"/merge" {:get ::merge
|
||||
:put ::merge-submit}
|
||||
|
||||
@@ -30,16 +30,6 @@
|
||||
[:i {:class icon-class}]])
|
||||
[:span {:class "name"} label]]])
|
||||
|
||||
(defn menu-item [{:keys [label route test-route active-route icon-class icon-style]}]
|
||||
[:p.menu-item
|
||||
[:a.item {:href (bidi/path-for all-client-visible-routes route)
|
||||
:class (when (test-route active-route) "is-active")}
|
||||
(if icon-style
|
||||
[:span {:class icon-class :style icon-style}]
|
||||
[:span {:class "icon"}
|
||||
[:i {:class icon-class}]])
|
||||
[:span {:class "name"} label]]])
|
||||
|
||||
(defn company-side-bar-impl [active-route]
|
||||
[:div
|
||||
(menu-item {:label "Reports"
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
[auto-ap.routes.admin.excel-invoices :as ei-routes]
|
||||
[auto-ap.routes.admin.import-batch :as ib-routes]
|
||||
[auto-ap.routes.admin.vendors :as v-routes]
|
||||
[auto-ap.routes.admin.clients :as ac-routes]
|
||||
[auto-ap.routes.admin.transaction-rules :as tr-routes]))
|
||||
|
||||
(def routes {"impersonate" :impersonate
|
||||
@@ -15,6 +16,7 @@
|
||||
"/update" {:patch :invoice-glimpse-update-textract-invoice}}}}}
|
||||
"account" {"/search" {:get :account-search}}
|
||||
"admin" {"" :auto-ap.routes.admin/page
|
||||
"/client" ac-routes/routes
|
||||
"/history" {"" :admin-history
|
||||
"/" :admin-history
|
||||
#"/search/?" :admin-history-search
|
||||
@@ -61,8 +63,10 @@
|
||||
"/table" {:get :pos-cash-drawer-shift-table}}}
|
||||
|
||||
"vendor" {"/search" :vendor-search}
|
||||
;; TODO Include IDS in routes for company-specific things, as opposed to headers
|
||||
"company" {"" :company
|
||||
"/dropdown" :company-dropdown-search-results
|
||||
"/signature" {"/put" :company-update-signature}
|
||||
"/search" :company-search
|
||||
"/bank-account/typeahead" :bank-account-typeahead
|
||||
["/" [#"\d+" :db/id] "/bank-account"] {"/search" :bank-account-search}
|
||||
|
||||
Reference in New Issue
Block a user