forked from extern/egroupware
* Add ability to rename current distribution list from context menu, as well as more consistent behaviour for adding lists
This commit is contained in:
parent
928c61d4cf
commit
4222d51e39
@ -250,9 +250,10 @@ class addressbook_ui extends addressbook_bo
|
|||||||
}
|
}
|
||||||
$sel_options['cat_id'] = array('' => lang('all'), '0' => lang('None'));
|
$sel_options['cat_id'] = array('' => lang('all'), '0' => lang('None'));
|
||||||
|
|
||||||
// Delete list action depends on permissions
|
// Edit and delete list actions depends on permissions
|
||||||
if($this->get_lists(EGW_ACL_EDIT))
|
if($this->get_lists(EGW_ACL_EDIT))
|
||||||
{
|
{
|
||||||
|
$content['nm']['placeholder_actions'][] = 'rename_list';
|
||||||
$content['nm']['placeholder_actions'][] = 'delete_list';
|
$content['nm']['placeholder_actions'][] = 'delete_list';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -482,6 +483,14 @@ class addressbook_ui extends addressbook_bo
|
|||||||
'fieldId' => 'exec[nm][filter2]',
|
'fieldId' => 'exec[nm][filter2]',
|
||||||
'fieldValue' => '!', // enable if list != ''
|
'fieldValue' => '!', // enable if list != ''
|
||||||
),
|
),
|
||||||
|
'rename_list' => array(
|
||||||
|
'caption' => 'Rename selected distribution list',
|
||||||
|
'icon' => 'edit',
|
||||||
|
'enabled' => 'javaScript:app.addressbook.nm_compare_field',
|
||||||
|
'fieldId' => 'exec[nm][filter2]',
|
||||||
|
'fieldValue' => '!', // enable if list != ''
|
||||||
|
'onExecute' => 'javaScript:app.addressbook.rename_list'
|
||||||
|
),
|
||||||
'delete_list' => array(
|
'delete_list' => array(
|
||||||
'caption' => 'Delete selected distribution list!',
|
'caption' => 'Delete selected distribution list!',
|
||||||
'confirm' => 'Delete selected distribution list!',
|
'confirm' => 'Delete selected distribution list!',
|
||||||
@ -494,6 +503,7 @@ class addressbook_ui extends addressbook_bo
|
|||||||
if(is_subclass_of('etemplate', 'etemplate_new'))
|
if(is_subclass_of('etemplate', 'etemplate_new'))
|
||||||
{
|
{
|
||||||
$actions['lists']['children']['remove_from_list']['fieldId'] = 'filter2';
|
$actions['lists']['children']['remove_from_list']['fieldId'] = 'filter2';
|
||||||
|
$actions['lists']['children']['rename_list']['fieldId'] = 'filter2';
|
||||||
$actions['lists']['children']['delete_list']['fieldId'] = 'filter2';
|
$actions['lists']['children']['delete_list']['fieldId'] = 'filter2';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -879,6 +889,50 @@ window.egw_LAB.wait(function() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create or rename an existing email list
|
||||||
|
*
|
||||||
|
* @param int $list_id ID of existing list, or 0 for a new one
|
||||||
|
* @param string $new_name List name
|
||||||
|
* @param int $owner List owner, or empty for current user
|
||||||
|
* @return boolean|string
|
||||||
|
*/
|
||||||
|
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
|
||||||
|
if(!(int)$list_id && !$this->check_list(null,EGW_ACL_ADD|EGW_ACL_EDIT,$owner))
|
||||||
|
{
|
||||||
|
egw_json_response::get()->apply('egw.message', array( lang('List creation failed, no rights!'),'error'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
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'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$list = array('list_owner' => $owner);
|
||||||
|
|
||||||
|
// Rename
|
||||||
|
if($list_id)
|
||||||
|
{
|
||||||
|
$list = $this->read_list((int)$list_id);
|
||||||
|
}
|
||||||
|
$list['list_name'] = $new_name;
|
||||||
|
|
||||||
|
$new_id = $this->add_list(array('list_id' => (int)$list_id), $list['list_owner'],array(),$list);
|
||||||
|
|
||||||
|
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
|
||||||
|
egw_json_response::get()->data($new_id == $list_id ? "true" : $new_id);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* apply an action to multiple contacts
|
* apply an action to multiple contacts
|
||||||
*
|
*
|
||||||
@ -989,7 +1043,7 @@ window.egw_LAB.wait(function() {
|
|||||||
egw_session::appsession($session_name,'addressbook',$query);
|
egw_session::appsession($session_name,'addressbook',$query);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
case 'document':
|
case 'document':
|
||||||
if (!$document) $document = $this->prefs['default_document'];
|
if (!$document) $document = $this->prefs['default_document'];
|
||||||
$document_merge = new addressbook_merge();
|
$document_merge = new addressbook_merge();
|
||||||
|
@ -438,14 +438,81 @@ app.classes.addressbook = AppJS.extend(
|
|||||||
|
|
||||||
add_new_list: function(owner)
|
add_new_list: function(owner)
|
||||||
{
|
{
|
||||||
var name = window.prompt(this.egw.lang('Name for the distribution list'));
|
if(!owner || typeof owner == 'object')
|
||||||
if (name)
|
|
||||||
{
|
{
|
||||||
egw.open('','addressbook', 'list', {
|
var filter = this.et2.getWidgetById('filter');
|
||||||
'add_list': name,
|
owner = filter.getValue()||egw.preference('add_default','addressbook');
|
||||||
'owner': owner
|
|
||||||
},'_self');
|
|
||||||
}
|
}
|
||||||
|
var lists = this.et2.getWidgetById('filter2');
|
||||||
|
et2_dialog.show_prompt(
|
||||||
|
function(button, name) {
|
||||||
|
if(button == et2_dialog.OK_BUTTON)
|
||||||
|
{
|
||||||
|
egw.json('addressbook.addressbook_ui.ajax_set_list',[0, name, owner],
|
||||||
|
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
|
||||||
|
*
|
||||||
|
* 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 {egwActionObject[]} selected The selected row(s). Not used for this.
|
||||||
|
*/
|
||||||
|
rename_list: function(action, selected)
|
||||||
|
{
|
||||||
|
var lists = this.et2.getWidgetById('filter2');
|
||||||
|
var list = lists.getValue() || 0;
|
||||||
|
var value = null;
|
||||||
|
for(var i = 0; i < lists.options.select_options.length; i++)
|
||||||
|
{
|
||||||
|
if(lists.options.select_options[i].value == list)
|
||||||
|
{
|
||||||
|
value = lists.options.select_options[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
et2_dialog.show_prompt(
|
||||||
|
function(button, name) {
|
||||||
|
if(button == et2_dialog.OK_BUTTON)
|
||||||
|
{
|
||||||
|
egw.json('addressbook.addressbook_ui.ajax_set_list',[list, name],
|
||||||
|
function(result)
|
||||||
|
{
|
||||||
|
if(typeof result == 'object') return; // This response not for us
|
||||||
|
// Update list
|
||||||
|
if(result)
|
||||||
|
{
|
||||||
|
value.label = name;
|
||||||
|
lists.set_select_options(lists.options.select_options);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
).sendRequest(true);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
this.egw.lang('Name for the distribution list'),
|
||||||
|
this.egw.lang('Rename list'),
|
||||||
|
value.label
|
||||||
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
filter2_onchange: function()
|
filter2_onchange: function()
|
||||||
|
Loading…
Reference in New Issue
Block a user