Skip to content

Commit

Permalink
UIPFU-89: add Cancel and New button to support Routing list featu…
Browse files Browse the repository at this point in the history
…re and fix select all toggle button issue
  • Loading branch information
alisher-epam committed May 3, 2024
1 parent d6a7aea commit 45d111f
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 18 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
[Full Changelog](https://github.com/folio-org/ui-plugin-find-user/compare/v7.1.0...v7.1.1)

* Fix Select User Modal with User Assignment Status Filters pagination issue. Refs UIPFU-87.
* Add `Cancel` and `New` button to support Routing list feature and fix select all toggle button issue. Refs UIPFU-89.

## [7.1.0](https://github.com/folio-org/ui-plugin-find-user/tree/v7.1.0) (2024-03-20)
[Full Changelog](https://github.com/folio-org/ui-plugin-find-user/compare/v7.0.0...v7.1.0)
Expand Down
4 changes: 4 additions & 0 deletions src/UserSearchModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class UserSearchModal extends Component {
}),
}),
tenantId: PropTypes.string,
showCreateUserButton: PropTypes.bool,
}

static defaultProps = {
Expand Down Expand Up @@ -91,6 +92,7 @@ class UserSearchModal extends Component {
initialSelectedUsers,
tenantId,
stripes,
showCreateUserButton = false,
} = this.props;

return (
Expand All @@ -116,8 +118,10 @@ class UserSearchModal extends Component {
{...viewProps}
onSaveMultiple={this.passUsersOut}
onSelectRow={this.passUserOut}
onClose={this.closeModal}
isMultiSelect={Boolean(selectUsers)}
initialSelectedUsers={initialSelectedUsers}
showCreateUserButton={showCreateUserButton}
/>}
</UserSearchContainer>
</Modal>
Expand Down
58 changes: 40 additions & 18 deletions src/UserSearchView.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import {
SearchAndSortSearchButton as FilterPaneToggle,
} from '@folio/stripes/smart-components';

import { CREATE_USER_URL } from './constants';
import filterConfig, { filterConfigWithUserAssignedStatus } from './filterConfig';
import Filters from './Filters';

Expand Down Expand Up @@ -58,6 +59,7 @@ class UserSearchView extends React.Component {
idPrefix: PropTypes.string,
isMultiSelect: PropTypes.bool,
onSelectRow: PropTypes.func,
onClose: PropTypes.func,
onSaveMultiple: PropTypes.func,
onComponentWillUnmount: PropTypes.func,
queryGetter: PropTypes.func,
Expand All @@ -67,6 +69,7 @@ class UserSearchView extends React.Component {
data: PropTypes.object,
onNeedMoreData: PropTypes.func,
visibleColumns: PropTypes.arrayOf(PropTypes.string),
showCreateUserButton: PropTypes.bool,
resultOffset: PropTypes.shape({
replace: PropTypes.func.isRequired,
}),
Expand Down Expand Up @@ -146,7 +149,7 @@ class UserSearchView extends React.Component {
this.setState((state, props) => {
const isAllChecked = !state.isAllChecked;
const { data: { users } } = props;
const checkedMap = reduceUsersToMap(users, isAllChecked);
const checkedMap = reduceUsersToMap(users.records, isAllChecked);

return {
checkedMap,
Expand Down Expand Up @@ -196,6 +199,8 @@ class UserSearchView extends React.Component {
isMultiSelect,
resultOffset,
initialSelectedUsers,
onClose,
showCreateUserButton,
} = this.props;
const { checkedMap, isAllChecked } = this.state;

Expand Down Expand Up @@ -258,6 +263,17 @@ class UserSearchView extends React.Component {
email: user => get(user, ['personal', 'email']),
};

const createUserButton = (
<Button
data-test-find-users-modal-save-multiple
marginBottom0
to={CREATE_USER_URL}
buttonStyle="primary"
>
<FormattedMessage id="ui-plugin-find-user.modal.button.new" />
</Button>
);

return (
<>
<div
Expand Down Expand Up @@ -357,6 +373,7 @@ class UserSearchView extends React.Component {
paneSub={resultPaneSub}
defaultWidth="fill"
padContent={false}
lastMenu={showCreateUserButton && createUserButton}
>
<MultiColumnList
visibleColumns={builtVisibleColumns}
Expand Down Expand Up @@ -405,23 +422,28 @@ class UserSearchView extends React.Component {
{
isMultiSelect && (
<div className={css.UserSearchViewFooter}>
<>
<div>
<FormattedMessage
id="ui-plugin-find-user.modal.total"
values={{ count: checkedUsersLength }}
/>
</div>
<Button
data-test-find-users-modal-save-multiple
marginBottom0
onClick={this.saveMultiple}
disabled={disabled}
buttonStyle="primary"
>
<FormattedMessage id="ui-plugin-find-user.modal.save" />
</Button>
</>
<Button
data-test-find-users-modal-save-multiple
marginBottom0
onClick={onClose}
>
<FormattedMessage id="ui-plugin-find-user.modal.button.cancel" />
</Button>
<div>
<FormattedMessage
id="ui-plugin-find-user.modal.total"
values={{ count: checkedUsersLength }}
/>
</div>
<Button
data-test-find-users-modal-save-multiple
marginBottom0
onClick={this.saveMultiple}
disabled={disabled}
buttonStyle="primary"
>
<FormattedMessage id="ui-plugin-find-user.modal.save" />
</Button>
</div>
)
}
Expand Down
1 change: 1 addition & 0 deletions src/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ export const UAS = 'uas';
export const ASSIGNED_FILTER_KEY = 'uas.Assigned';
export const UNASSIGNED_FILTER_KEY = 'uas.Unassigned';
export const ASSIGNED = 'Assigned';
export const CREATE_USER_URL = '/users/create';
2 changes: 2 additions & 0 deletions translations/ui-plugin-find-user/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
"modal.close": "Close",
"modal.save": "Save",
"modal.total": "Total selected: {count}",
"modal.button.new": "New",
"modal.button.cancel": "Cancel",
"searchButton.title": "Find User",
"information.patronGroup": "Patron group",
"active": "Active",
Expand Down

0 comments on commit 45d111f

Please sign in to comment.