Skip to content

Commit c9ab0ff

Browse files
committed
feat: add maxSelections to DataDimension
1 parent efc37a2 commit c9ab0ff

3 files changed

Lines changed: 12 additions & 2 deletions

File tree

src/components/DataDimension/DataDimension.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ const DataDimension = ({
3333
visType,
3434
height,
3535
heightCalculation,
36+
maxSelections,
3637
}) => {
3738
const { serverVersion } = useConfig()
3839

@@ -134,6 +135,7 @@ const DataDimension = ({
134135
onEditClick={onEditClick}
135136
height={height}
136137
heightCalculation={heightCalculation}
138+
maxSelections={maxSelections}
137139
/>
138140
{currentDataItem && (
139141
<ItemOptionsSelector
@@ -148,6 +150,7 @@ const DataDimension = ({
148150
onClose={() => setCurrentDataItem()}
149151
onEditClick={onEditClick}
150152
height={height}
153+
maxSelections={maxSelections}
151154
/>
152155
)}
153156
{infoDataItem && (
@@ -180,6 +183,7 @@ DataDimension.propTypes = {
180183
height: PropTypes.string,
181184
heightCalculation: PropTypes.string,
182185
infoBoxMessage: PropTypes.string,
186+
maxSelections: PropTypes.number,
183187
visType: PropTypes.string,
184188
onCalculationSave: PropTypes.func,
185189
}

src/components/DataDimension/ItemOptionsSelector/ItemOptionsSelector.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ export const ItemOptionsSelector = ({
5555
onClose,
5656
dataTest,
5757
height = TRANSFER_HEIGHT,
58+
maxSelections,
5859
}) => {
5960
const [state, setState] = useState({
6061
searchTerm: '',
@@ -236,7 +237,7 @@ export const ItemOptionsSelector = ({
236237
rightHeader={
237238
<p className="rightHeader">{i18n.t('Selected items')}</p>
238239
}
239-
enableOrderChange
240+
enableOrderChange={!maxSelections || maxSelections > 1}
240241
height={height}
241242
optionsWidth={TRANSFER_OPTIONS_WIDTH}
242243
selectedWidth={TRANSFER_SELECTED_WIDTH}
@@ -267,6 +268,7 @@ export const ItemOptionsSelector = ({
267268
/>
268269
)
269270
}}
271+
maxSelections={maxSelections}
270272
dataTest={`${dataTest}-option-view-mode-transfer`}
271273
/>
272274
<style jsx>{styles}</style>
@@ -286,6 +288,7 @@ ItemOptionsSelector.propTypes = {
286288
height: PropTypes.string,
287289
infoDataItem: PropTypes.object,
288290
itemsRef: PropTypes.object,
291+
maxSelections: PropTypes.number,
289292
selectedItems: PropTypes.arrayOf(
290293
PropTypes.exact({
291294
label: PropTypes.string.isRequired,

src/components/DataDimension/ItemSelector/ItemSelector.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ const ItemSelector = ({
138138
supportsEDI,
139139
height = TRANSFER_HEIGHT,
140140
heightCalculation,
141+
maxSelections,
141142
}) => {
142143
const [state, setState] = useState({
143144
searchTerm: '',
@@ -413,7 +414,7 @@ const ItemSelector = ({
413414
</div>
414415
) : undefined
415416
}
416-
enableOrderChange
417+
enableOrderChange={!maxSelections || maxSelections > 1}
417418
height={height}
418419
optionsWidth={TRANSFER_OPTIONS_WIDTH}
419420
selectedWidth={TRANSFER_SELECTED_WIDTH}
@@ -444,6 +445,7 @@ const ItemSelector = ({
444445
/* eslint-enable react/prop-types */
445446
/>
446447
)}
448+
maxSelections={maxSelections}
447449
dataTest={`${dataTest}-transfer`}
448450
/>
449451
{currentCalculation && supportsEDI && (
@@ -473,6 +475,7 @@ ItemSelector.propTypes = {
473475
infoDataItem: PropTypes.object,
474476
isOptionViewMode: PropTypes.bool,
475477
itemsRef: PropTypes.object,
478+
maxSelections: PropTypes.number,
476479
noItemsMessage: PropTypes.string,
477480
rightFooter: PropTypes.node,
478481
selectedItems: PropTypes.arrayOf(

0 commit comments

Comments
 (0)