Revert "Crop daytimes"
authorPhilipp Schüle <p.schuele@metaways.de>
Thu, 24 Jul 2014 08:52:14 +0000 (10:52 +0200)
committerPhilipp Schüle <p.schuele@metaways.de>
Thu, 24 Jul 2014 08:52:14 +0000 (10:52 +0200)
there are still problems with this / should be fixed and reviewed once again

This reverts commit 48da31ef602eea3c14201de68698963afdd4e168.

tine20/Calendar/Config.php
tine20/Calendar/Preference.php
tine20/Calendar/css/daysviewpanel.css
tine20/Calendar/js/DaysView.js
tine20/Calendar/js/EventEditDialog.js

index f000c83..f357404 100644 (file)
@@ -35,14 +35,7 @@ class Calendar_Config extends Tinebase_Config_Abstract
      * @var string
      */
     const ATTENDEE_ROLES = 'attendeeRoles';
-
-    /**
-     * Crop days view
-     *
-     * @var string
-     */
-    const CROP_DAYS_VIEW = 'daysviewcroptime';
-
+    
     /**
      * MAX_FILTER_PERIOD_CALDAV
      * 
@@ -83,17 +76,7 @@ class Calendar_Config extends Tinebase_Config_Abstract
             'description'           => 'Calendars always selected regardless of all filter parameters. A valid use case might be to force the display of an certain holiday calendar.',
             'type'                  => 'array',
             'contents'              => 'string', // in fact this are ids of Tinebase_Model_Container of app Calendar and we might what to have te ui to autocreate pickers panel here? x-type? -> later
-            'clientRegistryInclude' => TRUE
-        
-        ),
-        self::CROP_DAYS_VIEW => array(
-                                   //_('Crop Days')
-            'label'                 => 'Crop Days',
-                                   //_('Crop calendar view configured start and endtime.')
-            'description'           => 'Crop calendar view configured start and endtime.',
-            'type'                  => Tinebase_Config_Abstract::TYPE_BOOL,
-            'clientRegistryInclude' => true,
-            'default'               => false
+            'clientRegistryInclude' => TRUE,
         
         ),
         self::ATTENDEE_STATUS => array(
index eefb377..3f01761 100644 (file)
@@ -22,15 +22,10 @@ class Calendar_Preference extends Tinebase_Preference_Abstract
     const DAYSVIEW_STARTTIME = 'daysviewstarttime';
     
     /**
-     * where daysvoew should be scrolled maximum up to
-     */
-    const DAYSVIEW_ENDTIME = 'daysviewendtime';
-
-    /**
      * default calendar all newly created/invited events are placed in
      */
     const DEFAULTCALENDAR = 'defaultCalendar';
-
+    
     /**
      * have name of default favorite an a central palce
      * _("All my events")
@@ -71,7 +66,6 @@ class Calendar_Preference extends Tinebase_Preference_Abstract
     {
         $allPrefs = array(
             self::DAYSVIEW_STARTTIME,
-            self::DAYSVIEW_ENDTIME,
             self::DEFAULTCALENDAR,
             self::DEFAULTPERSISTENTFILTER,
             self::NOTIFICATION_LEVEL,
@@ -97,10 +91,6 @@ class Calendar_Preference extends Tinebase_Preference_Abstract
                 'label'         => $translate->_('Start Time'),
                 'description'   => $translate->_('Position on the left time axis, day and week view should start with'),
             ),
-            self::DAYSVIEW_ENDTIME => array(
-                'label'         => $translate->_('End Time'),
-                'description'   => $translate->_('Position on the left time axis, day and week view should end with'),
-            ),
             self::DEFAULTCALENDAR  => array(
                 'label'         => $translate->_('Default Calendar'),
                 'description'   => $translate->_('The default calendar for invitations and new events'),
@@ -131,39 +121,6 @@ class Calendar_Preference extends Tinebase_Preference_Abstract
     }
     
     /**
-     * Creates XML Data for a combobox
-     *
-     * Hours: 0 to 24
-     *
-     * @param string $default
-     * @return string
-     */
-    private function createTimespanDataXML($default)
-    {
-        $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);
-            $timeString = $time->format('H:i');
-            
-            $value  = $doc->createElement('value');
-            $value->appendChild($doc->createTextNode($timeString));
-            $label  = $doc->createElement('label');
-            $label->appendChild($doc->createTextNode($timeString)); // @todo l10n
-            
-            $option = $doc->createElement('option');
-            $option->appendChild($value);
-            $option->appendChild($label);
-            $options->appendChild($option);
-        }
-        
-        return $doc->saveXML();
-    }
-
-    /**
      * get preference defaults if no default is found in the database
      *
      * @param string $_preferenceName
@@ -180,12 +137,28 @@ class Calendar_Preference extends Tinebase_Preference_Abstract
         
         switch ($_preferenceName) {
             case self::DAYSVIEW_STARTTIME:
+                $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);
+                    $timeString = $time->format('H:i');
+                    
+                    $value  = $doc->createElement('value');
+                    $value->appendChild($doc->createTextNode($timeString));
+                    $label  = $doc->createElement('label');
+                    $label->appendChild($doc->createTextNode($timeString)); // @todo l10n
+                    
+                    $option = $doc->createElement('option');
+                    $option->appendChild($value);
+                    $option->appendChild($label);
+                    $options->appendChild($option);
+                }
+                
                 $preference->value      = '08:00';
-                $preference->options = $this->createTimespanDataXML($preference->value);
-                break;
-            case self::DAYSVIEW_ENDTIME:
-                $preference->value      = '18:00';
-                $preference->options = $this->createTimespanDataXML($preference->value);
+                $preference->options = $doc->saveXML();
                 break;
             case self::DEFAULTCALENDAR:
                 $this->_getDefaultContainerPreferenceDefaults($preference, $_accountId);
index ba03139..85e024b 100644 (file)
@@ -69,9 +69,8 @@
 }
 
 .cal-daysviewpanel-scroller {
-    border-top: 1px solid #D0D0D0;
-    overflow-y: scroll;
-    overflow-x: hidden;
+       border-top: 1px solid #D0D0D0;
+    overflow:auto;
     position:relative;
 }
 
     display: none;
 }
 
-.cal-daysviewpanel-body-cropDayTime .cal-daysviewpanel-body-daycolumn-hint-above,
-.cal-daysviewpanel-body-cropDayTime .cal-daysviewpanel-body-daycolumn-hint-below {
-    display: none !important;
-}
-
 .cal-daysviewpanel-body-daycolumn-today {
     background-color: #EBF3FD;
 }
index cc3de1c..e8b9f79 100644 (file)
@@ -86,21 +86,6 @@ Ext.extend(Tine.Calendar.DaysView, Ext.Container, {
      */
     numOfDays: 4,
     /**
-     * @cfg {String} (H:i) dayStart
-     * generic start of the (work) day
-     */
-    dayStart: '08:00',
-    /**
-     * @cfg {String} (H:i) dayEnd
-     * generic end of the (work) day
-     */
-    dayEnd: '18:00',
-    /**
-     * @cfg {Bool} cropDayTime
-     * crop times before and after dayStart and dayEnd
-     */
-    cropDayTime: false,
-    /**
      * @cfg {String} newEventSummary
      * _('New Event')
      */
@@ -135,13 +120,6 @@ Ext.extend(Tine.Calendar.DaysView, Ext.Container, {
      * @type {Number}
      */
     scrollOffset: 19,
-
-    /**
-     * The time in milliseconds, a scroll should be delayed after using the mousewheel
-     * 
-     * @type Number
-     */
-    scrollBuffer: 200,
     
     /**
      * @property {bool} editing
@@ -219,16 +197,6 @@ Ext.extend(Tine.Calendar.DaysView, Ext.Container, {
         }
         
         this.onLayout = Function.createBuffered(this.onLayout, 100, this);
-
-        // apply preferences
-        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.cropDayTime = !! Tine.Tinebase.configManager.get('daysviewcroptime', 'Calendar');
-        
         Tine.Calendar.DaysView.superclass.initComponent.apply(this, arguments);
     },
     
@@ -287,6 +255,9 @@ Ext.extend(Tine.Calendar.DaysView, Ext.Container, {
                 if (data.event) {
                     var event = data.event;
                     
+                    // we dont support multiple dropping yet
+                    data.scope.getSelectionModel().select(event);
+                
                     var targetDateTime = Tine.Calendar.DaysView.prototype.getTargetDateTime.call(data.scope, e);
                     if (targetDateTime) {
                         var dtString = targetDateTime.format(targetDateTime.is_all_day_event ? Ext.form.DateField.prototype.format : 'H:i');
@@ -316,21 +287,13 @@ Ext.extend(Tine.Calendar.DaysView, Ext.Container, {
                 if (targetDate) {
                     var event = data.event;
                     
-                    var originalDuration = (event.get('dtend').getTime() - event.get('dtstart').getTime()) / Date.msMINUTE;
-                    
-                    // Get the new endDate to ensure it's not out of croptimes
-                    var copyTargetDate = targetDate;
-                    var newEnd = copyTargetDate.add(Date.MINUTE, originalDuration);
-                    
-                    v.dayEnd.setDate(newEnd.getDate());
-                       
                     // deny drop for missing edit grant or no time change
-                    if (! event.get('editGrant') || Math.abs(targetDate.getTime() - event.get('dtstart').getTime()) < Date.msMINUTE
-                            || ((v.cropDayTime == true) && (newEnd > v.dayEnd))) {
+                    if (! event.get('editGrant') || Math.abs(targetDate.getTime() - event.get('dtstart').getTime()) < Date.msMINUTE) {
                         return false;
                     }
                     
                     event.beginEdit();
+                    var originalDuration = (event.get('dtend').getTime() - event.get('dtstart').getTime()) / Date.msMINUTE;
                     
                     event.set('dtstart', targetDate);
                     
@@ -463,24 +426,16 @@ Ext.extend(Tine.Calendar.DaysView, Ext.Container, {
             this.onLoad.apply(this);
         }
         
-        // apply os specific scrolling space
-        Ext.fly(this.innerHd.firstChild.firstChild).setStyle('margin-right', Ext.getScrollBarWidth() + 'px');
-        
-        // crop daytime
-        if (this.cropDayTime) {
-            var cropStartPx = this.getTimeOffset(this.dayStart),
-                cropHeightPx = this.getTimeOffset(this.dayEnd);
-                
-            this.mainBody.setStyle('margin-top', '-' + cropStartPx + 'px');
-            this.mainBody.setStyle('height', cropHeightPx + 'px');
-            this.mainBody.setStyle('overflow', 'hidden');
-            this.scroller.addClass('cal-daysviewpanel-body-cropDayTime');
-        }
-        
         // scrollTo initial position
         this.isScrolling = true;
         try {
-            this.scrollTo(this.dayStart);
+            var startTimeString = this.app.getRegistry().get('preferences').get('daysviewstarttime');
+            var startTime = Date.parseDate(startTimeString, 'H:i');
+            if (! Ext.isDate(startTime)) {
+                throw new Ext.Error('no valid startime given');
+            }
+            
+            this.scrollTo(startTime);
         } catch (e) {
             this.scrollTo();
         }
@@ -515,7 +470,7 @@ Ext.extend(Tine.Calendar.DaysView, Ext.Container, {
      */
     onScroll: function(e, t, o) {
         var visibleHeight = this.scroller.dom.clientHeight,
-            visibleStart  = this.scroller.dom.scrollTop - this.mainBody.dom.offsetTop,
+            visibleStart  = this.scroller.dom.scrollTop,
             visibleEnd    = visibleStart + visibleHeight,
             vStartMinutes = this.getHeightMinutes(visibleStart),
             vEndMinutes   = this.getHeightMinutes(visibleEnd);
@@ -780,6 +735,19 @@ Ext.extend(Tine.Calendar.DaysView, Ext.Container, {
     onAppActivate: function(app) {
         if (app === this.app) {
             this.redrawWholeDayEvents();
+            
+            // get Preference
+//            try {
+//                var startTimeString = this.app.getRegistry().get('preferences').get('daysviewstarttime');
+//                var startTime = Date.parseDate(startTimeString, 'H:i');
+//                if (! Ext.isDate(startTime)) {
+//                    throw new Ext.Error('no valid startime given');
+//                }
+//                
+//                this.scroller.dom.scrollTop = this.getTimeOffset(startTime);
+//            } catch (e) {
+//                this.scrollToNow();
+//            }
         }
     },
     
@@ -838,20 +806,6 @@ Ext.extend(Tine.Calendar.DaysView, Ext.Container, {
                 dtend = dtend.add(Date.HOUR, 23).add(Date.SECOND, -1);
             }
             
-            // do not create an event exceeding the crop day time limit
-            if (this.cropDayTime) {
-                var format = 'Hms';
-                if (dtStart.format(format) >= this.dayEnd.format(format)) {
-                    return false;
-                }
-                
-                if (dtend.format(format) >= this.dayEnd.format(format)) {
-                    dtend.setHours(this.dayEnd.getHours());
-                    dtend.setMinutes(this.dayEnd.getMinutes());
-                    dtend.setSeconds(this.dayEnd.getSeconds());
-                }
-            }
-            
             var event = new Tine.Calendar.Model.Event(Ext.apply(Tine.Calendar.Model.Event.getDefaultData(), {
                 id: newId,
                 dtstart: dtStart, 
@@ -969,7 +923,7 @@ Ext.extend(Tine.Calendar.DaysView, Ext.Container, {
         }
         
         var rzInfo = event.ui.getRzInfo(rz, width, height);
-        
+
         if (rzInfo.diff != 0) {
             if (rzInfo.duration > 0) {
                 event.set('dtend', rzInfo.dtend);
@@ -985,42 +939,6 @@ Ext.extend(Tine.Calendar.DaysView, Ext.Container, {
             event.summaryEditor.setHeight(event.ui.getEls()[0].getHeight() -18);
         }
         
-        if (this.cropDayTime) {
-            // on crop day time the end date must have the same day as the start date
-            var thisDayEnd = this.dayEnd;
-            thisDayEnd.setDate(rzInfo.dtend.getDate());
-            thisDayEnd.setMonth(rzInfo.dtend.getMonth());
-            thisDayEnd.setYear(rzInfo.dtend.getYear() + 1900);
-            
-            // if date end exceeds the crop day limit, set end date to limit
-            if (rzInfo.dtend > thisDayEnd) {
-                event.set('dtend', thisDayEnd);
-                
-                if (event.isRangeAdd != true) {
-                    this.fireEvent('updateEvent', event);
-                }
-                
-                return;
-            }
-            
-            // check day
-            if (event.get('dtstart').getDate() != event.get('dtend').getDate()) {
-                
-                var myDayEnd = event.get('dtstart');
-                myDayEnd.setHours(this.dayEnd.getHours());
-                myDayEnd.setMinutes(this.dayEnd.getMinutes());
-                myDayEnd.setSeconds(this.dayEnd.getSeconds());
-                
-                event.set('dtend', myDayEnd);
-                
-                if (event.isRangeAdd != true) {
-                    this.fireEvent('updateEvent', event);
-                }
-                
-                return; 
-            }
-        }
-        
         // don't fire update events on rangeAdd
         if (rzInfo.diff != 0 && event != this.editing && ! event.isRangeAdd) {
             this.fireEvent('updateEvent', event);
@@ -1278,6 +1196,7 @@ Ext.extend(Tine.Calendar.DaysView, Ext.Container, {
         this.mon(this.scroller, 'scroll', this.onScroll, this, {buffer: 200});
         
         this.mainBody = new E(this.scroller.dom.firstChild);
+        
         this.dayCols = this.mainBody.dom.firstChild.lastChild.childNodes;
 
         this.focusEl = new E(this.el.dom.lastChild.lastChild);
index d5ecfed..29f1a79 100644 (file)
@@ -152,7 +152,7 @@ Tine.Calendar.EventEditDialog = Ext.extend(Tine.widgets.dialog.EditDialog, {
                                     fieldLabel: this.app.i18n._('End Time'),
                                     listeners: {scope: this, change: this.onDtEndChange},
                                     name: 'dtend',
-                                    requiredGrant: 'editGrant',
+                                    requiredGrant: 'editGrant'
                                 }, {
                                     columnWidth: .3,
                                     xtype: 'combo',
@@ -428,10 +428,6 @@ Tine.Calendar.EventEditDialog = Ext.extend(Tine.widgets.dialog.EditDialog, {
      * @param {} oldValue
      */
     onDtStartChange: function(dtStartField, newValue, oldValue) {
-        if (this.validateDtStart() == false) {
-            return false;
-        }
-        
         if (Ext.isDate(newValue) && Ext.isDate(oldValue)) {
             var dtEndField = this.getForm().findField('dtend'),
                 dtEnd = dtEndField.getValue();
@@ -439,8 +435,8 @@ Tine.Calendar.EventEditDialog = Ext.extend(Tine.widgets.dialog.EditDialog, {
             if (Ext.isDate(dtEnd)) {
                 var duration = dtEnd.getTime() - oldValue.getTime(),
                     newDtEnd = newValue.add(Date.MILLI, duration);
+                
                 dtEndField.setValue(newDtEnd);
-                this.validateDtEnd();
             }
         }
     },
@@ -515,21 +511,12 @@ Tine.Calendar.EventEditDialog = Ext.extend(Tine.widgets.dialog.EditDialog, {
         var dtEndField = this.getForm().findField('dtend');
         var dtEnd = dtEndField.getValue();
         
-        var prefs = this.app.getRegistry().get('preferences'),
-            endTime = Date.parseDate(prefs.get('daysviewendtime'), 'H:i');
-      
-        // Update to the selected day
-        endTime.setDate(dtEnd.getDate());
-                
         if (! Ext.isDate(dtEnd)) {
             dtEndField.markInvalid(this.app.i18n._('End date is not valid'));
             return false;
         } else if (Ext.isDate(dtStart) && dtEnd.getTime() - dtStart.getTime() <= 0) {
             dtEndField.markInvalid(this.app.i18n._('End date must be after start date'));
             return false;
-        } else if  (!! Tine.Tinebase.configManager.get('daysviewcroptime', 'Calendar') && dtEnd > endTime) {
-            dtEndField.markInvalid(this.app.i18n._('End date is not allowed to be be higher than the configured time range.'));
-            return false;
         } else {
             dtEndField.clearInvalid();
             return true;
@@ -540,18 +527,9 @@ Tine.Calendar.EventEditDialog = Ext.extend(Tine.widgets.dialog.EditDialog, {
         var dtStartField = this.getForm().findField('dtstart');
         var dtStart = dtStartField.getValue();
         
-        var prefs = this.app.getRegistry().get('preferences'),
-            startTime = Date.parseDate(prefs.get('daysviewstarttime'), 'H:i');
-      
-        // Update to the selected day
-        startTime.setDate(dtStart.getDate());
-        
         if (! Ext.isDate(dtStart)) {
             dtStartField.markInvalid(this.app.i18n._('Start date is not valid'));
             return false;
-        } else if  (!! Tine.Tinebase.configManager.get('daysviewcroptime', 'Calendar') && dtStart < startTime) {
-            dtStartField.markInvalid(this.app.i18n._('End date is not allowed to be be lower than the configured time range.'));
-            return false;
         } else {
             dtStartField.clearInvalid();
             return true;