Skip to content

Commit

Permalink
STSMACOM-683: Add new prop to SearchAndSort to have possibility hide … (
Browse files Browse the repository at this point in the history
  • Loading branch information
UladzislauKutarkin authored and zburke committed Jul 26, 2022
1 parent f175b39 commit 1bd07c1
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## 7.2.1 IN PROGRESS

* Mark `initialValues` as immutable in `<LocationForm>`. Fixes STSMACOM-679.
* Add isCountHidden prop to SearchAndSort component. Refs STSMACOM-683.

## [7.2.0](https://github.com/folio-org/stripes-smart-components/tree/v7.2.0) (2022-06-14)
[Full Changelog](https://github.com/folio-org/stripes-smart-components/compare/v7.1.0...v7.2.0)
Expand Down
5 changes: 4 additions & 1 deletion lib/SearchAndSort/SearchAndSort.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ class SearchAndSort extends React.Component {
}).isRequired,
initialFilters: PropTypes.string,
initialResultCount: PropTypes.number.isRequired,
isCountHidden: PropTypes.bool,
location: PropTypes.shape({ // provided by withRouter
pathname: PropTypes.string.isRequired,
search: PropTypes.string.isRequired,
Expand Down Expand Up @@ -255,6 +256,7 @@ class SearchAndSort extends React.Component {
hasRowClickHandlers: true,
selectedIndex: '',
hasNewButton: true,
isCountHidden: false,
resultRowIsSelected: ({ item, criteria }) => {
if (criteria) {
return isMatch(item, criteria);
Expand Down Expand Up @@ -1219,6 +1221,7 @@ class SearchAndSort extends React.Component {
customPaneSub,
resultCountMessageKey,
customPaneSubText,
isCountHidden
} = this.props;

const messageKey = resultCountMessageKey || 'stripes-smart-components.searchResultsCountHeader';
Expand All @@ -1233,7 +1236,7 @@ class SearchAndSort extends React.Component {
{isSearchResultCountUnknown && (
<FormattedMessage id="stripes-smart-components.searchResultsCountUnknown" />
)}
{isSearchResultCountPresent && (
{isSearchResultCountPresent && !isCountHidden && (
<FormattedMessage id={messageKey} values={{ count: source.totalCount() }} />
)}
{!isSourceLoaded && (
Expand Down
8 changes: 4 additions & 4 deletions lib/SearchAndSort/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ visibleColumns | array of fieldnames | As for [`<MultiColumnList>`](https://gith
columnManagerProps | Applies additional props for the internal `<ColumnManager>` | As for [`<ColumnManager>`](https://github.com/folio-org/stripes-smart-components/blob/master/lib/ColumnManager/readme.md)
columnWidths | object whose names are field captions | As for [`<MultiColumnList>`](https://github.com/folio-org/stripes-components/blob/master/lib/MultiColumnList/readme.md)
columnMapping | object whose names are field captions | As for [`<MultiColumnList>`](https://github.com/folio-org/stripes-components/blob/master/lib/MultiColumnList/readme.md)
resultRowFormatter | object mapping field-names to functions | As for [`<MultiColumnList>`](https://github.com/folio-org/stripes-components/blob/master/lib/MultiColumnList/readme.md)
resultRowFormatter | object mapping field-names to functions | As for [`<MultiColumnList>`](https://github.com/folio-org/stripes-components/blob/master/lib/MultiColumnList/readme.md)
resultRowIsSelected | func | function returning a boolean to determine whether or not an item in the results should have the 'selected' CSS style applied. A default `isMatch` function is supplied.
onSelectRow | func | Optional function to override the default action when selecting a row (which displays the full record). May be used, for example, when running one module embedded in another, as when ui-checkin embeds an instance of ui-users to select the user for whom items are being checked out.
massageNewRecord | func | If provided, this function is passed newly submitted records and may massage them in whatever way it wishes before they are persisted to the back-end. May be used to perform lookups, expand abbreviations, etc.
Expand All @@ -63,14 +63,14 @@ getHelperComponent | func | An optional function which can be used to return con
title | string/element | An optional property to specify title of results pane. By default module display name is used.
hasNewButton | boolean | An optional property to specify appearance Of `New` button of results pane. By default pane displays with `New` button.
basePath | string | An optional string to customize the path which should be used after performing search.
resultsVirtualize | boolean | controls the `virtualize` prop to the internally rendered `<MultiColumnList>` component.
resultsVirtualize | boolean | controls the `virtualize` prop to the internally rendered `<MultiColumnList>` component.
resultsOnMarkPosition | func | sets the `onMarkPosition` prop to the internally rendered `<MultiColumnList>` component. A paramater "position" object with a list offset and selector is provided. This can be stored on the application side to resume scroll position of the results list (if using next/prev pagination.)
resultsOnResetMarkedPosition | func | sets the `onMarkReset` prop to the internally rendered `<MultiColumnList>` component. It can be used to nullify the "position" object in application state.
resultsOnResetMarkedPosition | func | sets the `onMarkReset` prop to the internally rendered `<MultiColumnList>` component. It can be used to nullify the "position" object in application state.
resultsCachedPosition | position object | sets the `ItemToView` prop of the internally rendered `<MultiColumnList>` component. It's in the shape of `{selector: string, clientTopOffset: number}`. This object is provided by the `resultsOnMarkPosition` prop.
resultsKey | string | Sets a `key` prop on the internally rendered `<MultiColumnList>`. Changing this value will re-initialize the MCL. If necessary, this can be used to refresh the component so that it resets/readjusts to updates in data. This should be used sparingly as it can cause multiple re-renders of the list.
customPaneSubText | node | A component that will be rendered in PaneSubHeader instead of default.
searchFieldButtonLabel | node | A component that will be rendered inside the SearchField button instead of default.

`isCountHidden` | bool | A prop that give us possibiblty to hide count of records in Pane.

See ui-users' top-level component [`<Users.js>`](https://github.com/folio-org/ui-users/blob/master/Users.js) for an example of how to use `<SearchAndSort>`.

Expand Down
4 changes: 4 additions & 0 deletions lib/SearchAndSort/tests/record-count-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import SearchAndSort from '../SearchAndSort';
const defaultProps = {
initialResultCount: 0,
resultCountIncrement: 0,
isCountHidden: false,
viewRecordPerms: 'test',
objectName: 'user',
parentResources: {
Expand Down Expand Up @@ -68,6 +69,7 @@ describe('SearchAndSort results', () => {

beforeEach(async () => {
const localProps = {
isCountHidden: false,
parentResources: {
records: {
hasLoaded: true,
Expand Down Expand Up @@ -104,6 +106,7 @@ describe('SearchAndSort results', () => {

beforeEach(async () => {
const localProps = {
isCountHidden: false,
parentResources: {
records: {
hasLoaded: true,
Expand Down Expand Up @@ -151,6 +154,7 @@ describe('SearchAndSort results', () => {

beforeEach(async () => {
const localProps = {
isCountHidden: false,
parentResources: {
records: {
isPending: false,
Expand Down

0 comments on commit 1bd07c1

Please sign in to comment.