Fix home bugs:

- Unable to add new single entry via context menu
- Did not save layout changes
This commit is contained in:
Nathan Gray 2013-09-23 20:01:14 +00:00
parent edd4cc49ca
commit 42b6c13b26
2 changed files with 23 additions and 3 deletions

View File

@ -59,12 +59,18 @@ class home_ui
protected function get_actions() protected function get_actions()
{ {
$portlets = $this->get_portlet_list(); $portlets = $this->get_portlet_list();
$add_portlets = $portlets;
foreach($add_portlets as $id => &$add)
{
$add['id'] = 'add_' . $id;
}
error_log(array2string($add_portlets));
$actions = array( $actions = array(
'add' => array( 'add' => array(
'type' => 'popup', 'type' => 'popup',
'caption' => 'Add', 'caption' => 'Add',
'onExecute' => 'javaScript:app.home.add', 'onExecute' => 'javaScript:app.home.add',
'children' => $portlets 'children' => $add_portlets
) )
); );
@ -267,6 +273,15 @@ class home_ui
// Get portlet settings, and merge new with old // Get portlet settings, and merge new with old
$content = ''; $content = '';
$context = $values+(array)$portlets[$portlet_id]; //array('class'=>$attributes['class']); $context = $values+(array)$portlets[$portlet_id]; //array('class'=>$attributes['class']);
// Handle add IDs
$classname =& $context['class'];
if(strpos($classname,'add_') == 0 && !class_exists($classname))
{
$add = true;
$classname = substr($classname, 4);
}
$portlet = $this->get_portlet($portlet_id, $context,$content, $attributes); $portlet = $this->get_portlet($portlet_id, $context,$content, $attributes);
$context['class'] = get_class($portlet); $context['class'] = get_class($portlet);
@ -287,7 +302,10 @@ class home_ui
$update = array('content' => $content, 'attributes' => $attributes); $update = array('content' => $content, 'attributes' => $attributes);
// New portlet? Flag going straight to edit mode // New portlet? Flag going straight to edit mode
//$update['edit_settings'] = true; if($add)
{
$update['edit_settings'] = true;
}
$response->data($update); $response->data($update);
// Store for preference update // Store for preference update

View File

@ -245,7 +245,9 @@ app.home = AppJS.extend(
for (var key in changed) for (var key in changed)
{ {
if(!changed[key].id) continue; if(!changed[key].id) continue;
var widget = window.app.home.portlet_container.getWidgetById(changed[key].id); // Changed ID is DOM id
var widget_id = changed[key].id.substr(window.app.home.et2.getInstanceManager().uniqueId.length + 1);
var widget = window.app.home.portlet_container.getWidgetById(widget_id);
if(!widget || widget == window.app.home.portlet_container) continue; if(!widget || widget == window.app.home.portlet_container) continue;
egw().jsonq("home.home_ui.ajax_set_properties",[widget.id, widget.options.settings,{ egw().jsonq("home.home_ui.ajax_set_properties",[widget.id, widget.options.settings,{