1 (function(angular
, $, _
) {
4 angular
.module('crmSearchDisplayList').component('crmSearchDisplayList', {
12 afFieldset
: '?^^afFieldset'
14 templateUrl
: '~/crmSearchDisplayList/crmSearchDisplayList.html',
15 controller: function($scope
, crmApi4
, searchDisplayUtils
) {
16 var ts
= $scope
.ts
= CRM
.ts(),
20 this.$onInit = function() {
21 this.apiParams
= _
.cloneDeep(this.apiParams
);
22 this.apiParams
.limit
= parseInt(this.settings
.limit
|| 0, 10);
23 this.columns
= searchDisplayUtils
.prepareColumns(this.settings
.columns
, this.apiParams
);
24 $scope
.displayUtils
= searchDisplayUtils
;
25 if (this.afFieldset
) {
26 $scope
.$watch(this.afFieldset
.getFieldData
, this.getResults
, true);
28 $scope
.$watch('$ctrl.filters', ctrl
.getResults
, true);
31 this.getResults
= _
.debounce(function() {
32 var params
= searchDisplayUtils
.prepareParams(ctrl
);
34 crmApi4(ctrl
.apiEntity
, 'get', params
).then(function(results
) {
35 ctrl
.results
= results
;
36 ctrl
.rowCount
= results
.count
;
40 $scope
.formatResult = function(row
, col
) {
41 var value
= row
[col
.key
],
42 formatted
= searchDisplayUtils
.formatSearchValue(row
, col
, value
),
44 if (formatted
.length
|| (col
.label
&& col
.forceLabel
)) {
45 if (col
.label
&& (formatted
.length
|| col
.forceLabel
)) {
46 output
+= '<label>' + _
.escape(col
.label
) + '</label> ';
48 if (formatted
.length
) {
49 output
+= (col
.prefix
|| '') + formatted
+ (col
.suffix
|| '');
58 })(angular
, CRM
.$, CRM
._
);