supports terms.
This commit is contained in:
@@ -32,6 +32,8 @@
|
||||
;; 2017-09-19T07:00:00.000Z
|
||||
(def is-8601 #"^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$")
|
||||
|
||||
(def is-year-month-day #"^\d{4}-\d{2}-\d{2}$")
|
||||
|
||||
|
||||
(defn dates->date-times [x]
|
||||
(walk/postwalk
|
||||
@@ -42,6 +44,10 @@
|
||||
(re-matches is-8601 node))
|
||||
(format/parse (format/formatters :date-time) node)
|
||||
|
||||
(and (string? node)
|
||||
(re-matches is-year-month-day node))
|
||||
(time/from-default-time-zone (format/parse (format/formatters :year-month-day) node))
|
||||
|
||||
(instance? js/Date node)
|
||||
(time/to-default-time-zone (c/from-date node))
|
||||
|
||||
|
||||
@@ -34,11 +34,12 @@
|
||||
(re-frame/reg-sub
|
||||
::create-query
|
||||
:<- [::forms/form ::form]
|
||||
(fn [{:keys [data] {:keys [id invoice-number date location total expense-accounts vendor client]} :data}]
|
||||
(fn [{:keys [data] {:keys [id invoice-number date due location total expense-accounts vendor client]} :data}]
|
||||
{:venia/operation {:operation/type :mutation
|
||||
:operation/name "AddInvoice"}
|
||||
:venia/queries [{:query/data [:add-invoice
|
||||
{:invoice {:date date
|
||||
:due due
|
||||
:vendor-id (:id vendor)
|
||||
:client-id (:id client)
|
||||
:invoice-number invoice-number
|
||||
@@ -56,13 +57,14 @@
|
||||
(re-frame/reg-sub
|
||||
::edit-query
|
||||
:<- [::forms/form ::form]
|
||||
(fn [{:keys [data] {:keys [id invoice-number date location total expense-accounts vendor client]} :data}]
|
||||
(fn [{:keys [data] {:keys [id invoice-number date due location total expense-accounts vendor client]} :data}]
|
||||
{:venia/operation {:operation/type :mutation
|
||||
:operation/name "EditInvoice"}
|
||||
:venia/queries [{:query/data [:edit-invoice
|
||||
{:invoice {:id id
|
||||
:invoice-number invoice-number
|
||||
:date date
|
||||
:due due
|
||||
:total total
|
||||
:expense-accounts (map (fn [ea]
|
||||
{:id (when-not (str/starts-with? (:id ea) "new-")
|
||||
@@ -113,12 +115,14 @@
|
||||
::editing
|
||||
(fn [db [_ which]]
|
||||
(let [edit-invoice (update which :date #(date->str % standard))
|
||||
edit-invoice (update edit-invoice :due #(date->str % standard))
|
||||
edit-invoice (assoc edit-invoice :original edit-invoice)
|
||||
locations @(re-frame/subscribe [::subs/locations-for-client (:id (:client which))])]
|
||||
(-> db
|
||||
(forms/start-form ::form {:id (:id edit-invoice)
|
||||
:status (:status edit-invoice)
|
||||
:date (:date edit-invoice)
|
||||
:due (:due edit-invoice)
|
||||
:invoice-number (:invoice-number edit-invoice)
|
||||
:total (:total edit-invoice)
|
||||
:original edit-invoice
|
||||
@@ -243,6 +247,18 @@
|
||||
:field [:date]
|
||||
:spec ::invoice/date}]]
|
||||
|
||||
[field "Due (optional)"
|
||||
[date-picker {:class-name "input"
|
||||
:class "input"
|
||||
:format-week-number (fn [] "")
|
||||
:previous-month-button-label ""
|
||||
:placeholder "mm/dd/yyyy"
|
||||
:next-month-button-label ""
|
||||
:next-month-label ""
|
||||
:type "date"
|
||||
:field [:due]
|
||||
:spec ::invoice/due}]]
|
||||
|
||||
[field "Invoice #"
|
||||
[:input.input {:type "text"
|
||||
:field [:invoice-number]
|
||||
|
||||
Reference in New Issue
Block a user