Skip to content

Commit

Permalink
fix: apply scrollbar to the dashboard area below the control bars and…
Browse files Browse the repository at this point in the history
… headerbar [DHIS2-9371] (#1034)

The overflow property of app-shell-app has to be overridden to achieve the scrollbar on the dashboard area. Then, the height of the dashboard area is calculated from window.innerHeight - any visible control/header bars. A few margin and padding updates were needed, which affected the print "page" size.

As part of the implementation, the print actions bar is now fixed and stays in place when scrolling through the print dashboard.
  • Loading branch information
jenniferarnesen authored Sep 4, 2020
1 parent c6ef175 commit ed049fe
Show file tree
Hide file tree
Showing 24 changed files with 205 additions and 79 deletions.
28 changes: 17 additions & 11 deletions src/components/App.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,16 @@ body {
background-color: #f4f6f8;
}

@media print {
body {
width: 100% !important;
padding: 0 !important;
margin: 0 !important;
background-color: white;
}

.app-shell-app {
overflow: visible !important;
}
.app-shell-app {
overflow: hidden !important;
}

.dashboard-wrapper {
background-color: #f4f6f8;
padding-left: 10px;
padding-right: 10px;
overflow: auto;
padding-bottom: 100px;
}

/* plugin TODO */
Expand All @@ -35,3 +28,16 @@ table.pivot * {
.secondary-light-bg {
background-color: #48a999;
}

@media print {
body {
width: 100% !important;
padding: 0 !important;
margin: 0 !important;
background-color: white;
}

.app-shell-app {
overflow: visible !important;
}
}
2 changes: 1 addition & 1 deletion src/components/ControlBar/ControlBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { colors } from '@dhis2/ui'

import classes from './styles/ControlBar.module.css'

const DRAG_HANDLE_HEIGHT = 7
export const DRAG_HANDLE_HEIGHT = 7

class ControlBar extends React.Component {
constructor(props) {
Expand Down
1 change: 1 addition & 0 deletions src/components/ControlBar/EditBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ export class EditBar extends Component {
</div>
</div>
</ControlBar>
<div className={classes.topMargin} />
{this.translationDialog()}
{this.confirmDeleteDialog()}
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ exports[`EditBar renders the EditBar 1`] = `
</div>
</div>
</ControlBar>
<div
className="topMargin"
/>
</Fragment>
`;

Expand Down Expand Up @@ -67,6 +70,9 @@ exports[`EditBar when update access is false renders only the Discard button 1`]
</div>
</div>
</ControlBar>
<div
className="topMargin"
/>
</Fragment>
`;

Expand Down Expand Up @@ -132,6 +138,9 @@ exports[`EditBar when update access is true when dashboard id property provided
</div>
</div>
</ControlBar>
<div
className="topMargin"
/>
<Component
className="translation-dialog"
d2={
Expand Down Expand Up @@ -226,6 +235,9 @@ exports[`EditBar when update access is true when dashboard id property provided
</div>
</div>
</ControlBar>
<div
className="topMargin"
/>
<Component
className="translation-dialog"
d2={
Expand Down Expand Up @@ -320,6 +332,9 @@ exports[`EditBar when update access is true when dashboard id property provided
</div>
</div>
</ControlBar>
<div
className="topMargin"
/>
<Component
className="translation-dialog"
d2={
Expand Down Expand Up @@ -421,6 +436,9 @@ exports[`EditBar when update access is true when dashboard id property provided
</div>
</div>
</ControlBar>
<div
className="topMargin"
/>
<ConfirmDeleteDialog
onContinueEditing={[Function]}
onDeleteConfirmed={[Function]}
Expand Down Expand Up @@ -484,5 +502,8 @@ exports[`EditBar when update access is true when no dashboard id property render
</div>
</div>
</ControlBar>
<div
className="topMargin"
/>
</Fragment>
`;
1 change: 1 addition & 0 deletions src/components/ControlBar/controlBarDimensions.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { SHOWMORE_BAR_HEIGHT } from './ShowMoreButton'
export const CONTROL_BAR_ROW_HEIGHT = 40
export const FIRST_ROW_PADDING_HEIGHT = 10
export const MIN_ROW_COUNT = 1
export const HEADERBAR_HEIGHT = 48

const CONTROL_BAR_OUTER_HEIGHT_DIFF =
FIRST_ROW_PADDING_HEIGHT + SHOWMORE_BAR_HEIGHT - 2 // 2 pixel "adjustment"
Expand Down
4 changes: 4 additions & 0 deletions src/components/ControlBar/styles/DashboardsBar.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,7 @@
.rightControls {
float: right;
}

.topMargin {
margin-top: 71px;
}
3 changes: 2 additions & 1 deletion src/components/Dashboard/DashboardVerticalOffset.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ import {
MIN_ROW_COUNT,
} from '../ControlBar/controlBarDimensions'
import { sGetControlBarUserRows } from '../../reducers/controlBar'
import { DRAG_HANDLE_HEIGHT } from '../ControlBar/ControlBar'

const DashboardVerticalOffset = props => {
const rows = props.editMode ? MIN_ROW_COUNT : props.userRows
const marginTop = getControlBarHeight(rows)
const marginTop = getControlBarHeight(rows) + DRAG_HANDLE_HEIGHT

return <div className="page-container-top-margin" style={{ marginTop }} />
}
Expand Down
11 changes: 8 additions & 3 deletions src/components/Dashboard/EditDashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { connect } from 'react-redux'
import i18n from '@dhis2/d2-i18n'
import PropTypes from 'prop-types'

import DashboardVerticalOffset from './DashboardVerticalOffset'
import TitleBar from '../TitleBar/TitleBar'
import ItemGrid from '../ItemGrid/ItemGrid'
import EditBar from '../ControlBar/EditBar'
Expand All @@ -16,6 +15,10 @@ import {
sGetDashboardItems,
} from '../../reducers/dashboards'
import { sGetIsPrintPreviewView } from '../../reducers/editDashboard'
import {
getControlBarHeight,
HEADERBAR_HEIGHT,
} from '../ControlBar/controlBarDimensions'

export class EditDashboard extends Component {
state = {
Expand Down Expand Up @@ -44,8 +47,11 @@ export class EditDashboard extends Component {
return <LayoutPrintPreview fromEdit={true} />
}

const height =
window.innerHeight - HEADERBAR_HEIGHT - getControlBarHeight(1)

return (
<div className="dashboard-wrapper">
<div className="dashboard-wrapper" style={{ height }}>
<TitleBar edit={true} />
<ItemGrid edit={true} />
</div>
Expand All @@ -56,7 +62,6 @@ export class EditDashboard extends Component {
return (
<>
<EditBar />
<DashboardVerticalOffset editMode={true} />
{this.props.updateAccess ? (
this.renderGrid()
) : (
Expand Down
12 changes: 9 additions & 3 deletions src/components/Dashboard/NewDashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import React, { Component } from 'react'
import { connect } from 'react-redux'
import PropTypes from 'prop-types'

import DashboardVerticalOffset from './DashboardVerticalOffset'
import EditBar from '../ControlBar/EditBar'
import TitleBar from '../TitleBar/TitleBar'
import ItemGrid from '../ItemGrid/ItemGrid'
Expand All @@ -11,20 +10,27 @@ import LayoutPrintPreview from './PrintLayoutDashboard'
import { acSetEditNewDashboard } from '../../actions/editDashboard'
import { sGetIsPrintPreviewView } from '../../reducers/editDashboard'

import {
getControlBarHeight,
HEADERBAR_HEIGHT,
} from '../ControlBar/controlBarDimensions'

class NewDashboard extends Component {
componentDidMount() {
this.props.setNewDashboard()
}

render() {
const height =
window.innerHeight - HEADERBAR_HEIGHT - getControlBarHeight(1)

return (
<>
<EditBar />
<DashboardVerticalOffset editMode={true} />
{this.props.isPrintPreviewView ? (
<LayoutPrintPreview fromEdit={true} />
) : (
<div className="dashboard-wrapper">
<div className="dashboard-wrapper" style={{ height }}>
<TitleBar edit={true} />
<ItemGrid edit={true} />
</div>
Expand Down
26 changes: 16 additions & 10 deletions src/components/Dashboard/PrintActionsBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,30 @@ import { a4LandscapeWidthPx } from '../../modules/printUtils'

import classes from './styles/PrintActionsBar.module.css'

// 42px set in the module css file
export const PRINT_ACTIONS_BAR_HEIGHT = 42

const PrintActionsBar = ({ id }) => {
const width =
a4LandscapeWidthPx < window.innerWidth
? a4LandscapeWidthPx
: window.innerWidth

return (
<div className={classes.container}>
<div className={classes.inner} style={{ width }}>
<Link className={classes.link} to={`/${id}`}>
<Button>
<LessHorizontalIcon />
{i18n.t('Exit print preview')}
</Button>
</Link>
<Button onClick={window.print}>{i18n.t('Print')}</Button>
<>
<div className={classes.container}>
<div className={classes.inner} style={{ width }}>
<Link className={classes.link} to={`/${id}`}>
<Button>
<LessHorizontalIcon />
{i18n.t('Exit print preview')}
</Button>
</Link>
<Button onClick={window.print}>{i18n.t('Print')}</Button>
</div>
</div>
</div>
<div className={classes.topMargin} />
</>
)
}

Expand Down
5 changes: 4 additions & 1 deletion src/components/Dashboard/PrintDashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
} from '../../reducers/dashboards'
import { PAGEBREAK, PRINT_TITLE_PAGE, SPACER } from '../../modules/itemTypes'
import { a4LandscapeWidthPx } from '../../modules/printUtils'
import { PRINT_ACTIONS_BAR_HEIGHT } from './PrintActionsBar'

import classes from './styles/PrintDashboard.module.css'

Expand Down Expand Up @@ -76,10 +77,12 @@ export class PrintDashboard extends Component {
}

render() {
const height = window.innerHeight - PRINT_ACTIONS_BAR_HEIGHT

return (
<>
<PrintActionsBar id={this.props.dashboard.id} />
<div className={classes.wrapper}>
<div className={classes.wrapper} style={{ height }}>
<PrintInfo isLayout={false} />
<div
className={classes.pageOuter}
Expand Down
Loading

0 comments on commit ed049fe

Please sign in to comment.