Improvements on validations
This commit is contained in:
@@ -190,113 +190,114 @@
|
||||
(let [change-event [::forms/change ::form]
|
||||
{:keys [data] } @(re-frame/subscribe [::forms/form ::form])
|
||||
locations @(re-frame/subscribe [::subs/locations-for-client (:id (:client data))])
|
||||
{:keys [form field raw-field error-notification submit-button ]} transaction-form
|
||||
{:keys [form-inline form field raw-field error-notification submit-button ]} transaction-form
|
||||
is-admin? @(re-frame/subscribe [::subs/is-admin?])
|
||||
should-disable-for-client? (and (not is-admin?)
|
||||
(not= :requires-feedback (:original-status data)))]
|
||||
[form {:title "Transaction"}
|
||||
(form-inline {:title "Transaction"}
|
||||
[:<>
|
||||
|
||||
(when (and @(re-frame/subscribe [::subs/is-admin?])
|
||||
(get-in data [:yodlee-merchant]))
|
||||
[:div.control
|
||||
[:p.help "Merchant"]
|
||||
[:input.input {:type "text"
|
||||
:disabled true
|
||||
:value (str (get-in data [:yodlee-merchant :name])
|
||||
" - "
|
||||
(get-in data [:yodlee-merchant :yodlee-id]))}]])
|
||||
(when (and @(re-frame/subscribe [::subs/is-admin?])
|
||||
(get-in data [:yodlee-merchant]))
|
||||
[:div.control
|
||||
[:p.help "Merchant"]
|
||||
[:input.input {:type "text"
|
||||
:disabled true
|
||||
:value (str (get-in data [:yodlee-merchant :name])
|
||||
" - "
|
||||
(get-in data [:yodlee-merchant :yodlee-id]))}]])
|
||||
|
||||
(when is-admin?
|
||||
[field "Matched Rule"
|
||||
[:input.input {:type "text"
|
||||
:field [:matched-rule :note]
|
||||
:disabled "disabled"}]])
|
||||
[field "Amount"
|
||||
[:input.input {:type "text"
|
||||
:field [:amount]
|
||||
:disabled "disabled"}]]
|
||||
[field "Description"
|
||||
[:input.input {:type "text"
|
||||
:field [:description-original]
|
||||
:disabled "disabled"}]]
|
||||
(when is-admin?
|
||||
(field "Matched Rule"
|
||||
[:input.input {:type "text"
|
||||
:field [:matched-rule :note]
|
||||
:disabled "disabled"}]))
|
||||
(field "Amount"
|
||||
[:input.input {:type "text"
|
||||
:field [:amount]
|
||||
:disabled "disabled"}])
|
||||
(field "Description"
|
||||
[:input.input {:type "text"
|
||||
:field [:description-original]
|
||||
:disabled "disabled"}])
|
||||
|
||||
(cond
|
||||
(and (seq (:potential-transaction-rule-matches data))
|
||||
(not (:matched-rule data))
|
||||
(not (:payment data))
|
||||
is-admin?)
|
||||
[potential-transaction-rule-matches-box {:potential-transaction-rule-matches (:potential-transaction-rule-matches data)}]
|
||||
(cond
|
||||
(and (seq (:potential-transaction-rule-matches data))
|
||||
(not (:matched-rule data))
|
||||
(not (:payment data))
|
||||
is-admin?)
|
||||
[potential-transaction-rule-matches-box {:potential-transaction-rule-matches (:potential-transaction-rule-matches data)}]
|
||||
|
||||
|
||||
(and (seq (:potential-payment-matches data))
|
||||
(not (:payment data))
|
||||
is-admin?)
|
||||
[potential-payment-matches-box {:potential-payment-matches (:potential-payment-matches data)}]
|
||||
(and (seq (:potential-payment-matches data))
|
||||
(not (:payment data))
|
||||
is-admin?)
|
||||
[potential-payment-matches-box {:potential-payment-matches (:potential-payment-matches data)}]
|
||||
|
||||
(and (not (seq (:potential-payment-matches data)))
|
||||
(not (seq (:potential-transaction-rule-matches data))))
|
||||
[:div
|
||||
[field "Vendor"
|
||||
[typeahead-entity {:matches @(re-frame/subscribe [::subs/vendors])
|
||||
:match->text :name
|
||||
:type "typeahead-entity"
|
||||
:auto-focus true
|
||||
:field [:vendor]
|
||||
:disabled (or (boolean (:payment data))
|
||||
should-disable-for-client?)}]]
|
||||
[field nil
|
||||
[expense-accounts-field
|
||||
{:type "expense-accounts"
|
||||
:field [:accounts]
|
||||
:max (Math/abs (js/parseFloat (:amount data)))
|
||||
:descriptor "credit account"
|
||||
:disabled (or (boolean (:payment data))
|
||||
should-disable-for-client?)
|
||||
:locations locations}]]
|
||||
(and (not (seq (:potential-payment-matches data)))
|
||||
(not (seq (:potential-transaction-rule-matches data))))
|
||||
[:div
|
||||
(field "Vendor"
|
||||
[typeahead-entity {:matches @(re-frame/subscribe [::subs/vendors])
|
||||
:match->text :name
|
||||
:type "typeahead-entity"
|
||||
:auto-focus true
|
||||
:field [:vendor]
|
||||
:disabled (or (boolean (:payment data))
|
||||
should-disable-for-client?)}])
|
||||
(field nil
|
||||
[expense-accounts-field
|
||||
{:type "expense-accounts"
|
||||
:field [:accounts]
|
||||
:max (Math/abs (js/parseFloat (:amount data)))
|
||||
:descriptor "credit account"
|
||||
:disabled (or (boolean (:payment data))
|
||||
should-disable-for-client?)
|
||||
:locations locations}])
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
[field "Approval Status"
|
||||
[button-radio
|
||||
{:type "button-radio"
|
||||
:field [:approval-status]
|
||||
:options [[:unapproved "Unapproved"]
|
||||
[:requires-feedback "Client Review"]
|
||||
[:approved "Approved"]
|
||||
[:excluded "Excluded from Ledger"]]
|
||||
:disabled should-disable-for-client?}]]
|
||||
(field "Approval Status"
|
||||
[button-radio
|
||||
{:type "button-radio"
|
||||
:field [:approval-status]
|
||||
:options [[:unapproved "Unapproved"]
|
||||
[:requires-feedback "Client Review"]
|
||||
[:approved "Approved"]
|
||||
[:excluded "Excluded from Ledger"]]
|
||||
:disabled should-disable-for-client?}])
|
||||
|
||||
[field "Forecasted-transaction"
|
||||
[typeahead-entity {:matches (doto @(re-frame/subscribe [::subs/forecasted-transactions-for-client (:id (:client data))]) println)
|
||||
:match->text :identifier
|
||||
:type "typeahead-entity"
|
||||
:field [:forecast-match]}]]
|
||||
(field "Forecasted-transaction"
|
||||
[typeahead-entity {:matches @(re-frame/subscribe [::subs/forecasted-transactions-for-client (:id (:client data))])
|
||||
:match->text :identifier
|
||||
:type "typeahead-entity"
|
||||
:field [:forecast-match]}])
|
||||
|
||||
|
||||
[error-notification]
|
||||
(when-not should-disable-for-client?
|
||||
[submit-button "Save"])]
|
||||
|
||||
(error-notification)
|
||||
(when-not should-disable-for-client?
|
||||
(submit-button "Save"))]
|
||||
|
||||
:else
|
||||
|
||||
[:div
|
||||
[field "Approval Status"
|
||||
[button-radio
|
||||
{:type "button-radio"
|
||||
:field [:approval-status]
|
||||
:options [[:unapproved "Unapproved"]
|
||||
[:requires-feedback "Client Review"]
|
||||
[:approved "Approved"]
|
||||
[:excluded "Excluded from Ledger"]]
|
||||
:disabled should-disable-for-client?}]]
|
||||
:else
|
||||
|
||||
[:div
|
||||
(field "Approval Status"
|
||||
[button-radio
|
||||
{:type "button-radio"
|
||||
:field [:approval-status]
|
||||
:options [[:unapproved "Unapproved"]
|
||||
[:requires-feedback "Client Review"]
|
||||
[:approved "Approved"]
|
||||
[:excluded "Excluded from Ledger"]]
|
||||
:disabled should-disable-for-client?}])
|
||||
|
||||
[field "Forecasted-transaction"
|
||||
[typeahead-entity {:matches (doto @(re-frame/subscribe [::subs/forecasted-transactions-for-client (:id (:client data))]) println)
|
||||
:match->text :identifier
|
||||
:type "typeahead-entity"
|
||||
:field [:forecast-match]}]]
|
||||
(field "Forecasted-transaction"
|
||||
[typeahead-entity {:matches (doto @(re-frame/subscribe [::subs/forecasted-transactions-for-client (:id (:client data))]) println)
|
||||
:match->text :identifier
|
||||
:type "typeahead-entity"
|
||||
:field [:forecast-match]}])
|
||||
|
||||
[error-notification]
|
||||
(when-not should-disable-for-client?
|
||||
[submit-button "Save"])])])])
|
||||
(error-notification)
|
||||
(when-not should-disable-for-client?
|
||||
(submit-button "Save"))])]))])
|
||||
|
||||
Reference in New Issue
Block a user