Skip to content

Commit 0702ace

Browse files
javier-godoypaodb
authored andcommitted
feat: add json-migration-helper
1 parent 7a7c7dd commit 0702ace

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,11 @@
125125
</exclusion>
126126
</exclusions>
127127
</dependency>
128+
<dependency>
129+
<groupId>com.flowingcode.vaadin</groupId>
130+
<artifactId>json-migration-helper</artifactId>
131+
<version>0.0.1-SNAPSHOT</version>
132+
</dependency>
128133
<dependency>
129134
<groupId>org.slf4j</groupId>
130135
<artifactId>slf4j-simple</artifactId>

src/main/java/com/flowingcode/vaadin/addons/chipfield/ChipField.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import java.util.Optional;
2828
import java.util.concurrent.atomic.AtomicInteger;
2929
import java.util.stream.Stream;
30+
import com.flowingcode.vaadin.jsonmigration.JsonMigration;
3031
import com.vaadin.flow.component.AbstractField;
3132
import com.vaadin.flow.component.AttachEvent;
3233
import com.vaadin.flow.component.ComponentEvent;
@@ -151,7 +152,7 @@ private void configure() {
151152
.addEventListener(
152153
"chip-created",
153154
e -> {
154-
JsonObject eventData = e.getEventData();
155+
JsonObject eventData = JsonMigration.getEventData(e);
155156
String chipLabel = eventData.get(CHIP_LABEL).asString();
156157
T newItem =
157158
findItemByLabel(chipLabel)
@@ -178,7 +179,7 @@ private void configure() {
178179
.addEventListener(
179180
"chip-removed",
180181
e -> {
181-
JsonObject eventData = e.getEventData();
182+
JsonObject eventData = JsonMigration.getEventData(e);
182183
String chipLabel = eventData.get(CHIP_LABEL).asString();
183184
findItemByLabel(chipLabel).ifPresent(item -> removeSelectedItem(item, true));
184185
})
@@ -197,7 +198,7 @@ private void configureItems() {
197198
object.put("value", itemLabelGenerator.apply(item));
198199
array.set(index.getAndIncrement(), object);
199200
});
200-
getElement().setPropertyJson("source", array);
201+
JsonMigration.setPropertyJson(getElement(), "source", array);
201202
}
202203

203204
@Override

0 commit comments

Comments
 (0)