]> source.dussan.org Git - vaadin-framework.git/commitdiff
The colon in the calendar event caption is now also hideable. Fixes #12460
authorJonatan Kronqvist <jonatan@vaadin.com>
Wed, 28 Aug 2013 13:04:54 +0000 (16:04 +0300)
committerVaadin Code Review <review@vaadin.com>
Mon, 2 Sep 2013 11:15:05 +0000 (11:15 +0000)
Change-Id: Idc81c3cc614bc59c2a93615bd5ac5cac9b72f752

WebContent/VAADIN/themes/tests-calendar/styles.css
client/src/com/vaadin/client/ui/calendar/schedule/DateCellDayEvent.java
uitest/src/com/vaadin/tests/components/calendar/TestHideTimeAndSeparator.html [new file with mode: 0644]
uitest/src/com/vaadin/tests/components/calendar/TestHideTimeAndSeparator.java [new file with mode: 0644]

index 7a37fcfdafa737dd443feeed6d75b5401b945a42..e3fa10775132a920d3659ac74254aaa6bbd68f68 100644 (file)
 .v-calendar .v-calendar-event-color4 .v-calendar-event-content {
        border-color: #cd6a00;
        background-color: #faa345;
-       }
\ No newline at end of file
+       }
+
+/**
+ * Hide time in captions
+ */
+.v-calendar-event-hide-time .v-calendar-event-caption>span,
+.v-calendar-event-hide-time .v-calendar-event-caption>br {
+    display: none;
+}
\ No newline at end of file
index b69d2a4fe7ee4b151b9b203f0bf608e9db78194c..39de122694282daaf1844a3dfd3e639366d8e778 100644 (file)
@@ -185,10 +185,15 @@ public class DateCellDayEvent extends FocusableHTML implements
      *            If false, event is so small that caption must be in time-row
      */
     private void updateCaptions(boolean bigMode) {
-        String separator = bigMode ? "<br />" : ": ";
-        caption.setInnerHTML("<span>" + calendarEvent.getTimeAsText()
-                + "</span>" + separator
-                + Util.escapeHTML(calendarEvent.getCaption()));
+        String innerHtml;
+        String escapedCaption = Util.escapeHTML(calendarEvent.getCaption());
+        String timeAsText = calendarEvent.getTimeAsText();
+        if (bigMode) {
+            innerHtml = "<span>" + timeAsText + "</span><br />" + escapedCaption;
+        } else {
+            innerHtml = "<span>" + timeAsText + "<span>:</span></span> " + escapedCaption;
+        }
+        caption.setInnerHTML(innerHtml);
         eventContent.setInnerHTML("");
     }
 
diff --git a/uitest/src/com/vaadin/tests/components/calendar/TestHideTimeAndSeparator.html b/uitest/src/com/vaadin/tests/components/calendar/TestHideTimeAndSeparator.html
new file mode 100644 (file)
index 0000000..38a6be2
--- /dev/null
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head profile="http://selenium-ide.openqa.org/profiles/test-case">
+    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+    <link rel="selenium.base" href="http://localhost:8888/" />
+    <title>TestHideTimeAndSeparator</title>
+</head>
+<body>
+<table cellpadding="1" cellspacing="1" border="1">
+    <thead>
+    <tr><td rowspan="1" colspan="3">TestHideTimeAndSeparator</td></tr>
+    </thead><tbody>
+<tr>
+    <td>open</td>
+    <td>/run/com.vaadin.tests.components.calendar.TestHideTimeAndSeparator?restartApplication</td>
+    <td></td>
+</tr>
+<tr>
+    <td>assertNotVisible</td>
+    <td>vaadin=runcomvaadintestscomponentscalendarTestHideTimeAndSeparator::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VCalendar[0]/domChild[0]/domChild[3]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[2]/domChild[0]/domChild[35]/domChild[0]/domChild[0]</td>
+    <td></td>
+</tr>
+<tr>
+    <td>assertNotVisible</td>
+    <td>vaadin=runcomvaadintestscomponentscalendarTestHideTimeAndSeparator::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VCalendar[0]/domChild[0]/domChild[3]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[2]/domChild[0]/domChild[34]/domChild[0]/domChild[0]</td>
+    <td></td>
+</tr>
+<tr>
+    <td>assertVisible</td>
+    <td>vaadin=runcomvaadintestscomponentscalendarTestHideTimeAndSeparator::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VCalendar[0]/domChild[0]/domChild[3]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[3]/domChild[0]/domChild[35]/domChild[0]/domChild[0]</td>
+    <td></td>
+</tr>
+<tr>
+    <td>assertVisible</td>
+    <td>vaadin=runcomvaadintestscomponentscalendarTestHideTimeAndSeparator::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VCalendar[0]/domChild[0]/domChild[3]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[3]/domChild[0]/domChild[34]/domChild[0]/domChild[0]</td>
+    <td></td>
+</tr>
+<tr>
+    <td>assertText</td>
+    <td>vaadin=runcomvaadintestscomponentscalendarTestHideTimeAndSeparator::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VCalendar[0]/domChild[0]/domChild[3]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[3]/domChild[0]/domChild[35]/domChild[0]/domChild[0]</td>
+    <td>8:00 AM:</td>
+</tr>
+
+</tbody></table>
+</body>
+</html>
diff --git a/uitest/src/com/vaadin/tests/components/calendar/TestHideTimeAndSeparator.java b/uitest/src/com/vaadin/tests/components/calendar/TestHideTimeAndSeparator.java
new file mode 100644 (file)
index 0000000..d82e75c
--- /dev/null
@@ -0,0 +1,105 @@
+package com.vaadin.tests.components.calendar;
+
+import com.vaadin.annotations.Theme;
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.ui.Calendar;
+import com.vaadin.ui.components.calendar.event.CalendarEvent;
+import com.vaadin.ui.components.calendar.event.CalendarEventProvider;
+
+import java.util.Arrays;
+import java.util.Date;
+import java.util.List;
+
+@Theme("tests-calendar")
+public class TestHideTimeAndSeparator extends AbstractTestUI {
+
+    class GenericEvent implements CalendarEvent {
+        private final Date start;
+        private final Date end;
+        private final String caption;
+        private final boolean hideTime;
+
+        public GenericEvent(Date start, Date end, String caption, boolean hideTime) {
+            this.start = start;
+            this.end = end;
+            this.caption = caption;
+            this.hideTime = hideTime;
+        }
+
+        @Override
+        public Date getStart() {
+            return start;
+        }
+
+        @Override
+        public Date getEnd() {
+            return end;
+        }
+
+        @Override
+        public String getCaption() {
+            return caption;
+        }
+
+        @Override
+        public String getDescription() {
+            return "This is a " + caption;
+        }
+
+        @Override
+        public String getStyleName() {
+            return hideTime ? "hide-time" : null;
+        }
+
+        @Override
+        public boolean isAllDay() {
+            return false;
+        }
+
+    }
+
+    CalendarEvent shortEventHidden = new GenericEvent(makeDate(2013, 1, 2, 8, 0), makeDate(2013, 1, 2, 8, 30), "Short event", true);
+    CalendarEvent longEventHidden = new GenericEvent(makeDate(2013, 1, 2, 10, 0), makeDate(2013, 1, 2, 12, 0), "Long event", true);
+    CalendarEvent shortEvent = new GenericEvent(makeDate(2013, 1, 3, 8, 0), makeDate(2013, 1, 3, 8, 30), "Short event", false);
+    CalendarEvent longEvent = new GenericEvent(makeDate(2013, 1, 3, 10, 0), makeDate(2013, 1, 3, 12, 0), "Long event", false);
+
+    @Override
+    protected void setup(VaadinRequest request) {
+        Calendar cal = new Calendar();
+        cal.setWidth("100%");
+        cal.setHeight("500px");
+
+        cal.addEvent(shortEventHidden);
+        cal.addEvent(longEventHidden);
+        cal.addEvent(shortEvent);
+        cal.addEvent(longEvent);
+
+        cal.setStartDate(makeDate(2013, 1, 1));
+        cal.setEndDate(makeDate(2013, 1, 7));
+        cal.setFirstVisibleHourOfDay(7);
+
+        addComponent(cal);
+    }
+
+    @Override
+    protected String getTestDescription() {
+        return "The time should be hideable by CSS";
+    }
+
+    @Override
+    protected Integer getTicketNumber() {
+        return 12460;
+    }
+
+    private Date makeDate(int year, int month, int day, int hour, int minute) {
+        java.util.Calendar juc = java.util.Calendar.getInstance();
+        juc.set(year, month, day, hour, minute);
+        return juc.getTime();
+    }
+    private Date makeDate(int year, int month, int day) {
+        java.util.Calendar juc = java.util.Calendar.getInstance();
+        juc.set(year, month, day);
+        return juc.getTime();
+    }
+}