If a home favorite loses it's associated favorite (it gets deleted), open the config dialog so user can pick another instead of always being blank.

This commit is contained in:
Nathan Gray 2015-05-04 15:26:18 +00:00
parent 9e3676a8c9
commit f1983a3f07
3 changed files with 23 additions and 8 deletions

View File

@ -64,13 +64,15 @@ class calendar_favorite_portlet extends home_favorite_portlet
else
{
$ui = new calendar_uiviews();
if($this->favorite['state']['start']) $ui->search_params['start'] = $this->favorite['state']['start'];
if($this->favorite['state']['cat_id']) $ui->search_params['cat_id'] = $this->favorite['state']['cat_id'];
// Owner can be 0 for current user
if(array_key_exists('owner',$this->favorite['state'])) $ui->search_params['users'] = explode(',',$this->favorite['state']['owner']);
if($this->favorite['state']['filter']) $ui->search_params['filter'] = $this->favorite['state']['filter'];
if($this->favorite['state']['sortby']) $ui->search_params['sortby'] = $this->favorite['state']['sortby'];
if ($this->favorite)
{
if($this->favorite['state']['start']) $ui->search_params['start'] = $this->favorite['state']['start'];
if($this->favorite['state']['cat_id']) $ui->search_params['cat_id'] = $this->favorite['state']['cat_id'];
// Owner can be 0 for current user
if(array_key_exists('owner',$this->favorite['state'])) $ui->search_params['users'] = explode(',',$this->favorite['state']['owner']);
if($this->favorite['state']['filter']) $ui->search_params['filter'] = $this->favorite['state']['filter'];
if($this->favorite['state']['sortby']) $ui->search_params['sortby'] = $this->favorite['state']['sortby'];
}
$etemplate->read('home.legacy');
$etemplate->set_dom_id($id);

View File

@ -187,7 +187,10 @@ class home_favorite_portlet extends home_portlet
$favorite_list = array();
foreach($favorites as $id => $favorite)
{
$favorite_list[$id] = $favorite['name'];
if($favorite)
{
$favorite_list[$id] = $favorite['name'];
}
}
$favorite = array(
'label' => lang('Favorite'),

View File

@ -873,6 +873,16 @@ app.classes.home.home_weather_portlet = app.classes.home.home_portlet.extend({
}
});
app.classes.home.home_favorite_portlet = app.classes.home.home_portlet.extend({
init: function(portlet) {
// call parent
this._super.apply(this, arguments);
// Somehow favorite got lost, or is not set
if(!portlet.options.settings.favorite)
{
portlet.edit_settings();
}
},
observer: function(_msg, _app, _id, _type, _msg_type, _targetapp)
{
if(this.portlet.class.indexOf(_app) == 0 || this.portlet.class == 'home_favorite_portlet')