Skip to content

Update fragment #6820

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
type: change
issue: 6819
title: "Updated the IPS Utility Fragment `concat` (which concatenates lists of values of different types) to filter out duplicates when rendering Narrative data "
Original file line number Diff line number Diff line change
Expand Up @@ -157,38 +157,44 @@
<!--/* Lists */-->

<th:block th:if="${list}" th:fragment="concat (list, attr)">
<th:block th:each="item,iter : ${list}" th:if="${!list.empty}">
<th:block th:switch="${attr} ?: 'value'">
<th:block th:case="'display'">
<th:block th:replace=":: concatItem (listItem=${item.getDisplayElement()}, iter=${iter}, separator='')"/>
</th:block>
<th:block th:case="'code'">
<th:block th:replace=":: concatItem (listItem=${item.getCodeElement()}, iter=${iter}, separator='')"/>
</th:block>
<th:block th:case="'text'">
<th:block th:replace=":: concatItem (listItem=${item.getTextElement()}, iter=${iter}, separator='')"/>
</th:block>
<th:block th:case="'value'">
<th:block th:replace=":: concatItem (listItem=${item}, iter=${iter}, separator='')"/>
</th:block>
<th:block th:case="'severity'">
<th:block th:if="${item.getSeverity() != null}">
<th:block th:replace=":: concatItem (listItem=${item.getSeverity().toCode()}, iter=${iter}, separator='')"/>
</th:block>
</th:block>
</th:block>
</th:block>
<th:block th:with="projected=${list.{
#vars.attr == 'display' ? getDisplayElement() :
(#vars.attr == 'code' ? getCodeElement :
(#vars.attr == 'text' ? getTextElement :
(#vars.attr == 'value' ? #this :
(#vars.attr == 'severity' ? getSeverity() != null ? getSeverity().toCode() : null : null)))
)}}">
<th:block th:with="noNulls=${projected.{? #this != null} }">
<th:block th:with="stringValues=${noNulls.{ #this.getClass().getSimpleName() == 'String' ? #this : getValue()} }">

<!-- Convert to set for uniqueness -->
<th:block th:with="uniqueSet=${#sets.toSet(stringValues)}">

<!-- Iterate over the set and concatenate the values -->
<th:block th:each="item, iter : ${uniqueSet}">
<th:block th:if="${item != null}">
<th:block th:text="${item}">
</th:block>
<th:block th:if="${!iter.last}">
<br />
</th:block>
</th:block>
</th:block>
</th:block>
</th:block>
</th:block>
</th:block>
</th:block>

<th:block th:if="${listItem}" th:fragment="concatItem (listItem, iter, separator)">
<th:block th:if="${!listItem.empty}">
<th:block th:text="${listItem.getClass().getSimpleName() == 'String'} ? ${listItem} : ${listItem.getValue()}">
</th:block>
<th:block th:if="${!iter.last}">
<th:block th:if="${!separator.empty}" th:text="${separator + ' '}"/>
<br th:if="${separator.empty}"/>
</th:block>
</th:block>
<th:block th:if="${!listItem.empty}">
<th:block th:text="${listItem.getClass().getSimpleName() == 'String'} ? ${listItem} : ${listItem.getValue()}">
</th:block>
<th:block th:if="${!iter.last}">
<th:block th:if="${!separator.empty}" th:text="${separator + ' '}"/>
<br th:if="${separator.empty}"/>
</th:block>
</th:block>
</th:block>

<!--/* Nested Lists */-->
Expand Down
Loading