non-et2 Favorites work in progress

Can now save & restore state.  Still some UI needed, not fully integrated with et2 favorites.
This commit is contained in:
Nathan Gray 2013-12-06 18:24:29 +00:00
parent 343a72c3a8
commit 79498c5ae5
3 changed files with 16 additions and 7 deletions

View File

@ -518,8 +518,16 @@ app.classes.calendar = AppJS.extend(
*/ */
setState: function(state) setState: function(state)
{ {
// State should be an object, not a string, but we'll parse
if(typeof state == "string")
{
if(state.indexOf('{') != -1 || state =='null')
{
state = JSON.parse(state);
}
}
// requested state is a listview and we are currently in a list-view // 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')) if (state.state.view == 'listview' && state.name && this.et2 && this.et2.getWidgetById('nm'))
{ {
return this._super.apply(this, arguments); // call default implementation return this._super.apply(this, arguments); // call default implementation
} }
@ -528,7 +536,7 @@ app.classes.calendar = AppJS.extend(
var menuaction = 'calendar.calendar_uiviews.index'; var menuaction = 'calendar.calendar_uiviews.index';
if (typeof state.view == 'undefined' || state.view == 'listview') if (typeof state.view == 'undefined' || state.view == 'listview')
{ {
menuaction = 'calendar.calendar_uilist.index'; menuaction = 'calendar.calendar_uilist.listview';
if (state.name) if (state.name)
{ {
state = {favorite: state.name.replace(/[^A-Za-z0-9-_]/g, '_')}; state = {favorite: state.name.replace(/[^A-Za-z0-9-_]/g, '_')};

View File

@ -1808,7 +1808,7 @@ $LAB.setOptions({AlwaysPreserveOrder:true,BasePath:"'.$GLOBALS['egw_info']['serv
if(!$registry) $registry = egw_link::get_registry($app,'index'); if(!$registry) $registry = egw_link::get_registry($app,'index');
foreach($filters as $name => $filter) foreach($filters as $name => $filter)
{ {
$href = "javascript:app.$app.setState(" . json_encode($filter['filter']) . ');'; $href = "javascript:app.$app.setState(" . json_encode($filter) . ');';
$html .= "<li id='$name' class='ui-menu-item' role='menuitem'>\n"; $html .= "<li id='$name' class='ui-menu-item' role='menuitem'>\n";
$html .= "<a href='$href' class='ui-corner-all' tabindex='-1'>"; $html .= "<a href='$href' class='ui-corner-all' tabindex='-1'>";
$html .= "<div class='" . ($name == $default_filter ? 'ui-icon ui-icon-heart' : 'sideboxstar') . "'></div>". $html .= "<div class='" . ($name == $default_filter ? 'ui-icon ui-icon-heart' : 'sideboxstar') . "'></div>".

View File

@ -188,11 +188,13 @@ var AppJS = Class.extend(
* The default implementation works with the favorites to apply filters to a nextmatch. * The default implementation works with the favorites to apply filters to a nextmatch.
* *
* *
* @param {object} state description * @param {{name: string, state: object}|string} state Object (or JSON string) for a state.
* Only state is required, and its contents are application specific.
* @param {type} name description
*/ */
setState: function(state) setState: function(state)
{ {
// State should be an object, not a string, but we'll try // State should be an object, not a string, but we'll parse
if(typeof state == "string") if(typeof state == "string")
{ {
if(state.indexOf('{') != -1 || state =='null') if(state.indexOf('{') != -1 || state =='null')
@ -383,13 +385,12 @@ var AppJS = Class.extend(
// Add to the list // Add to the list
name.val(name.val().replace(/(<([^>]+)>)/ig,"")); name.val(name.val().replace(/(<([^>]+)>)/ig,""));
var safe_name = name.val().replace(/[^A-Za-z0-9-_]/g,"_"); var safe_name = name.val().replace(/[^A-Za-z0-9-_]/g,"_");
self.stored_filters[safe_name] = { var favorite = {
name: name.val(), name: name.val(),
group: (typeof self.favorite_popup.group != "undefined" && group: (typeof self.favorite_popup.group != "undefined" &&
self.favorite_popup.group.get_value() ? self.favorite_popup.group.get_value() : false), self.favorite_popup.group.get_value() ? self.favorite_popup.group.get_value() : false),
state: self.favorite_popup.state state: self.favorite_popup.state
}; };
self.init_filters(self);
var favorite_pref = favorite_prefix+safe_name; var favorite_pref = favorite_prefix+safe_name;