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

feat: print dashboard [DHIS2-7045] #1015

Merged
merged 88 commits into from
Aug 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
88 commits
Select commit Hold shift + click to select a range
4c13797
fix: add button and route for print oipp
jenniferarnesen Aug 9, 2020
393a6ca
fix: hide headerbar in print mode
jenniferarnesen Aug 9, 2020
651b665
fix: print titlebar and grid
jenniferarnesen Aug 9, 2020
9d5321a
fix: css to get rid of absolute positioning of grid items
jenniferarnesen Aug 9, 2020
7509248
fix: remove unneeded resize code
jenniferarnesen Aug 9, 2020
2c7c45a
fix: for oipp use all the page w and h
jenniferarnesen Aug 9, 2020
bae629d
fix: sort items for oipp and no layoutChange cb needed
jenniferarnesen Aug 9, 2020
d631ca8
fix: add button to return to dashboard view mode
jenniferarnesen Aug 9, 2020
8226043
fix: move functions to utils and use variables in oipp
jenniferarnesen Aug 9, 2020
6872c4c
fix: restore view state when going to View
jenniferarnesen Aug 10, 2020
c3ccb97
fix: css to ensure all pages are printed, not just first
jenniferarnesen Aug 10, 2020
d28ddd0
fix: adjust item header based on print mode
jenniferarnesen Aug 10, 2020
290fbf9
fix: print layout with page break items
jenniferarnesen Aug 10, 2020
e3af7d5
fix: move print buttons to More menu
jenniferarnesen Aug 11, 2020
2981469
fix: move show/hide description to More menu
jenniferarnesen Aug 11, 2020
1667e5b
refactor: removed DashboardContent, caused more confusion than clarity
jenniferarnesen Aug 11, 2020
70d1fce
fix: restore error msgs when missing db - put all in Dashboard.js
jenniferarnesen Aug 11, 2020
2e1f3a7
fix: styling for page break item
jenniferarnesen Aug 12, 2020
7f091a1
fix: hide action buttons on items in print mode
jenniferarnesen Aug 17, 2020
79270d2
fix: spacer item should not take any space in print oipp
jenniferarnesen Aug 17, 2020
3b1028b
fix: adjust height of tall items to fit the page
jenniferarnesen Aug 17, 2020
f784235
fix: bg color white for print preview
jenniferarnesen Aug 17, 2020
39321a5
fix: styling for print preview
jenniferarnesen Aug 17, 2020
77f33cf
fix: styling for print dashboard layout
jenniferarnesen Aug 17, 2020
762af48
fix: can't use : in i18n string since it is namespace separator
jenniferarnesen Aug 18, 2020
7606cd8
fix: place Print button to the right, use consistent page width
jenniferarnesen Aug 18, 2020
c6b21db
fix: box-shadow on the page
jenniferarnesen Aug 18, 2020
3a876d1
fix: menu was showing behind the filter bar
jenniferarnesen Aug 18, 2020
0d33371
fix: remove editItemFilters from redux and useState and dashboard mode
jenniferarnesen Aug 18, 2020
dbed383
fix: filter and description info
jenniferarnesen Aug 18, 2020
16d7179
fix: start of making pages look like real pages
jenniferarnesen Aug 18, 2020
847649c
fix: differentiate id for dashboard not found
jenniferarnesen Aug 19, 2020
3ea7daf
fix: add < icon to the Exit print preview btn
jenniferarnesen Aug 19, 2020
3ecb106
feat: title page as separate dashboard item
jenniferarnesen Aug 19, 2020
a09c52f
fix: adjust page sizes for layout print
jenniferarnesen Aug 19, 2020
fe7ecfb
fix: add missing period
jenniferarnesen Aug 19, 2020
542a78e
fix: issue where maps and ER werent using full height oipp
jenniferarnesen Aug 19, 2020
f46ada9
fix: style edges of PAGEBREAKS
jenniferarnesen Aug 20, 2020
f7c1101
fix: remove unused removedashboarditem fn
jenniferarnesen Aug 20, 2020
9c6c6c7
fix: improve styling of the page breaks
jenniferarnesen Aug 20, 2020
7616995
fix: remove spacers for oipp print - they mess it up
jenniferarnesen Aug 20, 2020
b894dba
fix: background fixes for media print
jenniferarnesen Aug 20, 2020
1a97f3d
fix: body css needs to be declared at top of app
jenniferarnesen Aug 20, 2020
a481ddb
fix: hide extra pagebreaks and adjust grid height accordingly
jenniferarnesen Aug 21, 2020
a20e85b
fix: try to better calculate bottom of print preview
jenniferarnesen Aug 21, 2020
67e1d0a
fix: oipp should not have static pagebreaks - extends grid too far
jenniferarnesen Aug 21, 2020
1a8756b
fix: reduce height of pagebreak - some problems with oipp items
jenniferarnesen Aug 21, 2020
37219bf
fix: separate oipp and layout print css
jenniferarnesen Aug 21, 2020
185da7c
fix: adjust top margin and page space use for oipp
jenniferarnesen Aug 22, 2020
6247879
fix: adjustments for print layout
jenniferarnesen Aug 23, 2020
f7069b1
fix: new redux property printDashboard for print mode
jenniferarnesen Aug 23, 2020
70f4777
fix: dont directly manipulate redux store properties
jenniferarnesen Aug 23, 2020
7f6222f
fix: printpreview from edit mode
jenniferarnesen Aug 23, 2020
20a3b8e
fix: need onLayoutChange going from view to print
jenniferarnesen Aug 23, 2020
9d0540f
fix: show editing text in print preview
jenniferarnesen Aug 23, 2020
22b2416
fix: add margin above the print preview
jenniferarnesen Aug 23, 2020
1112bad
fix: fix perf issue. NEVER set props to new objects in MSTP
jenniferarnesen Aug 24, 2020
f94e220
fix: strings in pot file
jenniferarnesen Aug 24, 2020
240bf9e
Merge branch 'master' into print-oipp-rebased
jenniferarnesen Aug 24, 2020
ebf7e64
fix: move code to a function with descriptive name
jenniferarnesen Aug 24, 2020
0efd110
fix: check for new dashboard before empty dashboards
jenniferarnesen Aug 24, 2020
e75df89
fix: implement print preview for New dashboard
jenniferarnesen Aug 24, 2020
5c73790
fix: use semantic naming
jenniferarnesen Aug 24, 2020
3d620a8
fix: use correct info for layout and oipp in printinfo
jenniferarnesen Aug 24, 2020
bf9aa76
fix: succinct wording to reduce code lines used
jenniferarnesen Aug 24, 2020
4c3fa5d
fix: remove no-longer used functions
jenniferarnesen Aug 24, 2020
aa60677
fix: tiny localization fix
jenniferarnesen Aug 24, 2020
5507bb8
fix: i18n strings update
jenniferarnesen Aug 24, 2020
71b8c22
fix: width fixes on Print Info and add info about waiting til all loaded
jenniferarnesen Aug 24, 2020
0304162
Merge branch 'master' into print-oipp-rebased
jenniferarnesen Aug 24, 2020
9deab3b
fix: title page improvements. Applied filters in bullet list
jenniferarnesen Aug 24, 2020
4155256
fix: visItem snapshot update
jenniferarnesen Aug 24, 2020
5384b0f
fix: editbar tests now include the print preview button
jenniferarnesen Aug 24, 2020
36a4d61
fix: tests for top-level Dashboard logic
jenniferarnesen Aug 25, 2020
b2adb29
fix: strings for print title page
jenniferarnesen Aug 25, 2020
f49e771
chore: tests for ViewDashboard
jenniferarnesen Aug 25, 2020
65c9037
chore: update EditDashboard tests
jenniferarnesen Aug 25, 2020
f509e09
fix: move css module files to styles directory
jenniferarnesen Aug 25, 2020
0663589
fix: add some comments to clarify code
jenniferarnesen Aug 25, 2020
df37731
fix: add some comments to clarify code
jenniferarnesen Aug 25, 2020
618011b
Merge branch 'master' into print-oipp-rebased
jenniferarnesen Aug 25, 2020
091d21f
fix: a little more code clarification
jenniferarnesen Aug 25, 2020
904718d
Merge branch 'print-oipp-rebased' of github.com:dhis2/dashboards-app …
jenniferarnesen Aug 25, 2020
d891ab8
fix: upgrade to react-grid-layout 1.0.0
jenniferarnesen Aug 25, 2020
16a638b
fix: this change caused the routes to duplicate the db id
jenniferarnesen Aug 25, 2020
5a693fa
Merge branch 'master' into print-oipp-rebased
jenniferarnesen Aug 25, 2020
2d8bf75
fix: fix double border in Print submenu
edoardo Aug 25, 2020
56b8211
fix: store showdescription setting in userdata
jenniferarnesen Aug 25, 2020
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
73 changes: 66 additions & 7 deletions i18n/en.pot
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ msgstr ""
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1)\n"
"POT-Creation-Date: 2020-06-10T01:32:16.274Z\n"
"PO-Revision-Date: 2020-06-10T01:32:16.274Z\n"
"POT-Creation-Date: 2020-08-25T05:26:00.043Z\n"
"PO-Revision-Date: 2020-08-25T05:26:00.043Z\n"

msgid "Cancel"
msgstr ""
Expand All @@ -23,10 +23,10 @@ msgid ""
"this dashboard?"
msgstr ""

msgid "Exit without saving"
msgid "Exit Print preview"
msgstr ""

msgid "Go to dashboards"
msgid "Print preview"
msgstr ""

msgid "Save changes"
Expand All @@ -35,6 +35,12 @@ msgstr ""
msgid "Translate"
msgstr ""

msgid "Exit without saving"
msgstr ""

msgid "Go to dashboards"
msgstr ""

msgid "Search for a dashboard"
msgstr ""

Expand All @@ -44,13 +50,42 @@ msgstr ""
msgid "Show less"
msgstr ""

msgid "No dashboards found. Use the + button to create a new dashboard."
msgstr ""

msgid "Requested dashboard not found"
msgstr ""

msgid "No access"
msgstr ""

msgid "No dashboards found. Use the + button to create a new dashboard."
msgid "Exit print preview"
msgstr ""

msgid "Requested dashboard not found"
msgid "Print"
msgstr ""

msgid "The pages below are a preview of how the dashboard layout will be printed."
msgstr ""

msgid ""
"The pages below are a preview of how each dashboard item will be printed on "
"a separate page."
msgstr ""

msgid ""
"Use the default printer settings for best results and check that all "
"dashboard items have finished loading before printing. This text will not "
"be printed."
msgstr ""

msgid "dashboard layout"
msgstr ""

msgid "one item per page"
msgstr ""

msgid "Print Preview"
msgstr ""

msgid "{{count}} selected"
Expand All @@ -73,6 +108,9 @@ msgstr ""
msgid "Item type \"{{type}}\" not supported"
msgstr ""

msgid "Filters applied"
msgstr ""

msgid "Spacer"
msgstr ""

Expand Down Expand Up @@ -142,7 +180,16 @@ msgstr ""
msgid "Dashboard description"
msgstr ""

msgid "No description"
msgid "Hide description"
msgstr ""

msgid "Show description"
msgstr ""

msgid "Unstar dashboard"
msgstr ""

msgid "Star dashboard"
msgstr ""

msgid "Edit"
Expand All @@ -151,6 +198,18 @@ msgstr ""
msgid "Share"
msgstr ""

msgid "More"
msgstr ""

msgid "Dashboard layout"
msgstr ""

msgid "One item per page"
msgstr ""

msgid "No description"
msgstr ""

msgid "Visualizations"
msgstr ""

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"moment": "^2.27.0",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"react-grid-layout": "^0.18.3",
"react-grid-layout": "^1.0.0",
"react-redux": "^7.2.1",
"react-router-dom": "^5.2.0",
"redux": "^4.0.5",
Expand Down
3 changes: 2 additions & 1 deletion src/actions/dashboards.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
sGetDashboardById,
sGetDashboardsSortedByStarred,
} from '../reducers/dashboards'
import { NON_EXISTING_DASHBOARD_ID } from '../reducers/selected'
import { sGetUserUsername } from '../reducers/user'
import { tSetSelectedDashboardById, acSetSelectedId } from './selected'
import { acClearEditDashboard } from './editDashboard'
Expand Down Expand Up @@ -81,7 +82,7 @@ export const tSelectDashboard = id => async (dispatch, getState) => {
if (dashboardToSelect) {
dispatch(tSetSelectedDashboardById(dashboardToSelect.id))
} else {
dispatch(acSetSelectedId())
dispatch(acSetSelectedId(NON_EXISTING_DASHBOARD_ID))
}
} catch (err) {
return onError(err)
Expand Down
26 changes: 25 additions & 1 deletion src/actions/editDashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,19 @@ import {
ADD_DASHBOARD_ITEM,
UPDATE_DASHBOARD_ITEM,
REMOVE_DASHBOARD_ITEM,
SET_PRINT_PREVIEW_VIEW,
CLEAR_PRINT_PREVIEW_VIEW,
} from '../reducers/editDashboard'
import { sGetEditDashboardRoot } from '../reducers/editDashboard'
import { updateDashboard, postDashboard } from '../api/editDashboard'
import { tSetSelectedDashboardById } from '../actions/selected'
import {
NEW_ITEM_SHAPE,
getGridItemProperties,
getPageBreakItemShape,
getPrintTitlePageItemShape,
} from '../components/ItemGrid/gridUtil'
import { itemTypeMap } from '../modules/itemTypes'
import { itemTypeMap, PAGEBREAK, PRINT_TITLE_PAGE } from '../modules/itemTypes'
import { convertUiItemsToBackend } from '../modules/uiBackendItemConverter'

const onError = error => {
Expand Down Expand Up @@ -48,6 +52,14 @@ export const acClearEditDashboard = () => ({
type: RECEIVED_NOT_EDITING,
})

export const acSetPrintPreviewView = () => ({
type: SET_PRINT_PREVIEW_VIEW,
})

export const acClearPrintPreviewView = () => ({
type: CLEAR_PRINT_PREVIEW_VIEW,
})

export const acSetDashboardTitle = value => ({
type: RECEIVED_TITLE,
value,
Expand All @@ -71,14 +83,26 @@ export const acAddDashboardItem = item => {
const id = generateUid()
const gridItemProperties = getGridItemProperties(id)

let shape
if (type === PAGEBREAK) {
const yPos = item.yPos || 0
shape = getPageBreakItemShape(yPos, item.isStatic)
} else if (type === PRINT_TITLE_PAGE) {
shape = getPrintTitlePageItemShape()
} else {
shape = NEW_ITEM_SHAPE
}

return {
type: ADD_DASHBOARD_ITEM,
value: {
id,
type,
position: item.position || null,
[itemPropName]: item.content,
...NEW_ITEM_SHAPE,
...gridItemProperties,
...shape,
},
}
}
Expand Down
21 changes: 0 additions & 21 deletions src/actions/editItemFilters.js

This file was deleted.

10 changes: 0 additions & 10 deletions src/actions/index.js

This file was deleted.

80 changes: 80 additions & 0 deletions src/actions/printDashboard.js
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,
})
Loading