Skip to content

Commit

Permalink
feat: concatenate error item lists
Browse files Browse the repository at this point in the history
  • Loading branch information
aatkin committed Nov 27, 2024
1 parent aaa461d commit c0f4e01
Showing 1 changed file with 13 additions and 18 deletions.
31 changes: 13 additions & 18 deletions src/cljs/rems/administration/status_flags.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -117,30 +117,25 @@
:href (str "/administration/workflows/" id)
:label (get-localized-title-for-anything item)}]])))

(defn- render-with-preview [items]
(defn- format-update-error [errors]
(r/with-let [expanded? (r/atom false)]
(when (seq items)
(let [item-count (count items)
shown-items (cond->> items
(not @expanded?) (take 5))]
[:div
(into [:ul] (map render-error-item) shown-items)
(when-some [items (seq (concat (:catalogue-items errors)
(:forms errors)
(:licenses errors)
(:resources errors)
(:workflows errors)
(:categories errors)))]
[:div
[:p (text (:type errors))]
(into [:ul] (map render-error-item) (cond->> items
(not @expanded?) (take 5)))
(let [item-count (count items)]
(when (> item-count 5)
[atoms/action-link
{:on-click #(swap! expanded? not)
:label (if @expanded?
(text :t.collapse/hide)
(text-format :t.label/parens (text :t.collapse/show) (- item-count 5)))}])]))))

(defn- format-update-error [{:keys [type catalogue-items forms licenses resources workflows categories]}]
[:<>
[:p (text type)]
[render-with-preview catalogue-items]
[render-with-preview forms]
[render-with-preview licenses]
[render-with-preview resources]
[render-with-preview workflows]
[render-with-preview categories]])
(text-format :t.label/parens (text :t.collapse/show) (- item-count 5)))}]))])))

(defn format-update-failure [{:keys [errors]}]
(into [:div]
Expand Down

0 comments on commit c0f4e01

Please sign in to comment.