return crmApi4('SearchDisplay', 'run', getApiParams(ctrl)).then(function(results) {
ctrl.results = results;
ctrl.editing = false;
- if (ctrl.settings.pager && !ctrl.rowCount) {
- if (results.length < ctrl.settings.limit) {
+ if (!ctrl.rowCount) {
+ if (!ctrl.settings.limit || results.length < ctrl.settings.limit) {
ctrl.rowCount = results.length;
- } else {
+ } else if (ctrl.settings.pager) {
var params = getApiParams(ctrl, 'row_count');
crmApi4('SearchDisplay', 'run', params).then(function(result) {
ctrl.rowCount = result.count;
afFieldset: '?^^afFieldset'
},
templateUrl: '~/crmSearchDisplayList/crmSearchDisplayList.html',
- controller: function($scope, crmApi4, searchDisplayUtils) {
+ controller: function($scope, $element, crmApi4, searchDisplayUtils) {
var ts = $scope.ts = CRM.ts('org.civicrm.search'),
ctrl = this;
this.sort = this.settings.sort ? _.cloneDeep(this.settings.sort) : [];
$scope.displayUtils = searchDisplayUtils;
+ // If search is embedded in contact summary tab, display count in tab-header
+ var contactTab = $element.closest('.crm-contact-page .ui-tabs-panel').attr('id');
+ if (contactTab) {
+ var unwatchCount = $scope.$watch('$ctrl.rowCount', function(rowCount) {
+ if (typeof rowCount === 'number') {
+ unwatchCount();
+ CRM.tabHeader.updateCount(contactTab.replace('contact-', '#tab_'), rowCount);
+ }
+ });
+ }
+
if (this.afFieldset) {
$scope.$watch(this.afFieldset.getFieldData, onChangeFilters, true);
}
afFieldset: '?^^afFieldset'
},
templateUrl: '~/crmSearchDisplayTable/crmSearchDisplayTable.html',
- controller: function($scope, crmApi4, searchDisplayUtils) {
+ controller: function($scope, $element, crmApi4, searchDisplayUtils) {
var ts = $scope.ts = CRM.ts('org.civicrm.search'),
ctrl = this;
this.sort = this.settings.sort ? _.cloneDeep(this.settings.sort) : [];
$scope.displayUtils = searchDisplayUtils;
+ // If search is embedded in contact summary tab, display count in tab-header
+ var contactTab = $element.closest('.crm-contact-page .ui-tabs-panel').attr('id');
+ if (contactTab) {
+ var unwatchCount = $scope.$watch('$ctrl.rowCount', function(rowCount) {
+ if (typeof rowCount === 'number') {
+ unwatchCount();
+ CRM.tabHeader.updateCount(contactTab.replace('contact-', '#tab_'), rowCount);
+ }
+ });
+ }
+
if (this.afFieldset) {
$scope.$watch(this.afFieldset.getFieldData, onChangeFilters, true);
}