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

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

@ -132,14 +132,19 @@ class StepImport extends PureComponent<StepProps> {
} }
} }
handleSelectAll = () => { handleSelectAll = (accountsToSelect: Account[]) => {
const { scannedAccounts, setScannedAccounts } = this.props const { setScannedAccounts, checkedAccountsIds } = this.props
setScannedAccounts({ 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() { renderError() {
const { err, t } = this.props const { err, t } = this.props

Loading…
Cancel
Save