mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-25 09:23:28 +01:00
Remove full list reload when adding a new distribution list, using ajax instead.
This commit is contained in:
parent
02fbe1ef41
commit
235a847cff
@ -890,35 +890,47 @@ window.egw_LAB.wait(function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Rename an existing email list
|
* Create or rename an existing email list
|
||||||
*
|
*
|
||||||
* @param int $list_id
|
* @param int $list_id ID of existing list, or 0 for a new one
|
||||||
* @param string $new_name
|
* @param string $new_name List name
|
||||||
|
* @param int $owner List owner, or empty for current user
|
||||||
* @return boolean|string
|
* @return boolean|string
|
||||||
*/
|
*/
|
||||||
function ajax_rename_list($list_id, $new_name)
|
function ajax_set_list($list_id, $new_name, $owner = false)
|
||||||
{
|
{
|
||||||
|
// Set owner to current user, if not set
|
||||||
|
$owner = $owner ? $owner : $GLOBALS['egw_info']['user']['account_id'];
|
||||||
|
|
||||||
// Check for valid list & permissions
|
// Check for valid list & permissions
|
||||||
if (!$list_id)
|
if(!(int)$list_id && !$this->check_list(null,EGW_ACL_ADD|EGW_ACL_EDIT,$owner))
|
||||||
{
|
{
|
||||||
egw_json_response::get()->apply('egw.message',lang('You need to select a distribution list'),'error');
|
egw_json_response::get()->apply('egw.message', array( lang('List creation failed, no rights!'),'error'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (!$this->check_list((int)$list_id, EGW_ACL_EDIT, $GLOBALS['egw_info']['user']['account_id']))
|
if ((int)$list_id && !$this->check_list((int)$list_id, EGW_ACL_EDIT, $owner))
|
||||||
{
|
{
|
||||||
egw_json_response::get()->apply('egw.message', array( lang('Insufficent rights to edit this list!'),'error'));
|
egw_json_response::get()->apply('egw.message', array( lang('Insufficent rights to edit this list!'),'error'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$list = array('list_owner' => $owner);
|
||||||
|
|
||||||
// Rename
|
// Rename
|
||||||
$list = $this->read_list((int)$list_id);
|
if($list_id)
|
||||||
|
{
|
||||||
|
$list = $this->read_list((int)$list_id);
|
||||||
|
}
|
||||||
$list['list_name'] = $new_name;
|
$list['list_name'] = $new_name;
|
||||||
|
|
||||||
$this->add_list(array('list_id' => (int)$list_id), $list['list_owner'],array(),$list);
|
$new_id = $this->add_list(array('list_id' => (int)$list_id), $list['list_owner'],array(),$list);
|
||||||
|
|
||||||
egw_json_response::get()->apply('egw.message', array( lang('Distribution list renamed'),'success'));
|
egw_json_response::get()->apply('egw.message', array(
|
||||||
|
$new_id == $list_id ? lang('Distribution list renamed') : lang('List created'),
|
||||||
|
'success'
|
||||||
|
));
|
||||||
// Success, just update selectbox to new value
|
// Success, just update selectbox to new value
|
||||||
egw_json_response::get()->data("true");
|
egw_json_response::get()->data($new_id == $list_id ? "true" : $new_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -451,19 +451,39 @@ app.classes.addressbook = AppJS.extend(
|
|||||||
var filter = this.et2.getWidgetById('filter');
|
var filter = this.et2.getWidgetById('filter');
|
||||||
owner = filter.getValue()||egw.preference('add_default','addressbook');
|
owner = filter.getValue()||egw.preference('add_default','addressbook');
|
||||||
}
|
}
|
||||||
var name = window.prompt(this.egw.lang('Name for the distribution list'));
|
var lists = this.et2.getWidgetById('filter2');
|
||||||
if (name)
|
et2_dialog.show_prompt(
|
||||||
{
|
function(button, name) {
|
||||||
egw.open('','addressbook', 'list', {
|
if(button == et2_dialog.OK_BUTTON)
|
||||||
'add_list': name,
|
{
|
||||||
'owner': owner
|
egw.json('addressbook.addressbook_ui.ajax_set_list',[0, name, owner],
|
||||||
},'_self');
|
function(result)
|
||||||
}
|
{
|
||||||
|
if(typeof result == 'object') return; // This response not for us
|
||||||
|
// Update list
|
||||||
|
if(result)
|
||||||
|
{
|
||||||
|
lists.options.select_options.unshift({value:result,label:name});
|
||||||
|
lists.set_select_options(lists.options.select_options);
|
||||||
|
|
||||||
|
// Set to new list so they can see it easily
|
||||||
|
lists.set_value(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
).sendRequest(true);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
this.egw.lang('Name for the distribution list'),
|
||||||
|
this.egw.lang('Add a new list...')
|
||||||
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Rename the current distribution list selected in the nextmatch filter2
|
* Rename the current distribution list selected in the nextmatch filter2
|
||||||
*
|
*
|
||||||
|
* Differences from add_new_list are in the dialog, parameters sent, and how the
|
||||||
|
* response is dealt with
|
||||||
|
*
|
||||||
* @param {egwAction} action Action selected in context menu (rename)
|
* @param {egwAction} action Action selected in context menu (rename)
|
||||||
* @param {egwActionObject[]} selected The selected row(s). Not used for this.
|
* @param {egwActionObject[]} selected The selected row(s). Not used for this.
|
||||||
*/
|
*/
|
||||||
@ -483,11 +503,10 @@ app.classes.addressbook = AppJS.extend(
|
|||||||
function(button, name) {
|
function(button, name) {
|
||||||
if(button == et2_dialog.OK_BUTTON)
|
if(button == et2_dialog.OK_BUTTON)
|
||||||
{
|
{
|
||||||
egw.json('addressbook.addressbook_ui.ajax_rename_list',[list, name],
|
egw.json('addressbook.addressbook_ui.ajax_set_list',[list, name],
|
||||||
function(result)
|
function(result)
|
||||||
{
|
{
|
||||||
if(typeof result == 'object') return; // This response not for us
|
if(typeof result == 'object') return; // This response not for us
|
||||||
debugger;
|
|
||||||
// Update list
|
// Update list
|
||||||
if(result)
|
if(result)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user