Skip to content
Snippets Groups Projects
Commit 1e8127d2 authored by chris's avatar chris
Browse files

fix tool

parent 2c698ab7
No related branches found
No related tags found
1 merge request!348Multiple single
...@@ -55,9 +55,9 @@ class MultipleChoiceQuestion extends Tools { ...@@ -55,9 +55,9 @@ class MultipleChoiceQuestion extends Tools {
label = 'Multiple Choice'; label = 'Multiple Choice';
get run() { get run() {
return (view, main, context) => { return (view, context) => {
checkifEmpty(view); checkifEmpty(view);
createOption(main, context); createOption(view, context);
}; };
} }
......
...@@ -55,9 +55,9 @@ class MultipleChoiceSingleCorrectQuestion extends Tools { ...@@ -55,9 +55,9 @@ class MultipleChoiceSingleCorrectQuestion extends Tools {
label = 'Multiple Choice Single Correct'; label = 'Multiple Choice Single Correct';
get run() { get run() {
return (view, main, context) => { return (view, context) => {
checkifEmpty(view); checkifEmpty(view);
createOption(main, context); createOption(view, context);
}; };
} }
......
...@@ -55,9 +55,9 @@ class MultipleChoiceQuestion extends Tools { ...@@ -55,9 +55,9 @@ class MultipleChoiceQuestion extends Tools {
label = 'True False'; label = 'True False';
get run() { get run() {
return (view, main, context) => { return (view, context) => {
checkifEmpty(view); checkifEmpty(view);
createOption(main, context); createOption(view, context);
}; };
} }
......
...@@ -13,44 +13,37 @@ const StyledButton = styled(MenuButton)` ...@@ -13,44 +13,37 @@ const StyledButton = styled(MenuButton)`
`; `;
const ToolBarBtn = ({ view = {}, item }) => { const ToolBarBtn = ({ view = {}, item }) => {
const { active, icon, label, onlyOnMain, run, select, title } = item; const { icon, label, select, title } = item;
const context = useContext(WaxContext); const context = useContext(WaxContext);
const { const {
view: { main }, view: { main },
activeViewId,
activeView, activeView,
} = useContext(WaxContext); } = useContext(WaxContext);
if (onlyOnMain) view = main;
const isEditable = main.props.editable(editable => { const isEditable = main.props.editable(editable => {
return editable; return editable;
}); });
const { state } = view; const { state } = view;
const isActive = !!(
active(state, activeViewId) && select(state, activeViewId)
);
let isDisabled = !select(state, activeView); let isDisabled = !select(state, activeView);
if (!isEditable) isDisabled = true; if (!isEditable) isDisabled = true;
const ToolBarBtnComponent = useMemo( const ToolBarBtnComponent = useMemo(
() => ( () => (
<StyledButton <StyledButton
active={isActive || false} active={false}
disabled={isDisabled} disabled={isDisabled}
iconName={icon} iconName={icon}
label={label} label={label}
onMouseDown={e => { onMouseDown={e => {
e.preventDefault(); e.preventDefault();
item.run(view, main, context); item.run(context.view.main, context);
}} }}
title={title} title={title}
/> />
), ),
[isActive, isDisabled], [isDisabled],
); );
return ToolBarBtnComponent; return ToolBarBtnComponent;
......
...@@ -99,6 +99,10 @@ class MultipleDropDown extends ToolGroup { ...@@ -99,6 +99,10 @@ class MultipleDropDown extends ToolGroup {
} }
}); });
const onChange = option => {
this._tools[option.value].run(main, context);
};
const MultipleDropDown = useMemo( const MultipleDropDown = useMemo(
() => ( () => (
<Wrapper key={uuidv4()}> <Wrapper key={uuidv4()}>
...@@ -106,9 +110,7 @@ class MultipleDropDown extends ToolGroup { ...@@ -106,9 +110,7 @@ class MultipleDropDown extends ToolGroup {
value={found} value={found}
key={uuidv4()} key={uuidv4()}
options={dropDownOptions} options={dropDownOptions}
onChange={option => { onChange={option => onChange(option)}
this._tools[option.value].run(view, main, context);
}}
placeholder="Multiple Question Types" placeholder="Multiple Question Types"
select={isDisabled} select={isDisabled}
/> />
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment