diff --git a/src/components/Settings/Export/Export.component.js b/src/components/Settings/Export/Export.component.js index 80716804d..2a11345fa 100644 --- a/src/components/Settings/Export/Export.component.js +++ b/src/components/Settings/Export/Export.component.js @@ -39,6 +39,7 @@ class Export extends React.Component { this.state = { exportSingleBoard: '', exportAllBoard: '', + exportAllBoardSize: '16', singleBoard: '', loadingSingle: false, loadingAll: false, @@ -61,6 +62,13 @@ class Export extends React.Component { }); }; + handleSizeChange = event => { + this.setState({ + boardError: false, + exportAllBoardSize: event.target.value + }); + }; + handleAllBoardChange = event => { const doneCallback = () => { this.setState({ @@ -74,7 +82,12 @@ class Export extends React.Component { exportAllBoard: event.target.value }, () => { - this.props.onExportClick(this.state.exportAllBoard, '', doneCallback); + this.props.onExportClick( + this.state.exportAllBoard, + '', + this.state.exportAllBoardSize, + doneCallback + ); } ); }; @@ -101,6 +114,7 @@ class Export extends React.Component { this.props.onExportClick( this.state.exportSingleBoard, this.state.singleBoard, + this.state.exportAllBoardSize, doneCallback ); } @@ -282,6 +296,44 @@ class Export extends React.Component { + + + } + secondary={} + /> + +
+ {this.state.loadingAll && ( + + )} + + + {intl.formatMessage(messages.size)} + + + +
+
+
diff --git a/src/components/Settings/Export/Export.container.js b/src/components/Settings/Export/Export.container.js index b401763db..6dffc3e30 100644 --- a/src/components/Settings/Export/Export.container.js +++ b/src/components/Settings/Export/Export.container.js @@ -19,6 +19,7 @@ export class ExportContainer extends PureComponent { handleExportClick = async ( type = 'cboard', singleBoard = '', + exportAllBoardSize = '', doneCallback ) => { const exportConfig = EXPORT_CONFIG_BY_TYPE[type]; @@ -42,6 +43,7 @@ export class ExportContainer extends PureComponent { if (singleBoard) { await EXPORT_HELPERS[exportConfig.callback]( [singleBoard], + exportAllBoardSize, intl, true ); @@ -49,18 +51,35 @@ export class ExportContainer extends PureComponent { const currentBoard = boards.filter( board => board.id === activeBoardId ); - await EXPORT_HELPERS[exportConfig.callback](currentBoard, intl, true); + await EXPORT_HELPERS[exportConfig.callback]( + currentBoard, + exportAllBoardSize, + intl, + true + ); } } else if (type !== 'pdf' && !singleBoard) { - await EXPORT_HELPERS[exportConfig.callback](boards, intl); + await EXPORT_HELPERS[exportConfig.callback]( + boards, + exportAllBoardSize, + intl + ); } else { if (singleBoard) { - await EXPORT_HELPERS[exportConfig.callback]([singleBoard], intl); + await EXPORT_HELPERS[exportConfig.callback]( + [singleBoard], + exportAllBoardSize, + intl + ); } else { const currentBoard = boards.filter( board => board.id === activeBoardId ); - await EXPORT_HELPERS[exportConfig.callback](currentBoard, intl); + await EXPORT_HELPERS[exportConfig.callback]( + currentBoard, + exportAllBoardSize, + intl + ); } } const showBoardDowloadedNotification = () => { diff --git a/src/components/Settings/Export/Export.helpers.js b/src/components/Settings/Export/Export.helpers.js index 037726117..09f11c26f 100644 --- a/src/components/Settings/Export/Export.helpers.js +++ b/src/components/Settings/Export/Export.helpers.js @@ -372,16 +372,24 @@ function getCellWidths(columns, picsee = false) { return cellWidths; } -async function generatePDFBoard(board, intl, breakPage = true, picsee = false) { +async function generatePDFBoard( + board, + intl, + breakPage = true, + picsee = false, + exportAllBoardSize +) { const header = { absolutePosition: { x: 0, y: 5 }, text: board.name || '', alignment: 'center', fontSize: 8 }; + const columns = board.isFixed && board.grid ? board.grid.columns : CBOARD_COLUMNS; const rows = board.isFixed && board.grid ? board.grid.rows : CBOARD_ROWS; + const cellWidths = getCellWidths(columns, picsee); const table = { @@ -401,8 +409,22 @@ async function generatePDFBoard(board, intl, breakPage = true, picsee = false) { } const grid = board.isFixed - ? await generateFixedBoard(board, rows, columns, intl, picsee) - : await generateNonFixedBoard(board, rows, columns, intl, picsee); + ? await generateFixedBoard( + board, + rows, + columns, + intl, + picsee, + exportAllBoardSize + ) + : await generateNonFixedBoard( + board, + rows, + columns, + intl, + picsee, + exportAllBoardSize + ); const lastGridRowDiff = columns - grid[grid.length - 2].length; // labels row if (lastGridRowDiff > 0) { @@ -427,7 +449,14 @@ function chunks(array, size) { return results; } -async function generateFixedBoard(board, rows, columns, intl, picsee = false) { +async function generateFixedBoard( + board, + rows, + columns, + intl, + picsee = false, + exportAllBoardSize +) { let currentRow = 0; let cont = 0; @@ -482,7 +511,8 @@ async function generateFixedBoard(board, rows, columns, intl, picsee = false) { columns, currentRow, pageBreak, - picsee + picsee, + exportAllBoardSize ); cont++; } @@ -496,7 +526,8 @@ async function generateNonFixedBoard( rows, columns, intl, - picsee = false + picsee = false, + exportAllBoardSize ) { // Do a grid with 2n rows const grid = new Array(Math.ceil(board.tiles.length / columns) * 2); @@ -526,7 +557,8 @@ async function generateNonFixedBoard( columns, currentRow, pageBreak, - picsee + picsee, + exportAllBoardSize ); }, Promise.resolve()); return grid; @@ -540,7 +572,8 @@ const addTileToGrid = async ( columns, currentRow, pageBreak = false, - picsee = false + picsee = false, + exportAllBoardSize ) => { const { label, image } = getPDFTileData(tile, intl); const fixedRow = currentRow * 2; @@ -598,6 +631,7 @@ const addTileToGrid = async ( const labelData = { text: label, alignment: 'center', + fontSize: exportAllBoardSize, fillColor: hexBackgroundColor, border: PDF_GRID_BORDER[labelPosition].labelData }; @@ -845,9 +879,13 @@ export async function cboardExportAdapter(allBoards = [], board) { } } -export async function pdfExportAdapter(boards = [], intl, picsee = false) { +export async function pdfExportAdapter( + boards = [], + exportAllBoardSize, + intl, + picsee = false +) { const font = definePDFfont(intl); - const docDefinition = { pageSize: 'A4', pageOrientation: 'landscape', @@ -858,6 +896,9 @@ export async function pdfExportAdapter(boards = [], intl, picsee = false) { } }; if (picsee) { + //exportAllBoardSize = exportAllBoardSize - 4; + exportAllBoardSize = + exportAllBoardSize > 20 ? exportAllBoardSize - 3 : exportAllBoardSize; docDefinition.background = function() { return { stack: [ @@ -921,7 +962,13 @@ export async function pdfExportAdapter(boards = [], intl, picsee = false) { const content = await boards.reduce(async (prev, board, i) => { const prevContent = await prev; const breakPage = i !== 0; - const boardPDFData = await generatePDFBoard(board, intl, breakPage, picsee); + const boardPDFData = await generatePDFBoard( + board, + intl, + breakPage, + picsee, + exportAllBoardSize + ); return prevContent.concat(boardPDFData); }, Promise.resolve([])); diff --git a/src/components/Settings/Export/Export.messages.js b/src/components/Settings/Export/Export.messages.js index 39aa3a58e..6cecf9128 100644 --- a/src/components/Settings/Export/Export.messages.js +++ b/src/components/Settings/Export/Export.messages.js @@ -18,6 +18,18 @@ export default defineMessages({ id: 'cboard.components.Settings.Export.exportAll', defaultMessage: 'Export All Boards' }, + properties: { + id: 'cboard.components.Settings.Export.properties', + defaultMessage: 'Settings' + }, + propertiesSize: { + id: 'cboard.components.Settings.Export.propertiesSize', + defaultMessage: 'General PDF settings' + }, + size: { + id: 'cboard.components.Settings.Export.size', + defaultMessage: 'Font size' + }, exportAllSecondary: { id: 'cboard.components.Settings.Export.exportAllSecondary', defaultMessage: