Browse Source

fix weird glitch on Select/Unselect feature when selecting a New

master
Gaëtan Renaudeau 7 years ago
parent
commit
6979a2abaa
  1. 14
      src/components/base/AccountsList/index.js
  2. 13
      src/components/modals/AddAccounts/steps/03-step-import.js

14
src/components/base/AccountsList/index.js

@ -18,8 +18,8 @@ class AccountsList extends Component<
editedNames: { [accountId: string]: string },
setAccountName?: (Account, string) => void,
onToggleAccount?: Account => void,
onSelectAll?: () => void,
onUnselectAll?: () => void,
onSelectAll?: (Account[]) => void,
onUnselectAll?: (Account[]) => void,
title?: string,
emptyText?: string,
autoFocusFirstInput?: boolean,
@ -36,6 +36,14 @@ class AccountsList extends Component<
toggleCollapse = () => {
this.setState(({ collapsed }) => ({ collapsed: !collapsed }))
}
onSelectAll = () => {
const { accounts, onSelectAll } = this.props
if (onSelectAll) onSelectAll(accounts)
}
onUnselectAll = () => {
const { accounts, onUnselectAll } = this.props
if (onUnselectAll) onUnselectAll(accounts)
}
render() {
const {
accounts,
@ -76,7 +84,7 @@ class AccountsList extends Component<
{withToggleAll && (
<FakeLink
ml="auto"
onClick={isAllSelected ? onUnselectAll : onSelectAll}
onClick={isAllSelected ? this.onUnselectAll : this.onSelectAll}
fontSize={3}
style={{ lineHeight: '10px' }}
>

13
src/components/modals/AddAccounts/steps/03-step-import.js

@ -132,14 +132,19 @@ class StepImport extends PureComponent<StepProps> {
}
}
handleSelectAll = () => {
const { scannedAccounts, setScannedAccounts } = this.props
handleSelectAll = (accountsToSelect: Account[]) => {
const { setScannedAccounts, checkedAccountsIds } = this.props
setScannedAccounts({
checkedAccountsIds: scannedAccounts.filter(a => a.operations.length > 0).map(a => a.id),
checkedAccountsIds: uniq(checkedAccountsIds.concat(accountsToSelect.map(a => a.id))),
})
}
handleUnselectAll = () => this.props.setScannedAccounts({ checkedAccountsIds: [] })
handleUnselectAll = (accountsToRemove: Account[]) => {
const { setScannedAccounts, checkedAccountsIds } = this.props
setScannedAccounts({
checkedAccountsIds: checkedAccountsIds.filter(id => !accountsToRemove.some(a => id === a.id)),
})
}
renderError() {
const { err, t } = this.props

Loading…
Cancel
Save