/* * Tine 2.0 * * @license http://www.gnu.org/licenses/agpl.html AGPL Version 3 * @author Cornelius Weiss * @copyright Copyright (c) 2017 Metaways Infosystems GmbH (http://www.metaways.de) */ Ext.ns('Tine.Calendar'); /** * @namespace Tine.Calendar * @class Tine.Calendar.AbstractView * @extends Ext.Container * * Calendar abstract view * * @author Cornelius Weiss * @constructor * @param {Object} config */ Tine.Calendar.AbstractView = Ext.extend(Ext.Container, { /** * @cfg {String} eventCls * css class of event ui */ eventCls: '-evnet', initComponent: function() { this.initTemplates(); this.initData(this.store); if (! this.selModel) { this.selModel = new Tine.Calendar.EventSelectionModel(); } if (Ext.isFunction(this.unbufferedOnLayout)) { this.onLayout = Function.createBuffered(this.unbufferedOnLayout, 100, this); } Tine.Calendar.AbstractView.superclass.initComponent.apply(this, arguments); }, /** * @private * @param {Ext.data.Store} ds */ initData : function(ds){ if(this.store){ this.store.un("load", this.onLoad, this); this.store.un("beforeload", this.onBeforeLoad, this); this.store.un("add", this.onAdd, this); this.store.un("remove", this.onRemove, this); this.store.un("update", this.onUpdate, this); } if(ds){ ds.on("load", this.onLoad, this); ds.on("beforeload", this.onBeforeLoad, this); ds.on("add", this.onAdd, this); ds.on("remove", this.onRemove, this); ds.on("update", this.onUpdate, this); } this.store = ds; }, /** * fill the events into the view */ afterRender: function() { Tine.Calendar.AbstractView.superclass.afterRender.apply(this, arguments); this.mon(this.el, 'click', this.onClick, this); this.mon(this.el, 'dblclick', this.onDblClick, this); this.mon(this.el, 'contextmenu', this.onContextMenu, this); this.mon(this.el, 'keydown', this.onKeyDown, this); this.getSelectionModel().init(this); }, onBeforeLoad: function(store, options) { if (options.autoRefresh && this.editing) { return false; } if (! options.refresh) { this.removeAllEvents(); } }, /** * @private */ onLoad : function() { if(! this.rendered){ return; } // remove old events this.clearAll(); this.initParallelEventRegistry(); this.store.fields = Tine.Calendar.Model.Event.prototype.fields; this.store.sortInfo = {field: 'dtstart', direction: 'ASC'}; this.store.applySort(); this.store.each(function(event) { this.getParallelEventRegistry(event).register(event); }, this); // put the events in this.store.each(this.insertEvent, this); this.onLayout(); }, /** * @private */ onAdd : function(ds, records, index) { for (var i=0; i