diff --git a/addressbook/inc/class.addressbook_ui.inc.php b/addressbook/inc/class.addressbook_ui.inc.php index fb5fb4e8c4..121b52ae73 100644 --- a/addressbook/inc/class.addressbook_ui.inc.php +++ b/addressbook/inc/class.addressbook_ui.inc.php @@ -585,7 +585,8 @@ class addressbook_ui extends addressbook_bo 'hint' => 'Merge into first or account, deletes all other!', 'allowOnMultiple' => 'only', 'group' => $group, - 'hideOnMobile' => true + 'hideOnMobile' => true, + 'enabled' => 'javaScript:app.addressbook.can_merge' ); // Duplicates view $actions['merge_duplicates'] = array( diff --git a/addressbook/js/app.js b/addressbook/js/app.js index 37fedeb9e5..0ade9e5220 100644 --- a/addressbook/js/app.js +++ b/addressbook/js/app.js @@ -1247,5 +1247,20 @@ app.classes.addressbook = AppJS.extend( var geo_url = egw.config('geolocation_url'); if (geo_url) geo_url = geo_url[0]; return geo_url || default_url; + }, + + /** + * Check to see if the selection contains at most one account + * + * @param {egwAction} action + * @param {egwActionObject[]} selected Selected rows + */ + can_merge: function(action, selected) + { + return selected.filter(function (row) { + var data = egw.dataGetUIDdata(row.id); + return data && data.data.account_id; + }).length <= 1; } + });