Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Embed afforms & search displays on contact summary screen as blocks and tabs #19887

Merged
merged 3 commits into from
Apr 7, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
SearchKit - display count in tab header if embedded in contact summar…
…y tab
  • Loading branch information
colemanw committed Apr 6, 2021
commit 54a03b7b04997e805cce6b797ec880ab6e4bdeda
6 changes: 3 additions & 3 deletions ext/search/ang/crmSearchDisplay.module.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,10 @@
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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
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;

Expand All @@ -25,6 +25,17 @@
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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
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;

Expand All @@ -26,6 +26,17 @@
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);
}
Expand Down