+
diff --git a/src/components/Communicator/CommunicatorToolbar/__snapshots__/CommunicatorToolbar.test.js.snap b/src/components/Communicator/CommunicatorToolbar/__snapshots__/CommunicatorToolbar.test.js.snap
index cb5b035cb..85bdd077c 100644
--- a/src/components/Communicator/CommunicatorToolbar/__snapshots__/CommunicatorToolbar.test.js.snap
+++ b/src/components/Communicator/CommunicatorToolbar/__snapshots__/CommunicatorToolbar.test.js.snap
@@ -36,7 +36,7 @@ exports[`Communicator tests default renderer 1`] = `
@@ -142,7 +142,7 @@ exports[`Communicator tests menu behavior 1`] = `
@@ -249,7 +249,7 @@ exports[`Communicator tests menu behavior 2`] = `
@@ -356,7 +356,7 @@ exports[`Communicator tests switching boards behavior 1`] = `
@@ -463,7 +463,7 @@ exports[`Communicator tests switching boards behavior 2`] = `
diff --git a/src/components/Settings/Export/Export.container.js b/src/components/Settings/Export/Export.container.js
index 39c03be7a..a77a447b7 100644
--- a/src/components/Settings/Export/Export.container.js
+++ b/src/components/Settings/Export/Export.container.js
@@ -6,12 +6,12 @@ import { injectIntl, intlShape } from 'react-intl';
import { showNotification } from '../../Notifications/Notifications.actions';
import Export from './Export.component';
import { EXPORT_CONFIG_BY_TYPE } from './Export.constants';
+import messages from './Export.messages';
export class ExportContainer extends PureComponent {
static propTypes = {
boards: PropTypes.array.isRequired,
history: PropTypes.object.isRequired,
- activeBoardId: PropTypes.string.isRequired,
intl: intlShape.isRequired
};
@@ -27,9 +27,15 @@ export class ExportContainer extends PureComponent {
return false;
}
- const { boards, activeBoardId, intl } = this.props;
+ const { boards, intl, activeBoardId, showNotification } = this.props;
- await EXPORT_HELPERS[exportConfig.callback](boards, intl, activeBoardId);
+ if (type !== 'pdf') {
+ await EXPORT_HELPERS[exportConfig.callback](boards, intl);
+ } else {
+ const currentBoard = boards.filter(board => board.id === activeBoardId);
+ await EXPORT_HELPERS[exportConfig.callback](currentBoard, intl);
+ showNotification(intl.formatMessage(messages.boardDownloaded));
+ }
doneCallback();
};
@@ -39,12 +45,11 @@ export class ExportContainer extends PureComponent {
}
render() {
- const { boards, history, activeBoardId } = this.props;
+ const { boards, history } = this.props;
return (
diff --git a/src/components/Settings/Export/Export.helpers.js b/src/components/Settings/Export/Export.helpers.js
index b4692476f..9ebfa553c 100644
--- a/src/components/Settings/Export/Export.helpers.js
+++ b/src/components/Settings/Export/Export.helpers.js
@@ -11,6 +11,11 @@ import {
CBOARD_EXT_PROPERTIES,
CBOARD_ZIP_OPTIONS
} from './Export.constants';
+import {
+ isCordova,
+ requestCvaWritePermissions,
+ writeCvaFile
+} from '../../../cordova-util';
pdfMake.vfs = pdfFonts.pdfMake.vfs;
@@ -237,14 +242,17 @@ async function toDataURL(url, styles = {}, outputFormat = 'image/jpeg') {
ctx.lineWidth = 3;
ctx.strokeRect(0, 0, 150, 150);
}
-
const dataURL = canvas.toDataURL(outputFormat);
resolve(dataURL);
};
- imageElement.src = url;
+ // Cordova path cannot be absolute
+ const imageUrl =
+ isCordova() && url && url.search('/') === 0 ? `.${url}` : url;
+ imageElement.src = imageUrl;
if (imageElement.complete || imageElement.complete === undefined) {
- imageElement.src = url;
+ console.log(imageUrl);
+ imageElement.src = imageUrl;
}
});
}
@@ -410,15 +418,14 @@ export async function cboardExportAdapter(boards = []) {
}
}
-export async function pdfExportAdapter(boards = [], intl, activeBoardId) {
+export async function pdfExportAdapter(boards = [], intl) {
const docDefinition = {
pageSize: 'A4',
pageOrientation: 'landscape',
content: []
};
- const fboards = boards.filter(board => board.id === activeBoardId );
- const lastBoardIndex = fboards.length - 1;
- const content = await fboards.reduce(async (prev, board, i) => {
+ const lastBoardIndex = boards.length - 1;
+ const content = await boards.reduce(async (prev, board, i) => {
const prevContent = await prev;
const breakPage = i !== lastBoardIndex;
const boardPDFData = await generatePDFBoard(board, intl, breakPage);
@@ -426,8 +433,21 @@ export async function pdfExportAdapter(boards = [], intl, activeBoardId) {
}, Promise.resolve([]));
docDefinition.content = content;
-
- pdfMake.createPdf(docDefinition).download(EXPORT_CONFIG_BY_TYPE.pdf.filename);
+ const pdfObj = pdfMake.createPdf(docDefinition);
+
+ if (pdfObj) {
+ if (isCordova()) {
+ requestCvaWritePermissions();
+ pdfObj.getBuffer(buffer => {
+ var blob = new Blob([buffer], { type: 'application/pdf' });
+ const name = 'board.pdf';
+ writeCvaFile(name, blob);
+ });
+ } else {
+ // On a browser simply use download!
+ pdfObj.download(EXPORT_CONFIG_BY_TYPE.pdf.filename);
+ }
+ }
}
export default {
diff --git a/src/components/Settings/Export/Export.messages.js b/src/components/Settings/Export/Export.messages.js
index 3854df3e2..71092f5a7 100644
--- a/src/components/Settings/Export/Export.messages.js
+++ b/src/components/Settings/Export/Export.messages.js
@@ -8,5 +8,9 @@ export default defineMessages({
exportSecondary: {
id: 'cboard.components.Settings.Export.exportSecondary',
defaultMessage: 'Export your board to Cboard format or {link} format'
+ },
+ boardDownloaded: {
+ id: 'cboard.components.Settings.Export.boardDownloaded',
+ defaultMessage: 'Your board was downloaded'
}
});
diff --git a/src/components/UI/ColorSelect/ColorSelect.js b/src/components/UI/ColorSelect/ColorSelect.js
index 3a2efe14e..2e6c3a357 100644
--- a/src/components/UI/ColorSelect/ColorSelect.js
+++ b/src/components/UI/ColorSelect/ColorSelect.js
@@ -6,65 +6,137 @@ import FormLabel from '@material-ui/core/FormLabel';
import Radio from '@material-ui/core/Radio';
import RadioGroup from '@material-ui/core/RadioGroup';
import CloseIcon from '@material-ui/icons/Close';
+import Button from '@material-ui/core/Button';
+import Menu from '@material-ui/core/Menu';
+import MenuItem from '@material-ui/core/MenuItem';
import IconButton from '../IconButton';
import Circle from './Circle';
import messages from './ColorSelect.messages';
+const colorSchemes = [
+ {
+ name: 'Cboard',
+ colors: ['#bbdefb', '#fff176', '#CE93D8', '#2196F3', '#4CAF50', '#E57373']
+ },
+ {
+ name: 'Fitzgerald',
+ colors: [
+ '#2196F3',
+ '#4CAF50',
+ '#fff176',
+ '#ff6600',
+ '#ffffff',
+ '#ffc0cb',
+ '#800080',
+ '#a52a2a',
+ '#ff0000',
+ '#808080'
+ ]
+ },
+ {
+ name: 'Goossens',
+ colors: ['#ffc0cb', '#2196F3', '#4CAF50', '#fff176', '#ff6600']
+ }
+];
+
const propTypes = {
- colors: PropTypes.arrayOf(PropTypes.string),
intl: intlShape.isRequired,
onChange: PropTypes.func.isRequired,
selectedColor: PropTypes.string.isRequired
};
-const defaultProps = {
- colors: ['#CE93D8', '#2196F3', '#4CAF50', '#E57373']
-};
+class ColorSelect extends React.Component {
+ constructor(props) {
+ super(props);
-const ColorSelect = props => {
- const { colors, intl, onChange, selectedColor } = props;
+ this.state = {
+ colorMenu: null,
+ colors: colorSchemes[0].colors
+ };
+ }
+ handleOpenColorSchemeMenu(event) {
+ this.setState({ colorMenu: event.currentTarget });
+ }
+ handleColorSchemeClose(colorScheme) {
+ this.setState({ colors: colorScheme.colors, colorMenu: null });
+ }
- const colorLabel = intl.formatMessage(messages.color);
- const radioGroupStyle = { flexDirection: 'row' };
- const circleStrokeWidth = 2;
+ render() {
+ const { intl, onChange, selectedColor } = this.props;
+ const colorLabel = intl.formatMessage(messages.color);
+ const radioGroupStyle = { flexDirection: 'row' };
+ const radioItemStyle = { padding: '4px' };
+ const circleStrokeWidth = 2;
- return (
-
- {colorLabel}
-
- {colors.map(color => (
- }
- checkedIcon={
-
- }
- />
- ))}
- {selectedColor && (
- {
- onChange();
- }}
+ return (
+
+ {colorLabel}
+
+
+
+
+
+ {this.state.colors.map(color => (
+ }
+ checkedIcon={
+
+ }
+ />
+ ))}
+ {selectedColor && (
+ {
+ onChange();
+ }}
+ >
+
+
+ )}
+
+
+ );
+ }
+}
ColorSelect.propTypes = propTypes;
-ColorSelect.defaultProps = defaultProps;
-
export default injectIntl(ColorSelect);
diff --git a/src/components/UI/ColorSelect/ColorSelect.messages.js b/src/components/UI/ColorSelect/ColorSelect.messages.js
index 3eb7c6604..9019b3f4b 100644
--- a/src/components/UI/ColorSelect/ColorSelect.messages.js
+++ b/src/components/UI/ColorSelect/ColorSelect.messages.js
@@ -8,5 +8,9 @@ export default defineMessages({
clearSelection: {
id: 'cboard.components.ColorSelect.clearSelection',
defaultMessage: 'Clear selection'
+ },
+ colorScheme: {
+ id: 'cboard.components.ColorSelect.colorScheme',
+ defaultMessage: 'Color Scheme'
}
});
diff --git a/src/components/UI/ColorSelect/ColorSelect.test.js b/src/components/UI/ColorSelect/ColorSelect.test.js
index d17d74c79..c0302ba4e 100644
--- a/src/components/UI/ColorSelect/ColorSelect.test.js
+++ b/src/components/UI/ColorSelect/ColorSelect.test.js
@@ -11,6 +11,10 @@ jest.mock('./ColorSelect.messages', () => {
clearSelection: {
id: 'cboard.components.ColorSelect.clearSelection',
defaultMessage: 'Clear selection'
+ },
+ colorScheme: {
+ id: 'cboard.components.ColorSelect.colorScheme',
+ defaultMessage: 'Color Scheme'
}
};
});
diff --git a/src/components/UI/PrintBoardButton/PrintBoardButton.container.js b/src/components/UI/PrintBoardButton/PrintBoardButton.container.js
index 22b5ef261..affc60b16 100644
--- a/src/components/UI/PrintBoardButton/PrintBoardButton.container.js
+++ b/src/components/UI/PrintBoardButton/PrintBoardButton.container.js
@@ -5,7 +5,7 @@ import { intlShape, injectIntl } from 'react-intl';
import PrintBoardButton from './PrintBoardButton.component';
import PrintBoardDialog from './PrintBoardDialog.component';
import messages from './PrintBoardButton.messages';
-// import { pdfExportAdapter } from '../../Settings/Export/Export.helpers';
+import { showNotification } from '../../Notifications/Notifications.actions';
class PrintBoardButtonContainer extends React.Component {
constructor(props) {
@@ -31,22 +31,16 @@ class PrintBoardButtonContainer extends React.Component {
async onPrintCurrentBoard() {
this.setState({ loading: true });
- const { boardData, intl } = this.props;
+ const { boardData, intl, showNotification } = this.props;
const currentBoard = boardData.boards.find(
board => board.id === boardData.activeBoardId
);
const { pdfExportAdapter } = await this.exportHelpers;
- pdfExportAdapter([currentBoard], intl);
- this.setState({ loading: false });
- }
-
- async onPrintFullBoardSet() {
- this.setState({ loading: true });
- const { boardData, intl } = this.props;
- const { pdfExportAdapter } = await this.exportHelpers;
- pdfExportAdapter(boardData.boards, intl);
- this.setState({ loading: false });
+ pdfExportAdapter([currentBoard], intl).then(() => {
+ this.setState({ loading: false });
+ showNotification(intl.formatMessage(messages.boardDownloaded));
+ });
}
render() {
@@ -66,7 +60,6 @@ class PrintBoardButtonContainer extends React.Component {
open={this.state.openDialog}
onClose={this.closePrintBoardDialog.bind(this)}
onPrintCurrentBoard={this.onPrintCurrentBoard.bind(this)}
- onPrintFullBoardSet={this.onPrintFullBoardSet.bind(this)}
/>
);
@@ -83,4 +76,11 @@ const mapStateToProps = state => ({
boardData: state.board
});
-export default connect(mapStateToProps)(injectIntl(PrintBoardButtonContainer));
+const mapDispatchToProps = {
+ showNotification
+};
+
+export default connect(
+ mapStateToProps,
+ mapDispatchToProps
+)(injectIntl(PrintBoardButtonContainer));
diff --git a/src/components/UI/PrintBoardButton/PrintBoardButton.messages.js b/src/components/UI/PrintBoardButton/PrintBoardButton.messages.js
index 5add7f9b9..23718d58e 100644
--- a/src/components/UI/PrintBoardButton/PrintBoardButton.messages.js
+++ b/src/components/UI/PrintBoardButton/PrintBoardButton.messages.js
@@ -7,8 +7,7 @@ export default defineMessages({
},
printBoardSecondary: {
id: 'cboard.components.PrintBoardButton.printBoardSecondary',
- defaultMessage:
- 'Print current board or full board set (it can take a while).'
+ defaultMessage: 'Print current board (it can take a while).'
},
printCurrentBoard: {
id: 'cboard.components.PrintBoardButton.printCurrentBoard',
@@ -17,5 +16,9 @@ export default defineMessages({
printFullBoardSet: {
id: 'cboard.components.PrintBoardButton.printFullBoardSet',
defaultMessage: 'Full Board Set'
+ },
+ boardDownloaded: {
+ id: 'cboard.components.PrintBoardButton.boardDownloaded',
+ defaultMessage: 'Your board was downloaded'
}
});
diff --git a/src/components/UI/PrintBoardButton/PrintBoardDialog.component.js b/src/components/UI/PrintBoardButton/PrintBoardDialog.component.js
index f548b7129..d1b3c6dfb 100644
--- a/src/components/UI/PrintBoardButton/PrintBoardDialog.component.js
+++ b/src/components/UI/PrintBoardButton/PrintBoardDialog.component.js
@@ -18,8 +18,7 @@ const PrintBoardDialog = ({
open,
loading,
onClose,
- onPrintCurrentBoard,
- onPrintFullBoardSet
+ onPrintCurrentBoard
}) => (