@@ -97,14 +97,14 @@ private void configure() {
9797 .findFirst ();
9898 if (newItem .isPresent ()) {
9999 selectedItems .put (chipLabel , newItem .get ());
100- this .setValue (new ArrayList <T >(selectedItems .values ()));
100+ this .setValue (new ArrayList <>(selectedItems .values ()));
101101 } else {
102102 if (isAllowAdditionalItems ()) {
103103 if (newItemHandler == null )
104104 throw new IllegalStateException ("You need to setup a NewItemHandler" );
105105 T item = this .newItemHandler .apply (chipLabel );
106106 selectedItems .put (chipLabel , item );
107- this . setValue (new ArrayList <T >(selectedItems .values ()));
107+ setValue (new ArrayList <>(selectedItems .values ()));
108108 } else {
109109 throw new IllegalStateException (
110110 "Adding new items is not allowed, but still receiving new items (not present in DataProvider) from client-side. Probably wrong configuration." );
@@ -118,8 +118,6 @@ private void configure() {
118118 getValue ().remove (itemToRemove );
119119 }).addEventData (CHIP_LABEL );
120120 getElement ().addEventListener ("chip-clicked" , e -> {
121- JsonObject eventData = e .getEventData ();
122- String chipLabel = eventData .get (CHIP_LABEL ).asString ();
123121 }).addEventData (CHIP_LABEL );
124122 }
125123
@@ -150,19 +148,19 @@ private Chip generateChip(T item) {
150148 }
151149
152150 private void appendClientChipWithoutEvent (Chip chip ) {
153- String function = " (function _appendChipWithoutEvent() {" + " if ($0.allowDuplicates) {"
154- + " $0.push('items', $1);" + " } else if ($0.items.indexOf($1) == -1) {"
155- + " $0.push('items', $1);" + " }" + " $0.required = false;"
156- + " $0.autoValidate = false;" + " $0._value = '';" + " })()" ;
157- UI .getCurrent ().getPage ().executeJs (function , this . getElement (), chip .getLabel ());
151+ String function = "(function _appendChipWithoutEvent() {" + "if ($0.allowDuplicates) {"
152+ + "$0.push('items', $1);" + "} else if ($0.items.indexOf($1) == -1) {"
153+ + "$0.push('items', $1);}" + "$0.required = false;"
154+ + "$0.autoValidate = false;" + "$0._value = '';" + "})()" ;
155+ UI .getCurrent ().getPage ().executeJs (function , getElement (), chip .getLabel ());
158156 }
159157
160158 private void removeClientChipWithoutEvent (Chip chip ) {
161- String function = " (function _removeChipByLabel() {"
162- + " const index = $0.items.indexOf($1);" + " if (index != -1) {"
163- + " $0.items.splice('availableItems', index, 1);" + " }"
164- + " })()" ;
165- UI .getCurrent ().getPage ().executeJs (function , this . getElement (), chip .getLabel ());
159+ String function = "(function _removeChipByLabel() {"
160+ + "const index = $0.items.indexOf($1);" + "if (index != -1) {"
161+ + "$0.items.splice('availableItems', index, 1);}"
162+ + "})()" ;
163+ UI .getCurrent ().getPage ().executeJs (function , getElement (), chip .getLabel ());
166164 }
167165
168166 public void setAvailableItems (List <T > items ) {
0 commit comments