Some bugfixes for planner view in sitemgr:

- Add check on sel_options arrayMgr for missing owner names, since sidebox is not there
- Pre-fill sel_options for above, so they can be found
- Fix clicking on an event could alter the calendar state
This commit is contained in:
nathangray 2016-05-16 14:32:03 -06:00
parent 877d00b2ee
commit 2976d910db
5 changed files with 33 additions and 5 deletions

View File

@ -199,7 +199,7 @@ class calendar_owner_etemplate_widget extends Etemplate\Widget\Taglist
* Get just the label for a single owner * Get just the label for a single owner
* @param string $id * @param string $id
*/ */
protected static function get_owner_label($id) public static function get_owner_label($id)
{ {
static $bo; static $bo;
if(!$bo) $bo = new calendar_bo(); if(!$bo) $bo = new calendar_bo();

View File

@ -3446,7 +3446,11 @@ app.classes.calendar = (function(){ "use strict"; return AppJS.extend(
* hidden. * hidden.
*/ */
_set_autorefresh: function() { _set_autorefresh: function() {
// Listview not loaded
if(typeof app.classes.calendar.views.listview.etemplates[0] == 'string') return;
var nm = app.classes.calendar.views.listview.etemplates[0].widgetContainer.getWidgetById('nm'); var nm = app.classes.calendar.views.listview.etemplates[0].widgetContainer.getWidgetById('nm');
// nextmatch missing
if(!nm) return; if(!nm) return;
var refresh_preference = "nextmatch-" + nm.options.settings.columnselection_pref + "-autorefresh"; var refresh_preference = "nextmatch-" + nm.options.settings.columnselection_pref + "-autorefresh";

View File

@ -1779,7 +1779,7 @@ var et2_calendar_planner = (function(){ "use strict"; return et2_calendar_view.e
} }
return result; return result;
} }
else if (!jQuery.isEmptyObject(_ev.target.dataset)) else if (this.gridHeader.has(_ev.target).length > 0 && !jQuery.isEmptyObject(_ev.target.dataset))
{ {
// 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);

View File

@ -329,10 +329,19 @@ var et2_calendar_view = (function(){ "use strict"; return et2_valueWidget.extend
} }
if(typeof label === 'undefined') if(typeof label === 'undefined')
{ {
// Not found? Ask the sidebox owner widget, it gets updated // Not found? Ask the sidebox owner widget (it gets updated) or the original arrayMgr
var options = false
if(app.calendar && app.calendar.sidebox_et2 && app.calendar.sidebox_et2.getWidgetById('owner')) if(app.calendar && app.calendar.sidebox_et2 && app.calendar.sidebox_et2.getWidgetById('owner'))
{ {
user = app.calendar.sidebox_et2.getWidgetById('owner').options.select_options.find(function(element) {return element.id == user;}) || {}; options = app.calendar.sidebox_et2.getWidgetById('owner').options.select_options;
}
else
{
options = this.getArrayMgr("sel_options").getRoot().getEntry('owner');
}
if(options && options.find)
{
user = options.find(function(element) {return element.id == user;}) || {};
label = user.label; label = user.label;
} }
else else

View File

@ -306,6 +306,9 @@ class module_calendar_planner extends Module
$search_params['end'] = $ui->last; $search_params['end'] = $ui->last;
$search_params['owner'] = $ui->owner; $search_params['owner'] = $ui->owner;
$search_params['enum_groups'] = $ui->sortby == 'user'; $search_params['enum_groups'] = $ui->sortby == 'user';
$content = array();
$sel_options = array();
$content['planner'] = $ui->bo->search($search_params); $content['planner'] = $ui->bo->search($search_params);
foreach($content['planner'] as &$event) foreach($content['planner'] as &$event)
{ {
@ -318,7 +321,19 @@ class module_calendar_planner extends Module
$tmpl->setElementAttribute('planner','end_date', Api\DateTime::to($ui->last, Api\DateTime::ET2)); $tmpl->setElementAttribute('planner','end_date', Api\DateTime::to($ui->last, Api\DateTime::ET2));
$tmpl->setElementAttribute('planner','owner', $search_params['owner']); $tmpl->setElementAttribute('planner','owner', $search_params['owner']);
$tmpl->setElementAttribute('planner','group_by', $ui->sortby); $tmpl->setElementAttribute('planner','group_by', $ui->sortby);
$tmpl->exec(__METHOD__, $content,array(), array('__ALL__' => true),array(),2);
// Make sure all used owners are there, faking
// calendar_owner_etemplate_widget::beforeSendToClient() since the
// rest of the calendar app is probably missing.
foreach($search_params['owner'] as $owner)
{
$sel_options['owner'][] = Array(
'id' => $owner,
'value' => $owner,
'label' => calendar_owner_etemplate_widget::get_owner_label($owner)
);
}
$tmpl->exec(__METHOD__, $content,$sel_options, array('__ALL__' => true),array(),2);
$html .= ob_get_contents(); $html .= ob_get_contents();
$html .= '<script>' $html .= '<script>'
. ' window.egw_LAB.wait(function() {$j(function() {' . ' window.egw_LAB.wait(function() {$j(function() {'