|
|
|
@ -23,6 +23,7 @@ interface IProps {
@@ -23,6 +23,7 @@ interface IProps {
|
|
|
|
|
selectAllTextStyle?: StyleProp<TextStyle> |
|
|
|
|
selectAllBtnStyle?: ViewStyle |
|
|
|
|
disableIds?: number[] |
|
|
|
|
excludeIds?: number[] |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
export const UsersSelectListWithSearch: FC<IProps> = ({ |
|
|
|
@ -33,6 +34,7 @@ export const UsersSelectListWithSearch: FC<IProps> = ({
@@ -33,6 +34,7 @@ export const UsersSelectListWithSearch: FC<IProps> = ({
|
|
|
|
|
selectAllTextStyle, |
|
|
|
|
selectAllBtnStyle, |
|
|
|
|
disableIds, |
|
|
|
|
excludeIds, |
|
|
|
|
}) => { |
|
|
|
|
const { styles } = useTheme(createStyles) |
|
|
|
|
|
|
|
|
@ -58,12 +60,22 @@ export const UsersSelectListWithSearch: FC<IProps> = ({
@@ -58,12 +60,22 @@ export const UsersSelectListWithSearch: FC<IProps> = ({
|
|
|
|
|
return textA < textB ? -1 : textA > textB ? 1 : 0 |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
return sortedUsers |
|
|
|
|
}, [selectedUsers, items]) |
|
|
|
|
const filteredUsers = sortedUsers?.filter( |
|
|
|
|
it => !_.includes(excludeIds, it.id), |
|
|
|
|
) |
|
|
|
|
return filteredUsers |
|
|
|
|
}, [selectedUsers, items, excludeIds]) |
|
|
|
|
|
|
|
|
|
const handleSelectAll = async () => { |
|
|
|
|
if (isLoadedAll) { |
|
|
|
|
selectAll(_.filter(items, it => !_.includes(disableIds, it.id))) |
|
|
|
|
selectAll( |
|
|
|
|
_.filter( |
|
|
|
|
items, |
|
|
|
|
it => |
|
|
|
|
!_.includes(disableIds, it.id) && |
|
|
|
|
!_.includes(excludeIds, it.id), |
|
|
|
|
), |
|
|
|
|
) |
|
|
|
|
} else { |
|
|
|
|
setLoadSelectAll(true) |
|
|
|
|
await loadAll() |
|
|
|
@ -72,7 +84,14 @@ export const UsersSelectListWithSearch: FC<IProps> = ({
@@ -72,7 +84,14 @@ export const UsersSelectListWithSearch: FC<IProps> = ({
|
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
|
if (loadSelectAll) { |
|
|
|
|
selectAll(_.filter(items, it => !_.includes(disableIds, it.id))) |
|
|
|
|
selectAll( |
|
|
|
|
_.filter( |
|
|
|
|
items, |
|
|
|
|
it => |
|
|
|
|
!_.includes(disableIds, it.id) && |
|
|
|
|
!_.includes(excludeIds, it.id), |
|
|
|
|
), |
|
|
|
|
) |
|
|
|
|
setLoadSelectAll(false) |
|
|
|
|
} |
|
|
|
|
}, [items]) |
|
|
|
|