Merge pull request #19307 from eileenmcnaughton/534
[civicrm-core.git] / ext / search / ang / crmSearchActions.module.js
CommitLineData
e78d6a2d
CW
1(function(angular, $, _) {
2 "use strict";
3
4 // Declare module
014174e7
CW
5 angular.module('crmSearchActions', CRM.angRequires('crmSearchActions'))
6
7 // Reformat an array of objects for compatibility with select2
8 // Todo this probably belongs in core
9 .factory('formatForSelect2', function() {
10 return function(input, key, label, extra) {
11 return _.transform(input, function(result, item) {
12 var formatted = {id: item[key], text: item[label]};
13 if (extra) {
14 _.merge(formatted, _.pick(item, extra));
15 }
16 result.push(formatted);
17 }, []);
18 };
19 });
e78d6a2d
CW
20
21})(angular, CRM.$, CRM._);