fix(ssr): hide P&L warning box when there is no warning
The profit-and-loss report always passed :warning as a [:div ...] hiccup vector, which is truthy even when empty. The shared report table renders its red warning box with (when warning ...), so a clean report with no warning and no unresolved entries still showed an empty red error box. Only build the warning div when there is actual warning text or sample links, matching how the balance-sheet and cash-flows reports pass nil. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -129,7 +129,17 @@
|
|||||||
(let [{:keys [client warning]} (maybe-trim-clients request client)
|
(let [{:keys [client warning]} (maybe-trim-clients request client)
|
||||||
{:keys [data report]} (get-report (assoc-in request [:form-params :client] client))
|
{:keys [data report]} (get-report (assoc-in request [:form-params :client] client))
|
||||||
client-count (count (set (map :client-id (:data data))))
|
client-count (count (set (map :client-id (:data data))))
|
||||||
table-contents (concat-tables (concat (:summaries report) (:details report)))]
|
table-contents (concat-tables (concat (:summaries report) (:details report)))
|
||||||
|
warning-text (not-empty (str/join "\n " (filter not-empty [warning (:warning report)])))
|
||||||
|
sample-links (when (can? (:identity request)
|
||||||
|
{:subject :history
|
||||||
|
:activity :view})
|
||||||
|
(seq (for [n (:invalid-ids report)]
|
||||||
|
[:div
|
||||||
|
(com/link {:href (str (bidi/path-for ssr-routes/only-routes
|
||||||
|
:admin-history)
|
||||||
|
"/" n)}
|
||||||
|
"Sample")])))]
|
||||||
(list
|
(list
|
||||||
[:div.text-2xl.font-bold.text-gray-600 (str "Profit and loss - " (str/join ", " (map :client/name client)))]
|
[:div.text-2xl.font-bold.text-gray-600 (str "Profit and loss - " (str/join ", " (map :client/name client)))]
|
||||||
(table {:widths (into [20] (take (dec (cell-count table-contents))
|
(table {:widths (into [20] (take (dec (cell-count table-contents))
|
||||||
@@ -140,18 +150,8 @@
|
|||||||
[13 6])))))
|
[13 6])))))
|
||||||
:investigate-url (bidi.bidi/path-for ssr-routes/only-routes ::route/investigate)
|
:investigate-url (bidi.bidi/path-for ssr-routes/only-routes ::route/investigate)
|
||||||
:table table-contents
|
:table table-contents
|
||||||
:warning [:div
|
:warning (when (or warning-text sample-links)
|
||||||
(not-empty (str (str/join "\n " (filter not-empty [warning (:warning report)]))))
|
[:div warning-text sample-links])}))))])
|
||||||
|
|
||||||
(when (can? (:identity request)
|
|
||||||
{:subject :history
|
|
||||||
:activity :view})
|
|
||||||
(for [n (:invalid-ids report)]
|
|
||||||
[:div
|
|
||||||
(com/link {:href (str (bidi/path-for ssr-routes/only-routes
|
|
||||||
:admin-history)
|
|
||||||
"/" n)}
|
|
||||||
"Sample")]))]}))))])
|
|
||||||
|
|
||||||
(defn form* [request & children]
|
(defn form* [request & children]
|
||||||
(let [params (or (:query-params request) {})]
|
(let [params (or (:query-params request) {})]
|
||||||
|
|||||||
Reference in New Issue
Block a user