fixed dates.
This commit is contained in:
@@ -74,6 +74,7 @@
|
||||
(re-frame/reg-event-db
|
||||
::change-form
|
||||
(fn [db [_ location field value]]
|
||||
(println location field value)
|
||||
(if value
|
||||
(assoc-in db (into location field) value)
|
||||
(update-in db location dissoc field))))
|
||||
|
||||
@@ -180,7 +180,7 @@
|
||||
[:li.menu-item
|
||||
[:a {:href (bidi/path-for routes/routes :unpaid-invoices), :class (str "item" (active-when= ap :unpaid-invoices))}
|
||||
[:span {:class "icon"}
|
||||
[:i {:class "fa fa-envelope-o"}]]
|
||||
[:i {:class "fa fa-envelope-open-o"}]]
|
||||
[:span {:class "name"} "Unpaid Invoices"]]
|
||||
]
|
||||
[:li.menu-item
|
||||
|
||||
@@ -8,15 +8,14 @@
|
||||
[auto-ap.entities.invoice :as invoice]
|
||||
[auto-ap.entities.vendors :as vendor]
|
||||
[auto-ap.entities.invoices-expense-accounts :as invoices-expense-accounts]
|
||||
[auto-ap.views.utils :refer [dispatch-event bind-field horizontal-field]]
|
||||
[auto-ap.views.utils :refer [dispatch-event bind-field horizontal-field date->str str->date pretty standard]]
|
||||
[auto-ap.utils :refer [by replace-if]]
|
||||
[auto-ap.views.pages.check :as check]
|
||||
[auto-ap.views.components.invoice-table :refer [invoice-table] :as invoice-table]
|
||||
[auto-ap.views.components.modal :refer [modal action-modal]]
|
||||
[auto-ap.views.components.typeahead :refer [typeahead]]
|
||||
[auto-ap.subs :as subs]
|
||||
[auto-ap.events :as events]
|
||||
[bulma-calendar.core :as bc]))
|
||||
[auto-ap.events :as events]))
|
||||
|
||||
(re-frame/reg-sub
|
||||
::invoice-page
|
||||
@@ -217,6 +216,8 @@
|
||||
[:id :total :outstanding-balance :date :invoice-number
|
||||
[:company [:id :name]]
|
||||
[:vendor [:id :name]]
|
||||
[:expense_accounts [:amount :id :expense_account_id
|
||||
[:expense_account [:id :name [:parent [:id :name]]]]]]
|
||||
]]}]}
|
||||
:on-success [::invoice-created]}})))
|
||||
|
||||
@@ -395,30 +396,6 @@
|
||||
:max outstanding-balance
|
||||
:step "0.01"}]]]]]])]]])))
|
||||
|
||||
#_(defn date-picker []
|
||||
(let [cal (r/atom nil)]
|
||||
(r/create-class
|
||||
{:component-did-mount (fn [this]
|
||||
|
||||
(reset! cal (new bc (r/dom-node this) (clj->js {:overlay false :dateFormat "mm/dd/yyyy"} )))
|
||||
nil)
|
||||
|
||||
:component-will-unmount (fn [this]
|
||||
(.hide @cal)
|
||||
nil)
|
||||
:reagent-render (fn [props]
|
||||
[:input ])})))
|
||||
(defn my-date [props]
|
||||
(let [cal (r/atom nil)]
|
||||
(r/create-class
|
||||
{:component-did-mount (fn [this]
|
||||
(reset! cal (new bc (r/dom-node this) (clj->js {:overlay false :dateFormat "yyyy-mm-dd"} )))
|
||||
|
||||
nil)
|
||||
:reagent-render (fn [props]
|
||||
[:input.input (merge props {:on-blur (fn [] (js/setTimeout 100 #(.hide @cal)) )}) ])})))
|
||||
|
||||
|
||||
|
||||
(defn new-invoice-modal []
|
||||
(let [data @(re-frame/subscribe [::new-invoice])
|
||||
@@ -446,11 +423,12 @@
|
||||
|
||||
|
||||
[bind-field
|
||||
[my-date {:type "date"
|
||||
[:input.input {:type "date"
|
||||
:field [:date]
|
||||
:event change-event
|
||||
:spec ::invoice/date
|
||||
:subscription data}]]]
|
||||
|
||||
[horizontal-field
|
||||
[:label.label "Company"]
|
||||
[bind-field
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
(ns auto-ap.views.utils
|
||||
(:require [re-frame.core :as re-frame]
|
||||
[clojure.spec.alpha :as s]
|
||||
[cljs-time.coerce :as c]
|
||||
[cljs-time.core :as time]
|
||||
[auto-ap.events :as events]
|
||||
[auto-ap.subs :as subs]
|
||||
[cljs-time.format :as format]))
|
||||
@@ -27,15 +29,22 @@
|
||||
|
||||
(def pretty-long (format/formatter "MM/dd/yyyy HH:mm:ss"))
|
||||
(def pretty (format/formatter "MM/dd/yyyy"))
|
||||
(def standard (format/formatter "yyyy-MM-MM"))
|
||||
|
||||
(defn date->str [d]
|
||||
(when d
|
||||
(format/unparse pretty d)))
|
||||
(defn date->str
|
||||
([d] (date->str d pretty))
|
||||
([d format]
|
||||
(when d
|
||||
(format/unparse format d))))
|
||||
|
||||
(defn date-time->str [d]
|
||||
(when d
|
||||
(format/unparse pretty-long d)))
|
||||
|
||||
(defn str->date [d f]
|
||||
(when d
|
||||
(format/parse f d)))
|
||||
|
||||
(defmulti do-bind (fn [a {:keys [type] :as x}]
|
||||
type))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user