0013184: ignore default container if it's not definitely selected
authorMichael Spahn <m.spahn@metaways.de>
Thu, 8 Jun 2017 15:13:46 +0000 (17:13 +0200)
committerCornelius Weiss <c.weiss@metaways.de>
Thu, 15 Jun 2017 12:47:56 +0000 (14:47 +0200)
!usermanaual

https://forge.tine20.org/view.php?id=13184

Change-Id: I8d9ab38473952c2ca1a7aed3fbe1fb632d45b395
Reviewed-on: http://gerrit.tine20.com/customers/4848
Reviewed-by: Cornelius Weiss <c.weiss@metaways.de>
Tested-by: Cornelius Weiss <c.weiss@metaways.de>
tine20/Calendar/Preference.php
tine20/Calendar/js/ColorManager.js
tine20/Calendar/js/DaysView.js
tine20/Calendar/js/MainScreenCenterPanel.js
tine20/Calendar/js/Model.js
tine20/Calendar/js/TreePanel.js
tine20/Tinebase/js/data/Record.js

index 275e93f..489bc79 100644 (file)
@@ -93,6 +93,11 @@ class Calendar_Preference extends Tinebase_Preference_Abstract
     const FIRSTDAYOFWEEK = 'firstdayofweek';
 
     /**
+     * default calendar strategy
+     */
+    const DEFAULT_CALENDAR_STRATEGY = 'defaultCalendarStrategy';
+
+    /**
      * @var string application
      */
     protected $_application = 'Calendar';
@@ -121,7 +126,8 @@ class Calendar_Preference extends Tinebase_Preference_Abstract
             self::DEFAULT_TIMEINCREMENT,
             self::DEFAULTATTENDEE_STRATEGY,
             self::DEFAULT_EVENTS_RRIVATE,
-            self::FIRSTDAYOFWEEK
+            self::FIRSTDAYOFWEEK,
+            self::DEFAULT_CALENDAR_STRATEGY
         );
         
         if ($cropDays) {
@@ -195,12 +201,16 @@ class Calendar_Preference extends Tinebase_Preference_Abstract
             ),
             self::DEFAULT_EVENTS_RRIVATE => array(
                 'label'         => $translate->_('Default set Events to privat'),
-                'description'   => $translate->_('If enabled every created event is always privat.'),
+                'description'   => $translate->_('If enabled every created event is always privat'),
             ),
             self::FIRSTDAYOFWEEK => array(
                 'label'         => $translate->_('First Day of Week'),
                 'description'   => $translate->_('On what day the week should be starting'),
             ),
+            self::DEFAULT_CALENDAR_STRATEGY => array(
+                'label'         => $translate->_('Default calendar strategy'),
+                'description'   => $translate->_('The calendar for new events if no container is selected'),
+            ),
         );
         
         return $prefDescriptions;
@@ -411,6 +421,20 @@ class Calendar_Preference extends Tinebase_Preference_Abstract
                         </option>
                     </options>';
                 break;
+            case self::DEFAULT_CALENDAR_STRATEGY:
+                $preference->value = 'default';
+                $preference->options    = '<?xml version="1.0" encoding="UTF-8"?>
+                    <options>
+                        <option>
+                            <label>Default Calendar</label>
+                            <value>default</value>
+                        </option>
+                        <option>
+                            <label>None</label>
+                            <value>none</value>
+                        </option>
+                    </options>';
+                break;
             default:
                 throw new Tinebase_Exception_NotFound('Default preference with name ' . $_preferenceName . ' not found.');
         }
index 23c0c26..eac8b42 100644 (file)
@@ -226,6 +226,10 @@ Tine.Calendar.colorStrategies['container'] = {
         var container = null,
             color = null,
             schema = null;
+
+        if (null === container) {
+            return;
+        }
         
         if (! Ext.isFunction(event.get)) {
             // tree comes with containers only
index 62a6f2e..0c75a96 100644 (file)
@@ -696,7 +696,7 @@ Ext.extend(Tine.Calendar.DaysView, Ext.Container, {
      */
     createEvent: function(e, event) {
         // only add range events if mouse is down long enough
-        if (this.editing || (event.isRangeAdd && ! this.mouseDown)) {
+        if (this.editing || (event.isRangeAdd && ! this.mouseDown) || !event.isValid()) {
             return;
         }
         
@@ -928,7 +928,7 @@ Ext.extend(Tine.Calendar.DaysView, Ext.Container, {
                 dtend: dtend,
                 is_all_day_event: dtStart.is_all_day_event
             }), newId);
-            
+
             this.createEvent(e, event);
             event.dirty = true;
         } else if (target.className == 'cal-daysviewpanel-dayheader-day'){
index d7a8caa..3ed067e 100644 (file)
@@ -1330,9 +1330,10 @@ Tine.Calendar.MainScreenCenterPanel = Ext.extend(Ext.Panel, {
         if (action === 'edit' && (! event || event.dirty)) {
             return;
         }
-        
+
         if (! event) {
             event = new Tine.Calendar.Model.Event(Ext.apply(Tine.Calendar.Model.Event.getDefaultData(), defaults), 0);
+
             if (defaults && Ext.isDate(defaults.dtStart)) {
                 event.set('dtstart', defaults.dtStart);
                 event.set('dtend', defaults.dtStart.add(Date.MINUTE, Tine.Calendar.Model.Event.getMeta('defaultEventDuration')));
index 3aff9bb..cb68ddb 100644 (file)
@@ -75,6 +75,7 @@ Tine.Calendar.Model.Event = Tine.Tinebase.data.Record.create(Tine.Tinebase.Model
     containerName: 'Calendar',
     containersName: 'Calendars',
     copyOmitFields: ['uid', 'recurid'],
+    allowBlankContainer: false,
     
     /**
      * mark record out of current filter
@@ -220,7 +221,7 @@ Tine.Calendar.Model.Event.getDefaultAttendee = function(organizer, container) {
         filteredContainers = westPanel.getContainerTreePanel().getFilterPlugin().getFilter().value || [],
         prefs = app.getRegistry().get('preferences'),
         defaultAttendeeStrategy = prefs.get('defaultAttendeeStrategy') || 'me',// one of['me', 'intelligent', 'calendarOwner', 'filteredAttendee', 'none']
-        defaultAttendee = []
+        defaultAttendee = [],
         calendarResources = app.getRegistry().get('calendarResources');
         
     // shift -> change intelligent <-> me
index d90ee58..7adc191 100644 (file)
@@ -211,5 +211,20 @@ Tine.Calendar.TreePanel = Ext.extend(Tine.widgets.container.TreePanel, {
         if (abort) {
             return false;
         }
+    },
+
+    getSelectedContainer: function(requiredGrants, defaultContainer, onlySingle) {
+        var prefs = this.app.getRegistry().get('preferences');
+
+        if ('none' === prefs.get('defaultCalendarStrategy')) {
+            var sm = this.getSelectionModel(),
+                selection = typeof sm.getSelectedNodes == 'function' ? sm.getSelectedNodes() : [sm.getSelectedNode()];
+
+            if (selection.length > 1 || selection.length === 0) {
+                return null;
+            }
+        }
+
+        return this.supr().getSelectedContainer(requiredGrants, defaultContainer, onlySingle);
     }
 });
index b2619c7..ed5a950 100644 (file)
@@ -228,6 +228,9 @@ Tine.Tinebase.data.Record.create = function(o, meta) {
         return field.name;
     });
     for(var i = 0, len = o.length; i < len; i++) {
+        if (o[i]['name'] == meta.containerProperty && meta.allowBlankContainer === false) {
+            o[i]['allowBlank'] = false;
+        }
         p.fields.add(new Ext.data.Field(o[i]));
     }
     f.getField = function(name) {