Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/components/DataDimension/Calculation/CalculationModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ const CalculationModal = ({
onClose,
onDelete,
displayNameProp,
height,
}) => {
const { show: showError } = useAlert((error) => error, { critical: true })
const mutationParams = { onError: (error) => showError(error) }
Expand Down Expand Up @@ -311,6 +312,7 @@ const CalculationModal = ({
<DataElementSelector
displayNameProp={displayNameProp}
onDoubleClick={addItem}
height={height}
/>
<MathOperatorSelector onDoubleClick={addItem} />
</div>
Expand Down Expand Up @@ -484,6 +486,7 @@ CalculationModal.propTypes = {
id: PropTypes.string,
name: PropTypes.string,
}),
height: PropTypes.string,
}

export default CalculationModal
10 changes: 9 additions & 1 deletion src/components/DataDimension/Calculation/DataElementSelector.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import {
import DataElementOption from './DataElementOption.js'
import styles from './styles/DataElementSelector.style.js'

const SCROLLBOX_HEIGHT = '337px'

const getOptions = () => ({
[TOTALS]: i18n.t('Totals only'),
[DETAIL]: i18n.t('Details only'),
Expand Down Expand Up @@ -123,7 +125,11 @@ DisaggregationSelector.propTypes = {
onChange: PropTypes.func.isRequired,
}

const DataElementSelector = ({ displayNameProp, onDoubleClick }) => {
const DataElementSelector = ({
displayNameProp,
onDoubleClick,
height = SCROLLBOX_HEIGHT,
}) => {
const dataEngine = useDataEngine()

const [searchTerm, setSearchTerm] = useState('')
Expand Down Expand Up @@ -271,6 +277,7 @@ const DataElementSelector = ({ displayNameProp, onDoubleClick }) => {
<div
className="dimension-list-scrollbox"
ref={rootRef}
style={{ height }}
onScroll={() => {
if (isSorting) {
rootRef.current.scrollTo({
Expand Down Expand Up @@ -319,6 +326,7 @@ const DataElementSelector = ({ displayNameProp, onDoubleClick }) => {
DataElementSelector.propTypes = {
displayNameProp: PropTypes.string.isRequired,
onDoubleClick: PropTypes.func.isRequired,
height: PropTypes.string,
}

export default DataElementSelector
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ export default css`
.dimension-list-scrollbox {
position: relative;
width: 100%;
height: 337px;
overflow: hidden;
overflow-y: auto;
border: 1px solid ${colors.grey400};
Expand Down
11 changes: 11 additions & 0 deletions src/components/DataDimension/DataDimension.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ const DataDimension = ({
infoBoxMessage,
onCalculationSave,
visType,
height,
heightCalculation,
maxSelections,
}) => {
const { serverVersion } = useConfig()

Expand Down Expand Up @@ -130,6 +133,9 @@ const DataDimension = ({
infoDataItem={infoDataItem}
setInfoDataItem={setInfoDataItem}
onEditClick={onEditClick}
height={height}
heightCalculation={heightCalculation}
maxSelections={maxSelections}
/>
{currentDataItem && (
<ItemOptionsSelector
Expand All @@ -143,6 +149,8 @@ const DataDimension = ({
setInfoDataItem={setInfoDataItem}
onClose={() => setCurrentDataItem()}
onEditClick={onEditClick}
height={height}
maxSelections={maxSelections}
/>
)}
{infoDataItem && (
Expand Down Expand Up @@ -172,7 +180,10 @@ DataDimension.propTypes = {
onSelect: PropTypes.func.isRequired,
currentUser: PropTypes.object,
enabledDataTypes: PropTypes.array,
height: PropTypes.string,
heightCalculation: PropTypes.string,
infoBoxMessage: PropTypes.string,
maxSelections: PropTypes.number,
visType: PropTypes.string,
onCalculationSave: PropTypes.func,
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ export const ItemOptionsSelector = ({
onSelect,
onClose,
dataTest,
height = TRANSFER_HEIGHT,
maxSelections,
}) => {
const [state, setState] = useState({
searchTerm: '',
Expand Down Expand Up @@ -235,8 +237,8 @@ export const ItemOptionsSelector = ({
rightHeader={
<p className="rightHeader">{i18n.t('Selected items')}</p>
}
enableOrderChange
height={TRANSFER_HEIGHT}
enableOrderChange={!maxSelections || maxSelections > 1}
height={height}
optionsWidth={TRANSFER_OPTIONS_WIDTH}
selectedWidth={TRANSFER_SELECTED_WIDTH}
selectedEmptyComponent={<SelectedEmptyPlaceholder />}
Expand Down Expand Up @@ -266,6 +268,7 @@ export const ItemOptionsSelector = ({
/>
)
}}
maxSelections={maxSelections}
dataTest={`${dataTest}-option-view-mode-transfer`}
/>
<style jsx>{styles}</style>
Expand All @@ -282,8 +285,10 @@ ItemOptionsSelector.propTypes = {
onClose: PropTypes.func.isRequired,
onSelect: PropTypes.func.isRequired,
dataTest: PropTypes.string,
height: PropTypes.string,
infoDataItem: PropTypes.object,
itemsRef: PropTypes.object,
maxSelections: PropTypes.number,
selectedItems: PropTypes.arrayOf(
PropTypes.exact({
label: PropTypes.string.isRequired,
Expand Down
12 changes: 10 additions & 2 deletions src/components/DataDimension/ItemSelector/ItemSelector.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,9 @@ const ItemSelector = ({
onEditClick,
isOptionViewMode,
supportsEDI,
height = TRANSFER_HEIGHT,
heightCalculation,
maxSelections,
}) => {
const [state, setState] = useState({
searchTerm: '',
Expand Down Expand Up @@ -411,8 +414,8 @@ const ItemSelector = ({
</div>
) : undefined
}
enableOrderChange
height={TRANSFER_HEIGHT}
enableOrderChange={!maxSelections || maxSelections > 1}
height={height}
optionsWidth={TRANSFER_OPTIONS_WIDTH}
selectedWidth={TRANSFER_SELECTED_WIDTH}
selectedEmptyComponent={<SelectedEmptyPlaceholder />}
Expand Down Expand Up @@ -442,6 +445,7 @@ const ItemSelector = ({
/* eslint-enable react/prop-types */
/>
)}
maxSelections={maxSelections}
dataTest={`${dataTest}-transfer`}
/>
{currentCalculation && supportsEDI && (
Expand All @@ -451,6 +455,7 @@ const ItemSelector = ({
onClose={() => setCurrentCalculation()}
onDelete={onDeleteCalculation}
displayNameProp={displayNameProp}
height={heightCalculation}
/>
)}
<style jsx>{styles}</style>
Expand All @@ -464,10 +469,13 @@ ItemSelector.propTypes = {
currentCalculation: PropTypes.object,
dataTest: PropTypes.string,
dataTypes: PropTypes.array,
height: PropTypes.string,
heightCalculation: PropTypes.string,
infoBoxMessage: PropTypes.string,
infoDataItem: PropTypes.object,
isOptionViewMode: PropTypes.bool,
itemsRef: PropTypes.object,
maxSelections: PropTypes.number,
noItemsMessage: PropTypes.string,
rightFooter: PropTypes.node,
selectedItems: PropTypes.arrayOf(
Expand Down
Loading