have generic attendee record proxy with fbInfo
authorCornelius Weiß <c.weiss@metaways.de>
Wed, 12 Jul 2017 10:02:34 +0000 (12:02 +0200)
committerCornelius Weiss <c.weiss@metaways.de>
Wed, 12 Jul 2017 09:59:12 +0000 (11:59 +0200)
Change-Id: I9a7be97f96213ebb8e32548dd204a8cc776def4f
Reviewed-on: http://gerrit.tine20.com/customers/5114
Reviewed-by: Cornelius Weiss <c.weiss@metaways.de>
Tested-by: Cornelius Weiss <c.weiss@metaways.de>
tine20/Calendar/js/AttendeePickerCombo.js
tine20/Calendar/js/Model.js
tine20/Tinebase/js/data/RecordProxy.js

index 6b4711a..127e707 100644 (file)
@@ -26,14 +26,21 @@ Tine.Calendar.AttendeePickerCombo = Ext.extend(Tine.Tinebase.widgets.form.Record
      */
     eventRecord: null,
 
+    /**
+     * @property {Tine.Calendar.Model.AttenderProxy} recordProxy
+     */
+    recordProxy: null,
+
     recordClass: Tine.Calendar.Model.Attender,
+
     itemSelector: '.cal-attendee-picker-combo-list-item',
 
     initComponent: function() {
         this.typeTemplates = {};
 
+        this.recordProxy = new Tine.Calendar.Model.AttenderProxy({});
+
         Tine.Calendar.AttendeePickerCombo.superclass.initComponent.call(this);
-        this.store.proxy.jsonReader.readRecords = this.readRecords.createDelegate(this);
     },
 
     onBeforeLoad: function(store, options) {
@@ -47,44 +54,8 @@ Tine.Calendar.AttendeePickerCombo = Ext.extend(Tine.Tinebase.widgets.form.Record
                 options.params.ignoreUIDs.push(this.eventRecord.get('uid'));
             }
         }
-    },
 
-    readRecords : function(resultData){
-        // Tine.Calendar.AttendeePickerCombo.superclass.onStoreBeforeLoadRecords.apply(this, arguments);
-
-        var _ = window.lodash,
-            totalcount = 0,
-            eventRecord = this.eventRecord,
-            records = [],
-            fbInfo = new Tine.Calendar.FreeBusyInfo(resultData.freeBusyInfo)
-
-        _.each(['user', 'group', 'resource'], function(type) {
-            var typeResult = _.get(resultData, type, {}),
-                typeCount = _.get(typeResult, 'totalcount', 0),
-                typeData = _.get(typeResult, 'results', []);
-
-            totalcount += +typeCount;
-            _.each(typeData, function(userData) {
-                var id = type + '-' + userData.id,
-                    attendeeData = _.assign(Tine.Calendar.Model.Attender.getDefaultData(), {
-                        id: id,
-                        user_type: type,
-                        user_id: userData
-                    }),
-                    attendee = new Tine.Calendar.Model.Attender(attendeeData, id);
-
-                if (_.get(eventRecord, 'data.dtstart')) {
-                    attendee.set('fbInfo', fbInfo.getStateOfAttendee(attendee, eventRecord));
-                }
-                records.push(attendee);
-            });
-        });
-
-        return {
-            success : true,
-            records: records,
-            totalRecords: totalcount
-        };
+        this.recordProxy.eventRecord = this.eventRecord
     },
 
     /**
index 66a078f..25fa928 100644 (file)
@@ -805,6 +805,56 @@ Tine.Calendar.Model.Attender.getAttendeeStore.getData = function(attendeeStore,
     return attendeeData;
 };
 
+// PROXY
+Tine.Calendar.Model.AttenderProxy = function(config) {
+    Tine.Calendar.Model.AttenderProxy.superclass.constructor.call(this, config);
+    this.jsonReader.readRecords = this.readRecords.createDelegate(this);
+};
+Ext.extend(Tine.Calendar.Model.AttenderProxy, Tine.Tinebase.data.RecordProxy, {
+    /**
+     * @cfg {Tine.Calendar.Model.Event} eventRecord
+     */
+    eventRecord: null,
+
+    recordClass: Tine.Calendar.Model.Attender,
+
+    readRecords : function(resultData){
+        var _ = window.lodash,
+            totalcount = 0,
+            eventRecord = this.eventRecord,
+            records = [],
+            fbInfo = new Tine.Calendar.FreeBusyInfo(resultData.freeBusyInfo)
+
+        _.each(['user', 'group', 'resource'], function(type) {
+            var typeResult = _.get(resultData, type, {}),
+                typeCount = _.get(typeResult, 'totalcount', 0),
+                typeData = _.get(typeResult, 'results', []);
+
+            totalcount += +typeCount;
+            _.each(typeData, function(userData) {
+                var id = type + '-' + userData.id,
+                    attendeeData = _.assign(Tine.Calendar.Model.Attender.getDefaultData(), {
+                        id: id,
+                        user_type: type,
+                        user_id: userData
+                    }),
+                    attendee = new Tine.Calendar.Model.Attender(attendeeData, id);
+
+                if (_.get(eventRecord, 'data.dtstart')) {
+                    attendee.set('fbInfo', fbInfo.getStateOfAttendee(attendee, eventRecord));
+                }
+                records.push(attendee);
+            });
+        });
+
+        return {
+            success : true,
+            records: records,
+            totalRecords: totalcount
+        };
+    }
+});
+
 /**
  * @namespace Tine.Calendar.Model
  * @class Tine.Calendar.Model.Resource
index 6b53eb0..1bb022a 100644 (file)
@@ -39,11 +39,11 @@ Tine.Tinebase.data.RecordProxy = function(c) {
              This might change in future, but as long as we do so, we also need
              the reader/writer here.
      */
-    this.jsonReader = new Ext.data.JsonReader({
+    this.jsonReader = new Ext.data.JsonReader(Ext.apply({
         id: this.idProperty,
         root: 'results',
         totalProperty: 'totalcount'
-    }, this.recordClass);
+    }, c.readerConfig || {}), this.recordClass);
 };
 
 Ext.extend(Tine.Tinebase.data.RecordProxy, Ext.data.DataProxy, {