From: Coleman Watts Date: Tue, 25 Feb 2014 19:56:12 +0000 (-0500) Subject: CRM-13966 - Migrate mergeTags to use select2 X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=ebb5fc589086154766fb41b4bd8b1ef40dc73420;p=civicrm-core.git CRM-13966 - Migrate mergeTags to use select2 --- diff --git a/CRM/Admin/Page/AJAX.php b/CRM/Admin/Page/AJAX.php index 16af8500cf..c1ba11fabf 100644 --- a/CRM/Admin/Page/AJAX.php +++ b/CRM/Admin/Page/AJAX.php @@ -291,9 +291,9 @@ class CRM_Admin_Page_AJAX { } static function mergeTagList() { - $name = CRM_Utils_Type::escape($_GET['s'], 'String'); + $name = CRM_Utils_Type::escape($_GET['s'], 'String'); $fromId = CRM_Utils_Type::escape($_GET['fromId'], 'Integer'); - $limit = CRM_Utils_Type::escape($_GET['limit'], 'Integer'); + $limit = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'search_autocomplete_count', NULL, 10); // build used-for clause to be used in main query $usedForTagA = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Tag', $fromId, 'used_for'); @@ -317,20 +317,25 @@ WHERE t1.id <> {$fromId} AND ({$usedForClause}) LIMIT $limit"; $dao = CRM_Core_DAO::executeQuery($query); + $result = array(); while ($dao->fetch()) { - $warning = 0; + $row = array( + 'id' => $dao->id, + 'text' => ($dao->parent ? "{$dao->parent} :: " : '') . $dao->name, + ); + // Add warning about used_for types if (!empty($dao->used_for)) { $usedForTagB = explode(',', $dao->used_for); sort($usedForTagB); $usedForDiff = array_diff($usedForTagA, $usedForTagB); if (!empty($usedForDiff)) { - $warning = 1; + $row['warning'] = TRUE; } } - $tag = addcslashes($dao->name, '"') . "|{$dao->id}|{$warning}\n"; - echo $tag = $dao->parent ? (addcslashes($dao->parent, '"') . ' :: ' . $tag) : $tag; + $result[] = $row; } + print json_encode($result); CRM_Utils_System::civiExit(); } @@ -487,6 +492,10 @@ LIMIT $limit"; $result['tagB_used_for'] = implode(', ', $result['tagB_used_for']); } + $result['message'] = ts('"%1" has been merged with "%2". All records previously tagged "%1" are now tagged "%2".', + array(1 => $result['tagA'], 2 => $result['tagB']) + ); + echo json_encode($result); CRM_Utils_System::civiExit(); } diff --git a/js/Common.js b/js/Common.js index fda00936e0..e4ccf6112d 100644 --- a/js/Common.js +++ b/js/Common.js @@ -600,6 +600,7 @@ CRM.validate = CRM.validate || { * passing in a function instead of an object is a shortcut for a sinlgle button labeled "Continue" * @param options {object|void} Override defaults, keys include 'title', 'message', * see jQuery.dialog for full list of available params + * @param cancelLabel {string} */ CRM.confirm = function (buttons, options, cancelLabel) { var dialog, callbacks = {}; @@ -629,8 +630,9 @@ CRM.validate = CRM.validate || { } $.each(callbacks, function (label, callback) { settings.buttons[label] = function () { - callback.call(dialog); - dialog.dialog('close'); + if (callback.call(dialog) !== false) { + dialog.dialog('close'); + } }; }); dialog = $('
') diff --git a/templates/CRM/Admin/Page/Tag.tpl b/templates/CRM/Admin/Page/Tag.tpl index d74f916229..fa8e0b12c7 100644 --- a/templates/CRM/Admin/Page/Tag.tpl +++ b/templates/CRM/Admin/Page/Tag.tpl @@ -96,100 +96,76 @@ {/if} - - {literal} {/literal}