diff --git a/calendar/inc/class.calendar_ui.inc.php b/calendar/inc/class.calendar_ui.inc.php index cf2201ca82..dee2165e22 100644 --- a/calendar/inc/class.calendar_ui.inc.php +++ b/calendar/inc/class.calendar_ui.inc.php @@ -613,7 +613,6 @@ class calendar_ui } $sidebox = new etemplate_new('calendar.sidebox'); - $content = $this->cal_prefs['saved_states']; $content['view'] = $this->view ? $this->view : 'week'; $content['date'] = $this->date ? $this->date : egw_time(); @@ -633,63 +632,6 @@ class calendar_ui } $readonlys = array(); - foreach(array( - array( - 'text' => lang('dayview'), - 'value' => '{"view":"day"}', - 'selected' => $this->view == 'day', - ), - array( - 'text' => lang('four days view'), - 'value' => '{"view":"day4","days":4}', - 'selected' => $this->view == 'day4', - ), - array( - 'text' => lang('weekview'), - 'value' => '{"view":"week"}', - 'selected' => $this->view == 'week', - ), - array( - 'text' => lang('Multiple week view'), - 'value' => '{"view":"weekN"}', - 'selected' => $this->view == 'weekN', - ), - array( - 'text' => lang('monthview'), - 'value' => '{"view":"month"}', - 'selected' => $this->view == 'month', - ), - array( - 'text' => lang('planner by category'), - 'value' => '{"view":"planner", "sortby":"category"}', - 'selected' => $this->view == 'planner' && $this->sortby != 'user', - ), - array( - 'text' => lang('planner by user'), - 'value' => '{"view":"planner","sortby":"user"}', - 'selected' => $this->view == 'planner' && $this->sortby == 'user', - ), - array( - 'text' => lang('yearly planner'), - 'value' => '{"view":"planner","sortby":"month"}', - 'selected' => $this->view == 'planner' && $this->sortby == 'month', - ), - array( - 'text' => lang('listview'), - 'value' => '{"view":"listview"}', - 'selected' => $this->view == 'listview', - ), - )as $data) - { - if($data['selected']) - { - $content['view'] = $data['value']; - } - $sel_options['view'][] = array( - 'label' => $data['text'], - 'value' => $data['value'] - ); - } $sel_options['status_filter'] = array( array('value' => 'default', 'label' => lang('Not rejected'), 'title' => lang('Show all status, but rejected')), array('value' => 'accepted', 'label' => lang('Accepted'), 'title' => lang('Show only accepted events')), diff --git a/calendar/inc/class.calendar_uilist.inc.php b/calendar/inc/class.calendar_uilist.inc.php index 8705ab206a..fdbfd4deb1 100644 --- a/calendar/inc/class.calendar_uilist.inc.php +++ b/calendar/inc/class.calendar_uilist.inc.php @@ -391,9 +391,9 @@ class calendar_uilist extends calendar_ui // it to match changing list filters if($params['view'] && $params['view'] == 'listview') { - $GLOBALS['egw_info']['flags']['app_header'] = lang('listview') . ': '. + egw_json_response::get()->call('app.calendar.set_app_header', lang('listview') . ': '. (count($search_params['users']) == 1 ? $this->bo->participant_name($search_params['users'][0]).': ' : '') . - $label; + $label); } foreach((array) $this->bo->search($search_params, !empty($col_filter) ? $col_filter : null) as $event) { diff --git a/calendar/inc/class.calendar_uiviews.inc.php b/calendar/inc/class.calendar_uiviews.inc.php index ce5f3bce9d..b93dcc9e95 100644 --- a/calendar/inc/class.calendar_uiviews.inc.php +++ b/calendar/inc/class.calendar_uiviews.inc.php @@ -148,19 +148,7 @@ class calendar_uiviews extends calendar_ui $this->extraRowsOriginal = $this->extraRows; //save original extraRows value $GLOBALS['egw_info']['flags']['nonavbar'] = False; - $app_header = array( - 'day' => lang('Dayview'), - '4day' => lang('Four days view'), - 'week' => lang('Weekview'), - 'month' => lang('Monthview'), - 'year' => lang('yearview'), - 'planner' => lang('Group planner'), - ); - $GLOBALS['egw_info']['flags']['app_header'] = - (isset($app_header[$this->view]) ? $app_header[$this->view] : ''). - // for a single owner we add it's name to the app-header - (count(explode(',',$this->owner)) == 1 ? ': '.$this->bo->participant_name($this->owner) : ''); - + // Check for GET message (from merge) if($_GET['msg']) { @@ -252,6 +240,11 @@ class calendar_uiviews extends calendar_ui return; } + // Toolbar + $tmpl = new etemplate_new('calendar.toolbar'); + $tmpl->setElementAttribute('toolbar', 'actions', $this->getToolbarActions($content)); + $tmpl->exec('calendar_uiviews::index',array()); + // Load the different views once, we'll switch between them on the client side $tmpl = new etemplate_new('calendar.todo'); $label = ''; @@ -270,6 +263,135 @@ class calendar_uiviews extends calendar_ui $list_ui->listview(); } + /** + * Generate the calendar toolbar actions + * + * @param Array $content + */ + protected function getToolbarActions($content = array()) + { + $group = 0; + $actions = array( + 'add' => array( + 'caption' => 'Add', + 'icon' => 'add', + 'group' => ++$group, + 'onExecute' => 'javaScript:egw.open(null,"calendar","add");', + 'hint' => 'Add', + 'toolbarDefault' => true, + ), + 'day_view' => array( + 'caption' => 'Day view', + 'icon' => 'day', + 'group' => ++$group, + 'onExecute' => 'javaScript:app.calendar.toolbar_action', + 'hint' => 'Day view', + 'toolbarDefault' => true, + 'data' => array('state' => array('view' => 'day')) + ), + '4day_view' => array( + 'caption' => 'Four days view', + 'icon' => 'day4', + 'group' => $group, + 'onExecute' => 'javaScript:app.calendar.toolbar_action', + 'hint' => 'Four days view', + 'toolbarDefault' => false, + 'data' => array('state' => array('view' => 'day4')) + ), + 'week_view' => array( + 'caption' => 'Week view', + 'icon' => 'week', + 'group' => $group, + 'onExecute' => 'javaScript:app.calendar.toolbar_action', + 'hint' => 'Week view', + 'toolbarDefault' => true, + 'data' => array('state' => array('view' => 'week')) + ), + 'weekN_view' => array( + 'caption' => 'Multiple week view', + 'icon' => 'multiweek', + 'group' => $group, + 'onExecute' => 'javaScript:app.calendar.toolbar_action', + 'hint' => 'Multiple week view', + 'toolbarDefault' => true, + 'data' => array('state' => array('view' => 'weekN')) + ), + 'month_view' => array( + 'caption' => 'Month view', + 'icon' => 'month', + 'group' => $group, + 'onExecute' => 'javaScript:app.calendar.toolbar_action', + 'hint' => 'Month view', + 'toolbarDefault' => false, + 'data' => array('state' => array('view' => 'month')) + ), + 'planner_category' => array( + 'caption' => 'Planner by category', + 'icon' => 'planner', + 'group' => $group, + 'onExecute' => 'javaScript:app.calendar.toolbar_action', + 'hint' => 'Planner by category', + 'toolbarDefault' => false, + 'data' => array('state' => array('view' => 'planner', 'sortby' => 'category')), + ), + 'planner_user' => array( + 'caption' => 'Planner by user', + 'icon' => 'planner', + 'group' => $group, + 'onExecute' => 'javaScript:app.calendar.toolbar_action', + 'hint' => 'Planner by user', + 'toolbarDefault' => false, + 'data' => array('state' => array('view' => 'planner', 'sortby' => 'user')), + ), + 'planner_month' => array( + 'caption' => 'Yearly planner', + 'icon' => 'year', + 'group' => $group, + 'onExecute' => 'javaScript:app.calendar.toolbar_action', + 'hint' => 'Yearly planner', + 'toolbarDefault' => false, + 'data' => array('state' => array('view' => 'planner', 'sortby' => 'month')), + ), + 'list' => array( + 'caption' => 'Listview', + 'icon' => 'list', + 'group' => $group, + 'onExecute' => 'javaScript:app.calendar.toolbar_action', + 'hint' => 'Listview', + 'toolbarDefault' => true, + 'data' => array('state' => array('view' => 'listview')), + ), + 'weekend' => array( + 'caption' => 'Weekend', + 'icon' => 'weekend', + 'checkbox' => true, + 'checked' => $this->cal_prefs['saved_states']['weekend'], + 'group' => $group, + 'onExecute' => 'javaScript:app.calendar.toolbar_action', + 'hint' => 'Toggle weekend', + 'toolbarDefault' => false, + ), + 'previous' => array( + 'caption' => 'Previous', + 'icon' => 'previous', + 'group' => ++$group, + 'onExecute' => 'javaScript:app.calendar.toolbar_action', + 'hint' => 'Previous', + 'toolbarDefault' => true, + ), + 'next' => array( + 'caption' => 'Next', + 'icon' => 'next', + 'group' => $group, + 'onExecute' => 'javaScript:app.calendar.toolbar_action', + 'hint' => 'Next', + 'toolbarDefault' => true, + ), + ); + + return $actions; + } + /** * Show the calendar on the home page * @@ -648,7 +770,6 @@ class calendar_uiviews extends calendar_ui } } $this->last = strtotime("+$days days",$this->first) - 1; - $GLOBALS['egw_info']['flags']['app_header'] .=': ' .lang('Week').' '.$this->week_number($this->first).': '.$this->bo->long_date($this->first,$this->last); } $search_params = array( diff --git a/calendar/js/app.js b/calendar/js/app.js index 1bbe2b56c2..5538490a3d 100644 --- a/calendar/js/app.js +++ b/calendar/js/app.js @@ -404,6 +404,61 @@ app.classes.calendar = AppJS.extend( return false; }, + /** + * Handle actions from the toolbar + * + * @param {egwAction} action Action from the toolbar + */ + toolbar_action: function toolbar_action(action) + { + debugger; + // Most can just provide state change data + if(action.data && action.data.state) + { + this.update_state(action.data.state); + } + // Special handling + switch(action.id) + { + case 'weekend': + this.update_state({weekend: action.checked}); + break; + case 'next': + case 'previous': + var delta = action.id == 'previous' ? -1 : 1; + var view = app.classes.calendar.views[app.calendar.state.view] || false; + var start = new Date(app.calendar.state.date); + if (view) + { + start = view.scroll(delta); + app.calendar.update_state({date:app.calendar.date.toString(start)}); + } + break; + } + }, + + /** + * Set the app header + * + * Because the toolbar takes some vertical space and has some horizontal space, + * we don't use the system app header, but our own that is in the toolbar + * + * @param {string} header Text to display + */ + set_app_header: function(header) { + var template = etemplate2.getById('calendar-toolbar'); + var widget = template ? template.widgetContainer.getWidgetById('app_header') : false; + if(widget) + { + widget.set_value(header); + egw_app_header('','calendar'); + } + else + { + egw_app_header(header,'calendar'); + } + }, + /** * Setup and handle sortable calendars. * @@ -2201,7 +2256,7 @@ app.classes.calendar = AppJS.extend( this.highlight_favorite(); // Update app header - egw_app_header(view.header(state.state),'calendar'); + this.set_app_header(view.header(state.state)); // Sidebox is updated, we can clear the flag this.state_update_in_progress = false; diff --git a/calendar/js/et2_widget_planner.js b/calendar/js/et2_widget_planner.js index 8dd0f45af2..d6a7e38cce 100644 --- a/calendar/js/et2_widget_planner.js +++ b/calendar/js/et2_widget_planner.js @@ -802,7 +802,7 @@ var et2_calendar_planner = et2_calendar_view.extend([et2_IDetachedDOM, et2_IResi } // Set height for rows - this.rows.height(this.div.parent().height() - this.headers.outerHeight()); + this.rows.height(this.div.height() - this.headers.outerHeight()); // Draw the rows for(var key in labels) @@ -1890,9 +1890,15 @@ var et2_calendar_planner = et2_calendar_view.extend([et2_IDetachedDOM, et2_IResi }, // Resizable interface - resize: function (_height) + resize: function () { - this.options.height = _height; + // Take the whole tab height + var height = Math.min($j(this.getInstanceManager().DOMContainer).height(),$j(this.getInstanceManager().DOMContainer).parent().innerHeight()); + + // Allow for toolbar + height -= $j('#calendar-toolbar').outerHeight(true); + + this.options.height = height; this.div.css('height', this.options.height); } }); diff --git a/calendar/js/et2_widget_timegrid.js b/calendar/js/et2_widget_timegrid.js index 2af6aafb35..9744ea699b 100644 --- a/calendar/js/et2_widget_timegrid.js +++ b/calendar/js/et2_widget_timegrid.js @@ -1602,8 +1602,14 @@ var et2_calendar_timegrid = et2_calendar_view.extend([et2_IDetachedDOM, et2_IRes },this, et2_calendar_timegrid); // Take the whole tab height - this.options.height = Math.floor(Math.min($j(this.getInstanceManager().DOMContainer).height(),$j(this.getInstanceManager().DOMContainer).parent().innerHeight()) / rowCount); - this.options.height = Math.floor((egw.getHiddenDimensions(this.getInstanceManager().DOMContainer).h ) / rowCount); + var height = Math.min($j(this.getInstanceManager().DOMContainer).height(),$j(this.getInstanceManager().DOMContainer).parent().innerHeight()); + + // Allow for toolbar + height -= $j('#calendar-toolbar').outerHeight(true); + + this.options.height = Math.floor(height / rowCount); + + // Allow for borders & padding this.options.height -= 2*((this.div.outerWidth(true) - this.div.innerWidth()) + parseInt(this.div.parent().css('padding-top'))); if(this.options.height+"px" !== this.div.css('height')) { diff --git a/calendar/templates/default/app.css b/calendar/templates/default/app.css index 9797c30e47..8540cd43d6 100644 --- a/calendar/templates/default/app.css +++ b/calendar/templates/default/app.css @@ -49,6 +49,25 @@ background-color: #dac0c0; } +/* Toolbar */ +#calendar-toolbar { + height: 30px; +} +#calendar-toolbar .egw_fw_ui_app_header_container { + border: none; +} + +/* Space for toolbar */ +#calendar-view, #calendar-todo, #calendar-planner { + margin-top: -30px; +} +#calendar-list { + margin-top: -50px; +} +#calendar-planner .calendar_plannerWidget { + top: 30px; +} + #calendar-todo { position: absolute; width: 30%; diff --git a/calendar/templates/default/images/next.png b/calendar/templates/default/images/next.png new file mode 100644 index 0000000000..3d1b6d52cd Binary files /dev/null and b/calendar/templates/default/images/next.png differ diff --git a/calendar/templates/default/images/previous.png b/calendar/templates/default/images/previous.png new file mode 100644 index 0000000000..8db1953895 Binary files /dev/null and b/calendar/templates/default/images/previous.png differ diff --git a/calendar/templates/default/sidebox.xet b/calendar/templates/default/sidebox.xet index 4aa923a7f1..10857bce6a 100644 --- a/calendar/templates/default/sidebox.xet +++ b/calendar/templates/default/sidebox.xet @@ -14,30 +14,6 @@ Egroupware