diff options
author | Zhe Sun <31067185+ZheSun88@users.noreply.github.com> | 2019-06-14 15:31:44 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-06-14 15:31:44 +0300 |
commit | 7bda912a77f6295ac339a3035b0de8d7ed45cfa3 (patch) | |
tree | d49208274e8441ceedac8fa9ef292b3f065c846e /client | |
parent | d18f8ddbaab2d192dacf7d7485d87b51fe1e7cb9 (diff) | |
download | vaadin-framework-7bda912a77f6295ac339a3035b0de8d7ed45cfa3.tar.gz vaadin-framework-7bda912a77f6295ac339a3035b0de8d7ed45cfa3.zip |
Separates a rpc for handling the client event order in DateTimeField (#11574)
* Using @Delayed annotation for DateField Rpc
* Separate a rpc for handling the time change in DateTimeField
* Add test case for wrong event order
Diffstat (limited to 'client')
-rw-r--r-- | client/src/main/java/com/vaadin/client/ui/VAbstractPopupCalendar.java | 4 | ||||
-rw-r--r-- | client/src/main/java/com/vaadin/client/ui/VDateField.java | 20 |
2 files changed, 24 insertions, 0 deletions
diff --git a/client/src/main/java/com/vaadin/client/ui/VAbstractPopupCalendar.java b/client/src/main/java/com/vaadin/client/ui/VAbstractPopupCalendar.java index 2682973964..a199e2cd4a 100644 --- a/client/src/main/java/com/vaadin/client/ui/VAbstractPopupCalendar.java +++ b/client/src/main/java/com/vaadin/client/ui/VAbstractPopupCalendar.java @@ -496,6 +496,10 @@ public abstract class VAbstractPopupCalendar<PANEL extends VAbstractCalendarPane setText(previousValue); } updateTextFieldEnabled(); + bufferedDateString = text.getText(); + updateBufferedResolutions(); + // send the Time changes with delayed rpc. + sendBufferedValuesWithDelay(); } /** diff --git a/client/src/main/java/com/vaadin/client/ui/VDateField.java b/client/src/main/java/com/vaadin/client/ui/VDateField.java index 2d4136bd76..a6c5a158de 100644 --- a/client/src/main/java/com/vaadin/client/ui/VDateField.java +++ b/client/src/main/java/com/vaadin/client/ui/VDateField.java @@ -291,6 +291,26 @@ public abstract class VDateField<R extends Enum<R>> extends FlowPanel } /** + * Puts the {@link #bufferedDateString} and {@link #bufferedResolutions} + * changes into the rpc queue and clears their values. + * <p> + * Note: The value will not be sent to the server immediately. It will be + * sent when a non {@link com.vaadin.shared.annotations.Delayed} annotated + * rpc is triggered. + * </p> + * + * @since + */ + public void sendBufferedValuesWithDelay() { + rpc.updateValueWithDelay(bufferedDateString, + bufferedResolutions.entrySet().stream().collect( + Collectors.toMap(entry -> entry.getKey().name(), + entry -> entry.getValue()))); + bufferedDateString = null; + bufferedResolutions.clear(); + } + + /** * Returns all available resolutions for the field in the ascending order * (which is the same as order of enumeration ordinals). * <p> |