forked from extern/egroupware
Stop using iframe, better list duplicate detection, better support different ways of getting list content (ajax)
This commit is contained in:
parent
07b311d495
commit
dadf3046c2
@ -59,25 +59,6 @@ class home_list_portlet extends home_portlet
|
||||
{
|
||||
$this->title = $context['title'];
|
||||
}
|
||||
// Add a new entry to the list
|
||||
if($context['add'])
|
||||
{
|
||||
$ok_to_add = true;
|
||||
foreach($context['list'] as $key => $entry)
|
||||
{
|
||||
if($entry == $context['add'])
|
||||
{
|
||||
$ok_to_add = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if($ok_to_add)
|
||||
{
|
||||
$context['list'][] = $context['add'];
|
||||
}
|
||||
unset($context['add']);
|
||||
}
|
||||
|
||||
$this->context = $context;
|
||||
}
|
||||
|
||||
@ -120,7 +101,27 @@ class home_list_portlet extends home_portlet
|
||||
}
|
||||
|
||||
// Find the portlet widget, and add a link-list to it
|
||||
return "<script>app.home.List.set_content('$id', ".json_encode($list).")</script>";
|
||||
$script = 'app.home.List.set_content("'.$id.'", '.json_encode($list).');';
|
||||
if(egw_json_response::isJSONResponse())
|
||||
{
|
||||
$response = egw_json_response::get();
|
||||
// This has to go last, after the template is loaded
|
||||
$response->addBeforeSendDataCallback(
|
||||
function($response, $script) {
|
||||
// Bind to load event to make sure template is loaded first
|
||||
$response->script('$j("#home-index").on("load", function() {'.$script.'});');
|
||||
// Or just call it, in the event of a normal ajax change - no load event
|
||||
$response->script("try { $script } catch (e) {egw.debug('error', e.message);}");
|
||||
}
|
||||
,$response, $script
|
||||
);
|
||||
} else {
|
||||
// Not a JSON Response? Probably an idots first load
|
||||
$response = egw_json_response::get();
|
||||
// Bind to load event to make sure template is loaded first
|
||||
$response->script('$j("#home-index").on("load", function() {'.$script.'});');
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -356,10 +356,21 @@ app.home = AppJS.extend(
|
||||
var link = et2_createWidget('link-entry', {label: egw.lang('Add')}, this.portlet_container);
|
||||
var dialog = et2_dialog.show_dialog(
|
||||
function(button_id) {
|
||||
if(button_id == et2_dialog.CANCEL_BUTTON) return;
|
||||
var new_list = widget.options.settings.list || [];
|
||||
new_list.push(link.getValue());
|
||||
widget._process_edit(button_id,{list: new_list || [],add: link.getValue()});
|
||||
var add = link.getValue();
|
||||
link.destroy();
|
||||
for(var i = 0; i < new_list.length; i++)
|
||||
{
|
||||
if(new_list[i].app == add.app && new_list[i].id == add.id)
|
||||
{
|
||||
// Duplicate
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
new_list.push(add);
|
||||
widget._process_edit(button_id,{list: new_list});
|
||||
},
|
||||
'Add',
|
||||
egw.lang('Add'), {},
|
||||
|
@ -11,9 +11,10 @@
|
||||
/* Basic information about this app */
|
||||
$setup_info['home']['name'] = 'home';
|
||||
$setup_info['home']['title'] = 'Home';
|
||||
$setup_info['home']['version'] = '1.8';
|
||||
$setup_info['home']['version'] = '1.9';
|
||||
$setup_info['home']['app_order'] = 1;
|
||||
$setup_info['home']['enable'] = 1;
|
||||
$setup_info['home']['index'] = 'home.home_ui.index&ajax=true';
|
||||
|
||||
$setup_info['home']['author'] = 'eGroupWare Core Team';
|
||||
$setup_info['home']['license'] = 'GPL';
|
||||
@ -30,5 +31,5 @@ $setup_info['home']['hooks']['showUpdates'] = 'home.updates.showUpdates';
|
||||
/* Dependencies for this app to work */
|
||||
$setup_info['home']['depends'][] = array(
|
||||
'appname' => 'phpgwapi',
|
||||
'versions' => Array('1.7','1.8','1.9')
|
||||
'versions' => Array('1.9')
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user