Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: dimensions panel divided in to sections #581

Merged
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
2 changes: 2 additions & 0 deletions packages/app/src/components/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React, { Component } from 'react'
import { connect } from 'react-redux'
import PropTypes from 'prop-types'
import i18n from '@dhis2/d2-i18n'
import { CssVariables } from '@dhis2/ui-core'

import DndContext from './DndContext'
import Snackbar from '../components/Snackbar/Snackbar'
Expand Down Expand Up @@ -199,6 +200,7 @@ export class App extends Component {
</div>
</div>
<Snackbar />
<CssVariables colors spacers />
</>
)
}
Expand Down
53 changes: 50 additions & 3 deletions packages/app/src/components/DimensionsPanel/DndDimensionList.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ import { createSelector } from 'reselect'
import {
getDisallowedDimensions,
getAllLockedDimensionIds,
getFixedDimensions,
getDynamicDimensions,
getPredefinedDimensions,
} from '@dhis2/analytics'

import DndDimensionItem from './DndDimensionItem'
Expand Down Expand Up @@ -47,11 +50,30 @@ export class DndDimensionList extends Component {
)
}

render() {
const dimensionsList = this.props.dimensions
getDimensionItemsByFilter = filter =>
this.props.dimensions
.filter(filter)
.filter(this.nameContainsFilterText)
.map(this.renderItem)

render() {
const fixedDimensions = this.getDimensionItemsByFilter(dimension =>
Object.values(getFixedDimensions()).some(
fixedDim => fixedDim.id === dimension.id
)
)
const dynamicDimensions = this.getDimensionItemsByFilter(dimension =>
Object.values(getDynamicDimensions()).some(
dynDim => dynDim.id === dimension.id
)
)
const nonPredefinedDimensions = this.getDimensionItemsByFilter(
dimension =>
!Object.values(getPredefinedDimensions()).some(
predefDim => predefDim.id === dimension.id
)
)

return (
<Droppable droppableId={SOURCE_DIMENSIONS} isDropDisabled={true}>
{provided => (
Expand All @@ -60,7 +82,32 @@ export class DndDimensionList extends Component {
ref={provided.innerRef}
{...provided.droppableProps}
>
<ul className={styles.list}>{dimensionsList}</ul>
<div className={styles.wrapper}>
<div className={styles.section}>
<h3 className={styles.header}>
Main dimensions
</h3>
<ul className={styles.list}>
{fixedDimensions}
</ul>
</div>
<div className={styles.section}>
<h3 className={styles.header}>
Other dimensions
</h3>
<ul className={styles.list}>
{dynamicDimensions}
</ul>
</div>
<div className={styles.section}>
<h3 className={styles.header}>
Your dimensions
</h3>
<ul className={styles.list}>
{nonPredefinedDimensions}
</ul>
</div>
</div>
{provided.placeholder}
</div>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React, { Component } from 'react'
import PropTypes from 'prop-types'
import i18n from '@dhis2/d2-i18n'
import { DimensionFilter } from '@dhis2/analytics'
import { colors } from '@dhis2/ui-core'

import DndDimensionList from './DndDimensionList'

Expand All @@ -22,11 +23,17 @@ export class DndDimensionsPanel extends Component {
return (
<div className={styles.container}>
<DimensionFilter
style={{ paddingBottom: '6px' }}
placeholder={i18n.t('Search dimensions')}
style={{
marginBottom: '6px',
background: '#fff',
border: `1px solid ${colors.grey400}`,
borderRadius: '5px',
}}
placeholder={i18n.t('Filter dimensions')}
text={this.state.filterText}
onChange={this.onFilterTextChange}
onClear={this.onClearFilter}
disableUnderline={true}
/>
<DndDimensionList
filterText={this.state.filterText}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,28 @@
min-height: 30vh;
}

.list {
.wrapper {
position: absolute;
width: 100%;
height: 100%;
overflow: auto;
margin-top: 0px;
padding: 0;
}

.list {
margin: 0;
padding: 0;
}

.header {
text-transform: uppercase;
font-size: 11px;
color: var(--colors-grey700);
margin: 5px 0;
letter-spacing: 0.3px;
}

.section:not(:last-child) {
margin-bottom: var(--spacers-dp24);
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
display: flex;
flex-direction: column;
background-color: #f4f6f8;
padding: 8px;
padding: 8px 8px 0 8px;
overflow: hidden;
}