Fix new portlets lose their size after configuring them.

This commit is contained in:
Nathan Gray 2015-01-13 21:58:53 +00:00
parent abb02c7b40
commit c961edcc59
3 changed files with 24 additions and 7 deletions

View File

@ -85,6 +85,7 @@ class home_favorite_portlet extends home_portlet
{
$favorites = egw_favorites::get_favorites($context['appname']);
$context['favorite'] = $favorites[$context['favorite']];
$need_reload = true;
}
$this->favorite = $context['favorite'];

View File

@ -240,6 +240,7 @@ class home_ui
if(is_array($setting) && !array_key_exists('type',$setting)) unset($settings[$key]);
}
$settings += $context;
error_log(__LINE__ . ' ' . array2string($context));
foreach(home_portlet::$common_attributes as $attr)
{
unset($settings[$attr]);
@ -268,7 +269,16 @@ class home_ui
}
// Make sure custom javascript is loaded
egw_framework::validate_file('', $classname, $context['appname'] ? $context['appname'] : 'home');
$appname = $context['appname'];
if(!$appname)
{
list($app) = explode('_',$classname);
if($GLOBALS['egw_info']['apps'][$app])
{
$appname = $app;
}
}
egw_framework::validate_file('', $classname, $appname ? $appname : 'home');
if($full_exec)
{
@ -481,7 +491,7 @@ class home_ui
*/
public function ajax_set_properties($portlet_id, $attributes, $values, $group = false)
{
//error_log(__METHOD__ . "($portlet_id, " .array2string($attributes).','.array2string($values).",$group)");
error_log(__METHOD__ . "($portlet_id, " .array2string($attributes).','.array2string($values).",$group)");
if(!$attributes)
{
$attributes = array();
@ -588,6 +598,8 @@ class home_ui
$response->data($update);
// Store for preference update
error_log("Storing " . $portlet_id);
error_log(array2string($context));
$prefs->add('home', $portlet_id, $context, $type);
}
@ -696,7 +708,6 @@ class home_ui
'height' => 5,
'title' => 'Tutorials: www.egroupware.org',
'color' => '',
'resize_ratio' => '',
'group' => 'default',
'note' => '<iframe src="'.$tutorial_url.'" width="100%" height="250"></iframe>',
),
@ -723,7 +734,6 @@ class home_ui
),
),
'title' => $weekview,
'resize_ratio' => '',
'group' => 'default',
'appname' => 'calendar',
),
@ -756,7 +766,6 @@ class home_ui
'id' => 'portlet_setup142n',
'class' => 'news_admin_favorite_portlet',
'title' => 'www.egroupware.org',
'resize_ratio' => '',
'group' => 'default',
'appname' => 'news_admin'
),

View File

@ -260,11 +260,15 @@ app.classes.home = AppJS.extend(
attrs.col = Math.max(1,Math.round((action.menu_context.posx - $portlet_container.offset().left) / this.GRID)+1);
}
var portlet = et2_createWidget('portlet',attrs, this.portlet_container);
// Don't pass default width & height so class can set it
delete attrs.width;
delete attrs.height;
var portlet = et2_createWidget('portlet',jQuery.extend({},attrs), this.portlet_container);
portlet.loadingFinished();
// Immediately add content ID so etemplate loads into the right place
portlet.content.append('<div id="'+ attrs.id+'" class="et2_container"/>');
// Get actual attributes & settings, since they're not available client side yet
portlet._process_edit(et2_dialog.OK_BUTTON, attrs);
@ -308,7 +312,7 @@ app.classes.home = AppJS.extend(
attrs.col = Math.max(1,Math.round((action.ui.position.left - $portlet_container.offset().left) / this.GRID));
}
var portlet = et2_createWidget('portlet',attrs, this.portlet_container);
var portlet = et2_createWidget('portlet',jQuery.extend({},attrs), this.portlet_container);
portlet.loadingFinished();
// Immediately add content ID so etemplate loads into the right place
portlet.content.append('<div id="'+ attrs.id+'" class="et2_container"/>');
@ -326,6 +330,9 @@ app.classes.home = AppJS.extend(
drop_data.push(source[i].data);
}
}
// Don't pass default width & height so class can set it
delete attrs.width;
delete attrs.height;
portlet._process_edit(et2_dialog.OK_BUTTON, jQuery.extend({dropped_data: drop_data},attrs));
// Set up sorting/grid of new portlet