From b4087292a83d299d03582ad35cbffa9535fee5d7 Mon Sep 17 00:00:00 2001 From: Nathan Gray Date: Fri, 6 Nov 2015 00:37:23 +0000 Subject: [PATCH] Add toggle button for weekends --- calendar/inc/class.calendar_hooks.inc.php | 16 ---------- calendar/inc/class.calendar_ui.inc.php | 34 ++++----------------- calendar/inc/class.calendar_uiviews.inc.php | 13 -------- calendar/js/app.js | 22 +++++-------- calendar/templates/default/app.css | 3 ++ calendar/templates/default/sidebox.xet | 2 ++ 6 files changed, 18 insertions(+), 72 deletions(-) diff --git a/calendar/inc/class.calendar_hooks.inc.php b/calendar/inc/class.calendar_hooks.inc.php index d9fb4acbb6..2f86e1ead6 100644 --- a/calendar/inc/class.calendar_hooks.inc.php +++ b/calendar/inc/class.calendar_hooks.inc.php @@ -119,12 +119,6 @@ class calendar_hooks 'day4' => lang('Dayview').' & '.lang('Four days view'), 'day' => lang('Dayview'), ); - /* Select list with number of day by week */ - $week_view = array( - '5' => lang('Weekview without weekend'), - '7' => lang('Weekview with weekend'), - ); - $updates = array( 'no' => lang('Never'), 'add_cancel' => lang('on invitation / cancelation only'), @@ -235,16 +229,6 @@ class calendar_hooks 'admin' => False, 'default'=> '1', // 1 = week ),*/ - 'days_in_weekview' => array( - 'type' => 'select', - 'label' => 'default week view', - 'name' => 'days_in_weekview', - 'values' => $week_view, - 'help' => 'Do you want a weekview with or without weekend?', - 'xmlrpc' => True, - 'admin' => False, - 'default'=> '7', - ), 'multiple_weeks' => array( 'type' => 'select', 'label' => 'Weeks in multiple week view', diff --git a/calendar/inc/class.calendar_ui.inc.php b/calendar/inc/class.calendar_ui.inc.php index 84614b6c32..d792cc828f 100644 --- a/calendar/inc/class.calendar_ui.inc.php +++ b/calendar/inc/class.calendar_ui.inc.php @@ -127,7 +127,7 @@ class calendar_ui /** * @var array $states_to_save all states that will be saved to the user prefs */ - var $states_to_save = array('owner','filter','cat_id','view','sortby','planner_days'); + var $states_to_save = array('owner','filter','cat_id','view','sortby','planner_days','weekend'); /** * Constructor @@ -420,30 +420,12 @@ class calendar_ui // save defined states into the user-prefs if(!empty($states) && is_array($states)) { - $saved_states = serialize(array_intersect_key($states,array_flip($this->states_to_save))); + $saved_states = array_intersect_key($states,array_flip($this->states_to_save)); if ($saved_states != $this->cal_prefs['saved_states']) { $GLOBALS['egw']->preferences->add('calendar','saved_states',$saved_states); $GLOBALS['egw']->preferences->save_repository(false,'user',true); } - - // store state in request for clientside favorites to use - // remove date and other states never stored in a favorite - $states = array_diff_key($states,array('date'=>false,'year'=>false,'month'=>false,'day'=>false,'save_owner'=>false)); - if (strpos($_GET['menuaction'], 'ajax_sidebox') !== false) - { - // sidebox request is from top frame, which has app.calendar NOT loaded by time response arrives - } - elseif (egw_json_request::isJSONRequest())// && strpos($_GET['menuaction'], 'calendar_uiforms') === false) - { - $response = egw_json_response::get(); - //$response->apply('app.calendar.set_state', array($states, $_GET['menuaction'])); - } - else - { - egw_framework::set_extra('calendar', 'state', $states); - } - } } } @@ -647,6 +629,7 @@ 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(); $owners = $this->owner ? is_array($this->owner) ? array($this->owner) : explode(',',$this->owner) : array($GLOBALS['egw_info']['user']['account_id']); @@ -677,14 +660,9 @@ class calendar_ui 'selected' => $this->view == 'day4', ), array( - 'text' => lang('weekview with weekend'), - 'value' => '{"view":"week","days":7}', - 'selected' => $this->view == 'week' && $this->cal_prefs['days_in_weekview'] != 5, - ), - array( - 'text' => lang('weekview without weekend'), - 'value' => '{"view":"week","days":5}', - 'selected' => $this->view == 'week' && $this->cal_prefs['days_in_weekview'] == 5, + 'text' => lang('weekview'), + 'value' => '{"view":"week"}', + 'selected' => $this->view == 'week', ), array( 'text' => lang('Multiple week view'), diff --git a/calendar/inc/class.calendar_uiviews.inc.php b/calendar/inc/class.calendar_uiviews.inc.php index 11c83a4004..bdff6f7566 100644 --- a/calendar/inc/class.calendar_uiviews.inc.php +++ b/calendar/inc/class.calendar_uiviews.inc.php @@ -269,19 +269,6 @@ class calendar_uiviews extends calendar_ui // List view in a separate file $list_ui = new calendar_uilist(); $list_ui->listview(); - - // Set the current state - if (egw_json_request::isJSONRequest())// && strpos($_GET['menuaction'], 'calendar_uiforms') === false) - { - $states = array(); - foreach(array('date','cat_id','filter','owner','view','sortby') as $state) - { - if($this->$state) $states[$state] = $this->$state; - } - $states['date'] = egw_time::to($states['date'],egw_time::ET2); - $response = egw_json_response::get(); - $response->apply('app.calendar.set_state', array($states)); - } } /** diff --git a/calendar/js/app.js b/calendar/js/app.js index 5df8cf8af3..d6f8db727c 100644 --- a/calendar/js/app.js +++ b/calendar/js/app.js @@ -60,11 +60,10 @@ app.classes.calendar = AppJS.extend( state: { date: new Date(), view: egw.preference('defaultcalendar','calendar') || 'day', - owner: egw.user('account_id'), - days: egw.preference('days_in_weekview','calendar') + owner: egw.user('account_id') }, - states_to_save: ['owner','filter','cat_id','view','sortby','planner_days'], + states_to_save: ['owner','filter','cat_id','view','sortby','planner_days','weekend'], // If you are in one of these views and select a date in the sidebox, the view // will change as needed to show the date. Other views will only change the @@ -90,6 +89,7 @@ app.classes.calendar = AppJS.extend( // Scroll jQuery(jQuery.proxy(this._scroll,this)); + jQuery.extend(this.state, this.egw.preference('saved_states','calendar')); }, /** @@ -2553,7 +2553,7 @@ app.classes.calendar = AppJS.extend( { sidebox.parentsUntil('#calendar_sidebox_content') .find('.egw_fw_ui_category_content').not(sidebox.parent()) - .on('change.sidebox', 'select:not(.et2_selectbox),input', this, function(event) { + .on('change.sidebox', 'select:not(.et2_selectbox),input[type!="checkbox"]', this, function(event) { var state = {}; var name = this.name.replace('[]',''); var value = $j(this).val(); @@ -2860,7 +2860,7 @@ app.classes.calendar = AppJS.extend( */ show_weekend: function(state) { - return state.days ? parseInt(state.days) === 7 : parseInt(egw.preference('days_in_weekview','calendar')) == 7; + return state.weekend; }, /** * How big or small are the displayed time chunks? @@ -2947,7 +2947,7 @@ jQuery.extend(app.classes.calendar,{ }, show_weekend: function(state) { state.days = '1'; - + state.weekend = 'true'; return app.calendar.View.show_weekend.call(this,state); }, scroll: function(delta) @@ -2971,6 +2971,7 @@ jQuery.extend(app.classes.calendar,{ return d; }, show_weekend: function(state) { + state.weekend = 'true'; return true; }, scroll: function(delta) @@ -3002,12 +3003,7 @@ jQuery.extend(app.classes.calendar,{ d.setUTCMinutes(59); d.setUTCSeconds(59); d.setUTCMilliseconds(0); - state.days = '' + (state.days >= 5 ? state.days : egw.preference('days_in_weekview','calendar') || 7); return d; - }, - show_weekend: function(state) - { - return parseInt(state.days) === 7; } }), weekN: app.classes.calendar.prototype.View.extend({ @@ -3060,10 +3056,6 @@ jQuery.extend(app.classes.calendar,{ var d = new Date(app.calendar.state.date); d.setUTCMonth(d.getUTCMonth() + delta); return d; - }, - show_weekend: function(state) - { - return true; } }), diff --git a/calendar/templates/default/app.css b/calendar/templates/default/app.css index 32326e8aca..366104f7ab 100644 --- a/calendar/templates/default/app.css +++ b/calendar/templates/default/app.css @@ -25,6 +25,9 @@ #calendar-sidebox_buttons tbody { width: 100%; } +#calendar-sidebox_weekend { + /* Special css styling goes here */ +} #calendar-sidebox_date td.ui-datepicker-week-col { cursor: pointer; } diff --git a/calendar/templates/default/sidebox.xet b/calendar/templates/default/sidebox.xet index 827544bbd5..656de2df7d 100644 --- a/calendar/templates/default/sidebox.xet +++ b/calendar/templates/default/sidebox.xet @@ -23,6 +23,7 @@ Egroupware + @@ -32,6 +33,7 @@ Egroupware +