From 2de5284bd3280a5103b75ad7a59d8c4002c2cd3c Mon Sep 17 00:00:00 2001 From: Heikki Ohinmaa Date: Thu, 4 Sep 2014 15:26:00 +0300 Subject: [PATCH] Fix Valo DateField rendering in read-only FieldGroups (#14603) Change-Id: Icb05cffe68b948777036e282a2055e3343de9252 --- .../themes/valo/components/_datefield.scss | 6 ++--- .../vaadin/tests/themes/valo/DateFields.java | 25 ++++++++++++++++--- .../vaadin/tests/themes/valo/ValoThemeUI.java | 11 -------- .../tests/themes/valo/ValoThemeUITest.java | 2 +- 4 files changed, 26 insertions(+), 18 deletions(-) diff --git a/WebContent/VAADIN/themes/valo/components/_datefield.scss b/WebContent/VAADIN/themes/valo/components/_datefield.scss index b1d5dcce5b..48977d4d20 100644 --- a/WebContent/VAADIN/themes/valo/components/_datefield.scss +++ b/WebContent/VAADIN/themes/valo/components/_datefield.scss @@ -154,14 +154,14 @@ @include valo-textfield-prompt-style($background-color); } - [class$="button"] { + [class*="button"] { @include valo-datefield-button-style($unit-size: $unit-size, $bevel: $bevel, $background-color: $background-color, $border-radius: $border-radius, $border: $border); } &.v-disabled { @include opacity($v-disabled-opacity); - [class$="button"] { + [class*="button"] { cursor: default; pointer-events: none; &:active:after { @@ -175,7 +175,7 @@ @include valo-textfield-readonly-style; } - [class$="button"] { + [class*="button"] { cursor: default; pointer-events: none; &:active:after { diff --git a/uitest/src/com/vaadin/tests/themes/valo/DateFields.java b/uitest/src/com/vaadin/tests/themes/valo/DateFields.java index 7738b2d6db..5dca5ab9af 100644 --- a/uitest/src/com/vaadin/tests/themes/valo/DateFields.java +++ b/uitest/src/com/vaadin/tests/themes/valo/DateFields.java @@ -18,6 +18,9 @@ package com.vaadin.tests.themes.valo; import java.util.Date; import java.util.Locale; +import com.vaadin.data.fieldgroup.FieldGroup; +import com.vaadin.data.util.ObjectProperty; +import com.vaadin.data.util.PropertysetItem; import com.vaadin.navigator.View; import com.vaadin.navigator.ViewChangeListener.ViewChangeEvent; import com.vaadin.server.UserError; @@ -27,6 +30,7 @@ import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.CssLayout; import com.vaadin.ui.DateField; +import com.vaadin.ui.FormLayout; import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.InlineDateField; import com.vaadin.ui.Label; @@ -193,13 +197,29 @@ public class DateFields extends VerticalLayout implements View { date.setLocale(new Locale("fi", "fi")); date.setShowISOWeekNumbers(true); row.addComponent(date); + + PropertysetItem item = new PropertysetItem(); + item.addItemProperty("date", new ObjectProperty(getDefaultDate())); + + FormLayout form = new FormLayout(); + + FieldGroup binder = new FieldGroup(item); + form.addComponent(binder.buildAndBind( + "Picker in read-only field group", "date")); + binder.setReadOnly(true); + + row.addComponent(form); } private void setDate(DateField date) { + date.setValue(getDefaultDate()); + } + + private Date getDefaultDate() { if (ValoThemeUI.isTestMode()) { - date.setValue(new Date(2014 - 1900, 5, 7)); + return new Date(2014 - 1900, 5, 7); } else { - date.setValue(new Date()); + return new Date(); } } @@ -208,5 +228,4 @@ public class DateFields extends VerticalLayout implements View { // TODO Auto-generated method stub } - } diff --git a/uitest/src/com/vaadin/tests/themes/valo/ValoThemeUI.java b/uitest/src/com/vaadin/tests/themes/valo/ValoThemeUI.java index f30cec76cc..988b3487bd 100644 --- a/uitest/src/com/vaadin/tests/themes/valo/ValoThemeUI.java +++ b/uitest/src/com/vaadin/tests/themes/valo/ValoThemeUI.java @@ -101,12 +101,6 @@ public class ValoThemeUI extends UI { && getPage().getWebBrowser().getBrowserMajorVersion() == 9) { menu.setWidth("320px"); } - // Show .v-app-loading valo-menu-badge - // try { - // Thread.sleep(2000); - // } catch (InterruptedException e) { - // e.printStackTrace(); - // } if (!testMode) { Responsive.makeResponsive(this); @@ -434,7 +428,6 @@ public class ValoThemeUI extends UI { sg.nextString(true) + " " + sg.nextString(false)); child.getItemProperty(ICON_PROPERTY).setValue( testIcon.get()); - // ((Hierarchical) container).setChildrenAllowed(id, false); ((Hierarchical) container).setParent(id, i); for (int k = 1; k < 6; k++) { @@ -445,8 +438,6 @@ public class ValoThemeUI extends UI { + sg.nextString(false)); child.getItemProperty(ICON_PROPERTY).setValue( testIcon.get()); - // ((Hierarchical) container) - // .setChildrenAllowed(id, false); ((Hierarchical) container).setParent(id2, id); for (int l = 1; l < 5; l++) { @@ -457,8 +448,6 @@ public class ValoThemeUI extends UI { + sg.nextString(false)); child.getItemProperty(ICON_PROPERTY).setValue( testIcon.get()); - // ((Hierarchical) container) - // .setChildrenAllowed(id, false); ((Hierarchical) container).setParent(id3, id2); } } diff --git a/uitest/src/com/vaadin/tests/themes/valo/ValoThemeUITest.java b/uitest/src/com/vaadin/tests/themes/valo/ValoThemeUITest.java index 71f770ab8f..20c74bff5e 100644 --- a/uitest/src/com/vaadin/tests/themes/valo/ValoThemeUITest.java +++ b/uitest/src/com/vaadin/tests/themes/valo/ValoThemeUITest.java @@ -64,7 +64,7 @@ public class ValoThemeUITest extends MultiBrowserTest { // Note that this can look broken in IE9 because of some browser // rendering issue... The problem seems to be in the customized // horizontal layout in the test app - compareScreen("datefields"); + compareScreen("datefields-with-disabled"); } @Test -- 2.39.5