From c961edcc590e44acf5afd61ad0cf05cf49625c14 Mon Sep 17 00:00:00 2001 From: Nathan Gray Date: Tue, 13 Jan 2015 21:58:53 +0000 Subject: [PATCH] Fix new portlets lose their size after configuring them. --- home/inc/class.home_favorite_portlet.inc.php | 1 + home/inc/class.home_ui.inc.php | 19 ++++++++++++++----- home/js/app.js | 11 +++++++++-- 3 files changed, 24 insertions(+), 7 deletions(-) diff --git a/home/inc/class.home_favorite_portlet.inc.php b/home/inc/class.home_favorite_portlet.inc.php index 6a9c6ffedc..263cbc7133 100644 --- a/home/inc/class.home_favorite_portlet.inc.php +++ b/home/inc/class.home_favorite_portlet.inc.php @@ -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']; diff --git a/home/inc/class.home_ui.inc.php b/home/inc/class.home_ui.inc.php index 7076a05bf2..46b4496ef6 100644 --- a/home/inc/class.home_ui.inc.php +++ b/home/inc/class.home_ui.inc.php @@ -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' => '', ), @@ -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' ), diff --git a/home/js/app.js b/home/js/app.js index 35fe19beb1..a23ec3d8a8 100644 --- a/home/js/app.js +++ b/home/js/app.js @@ -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('
'); + // 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('
'); @@ -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