-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: print dashboard [DHIS2-7045] (#1015)
To implement dashboard printing, two routes have been added: printlayout and printoipp (oipp = one item per page). Note that these routes are used when navigating to Print from View mode. But in Edit mode, the print preview does not change the route. Some components have been broken out into separate ones (e.g. ItemGrid), to avoid adding even more conditional statements into an already complex component, and risk breaking stuff that works (normal View and Edit mode). Some refactors were done to prevent code from getting even more complex due to the introduction of Print Mode. * Dashboard component now handles all the potential error or not-ready states (test scenarios: no dashboards, invalid id, dashboards not yet loaded). This functionality was previously in ViewDashboard/EditDashboard * Removed the editItemFilters redux prop, and replaced with useState in the FilterSelector component * src/actions/index.js removed bc it was never used * ItemHeader is moved to a directory and code split up * Show/hide description is now an user setting that persists across dashboards
- Loading branch information
1 parent
4f236c3
commit 20cb64f
Showing
76 changed files
with
2,545 additions
and
840 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
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,80 @@ | ||
import { generateUid } from 'd2/uid' | ||
|
||
import { | ||
SET_PRINT_DASHBOARD, | ||
CLEAR_PRINT_DASHBOARD, | ||
SET_PRINT_DASHBOARD_LAYOUT, | ||
ADD_PRINT_DASHBOARD_ITEM, | ||
REMOVE_PRINT_DASHBOARD_ITEM, | ||
UPDATE_PRINT_DASHBOARD_ITEM, | ||
} from '../reducers/printDashboard' | ||
import { | ||
NEW_ITEM_SHAPE, | ||
getGridItemProperties, | ||
getPageBreakItemShape, | ||
getPrintTitlePageItemShape, | ||
} from '../components/ItemGrid/gridUtil' | ||
import { itemTypeMap, PAGEBREAK } from '../modules/itemTypes' | ||
|
||
// actions | ||
|
||
export const acSetPrintDashboard = (dashboard, items) => { | ||
const val = { | ||
...dashboard, | ||
dashboardItems: items, | ||
} | ||
|
||
return { | ||
type: SET_PRINT_DASHBOARD, | ||
value: val, | ||
} | ||
} | ||
|
||
export const acClearPrintDashboard = () => ({ | ||
type: CLEAR_PRINT_DASHBOARD, | ||
}) | ||
|
||
export const acUpdatePrintDashboardLayout = value => ({ | ||
type: SET_PRINT_DASHBOARD_LAYOUT, | ||
value, | ||
}) | ||
|
||
export const acAddPrintDashboardItem = item => { | ||
const type = item.type | ||
delete item.type | ||
const itemPropName = itemTypeMap[type].propName | ||
|
||
const id = generateUid() | ||
const gridItemProperties = getGridItemProperties(id) | ||
|
||
let shape | ||
if (type === PAGEBREAK) { | ||
const yPos = item.yPos || 0 | ||
shape = getPageBreakItemShape(yPos, item.isStatic) | ||
} else { | ||
shape = getPrintTitlePageItemShape() | ||
} | ||
|
||
return { | ||
type: ADD_PRINT_DASHBOARD_ITEM, | ||
value: { | ||
id, | ||
type, | ||
position: item.position || null, | ||
[itemPropName]: item.content, | ||
...NEW_ITEM_SHAPE, | ||
...gridItemProperties, | ||
...shape, | ||
}, | ||
} | ||
} | ||
|
||
export const acRemovePrintDashboardItem = value => ({ | ||
type: REMOVE_PRINT_DASHBOARD_ITEM, | ||
value, | ||
}) | ||
|
||
export const acUpdatePrintDashboardItem = item => ({ | ||
type: UPDATE_PRINT_DASHBOARD_ITEM, | ||
value: item, | ||
}) |
Oops, something went wrong.