You can now turn schedules on and off
This commit is contained in:
@@ -0,0 +1,2 @@
|
|||||||
|
-- 1522964310 DOWN add-email-schedule
|
||||||
|
ALTER TABLE companies DROP COLUMN invoice_reminder_schedule;
|
||||||
2
migrator/migrations/1522964310-UP-add-email-schedule.sql
Normal file
2
migrator/migrations/1522964310-UP-add-email-schedule.sql
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
-- 1522964310 UP add-email-schedule
|
||||||
|
ALTER TABLE companies ADD COLUMN invoice_reminder_schedule varchar(255);
|
||||||
@@ -19,5 +19,5 @@
|
|||||||
))
|
))
|
||||||
|
|
||||||
(defn upsert [id data]
|
(defn upsert [id data]
|
||||||
(j/update! (get-conn) :companies data ["id = ?" (Integer/parseInt id)] )
|
(j/update! (get-conn) :companies (clj->db data) ["id = ?" (Integer/parseInt id)] )
|
||||||
(merge-data (first (j/query (get-conn) ["SELECT * FROM companies WHERE id = ?" (Integer/parseInt id)]))))
|
(merge-data (db->clj (first (j/query (get-conn) ["SELECT * FROM companies WHERE id = ?" (Integer/parseInt id)])))))
|
||||||
|
|||||||
@@ -59,8 +59,7 @@
|
|||||||
profile (-> (http/get "https://www.googleapis.com/oauth2/v1/userinfo"
|
profile (-> (http/get "https://www.googleapis.com/oauth2/v1/userinfo"
|
||||||
{:headers {"Authorization" (str "Bearer " token)} :as :json})
|
{:headers {"Authorization" (str "Bearer " token)} :as :json})
|
||||||
:body
|
:body
|
||||||
(doto println)
|
(doto println))
|
||||||
)
|
|
||||||
user (users/find-or-insert! {:provider "google"
|
user (users/find-or-insert! {:provider "google"
|
||||||
:provider_id (:id profile)})]
|
:provider_id (:id profile)})]
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
{:db (assoc-in db [:admin-companies :editing :saving?] true)
|
{:db (assoc-in db [:admin-companies :editing :saving?] true)
|
||||||
:http {:method :put
|
:http {:method :put
|
||||||
:token (:user db)
|
:token (:user db)
|
||||||
:body (pr-str (select-keys edited-company [:name :email :data]))
|
:body (pr-str (select-keys edited-company [:name :email :data :invoice-reminder-schedule]))
|
||||||
:headers {"Content-Type" "application/edn"}
|
:headers {"Content-Type" "application/edn"}
|
||||||
:uri (str "/api/companies/" (:id edited-company))
|
:uri (str "/api/companies/" (:id edited-company))
|
||||||
:on-success [::save-complete]}})))
|
:on-success [::save-complete]}})))
|
||||||
@@ -36,5 +36,3 @@
|
|||||||
(fn [db [_ path value]]
|
(fn [db [_ path value]]
|
||||||
(assoc-in db (concat [:admin-companies :editing] path)
|
(assoc-in db (concat [:admin-companies :editing] path)
|
||||||
value)))
|
value)))
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -16,13 +16,15 @@
|
|||||||
[:thead
|
[:thead
|
||||||
[:tr
|
[:tr
|
||||||
[:th "Name"]
|
[:th "Name"]
|
||||||
[:th "Email"]]]
|
[:th "Email"]
|
||||||
[:tbody (for [{:keys [id name email data] :as c} @companies]
|
[:th "Invoice Reminders"]]]
|
||||||
|
[:tbody (for [{:keys [id name email data invoice-reminder-schedule] :as c} @companies]
|
||||||
^{:key (str name "-" id )}
|
^{:key (str name "-" id )}
|
||||||
[:tr {:on-click (fn [] (re-frame/dispatch [::events/edit id]))
|
[:tr {:on-click (fn [] (re-frame/dispatch [::events/edit id]))
|
||||||
:style {"cursor" "pointer"}}
|
:style {"cursor" "pointer"}}
|
||||||
[:td name]
|
[:td name]
|
||||||
[:td email]])]]))
|
[:td email]
|
||||||
|
[:td invoice-reminder-schedule]])]]))
|
||||||
|
|
||||||
(defn admin-companies-page []
|
(defn admin-companies-page []
|
||||||
[:div {:class "inbox-messages"}
|
[:div {:class "inbox-messages"}
|
||||||
@@ -32,11 +34,12 @@
|
|||||||
(let [companies (re-frame/subscribe [::subs/companies])
|
(let [companies (re-frame/subscribe [::subs/companies])
|
||||||
admin-companies (re-frame/subscribe [::subs/admin-companies])
|
admin-companies (re-frame/subscribe [::subs/admin-companies])
|
||||||
editing-company (:editing @admin-companies)]
|
editing-company (:editing @admin-companies)]
|
||||||
|
(println editing-company)
|
||||||
|
|
||||||
[:div
|
[:div
|
||||||
[:h1.title "Companies"]
|
[:h1.title "Companies"]
|
||||||
[companies-table]
|
[companies-table]
|
||||||
[:a.button.is-primary "New Company"]
|
|
||||||
|
|
||||||
|
|
||||||
(when editing-company
|
(when editing-company
|
||||||
@@ -61,18 +64,31 @@
|
|||||||
[:input.input {:type "email"
|
[:input.input {:type "email"
|
||||||
:value (:email editing-company)
|
:value (:email editing-company)
|
||||||
:on-change (dispatch-value-change [::events/change [:email]])}]]]
|
:on-change (dispatch-value-change [::events/change [:email]])}]]]
|
||||||
|
|
||||||
[:div.field
|
[:div.field
|
||||||
|
[:labal.label "Invoice Reminders"]
|
||||||
[:div.control
|
[:div.control
|
||||||
[:label.radio
|
[:label.radio
|
||||||
[:input {:type "radio" :name "schedule"}]
|
[:input {:type "radio"
|
||||||
"Send Invoice Reminders Weekly"]
|
:name "schedule"
|
||||||
|
:value "Weekly"
|
||||||
|
:checked (if (= "Weekly" (:invoice-reminder-schedule editing-company))
|
||||||
|
"checked"
|
||||||
|
"")
|
||||||
|
:on-change (dispatch-value-change [::events/change [:invoice-reminder-schedule]])}]
|
||||||
|
" Send weekly"]]
|
||||||
|
[:div.control
|
||||||
[:label.radio
|
[:label.radio
|
||||||
[:input {:type "radio" :name "schedule"}]
|
[:input {:type "radio"
|
||||||
"Do not send invoice reminders"]]]
|
:name "schedule"
|
||||||
|
:value "Never"
|
||||||
|
:checked (if (= "Never" (:invoice-reminder-schedule editing-company))
|
||||||
|
"checked"
|
||||||
|
"")
|
||||||
|
:on-change (dispatch-value-change [::events/change [:invoice-reminder-schedule]])}]
|
||||||
|
" Never"]]]
|
||||||
|
|
||||||
|
(when (:saving? editing-company) [:div.is-overlay {:style {"backgroundColor" "rgba(150,150,150, 0.5)"}}])]
|
||||||
|
|
||||||
(when (:saving? editing-company) [:div.is-overlay {:style {"background-color" "rgba(150,150,150, 0.5)"}}])]
|
|
||||||
|
|
||||||
[:footer.modal-card-foot
|
[:footer.modal-card-foot
|
||||||
[:a.button.is-primary {:on-click (fn [] (re-frame/dispatch [::events/save]))}
|
[:a.button.is-primary {:on-click (fn [] (re-frame/dispatch [::events/save]))}
|
||||||
@@ -80,4 +96,3 @@
|
|||||||
(when (:saving? editing-company)
|
(when (:saving? editing-company)
|
||||||
[:span.icon
|
[:span.icon
|
||||||
[:i.fa.fa-spin.fa-spinner]])]]]])])]]]])
|
[:i.fa.fa-spin.fa-spinner]])]]]])])]]]])
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user