mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-23 00:13:35 +01:00
calendar state handling via set/getState methods in calendar app.js
This commit is contained in:
parent
e008bd63bb
commit
9cba54fb63
@ -414,6 +414,9 @@ class calendar_ui
|
||||
$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
|
||||
egw_framework::set_extra('calendar', 'state', array_diff_key($states,array('date'=>false,'year'=>false,'month'=>false,'day'=>false,'save_owner'=>false)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -487,5 +487,59 @@ app.classes.calendar = AppJS.extend(
|
||||
}
|
||||
},this.egw.lang("Do you want to edit this event as an exception or the whole series?"),
|
||||
this.egw.lang("This event is part of a series"), {}, buttons, et2_dialog.WARNING_MESSAGE);
|
||||
},
|
||||
|
||||
/**
|
||||
* Return state object defining current view
|
||||
*
|
||||
* Called by favorites to query current state.
|
||||
*
|
||||
* @return {object} description
|
||||
*/
|
||||
getState: function()
|
||||
{
|
||||
var egw_script_tag = document.getElementById('egw_script_id');
|
||||
var state = egw_script_tag.getAttribute('data-calendar-state');
|
||||
|
||||
return state ? JSON.parse(state) : this._super.apply(this, arguments);
|
||||
},
|
||||
|
||||
/**
|
||||
* Set a state previously returned by getState
|
||||
*
|
||||
* Called by favorites to set a state saved as favorite.
|
||||
*
|
||||
* @param {object} state containing "name" attribute to be used as "favorite" GET parameter to a nextmatch
|
||||
*/
|
||||
setState: function(state)
|
||||
{
|
||||
// requested state is a listview and we are currently in a list-view
|
||||
if (state.view == 'listview' && view.name && this.et2 && this.et2.getWidgetById('nm'))
|
||||
{
|
||||
return this._super.apply(this, arguments); // call default implementation
|
||||
}
|
||||
|
||||
// old calendar state handling on server-side (incl. switching to and from listview)
|
||||
var menuaction = 'calendar.calendar_uiviews.index';
|
||||
if (state.view == 'listview')
|
||||
{
|
||||
menuaction = 'calendar.calendar_uilist.index';
|
||||
if (state.name)
|
||||
{
|
||||
state.favorite = state.name.replace(/[^A-Za-z0-9-_]/g, '_');
|
||||
}
|
||||
}
|
||||
for(name in state)
|
||||
{
|
||||
var value = state[name];
|
||||
switch(name)
|
||||
{
|
||||
case 'owner': // prepend an owner 0, to reset all owners and not just set given resource type
|
||||
value = '0,'+owner;
|
||||
break;
|
||||
}
|
||||
menuaction += '&'+name+'='+encodeURIComponent(value)
|
||||
}
|
||||
this.egw.open_link(menuaction);
|
||||
}
|
||||
});
|
||||
|
@ -295,6 +295,20 @@ abstract class egw_framework
|
||||
self::$extra['window-focus'] = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Allow app to store arbitray values in egw script tag
|
||||
*
|
||||
* Attribute name will be "data-$app-$name" and value will be json serialized, if not scalar.
|
||||
*
|
||||
* @param string $app
|
||||
* @param string $name
|
||||
* @param mixed $value
|
||||
*/
|
||||
public static function set_extra($app, $name, $value)
|
||||
{
|
||||
self::$extra[$app.'-'.$name] = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Allow eg. ajax to query content set via refresh_opener or window_close
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user