brutal process of getting sorting to not mess stuff up.

This commit is contained in:
Bryce Covert
2019-04-11 15:00:34 -07:00
parent 0eedc8908d
commit 5d93e3a5a3
3 changed files with 11 additions and 31 deletions

View File

@@ -10,28 +10,11 @@
#(-> % :transaction/client :client/name)
(= "account" sort-by)
#(-> % :transaction/account :account/name)
#(vector (-> % :transaction/account :account/name) (-> % :db/id))
:else
(keyword "transaction" sort-by)))
;; TODO - unneeeded with merge-query
(defn add-where [query & wheres]
(reduce #(update-in %1 [:query :where] conj %2) query wheres))
;; TODO - unneeeded with merge-query
(defn add-wheres [query wheres]
(apply add-where query wheres))
;; TODO - unneeeded with merge-query
(defn add-arg [query name value where & rest]
(let [query (-> query
(update :args conj value)
(update-in [:query :in] conj name)
(update-in [:query :where] conj where))]
(reduce #(update-in %1 [:query :where] conj %2) query rest)))
(defn add-sorter-field [q sort-map args]
(merge-query q
{:query {:find ['?sorter]
@@ -68,12 +51,13 @@
(:sort-by args) (add-sorter-field {"client" ['[?e :transaction/client ?c]
'[?c :client/name ?sorter]]
"account" #_['[(get-else $ ?e :transaction/account 0) ?sorter]]
['(or (and [?e :transaction/account ?c]
[?c :account/name ?sorter])
(and
[?e :transaction/client]
[(ground 0) ?c]
[(ground "") ?sorter]))]
['[?e :transaction/date]
'(or-join [?e ?sorter]
(and [?e :transaction/account ?c]
[?c :account/name ?sorter])
(and
(not [?e :transaction/account])
[(ground "") ?sorter]))]
"description-original" ['[?e :transaction/description-original ?sorter]]
"date" ['[?e :transaction/date ?sorter]]
"amount" ['[?e :transaction/amount ?sorter]]

View File

@@ -26,6 +26,7 @@
(defn edit-transaction [context {{:keys [id account_id vendor_id] :as transaction} :transaction} value]
(assert-can-see-client (:id context) (:db/id (d-transactions/get-by-id id)))
(println transaction)
@(d/transact (d/connect uri)
[{:db/id id
:transaction/vendor vendor_id

View File

@@ -39,12 +39,7 @@
:asc asc}
"Vendor"]
[sorted-column {:on-sort opc
:style {:width percentage-size :cursor "pointer"}
:sort-key "description-original"
:sort-by sort-by
:asc asc}
"Description"]
[sorted-column {:on-sort opc
@@ -90,7 +85,7 @@
[:td (if vendor
(:name vendor)
(str "Merchant '" "Hello" "'"))]
[:td description-original]
#_[:td description-original]
[:td (date->str date) ]
[:td.has-text-right (nf amount )]
[:td (:name account)]