Added a check isPresenter to shapeFactory in order to render either presenter's or viewer's version of the text shape
This commit is contained in:
parent
465c0c1517
commit
2bcc03527c
@ -25,6 +25,8 @@ export default class ShapeGroup extends React.Component {
|
||||
|
||||
renderShape(shape, width, height) {
|
||||
let Component = this.props.shapeSelector[shape.shape.type];
|
||||
let additionalProps = shape.shape.type == "text" ? { isPresenter: this.props.isPresenter } : null;
|
||||
|
||||
if (Component != null) {
|
||||
return (
|
||||
<Component
|
||||
@ -32,6 +34,7 @@ export default class ShapeGroup extends React.Component {
|
||||
shape={shape.shape}
|
||||
slideWidth={width}
|
||||
slideHeight={height}
|
||||
{...additionalProps}
|
||||
/>
|
||||
);
|
||||
} else {
|
||||
|
@ -23,11 +23,7 @@ class ShapeGroupContainer extends React.Component {
|
||||
|
||||
render() {
|
||||
return (
|
||||
<ShapeGroup
|
||||
shapes={this.props.shapes}
|
||||
width={this.props.width}
|
||||
height={this.props.height}
|
||||
/>
|
||||
<ShapeGroup {...this.props} />
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -35,11 +31,13 @@ class ShapeGroupContainer extends React.Component {
|
||||
export default createContainer((params) => {
|
||||
const { whiteboardId, width, height } = params;
|
||||
const shapes = ShapeGroupService.getCurrentShapes(whiteboardId);
|
||||
const isPresenter = ShapeGroupService.isPresenter();
|
||||
|
||||
return {
|
||||
shapes,
|
||||
width,
|
||||
height,
|
||||
isPresenter,
|
||||
};
|
||||
}, ShapeGroupContainer);
|
||||
|
||||
|
@ -1,4 +1,6 @@
|
||||
import Shapes from '/imports/api/shapes';
|
||||
import Users from '/imports/api/users';
|
||||
import Auth from '/imports/ui/services/auth';
|
||||
|
||||
const getCurrentShapes = (whiteboardId) => {
|
||||
|
||||
@ -11,6 +13,17 @@ const getCurrentShapes = (whiteboardId) => {
|
||||
}).fetch();
|
||||
};
|
||||
|
||||
const isPresenter = () => {
|
||||
const currentUser = Users.findOne({ userId: Auth.userID, });
|
||||
|
||||
if (currentUser && currentUser.user) {
|
||||
return currentUser.user.presenter;
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
export default {
|
||||
getCurrentShapes,
|
||||
isPresenter,
|
||||
};
|
||||
|
@ -53,37 +53,51 @@ export default class TextDrawComponent extends React.Component {
|
||||
return styles;
|
||||
}
|
||||
|
||||
render() {
|
||||
let results = this.getCoordinates();
|
||||
let styles = this.getStyles(results);
|
||||
|
||||
renderViewerTextShape(results, styles) {
|
||||
return (
|
||||
<g>
|
||||
<clipPath id="c1">
|
||||
<rect
|
||||
<g>
|
||||
<clipPath id="c1">
|
||||
<rect
|
||||
x={results.x}
|
||||
y={results.y}
|
||||
width={results.width}
|
||||
height={results.height}
|
||||
fill="purple"
|
||||
strokeWidth="2"
|
||||
/>
|
||||
</clipPath>
|
||||
|
||||
<foreignObject
|
||||
clipPath="url(#c1)"
|
||||
x={results.x}
|
||||
y={results.y}
|
||||
width={results.width}
|
||||
height={results.height}
|
||||
fill="purple"
|
||||
strokeWidth="2"
|
||||
/>
|
||||
</clipPath>
|
||||
|
||||
<foreignObject
|
||||
clipPath="url(#c1)"
|
||||
x={results.x}
|
||||
y={results.y}
|
||||
width={results.width}
|
||||
height={results.height}
|
||||
>
|
||||
<p style={styles}>
|
||||
{results.text}
|
||||
</p>
|
||||
</foreignObject>
|
||||
</g>
|
||||
>
|
||||
<p style={styles}>
|
||||
{results.text}
|
||||
</p>
|
||||
</foreignObject>
|
||||
</g>
|
||||
);
|
||||
}
|
||||
|
||||
renderPresenterTextShape(results, styles) {
|
||||
return (
|
||||
<g></g>
|
||||
);
|
||||
}
|
||||
|
||||
render() {
|
||||
let results = this.getCoordinates();
|
||||
let styles = this.getStyles(results);
|
||||
|
||||
if(this.props.isPresenter && this.props.shape.status != "textPublished") {
|
||||
return this.renderPresenterTextShape(results, styles);
|
||||
} else {
|
||||
return this.renderViewerTextShape(results, styles);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TextDrawComponent.defaultProps = {
|
||||
|
Loading…
Reference in New Issue
Block a user