Fix 24:00 crop
authorsstamer <s.stamer@metaways.de>
Fri, 19 Dec 2014 11:54:37 +0000 (12:54 +0100)
committerPhilipp Schüle <p.schuele@metaways.de>
Fri, 19 Dec 2014 12:58:03 +0000 (13:58 +0100)
- don't set height to 0 if offset is 0 (24:00 = no offset)

Change-Id: If585022a0abe1d85c518bfc4370df4951af05f82
Reviewed-on: http://gerrit.tine20.com/customers/1472
Reviewed-by: Philipp Schüle <p.schuele@metaways.de>
Tested-by: Philipp Schüle <p.schuele@metaways.de>
tine20/Calendar/Preference.php
tine20/Calendar/js/DaysView.js

index 2469e55..13e0d00 100644 (file)
@@ -148,17 +148,19 @@ class Calendar_Preference extends Tinebase_Preference_Abstract
      * @param string $default
      * @return string
      */
-    private function createTimespanDataXML($default)
+    protected function _createTimespanDataXML($start=0, $end=24)
     {
         $doc = new DomDocument('1.0');
         $options = $doc->createElement('options');
         $doc->appendChild($options);
         
         $time = new Tinebase_DateTime('@0');
-        for ($i=0; $i<48; $i++) {
-            $time->addMinute($i ? 30 : 0);
+        for ($i=$start; $i<=$end; $i++) {
+            $time->setHour($i);
             $timeString = $time->format('H:i');
-            
+            if ($i == $end && $timeString == '00:00') {
+                $timeString = '24:00';
+            }
             $value  = $doc->createElement('value');
             $value->appendChild($doc->createTextNode($timeString));
             $label  = $doc->createElement('label');
@@ -191,11 +193,11 @@ class Calendar_Preference extends Tinebase_Preference_Abstract
         switch ($_preferenceName) {
             case self::DAYSVIEW_STARTTIME:
                 $preference->value      = '08:00';
-                $preference->options = $this->createTimespanDataXML($preference->value);
+                $preference->options = $this->_createTimespanDataXML(0, 23);
                 break;
             case self::DAYSVIEW_ENDTIME:
                 $preference->value      = '18:00';
-                $preference->options = $this->createTimespanDataXML($preference->value);
+                $preference->options = $this->_createTimespanDataXML(1, 24);
                 break;
             case self::DEFAULTCALENDAR:
                 $this->_getDefaultContainerPreferenceDefaults($preference, $_accountId);
index 44fac9e..5045341 100644 (file)
@@ -224,11 +224,12 @@ Ext.extend(Tine.Calendar.DaysView, Ext.Container, {
         var prefs = this.app.getRegistry().get('preferences'),
             startTime = Date.parseDate(prefs.get('daysviewstarttime'), 'H:i'),
             endTime = Date.parseDate(prefs.get('daysviewendtime'), 'H:i');
-
+        
         this.dayStart = Ext.isDate(startTime) ? startTime : Date.parseDate(this.dayStart, 'H:i');
         this.dayEnd = Ext.isDate(endTime) ? endTime : Date.parseDate(this.dayEnd, 'H:i');
         this.dayEndPx = this.getTimeOffset(this.dayEnd);
-        this.cropDayTime = !! Tine.Tinebase.configManager.get('daysviewcroptime', 'Calendar');
+        
+        this.cropDayTime = !! Tine.Tinebase.configManager.get('daysviewcroptime', 'Calendar') && !(!this.getTimeOffset(this.dayStart) && !this.getTimeOffset(this.dayEnd));
         
         Tine.Calendar.DaysView.superclass.initComponent.apply(this, arguments);
     },
@@ -473,8 +474,10 @@ Ext.extend(Tine.Calendar.DaysView, Ext.Container, {
                 cropHeightPx = this.getTimeOffset(this.dayEnd) +2;
                 
             this.mainBody.setStyle('margin-top', '-' + cropStartPx + 'px');
-            this.mainBody.setStyle('height', cropHeightPx + 'px');
-            this.mainBody.setStyle('overflow', 'hidden');
+            if (this.getTimeOffset(this.dayEnd)) {
+                this.mainBody.setStyle('height', cropHeightPx + 'px');
+                this.mainBody.setStyle('overflow', 'hidden');
+            }
             this.scroller.addClass('cal-daysviewpanel-body-cropDayTime');
         }