Calendar et2 conversion work in progress.

- Home favorites with context menus
This commit is contained in:
Nathan Gray 2015-08-05 21:24:07 +00:00
parent 51ab65131f
commit 9903a5f926
13 changed files with 264 additions and 108 deletions

View File

@ -24,6 +24,8 @@ class calendar_favorite_portlet extends home_favorite_portlet
public function __construct(Array &$context = array(), &$need_reload = false) public function __construct(Array &$context = array(), &$need_reload = false)
{ {
$context['appname'] = 'calendar'; $context['appname'] = 'calendar';
// Reload is NULL when changing properties via AJAX
$reload = !is_null($need_reload);
// Let parent handle the basic stuff // Let parent handle the basic stuff
parent::__construct($context,$need_reload); parent::__construct($context,$need_reload);
@ -48,7 +50,9 @@ class calendar_favorite_portlet extends home_favorite_portlet
'default_cols' => 'cal_start_cal_end,cal_title' 'default_cols' => 'cal_start_cal_end,cal_title'
); );
} }
$need_reload = true;
// Checking against NULL allows us to skip the reload for resizing
$need_reload = $reload && $need_reload;
} }
public function exec($id = null, etemplate_new &$etemplate = null) public function exec($id = null, etemplate_new &$etemplate = null)
@ -95,8 +99,14 @@ class calendar_favorite_portlet extends home_favorite_portlet
case 'planner_user': case 'planner_user':
case 'planner_cat': case 'planner_cat':
case 'planner': case 'planner':
$content = array('legacy' => $ui->planner(true)); $content = array();
break; $etemplate->read('calendar.planner');
$etemplate->set_dom_id($id);
$this->actions =& $etemplate->getElementAttribute('planner', 'actions');
// Don't notify the calendar app of date changes
$etemplate->setElementAttribute('planner','onchange',false);
$ui->planner(array(), $etemplate);
return;
case 'year': case 'year':
$content = array('legacy' => $ui->year(true)); $content = array('legacy' => $ui->year(true));
break; break;
@ -109,15 +119,21 @@ class calendar_favorite_portlet extends home_favorite_portlet
case 'week': case 'week':
$etemplate->read('calendar.view'); $etemplate->read('calendar.view');
$etemplate->set_dom_id($id); $etemplate->set_dom_id($id);
$this->actions =& $etemplate->getElementAttribute('view', 'actions');
// Don't notify the calendar app of date changes
$etemplate->setElementAttribute('view[0]','onchange',false);
$ui->week(array(), $etemplate); $ui->week(array(), $etemplate);
return; return;
break;
case 'day': case 'day':
$content = array('legacy' => $ui->day(true));
break;
case 'day4': case 'day4':
$content = array('legacy' => $ui->week(4,true)); $etemplate->read('calendar.view');
break; $etemplate->set_dom_id($id);
$days = $this->favorite['state']['days'] ? $this->favorite['state']['days'] : (
$this->favorite['state']['view'] == 'day' ? 1 : 4
);
$this->actions =& $etemplate->getElementAttribute('view', 'actions');
$ui->week($days, $etemplate);
return;
} }
unset($GLOBALS['egw_info']['flags']['app_header']); unset($GLOBALS['egw_info']['flags']['app_header']);
@ -218,4 +234,15 @@ class calendar_favorite_portlet extends home_favorite_portlet
} }
return $properties; return $properties;
} }
}
public function get_actions() {
if($this->favorite['state']['view'] == 'listview' || !$this->actions)
{
return array();
}
else
{
return $this->actions;
}
}
}

View File

@ -2552,7 +2552,7 @@ class calendar_uiforms extends calendar_ui
* @param string $_eventId id of the event which has to be moved * @param string $_eventId id of the event which has to be moved
* @param string $calendarOwner the owner of the calendar the event is in * @param string $calendarOwner the owner of the calendar the event is in
* @param string $targetDateTime the datetime where the event should be moved to, format: YYYYMMDD * @param string $targetDateTime the datetime where the event should be moved to, format: YYYYMMDD
* @param string $targetOwner the owner of the target calendar * @param string|string[] $targetOwner the owner of the target calendar
* @param string $durationT the duration to support resizable calendar event * @param string $durationT the duration to support resizable calendar event
* @return string XML response if no error occurs * @return string XML response if no error occurs
*/ */
@ -2563,6 +2563,10 @@ class calendar_uiforms extends calendar_ui
{ {
$targetOwner = array($targetOwner); $targetOwner = array($targetOwner);
} }
if($targetOwner == 0 || is_array($targetOwner) && $targetOwner[0] == 0)
{
$targetOwner = $calendarOwner;
}
if($calendarOwner !== $targetOwner && !is_array($targetOwner)) if($calendarOwner !== $targetOwner && !is_array($targetOwner))
{ {
return false; return false;

View File

@ -336,9 +336,9 @@ class calendar_uiviews extends calendar_ui
/** /**
* Displays the planner view * Displays the planner view
* *
* @param boolean $home = false if true return content suitable for home-page * @param boolean|etemplate_new $home = false if etemplate return content suitable for home-page
*/ */
function &planner($home=false) function &planner($content = array(), $home=false)
{ {
if ($this->sortby == 'month') // yearly planner with month rows if ($this->sortby == 'month') // yearly planner with month rows
{ {
@ -401,20 +401,23 @@ class calendar_uiviews extends calendar_ui
$search_params['start'] = $this->first; $search_params['start'] = $this->first;
$search_params['end'] = $this->last; $search_params['end'] = $this->last;
$search_params['enum_groups'] = $this->sortby == 'user'; $search_params['enum_groups'] = $this->sortby == 'user';
$events =& $this->bo->search($search_params); $content['planner'] = $this->bo->search($search_params);
foreach($content['planner'] as &$event)
{
$this->to_client($event);
}
if ($this->debug > 0) $this->bo->debug_message('uiviews::planner() date=%1: first=%2, last=%3',False,$this->date,$this->bo->date2string($this->first),$this->bo->date2string($this->last)); if ($this->debug > 0) $this->bo->debug_message('uiviews::planner() date=%1: first=%2, last=%3',False,$this->date,$this->bo->date2string($this->first),$this->bo->date2string($this->last));
$content =& $this->plannerWidget($events,$this->first,$this->last,$this->sortby != 'category' ? $this->sortby : (int) $this->cat_id); $tmpl = $home ? $home :new etemplate_new('calendar.planner');
$tmpl->setElementAttribute('planner','start_date', egw_time::to($this->first, egw_time::ET2));
$tmpl->setElementAttribute('planner','end_date', egw_time::to($this->last, egw_time::ET2));
$tmpl->setElementAttribute('planner','group_by', $this->sortby);
// Get the actions
$tmpl->setElementAttribute('planner','actions',$this->get_actions());
if (!$home) $tmpl->exec(__METHOD__, $content);
{
$this->do_header();
echo $content;
}
return $content;
} }
/** /**
@ -878,7 +881,7 @@ class calendar_uiviews extends calendar_ui
else else
{ {
$wd_start = $this->first = $this->datetime->get_weekday_start($this->year,$this->month,$this->day); $wd_start = $this->first = $this->datetime->get_weekday_start($this->year,$this->month,$this->day);
if ($days == 5) // no weekend-days if ($days <= 5) // no weekend-days
{ {
switch($this->cal_prefs['weekdaystarts']) switch($this->cal_prefs['weekdaystarts'])
{ {
@ -905,7 +908,7 @@ class calendar_uiviews extends calendar_ui
$content = array('view' => array()); $content = array('view' => array());
// Always do 7 days for a week so scrolling works properly // Always do 7 days for a week so scrolling works properly
$this->last = ($days == 4 ? $this->last : $search_params['end'] = strtotime("+7 days",$this->first) - 1); $this->last = ($days == 4 ? $this->last : $search_params['end'] = strtotime("+$days days",$this->first) - 1);
if (count($users) == 1 || count($users) > $this->bo->calview_no_consolidate) // for more then X users, show all in one row if (count($users) == 1 || count($users) > $this->bo->calview_no_consolidate) // for more then X users, show all in one row
{ {
$content['view'][] = $this->tagWholeDayOnTop($this->bo->search($search_params)) + $content['view'][] = $this->tagWholeDayOnTop($this->bo->search($search_params)) +
@ -2925,6 +2928,11 @@ class calendar_uiviews extends calendar_ui
$actions['timesheet']['open'] = '{"app": "timesheet", "type": "add", "extra": "link_app[]=$app&link_id[]=$id"}'; $actions['timesheet']['open'] = '{"app": "timesheet", "type": "add", "extra": "link_app[]=$app&link_id[]=$id"}';
$actions['timesheet']['onExecute'] = 'javaScript:app.calendar.action_open'; $actions['timesheet']['onExecute'] = 'javaScript:app.calendar.action_open';
} }
if ($actions['documents'])
{
// TODO: See if we can get this working sensibly
$actions['documents']['enabled'] = false;
}
$actions['delete']['onExecute'] = 'javaScript:app.calendar.delete'; $actions['delete']['onExecute'] = 'javaScript:app.calendar.delete';

View File

@ -63,13 +63,6 @@ app.classes.calendar = AppJS.extend(
owner: egw.user('account_id'), owner: egw.user('account_id'),
days: egw.preference('days_in_weekview','calendar') days: egw.preference('days_in_weekview','calendar')
}, },
/**
* This is the data cache prefix for the daywise event index cache
* Daywise cache IDs look like: calendar_daywise::20150101 and
* contain a list of event IDs for that day (or empty array)
*/
DAYWISE_CACHE_ID: 'calendar_daywise',
/** /**
* Constructor * Constructor
@ -250,7 +243,7 @@ app.classes.calendar = AppJS.extend(
var event = egw.dataGetUIDdata('calendar::'+_id); var event = egw.dataGetUIDdata('calendar::'+_id);
if(event && event.data && event.data.date) if(event && event.data && event.data.date)
{ {
var new_cache_id = this._daywise_cache_id(event.data.date) var new_cache_id = app.classes.calendar._daywise_cache_id(event.data.date)
var daywise = egw.dataGetUIDdata(new_cache_id); var daywise = egw.dataGetUIDdata(new_cache_id);
daywise = daywise ? daywise.data : []; daywise = daywise ? daywise.data : [];
if(_type === 'delete') if(_type === 'delete')
@ -411,14 +404,51 @@ app.classes.calendar = AppJS.extend(
var start = new Date(app.calendar.state.date); var start = new Date(app.calendar.state.date);
var end = null; var end = null;
// Find the template
var id = $j(this).closest('.et2_container').attr('id');
if(!id) return;
var template = etemplate2.getById(id);
if(!template) return;
// Get the view to calculate // Get the view to calculate
var view = app.classes.calendar.views[app.calendar.state.view] || false; var view = app.classes.calendar.views[app.calendar.state.view] || false;
if (view) if (view && view.etemplates.indexOf(template) !== -1)
{ {
start = view.scroll(direction * delta); start = view.scroll(direction * delta);
app.calendar.update_state({date:app.calendar.date.toString(start)});
} }
else
{
// Home - always 1 week
// TODO
return false;
var widget = [];
var value = [];
template.widgetContainer.iterateOver(function(w) {
if(typeof w.set_start_date === 'function' && typeof w.set_value === 'function')
{
widget.push(w);
}
},this,et2_valueWidget);
for(var i = 0; i < widget.length; i++)
{
var state = template.widgetContainer.getParent().settings.favorite.state || {};
debugger;
var start = new Date(widget[i].options.start_date || state.start);
start.setUTCDate(start.getUTCDate() + (7 * direction * delta));
var end = new Date(widget[i].options.end_date || state.end);
end.setUTCDate(end.getUTCDate() + (7 * direction * delta));
app.calendar.update_state({date:app.calendar.date.toString(start)}); // Get data
value[i] = {
start_date: start,
end_date: end
};
app.calendar._need_data([value[i]], state);
widget[i].set_value(value[i]);
}
}
return false; return false;
} }
@ -1773,22 +1803,6 @@ app.classes.calendar = AppJS.extend(
} }
}, },
/**
* Create a cache ID for the daywise cache
*
* @param {String|Date} date
* @param {String|integer|String[]} owner
* @returns {String} Cache ID
*/
_daywise_cache_id: function(date, owner)
{
if(typeof date === 'object')
{
date = date.getUTCFullYear() + sprintf('%02d',date.getUTCMonth()+1) + sprintf('%02d',date.getUTCDate());
}
return this.DAYWISE_CACHE_ID+'::'+date+(owner && owner.toString() !== (this.state.owner.toString()||'') ? '-' + owner : '');
},
/** /**
* Take the date range(s) in the value and decide if we need to fetch data * Take the date range(s) in the value and decide if we need to fetch data
* for the date ranges, or if they're already cached fill them in. * for the date ranges, or if they're already cached fill them in.
@ -1815,7 +1829,7 @@ app.classes.calendar = AppJS.extend(
{ {
// Cache is by date (and owner, if seperate) // Cache is by date (and owner, if seperate)
var date = t.getUTCFullYear() + sprintf('%02d',t.getUTCMonth()+1) + sprintf('%02d',t.getUTCDate()); var date = t.getUTCFullYear() + sprintf('%02d',t.getUTCMonth()+1) + sprintf('%02d',t.getUTCDate());
var cache_id = this._daywise_cache_id(date, seperate_owners ? value[i].owner : false); var cache_id = app.classes.calendar._daywise_cache_id(date, seperate_owners ? value[i].owner : false);
if(egw.dataHasUID(cache_id)) if(egw.dataHasUID(cache_id))
{ {
@ -1940,7 +1954,7 @@ app.classes.calendar = AppJS.extend(
} }
for(var day in updated_days) for(var day in updated_days)
{ {
this.egw.dataStoreUID(this._daywise_cache_id(day, state.owner), updated_days[day]); this.egw.dataStoreUID(app.classes.calendar._daywise_cache_id(day, state.owner), updated_days[day]);
} }
}, this,null }, this,null
); );
@ -2041,6 +2055,9 @@ app.classes.calendar = AppJS.extend(
var hidden = typeof this.state.view !== 'undefined'; var hidden = typeof this.state.view !== 'undefined';
var all_loaded = true; var all_loaded = true;
// Avoid home portlets using our templates, and get them right
if(_et2.uniqueId.indexOf('portlet') === 0) return;
// Flag to make sure we don't hide non-view templates // Flag to make sure we don't hide non-view templates
var view_et2 = false; var view_et2 = false;
@ -2054,7 +2071,7 @@ app.classes.calendar = AppJS.extend(
// If a template disappears, we want to release it // If a template disappears, we want to release it
$j(_et2.DOMContainer).one('clear',jQuery.proxy(function() { $j(_et2.DOMContainer).one('clear',jQuery.proxy(function() {
this.view[index] = _name; this.view[index] = _name;
},{view: app.classes.calendar.views[view], index: index, name: _name})); },jQuery.extend({},{view: app.classes.calendar.views[view], index: ""+index, name: _name})));
if(this.state.view === view) if(this.state.view === view)
{ {
@ -2160,17 +2177,49 @@ app.classes.calendar = AppJS.extend(
} }
}); });
/**
* Etemplates and settings for the different views. Some (day view)
* use more than one template, some use the same template as others,
* most need different handling for their various attributes.
*
* Not using the standard Class.extend here because it hides the members,
* and we want to be able to look inside them. This is done seperately instead
* of inside the normal object to allow access to the View object.
*/
jQuery.extend(app.classes.calendar,{ jQuery.extend(app.classes.calendar,{
/**
* This is the data cache prefix for the daywise event index cache
* Daywise cache IDs look like: calendar_daywise::20150101 and
* contain a list of event IDs for that day (or empty array)
*/
DAYWISE_CACHE_ID: 'calendar_daywise',
/**
* Create a cache ID for the daywise cache
*
* @param {String|Date} date
* @param {String|integer|String[]} owner
* @returns {String} Cache ID
*/
_daywise_cache_id: function(date, owner)
{
if(typeof date === 'object')
{
date = date.getUTCFullYear() + sprintf('%02d',date.getUTCMonth()+1) + sprintf('%02d',date.getUTCDate());
}
// If the owner is not set, 0, or the current user, don't bother adding it
var _owner = (owner && owner.toString() != '0' && owner !== (app.calendar.state.owner.toString()||'')) ? owner.toString() : '';
if(_owner == egw.user('account_id'))
{
_owner = '';
}
return app.classes.calendar.DAYWISE_CACHE_ID+'::'+date+(_owner ? '-' + _owner : '');
},
/**
* Etemplates and settings for the different views. Some (day view)
* use more than one template, some use the same template as others,
* most need different handling for their various attributes.
*
* Not using the standard Class.extend here because it hides the members,
* and we want to be able to look inside them. This is done seperately instead
* of inside the normal object to allow access to the View object.
*/
views: { views: {
day: app.classes.calendar.prototype.View.extend({ day: app.classes.calendar.prototype.View.extend({
header: function(state) { header: function(state) {

View File

@ -7,6 +7,9 @@
* @author Nathan Gray * @author Nathan Gray
* @version $Id$ * @version $Id$
*/ */
/*egw:uses
/calendar/js/app.js;
*/
/** /**
* Custom code for calendar favorite home page portlets. * Custom code for calendar favorite home page portlets.
@ -26,12 +29,31 @@ observer: function(_msg, _app, _id, _type, _msg_type, _targetapp)
} }
else else
{ {
// No intelligence since we don't have access to the state var event = egw.dataGetUIDdata('calendar::'+_id);
// (app.calendar.getState() is for the calendar tab, not home) if(event && event.data && event.data.date)
// just refresh on every calendar or infolog change
if(_app == 'calendar' || _app == 'infolog')
{ {
app.home.refresh(this.portlet.id); var new_cache_id = app.classes.calendar._daywise_cache_id(event.data.date);
var daywise = egw.dataGetUIDdata(new_cache_id);
daywise = daywise ? daywise.data : [];
if(_type === 'delete')
{
daywise.splice(daywise.indexOf(_id),1);
}
else if (daywise.indexOf(_id) < 0)
{
daywise.push(_id);
}
egw.dataStoreUID(new_cache_id,daywise);
}
else
{
// No intelligence since we don't have access to the state
// (app.calendar.getState() is for the calendar tab, not home)
// just refresh on every calendar or infolog change
if(_app == 'calendar' || _app == 'infolog')
{
app.home.refresh(this.portlet.id);
}
} }
} }
} }

View File

@ -207,7 +207,10 @@ var et2_calendar_daycol = et2_valueWidget.extend([et2_IDetachedDOM, et2_IResizea
return; return;
} }
egw.dataUnregisterUID(app.calendar._daywise_cache_id+(this.options.date,this.options.owner),false,this); if(this.options.date)
{
egw.dataUnregisterUID(app.classes.calendar._daywise_cache_id(this.options.date,this.options.owner),false,this);
}
this.options.date = new_date; this.options.date = new_date;
@ -221,7 +224,8 @@ var et2_calendar_daycol = et2_valueWidget.extend([et2_IDetachedDOM, et2_IResizea
// Register for updates on events for this day // Register for updates on events for this day
egw.dataRegisterUID(app.calendar._daywise_cache_id(new_date,this.options.owner), function(event_ids) { var cache_id = app.classes.calendar._daywise_cache_id(new_date,this.options.owner);
egw.dataRegisterUID(cache_id, function(event_ids) {
var events = []; var events = [];
for(var i = 0; i < event_ids.length; i++) for(var i = 0; i < event_ids.length; i++)
{ {
@ -247,13 +251,13 @@ var et2_calendar_daycol = et2_valueWidget.extend([et2_IDetachedDOM, et2_IResizea
set_owner: function(_owner) { set_owner: function(_owner) {
if(_owner !== this.options.owner) if(_owner !== this.options.owner)
{ {
egw.dataUnregisterUID(app.calendar._daywise_cache_id+(this.options.date,this.options.owner),false,this); egw.dataUnregisterUID(app.classes.calendar._daywise_cache_id+(this.options.date,this.options.owner),false,this);
this.options.owner = parseInt(_owner); this.options.owner = parseInt(_owner);
this.div.attr('data-sortable-id', this.options.owner); this.div.attr('data-sortable-id', this.options.owner);
// Register for updates on events for this day // Register for updates on events for this day
egw.dataRegisterUID(app.calendar._daywise_cache_id(this.options.date,this.options.owner), function(event_ids) { egw.dataRegisterUID(app.classes.calendar._daywise_cache_id(this.options.date,this.options.owner), function(event_ids) {
var events = []; var events = [];
for(var i = 0; i < event_ids.length; i++) for(var i = 0; i < event_ids.length; i++)
{ {

View File

@ -470,7 +470,8 @@ var et2_calendar_event = et2_valueWidget.extend([et2_IDetachedDOM],
_link_actions: function(actions) _link_actions: function(actions)
{ {
// Get the top level element - timegrid or so // Get the top level element - timegrid or so
var objectManager = egw_getAppObjectManager(true).getObjectById(this._parent._parent._parent.id) || egw_getAppObjectManager(true); var objectManager = this.getParent().getParent()._actionObject ||
egw_getAppObjectManager(true).getObjectById(this._parent._parent._parent.id) || egw_getAppObjectManager(true);
var widget_object = objectManager.getObjectById('calendar::'+this.id); var widget_object = objectManager.getObjectById('calendar::'+this.id);
if (widget_object == null) { if (widget_object == null) {
// Add a new container to the object manager which will hold the widget // Add a new container to the object manager which will hold the widget
@ -576,7 +577,6 @@ et2_calendar_event.recur_prompt = function(event_data, callback)
}; };
et2_calendar_event.drag_helper = function(event,ui) { et2_calendar_event.drag_helper = function(event,ui) {
debugger;
ui.helper.width(ui.width()); ui.helper.width(ui.width());
}; };
/** /**

View File

@ -343,7 +343,13 @@ var et2_calendar_planner = et2_valueWidget.extend([et2_IDetachedDOM, et2_IResize
rows[event.category].push(event); rows[event.category].push(event);
if(typeof labels[event.category] === 'undefined') if(typeof labels[event.category] === 'undefined')
{ {
var categories = et2_selectbox.cat_options({_type:'select-cat'}, {application: 'calendar'}); labels[event.category] = '';
var im = this.getInstanceManager();
// Fake it to use the cache / call
var categories = et2_selectbox.cat_options({
_type:'select-cat',
getInstanceManager: function() {return im;}
}, {application: 'calendar'});
for(var i in categories ) for(var i in categories )
{ {
if(parseInt(categories[i].value) === parseInt(event.category)) if(parseInt(categories[i].value) === parseInt(event.category))
@ -727,6 +733,8 @@ var et2_calendar_planner = et2_valueWidget.extend([et2_IDetachedDOM, et2_IResize
{ {
var prev = new Date(t); var prev = new Date(t);
prev.setUTCDate(prev.getUTCDate() - 1); prev.setUTCDate(prev.getUTCDate() - 1);
prev.setUTCHours(0);
prev.setUTCMinutes(0);
title = this._scroll_button('left',prev.toJSON()) + title; title = this._scroll_button('left',prev.toJSON()) + title;
} }
if (i == days-1) // next day only for the last day if (i == days-1) // next day only for the last day
@ -864,18 +872,37 @@ var et2_calendar_planner = et2_valueWidget.extend([et2_IDetachedDOM, et2_IResize
// Get the parent? Might be a grid row, might not. Either way, it is // Get the parent? Might be a grid row, might not. Either way, it is
// just a container with no valid actions // just a container with no valid actions
var objectManager = egw_getAppObjectManager(true); var objectManager = egw_getAppObjectManager(true);
var parent = objectManager.getObjectById(this._parent.id); var parent = this;
if(!parent) return; var om = false;
while(parent && om !== objectManager)
for(var i = 0; i < parent.children.length; i++)
{ {
var parent_finder = jQuery(this.div, parent.children[i].iface.doGetDOMNode()); if(parent.id && objectManager.getObjectById(parent.id))
if(parent_finder.length > 0)
{ {
parent = parent.children[i]; om = objectManager.getObjectById(parent.id);
break; break;
} }
parent = parent.getParent();
} }
if(!om)
{
om = objectManager.getObjectById(this.getInstanceManager().uniqueId);
}
if(!om) return;
var widget_object = om.getObjectById(this.id);
if(widget_object == null)
{
widget_object = om.addObject(this.id, null, EGW_AO_FLAG_IS_CONTAINER);
}
// Go over the widget & add links - this is where we decide which actions are
// 'allowed' for this widget at this time
var action_links = this._get_action_links(actions);
this._init_links_dnd(widget_object.manager, action_links);
widget_object.updateActionLinks(action_links);
this._actionObject = widget_object;
}, },
/** /**
@ -888,8 +915,8 @@ var et2_calendar_planner = et2_valueWidget.extend([et2_IDetachedDOM, et2_IResize
var drag_action = mgr.getActionById('egw_link_drag'); var drag_action = mgr.getActionById('egw_link_drag');
// Check if this app supports linking // Check if this app supports linking
if(!egw.link_get_registry(this.dataStorePrefix || this.egw().appName, 'query') || if(!egw.link_get_registry(this.dataStorePrefix || 'calendar', 'query') ||
egw.link_get_registry(this.dataStorePrefix || this.egw().appName, 'title')) egw.link_get_registry(this.dataStorePrefix || 'calendar', 'title'))
{ {
if(drop_action) if(drop_action)
{ {
@ -962,17 +989,6 @@ var et2_calendar_planner = et2_valueWidget.extend([et2_IDetachedDOM, et2_IResize
{ {
// Create drag action that allows linking // Create drag action that allows linking
drag_action = mgr.addAction('drag', 'egw_link_drag', egw.lang('link'), 'link', function(action, selected) { drag_action = mgr.addAction('drag', 'egw_link_drag', egw.lang('link'), 'link', function(action, selected) {
// Drag helper - list titles. Arbitrarily limited to 10.
var helper = $j(document.createElement("div"));
for(var i = 0; i < selected.length && i < 10; i++)
{
var id = selected[i].id.split('::');
var span = $j(document.createElement('span')).appendTo(helper);
egw.link_title(id[0],id[1], function(title) {
this.append(title);
this.append('<br />');
}, span);
}
// As we wanted to have a general defaul helper interface, we return null here and not using customize helper for links // As we wanted to have a general defaul helper interface, we return null here and not using customize helper for links
// TODO: Need to decide if we need to create a customized helper interface for links anyway // TODO: Need to decide if we need to create a customized helper interface for links anyway
//return helper; //return helper;
@ -1026,7 +1042,7 @@ var et2_calendar_planner = et2_valueWidget.extend([et2_IDetachedDOM, et2_IResize
{ {
// Cache is by date (and owner, if seperate) // Cache is by date (and owner, if seperate)
var date = t.getUTCFullYear() + sprintf('%02d',t.getUTCMonth()+1) + sprintf('%02d',t.getUTCDate()); var date = t.getUTCFullYear() + sprintf('%02d',t.getUTCMonth()+1) + sprintf('%02d',t.getUTCDate());
var cache_id = app.calendar._daywise_cache_id(date, this.options.owner); var cache_id = app.classes.calendar._daywise_cache_id(date, this.options.owner);
if(egw.dataHasUID(cache_id)) if(egw.dataHasUID(cache_id))
{ {
@ -1082,7 +1098,20 @@ var et2_calendar_planner = et2_valueWidget.extend([et2_IDetachedDOM, et2_IResize
delete events.end_date; delete events.end_date;
} }
this.value = events || []; if(typeof events.length === "undefined" && events)
{
for(var key in events)
{
if(typeof events[key] === 'object' && events[key] !== null)
{
this.value.push(events[key]);
}
}
}
else
{
this.value = events || [];
}
}, },
/** /**
@ -1297,6 +1326,7 @@ var et2_calendar_planner = et2_valueWidget.extend([et2_IDetachedDOM, et2_IResize
{ {
// Click on a header, we can go there // Click on a header, we can go there
_ev.data = jQuery.extend({},_ev.target.parentNode.dataset, _ev.target.dataset); _ev.data = jQuery.extend({},_ev.target.parentNode.dataset, _ev.target.dataset);
debugger;
this.change(_ev); this.change(_ev);
} }
else else

View File

@ -93,7 +93,7 @@ var et2_calendar_planner_row = et2_valueWidget.extend([et2_IDetachedDOM],
*/ */
_draw: function() { _draw: function() {
// Remove any existing // Remove any existing
this.rows.empty().nextAll().remove(); this.rows.remove('.calendar_eventRowsMarkedDay,.calendar_eventRowsFiller').nextAll().remove();
var days = 31; var days = 31;
var width = 85; var width = 85;
@ -195,7 +195,7 @@ var et2_calendar_planner_row = et2_valueWidget.extend([et2_IDetachedDOM],
} }
// Copy actions set in parent // Copy actions set in parent
event._link_actions(this._parent._parent.options.actions||{}); event._link_actions(this._parent._parent.options.actions||this._parent.options.actions||{});
} }
// Seperate loop so column sorting finds all children in the right place // Seperate loop so column sorting finds all children in the right place

View File

@ -372,9 +372,9 @@ var et2_calendar_timegrid = et2_valueWidget.extend([et2_IDetachedDOM, et2_IResiz
this.widget.update_timer = null; this.widget.update_timer = null;
// Update actions // Update actions
if(this._actionManager) if(this.widget._actionManager)
{ {
this._link_actions(this._actionManager.children); this.widget._link_actions(this.widget._actionManager.children);
} }
this.widget._drawDays(); this.widget._drawDays();
@ -542,7 +542,7 @@ var et2_calendar_timegrid = et2_valueWidget.extend([et2_IDetachedDOM, et2_IResiz
// Set the date, and pass any data we have // Set the date, and pass any data we have
if(typeof this.value[this.day_list[i]] === 'undefined') if(typeof this.value[this.day_list[i]] === 'undefined')
{ {
var ids = (egw.dataGetUIDdata(app.calendar._daywise_cache_id(this.day_list[i],this.options.owner))||{data:[]}); var ids = (egw.dataGetUIDdata(app.classes.calendar._daywise_cache_id(this.day_list[i],this.options.owner))||{data:[]});
for(var j = 0; j < ids.length; j++) for(var j = 0; j < ids.length; j++)
{ {
this.value[this.day_list[i]] = []; this.value[this.day_list[i]] = [];
@ -620,9 +620,15 @@ var et2_calendar_timegrid = et2_valueWidget.extend([et2_IDetachedDOM, et2_IResiz
{ {
// Get the parent? Might be a grid row, might not. Either way, it is // Get the parent? Might be a grid row, might not. Either way, it is
// just a container with no valid actions // just a container with no valid actions
var objectManager = egw_getAppObjectManager(true); var objectManager = egw_getObjectManager(this.getInstanceManager().app,true,1);
var parent = objectManager.getObjectById(this._parent.id); objectManager = objectManager.getObjectById(this.getInstanceManager().uniqueId,2) || objectManager;
if(!parent) return; var parent = objectManager.getObjectById(this.id,3) || objectManager.getObjectById(this._parent.id,3) || objectManager;
if(!parent)
{
debugger;
egw.debug('error','No parent objectManager found')
return;
}
for(var i = 0; i < parent.children.length; i++) for(var i = 0; i < parent.children.length; i++)
{ {
@ -720,6 +726,7 @@ var et2_calendar_timegrid = et2_valueWidget.extend([et2_IDetachedDOM, et2_IResiz
this._init_links_dnd(widget_object.manager, action_links); this._init_links_dnd(widget_object.manager, action_links);
widget_object.updateActionLinks(action_links); widget_object.updateActionLinks(action_links);
this._actionObject = widget_object;
}, },
/** /**
@ -732,8 +739,8 @@ var et2_calendar_timegrid = et2_valueWidget.extend([et2_IDetachedDOM, et2_IResiz
var drag_action = mgr.getActionById('egw_link_drag'); var drag_action = mgr.getActionById('egw_link_drag');
// Check if this app supports linking // Check if this app supports linking
if(!egw.link_get_registry(this.dataStorePrefix || this.egw().appName, 'query') || if(!egw.link_get_registry(this.dataStorePrefix || 'calendar', 'query') ||
egw.link_get_registry(this.dataStorePrefix || this.egw().appName, 'title')) egw.link_get_registry(this.dataStorePrefix || 'calendar', 'title'))
{ {
if(drop_action) if(drop_action)
{ {

View File

@ -14,7 +14,7 @@ Egroupware
<overlay> <overlay>
<template id="calendar.planner"> <template id="calendar.planner">
<calendar-planner id="planner" <calendar-planner id="planner"
onchange="app.calendar.update_state(ev.data);" onchange="app.calendar.update_state(jQuery.extend(ev.data,{view:'planner'}));"
onevent_change="app.calendar.event_change" onevent_change="app.calendar.event_change"
> >
</calendar-planner> </calendar-planner>

View File

@ -463,9 +463,13 @@ var et2_DOMWidget = et2_widget.extend(et2_IDOMNode,
var gam = egw_getActionManager(this.egw().appName,true,1); var gam = egw_getActionManager(this.egw().appName,true,1);
if(typeof this._actionManager != "object") if(typeof this._actionManager != "object")
{ {
if(gam.getActionById(this.id) != null) if(gam.getActionById(this.getInstanceManager().uniqueId,1) !== null)
{ {
this._actionManager = gam.getActionById(this.id); gam = gam.getActionById(this.getInstanceManager().uniqueId,1);
}
if(gam.getActionById(this.id,1) != null)
{
this._actionManager = gam.getActionById(this.id,1);
} }
else else
{ {

View File

@ -927,6 +927,7 @@ var et2_grid = et2_DOMWidget.extend([et2_IDetachedDOM, et2_IAligned, et2_IResize
{ {
// Get the top level element for the tree // Get the top level element for the tree
var objectManager = egw_getAppObjectManager(true); var objectManager = egw_getAppObjectManager(true);
objectManager = objectManager.getObjectById(this.getInstanceManager().uniqueId,2) || objectManager;
var widget_object = objectManager.getObjectById(this.id); var widget_object = objectManager.getObjectById(this.id);
if (widget_object == null) { if (widget_object == null) {
// Add a new container to the object manager which will hold the widget // Add a new container to the object manager which will hold the widget