This is an automated email from the ASF dual-hosted git repository.
mdisabatino pushed a commit to branch 2_1_X
in repository https://gitbox.apache.org/repos/asf/syncope.git
The following commit(s) were added to refs/heads/2_1_X by this push:
new cdd3d42 [SYNCOPE-1521] Role assignment filter
cdd3d42 is described below
commit cdd3d42a76ad007c4fe1a1e23d7be85ae9015b3d
Author: Marco Di Sabatino Di Diodoro <[email protected]>
AuthorDate: Wed Dec 4 07:34:27 2019 +0100
[SYNCOPE-1521] Role assignment filter
---
.../syncope/client/console/wizards/any/Roles.java | 31 +++++++++++++++++++---
1 file changed, 27 insertions(+), 4 deletions(-)
diff --git
a/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/Roles.java
b/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/Roles.java
index 974d7e9..fd05ced 100644
---
a/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/Roles.java
+++
b/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/Roles.java
@@ -44,6 +44,8 @@ public class Roles extends WizardStep implements ICondition {
private static final long serialVersionUID = 552437609667518888L;
+ private static final int MAX_ROLE_LIST_SIZE = 30;
+
private final List<String> allRoles;
public <T extends AnyTO> Roles(final AnyWrapper<?> modelObject) {
@@ -79,12 +81,33 @@ public class Roles extends WizardStep implements ICondition
{
: Collections.<String>emptyList();
Collections.sort(allRoles);
- add(new AjaxPalettePanel.Builder<String>().build("roles",
- new PropertyModel<List<String>>(entityTO, "roles"),
- new
ListModel<>(allRoles)).hideLabel().setOutputMarkupId(true));
+ add(new AjaxPalettePanel.Builder<String>().
+ withFilter().
+ setAllowOrder(true).
+ build("roles",
+ new PropertyModel<>(modelObject.getInnerObject(),
"roles"),
+ new AjaxPalettePanel.Builder.Query<String>() {
+
+ private static final long serialVersionUID =
3900199363626636719L;
+
+ @Override
+ public List<String> execute(final String filter) {
+ if (StringUtils.isEmpty(filter) || "*".equals(filter))
{
+ return allRoles.size() > MAX_ROLE_LIST_SIZE
+ ? allRoles.subList(0, MAX_ROLE_LIST_SIZE)
+ : allRoles;
+
+ }
+ return allRoles.stream().
+ filter(role ->
StringUtils.containsIgnoreCase(role, filter)).
+ collect(Collectors.toList());
+ }
+ }).
+ hideLabel().
+ setOutputMarkupId(true));
add(new AjaxPalettePanel.Builder<String>().build("dynroles",
- new PropertyModel<List<String>>(entityTO, "dynRoles"),
+ new PropertyModel<>(entityTO, "dynRoles"),
new
ListModel<>(allRoles)).hideLabel().setEnabled(false).setOutputMarkupId(true));
}