Skip to content
Snippets Groups Projects
Unverified Commit b18c05de authored by Chad Pilkey's avatar Chad Pilkey Committed by GitHub
Browse files

Merge pull request #7093 from KDSBrowne/2.2-Imp-quick-poll

Improvements to quick poll menu options
parents 687d3dbc 1b8ff2f9
No related branches found
No related tags found
No related merge requests found
......@@ -38,7 +38,6 @@ const propTypes = {
intl: intlShape.isRequired,
parseCurrentSlideContent: PropTypes.func.isRequired,
isUserPresenter: PropTypes.bool.isRequired,
};
const handleClickQuickPoll = (slideId, poll) => {
......@@ -49,23 +48,44 @@ const handleClickQuickPoll = (slideId, poll) => {
makeCall('startPoll', type, slideId);
};
const getAvailableQuickPolls = (slideId, parsedSlides) => {
const pollItemElements = parsedSlides.map((poll) => {
const { poll: label, type } = poll;
let itemLabel = label;
const getAvailableQuickPolls = (slideId, parsedSlides) => parsedSlides.map((poll) => {
const { poll: label, type } = poll;
let itemLabel = label;
if (type !== 'YN' && type !== 'TF') {
const { options } = itemLabel;
itemLabel = options.join('/').replace(/[\n.)]/g, '');
}
if (type !== 'YN' && type !== 'TF') {
const { options } = itemLabel;
itemLabel = options.join('/').replace(/[\n.)]/g, '');
}
// removes any whitespace from the label
itemLabel = itemLabel.replace(/\s+/g, '').toUpperCase();
return (
<DropdownListItem
label={itemLabel}
key={_.uniqueId('quick-poll-item')}
onClick={() => handleClickQuickPoll(slideId, poll)}
/>);
});
const numChars = {
1: 'A', 2: 'B', 3: 'C', 4: 'D', 5: 'E',
};
itemLabel = itemLabel.split('').map((c) => {
if (numChars[c]) return numChars[c];
return c;
}).join('');
return (
<DropdownListItem
label={itemLabel}
key={_.uniqueId('quick-poll-item')}
onClick={() => handleClickQuickPoll(slideId, poll)}
/>
);
});
const sizes = [];
return pollItemElements.filter((el) => {
const { label } = el.props;
if (label.length === sizes[sizes.length - 1]) return;
sizes.push(label.length);
return el;
});
};
const QuickPollDropdown = (props) => {
const { isUserPresenter, intl, parseCurrentSlideContent } = props;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment