-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
IBX-9227: Restore multipleItemsLimit cehcks in UDW
- Loading branch information
Showing
9 changed files
with
90 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,6 +43,10 @@ | |
} | ||
} | ||
} | ||
|
||
&--not-selectable { | ||
cursor: not-allowed; | ||
} | ||
} | ||
|
||
&__cell:first-child { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
src/bundle/ui-dev/src/modules/universal-discovery/helpers/selected.locations.helper.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
export const checkIsSelectable = ({ location, contentTypesMap, allowedContentTypes, containersOnly }) => { | ||
const contentType = contentTypesMap[location.ContentInfo.Content.ContentType._href]; | ||
const { isContainer, identifier } = contentType; | ||
const isAllowedContentType = allowedContentTypes?.includes(identifier) ?? true; | ||
|
||
return (!containersOnly || isContainer) && isAllowedContentType; | ||
}; | ||
|
||
export const checkIsSelected = ({ location, selectedLocations }) => | ||
selectedLocations.some((selectedLocation) => selectedLocation.location.id === location.id); | ||
|
||
export const checkIsSelectionBlocked = ({ location, selectedLocations, multipleItemsLimit }) => | ||
multipleItemsLimit !== 0 && selectedLocations.length >= multipleItemsLimit && !checkIsSelected({ location, selectedLocations }); |
33 changes: 33 additions & 0 deletions
33
src/bundle/ui-dev/src/modules/universal-discovery/hooks/useSelectedLocationsHelpers.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { useCallback, useContext } from 'react'; | ||
|
||
import { checkIsSelectable, checkIsSelected, checkIsSelectionBlocked } from '../helpers/selected.locations.helper'; | ||
import { | ||
AllowedContentTypesContext, | ||
ContainersOnlyContext, | ||
ContentTypesMapContext, | ||
MultipleConfigContext, | ||
SelectedLocationsContext, | ||
} from '../universal.discovery.module'; | ||
|
||
export const useSelectedLocationsHelpers = () => { | ||
const [, multipleItemsLimit] = useContext(MultipleConfigContext); | ||
const contentTypesMap = useContext(ContentTypesMapContext); | ||
const [selectedLocations] = useContext(SelectedLocationsContext); | ||
const containersOnly = useContext(ContainersOnlyContext); | ||
const allowedContentTypes = useContext(AllowedContentTypesContext); | ||
const checkIsSelectableWrapped = useCallback( | ||
(location) => checkIsSelectable({ location, contentTypesMap, allowedContentTypes, containersOnly }), | ||
[contentTypesMap, allowedContentTypes, containersOnly], | ||
); | ||
const checkIsSelectedWrapped = useCallback((location) => checkIsSelected({ location, selectedLocations }), [selectedLocations]); | ||
const checkIsSelectionBlockedWrapped = useCallback( | ||
(location) => checkIsSelectionBlocked({ location, selectedLocations, multipleItemsLimit }), | ||
[selectedLocations, multipleItemsLimit], | ||
); | ||
|
||
return { | ||
checkIsSelectable: checkIsSelectableWrapped, | ||
checkIsSelected: checkIsSelectedWrapped, | ||
checkIsSelectionBlocked: checkIsSelectionBlockedWrapped, | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters