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

SearchKit - Customizable "No Results" text #22770

Merged
merged 1 commit into from
Feb 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@
</div>
<search-admin-css-rules label="{{:: ts('Row Style') }}" item="$ctrl.display.settings"></search-admin-css-rules>
<search-admin-pager-config display="$ctrl.display"></search-admin-pager-config>
<div class="form-inline crm-search-admin-flex-row" title="{{:: ts('Text to display if the table is empty.') }}">
<label for="crm-search-admin-display-no-results-text">{{:: ts('No Results Text') }}</label>
<input class="form-control crm-flex-1" id="crm-search-admin-display-no-results-text" ng-model="$ctrl.display.settings.noResultsText" placeholder="{{:: ts('None found.') }}">
</div>
</fieldset>
<fieldset class="crm-search-admin-edit-columns-wrapper">
<legend>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,25 @@
this.initializeDisplay($scope, $element);
// Keep tab counts up-to-date - put rowCount in current tab if there are no other filters
$scope.$watch('$ctrl.rowCount', function(val) {
if (typeof val === 'number' && angular.equals(['has_base'], _.keys(ctrl.filters))) {
if (typeof val === 'number' && angular.equals(['has_base'], getActiveFilters())) {
ctrl.tabCount = val;
}
});
// Customize the noResultsText
$scope.$watch('$ctrl.filters', function() {
ctrl.settings.noResultsText = (angular.equals(['has_base'], getActiveFilters())) ?
ts('Welcome to Search Kit. Click the New Search button above to start composing your first search.') :
ts('No Saved Searches match filter criteria.');
}, true);
};

// Get the names of in-use filters
function getActiveFilters() {
return _.keys(_.pick(ctrl.filters, function(val) {
return val !== null && (val === true || val === false || val.length);
}));
}

this.onPostRun.push(function(result) {
_.each(result, function(row) {
row.permissionToEdit = CRM.checkPerm('all CiviCRM permissions and ACLs') || !_.includes(row.data.display_acl_bypass, true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<tr ng-if="$ctrl.rowCount === 0">
<td colspan="{{ $ctrl.settings.columns.length + 2 }}">
<p class="alert alert-info text-center">
{{:: ts('None Found') }}
{{ $ctrl.settings.noResultsText || ts('None Found') }}
</p>
</td>
</tr>