add right click option to problem status checkbox
This commit is contained in:
parent
6d5c0c6b9e
commit
21610a6860
|
@ -3,7 +3,11 @@ import Tooltip from '../../Tooltip/Tooltip';
|
||||||
import { Problem } from '../../../../content/models';
|
import { Problem } from '../../../../content/models';
|
||||||
import { useContext } from 'react';
|
import { useContext } from 'react';
|
||||||
import UserDataContext from '../../../context/UserDataContext';
|
import UserDataContext from '../../../context/UserDataContext';
|
||||||
import { NEXT_PROBLEM_STATUS, ProblemProgress } from '../../../models/problem';
|
import {
|
||||||
|
NEXT_PROBLEM_STATUS,
|
||||||
|
PREV_PROBLEM_STATUS,
|
||||||
|
ProblemProgress,
|
||||||
|
} from '../../../models/problem';
|
||||||
|
|
||||||
export default function ProblemStatusCheckbox({
|
export default function ProblemStatusCheckbox({
|
||||||
problem,
|
problem,
|
||||||
|
@ -25,6 +29,10 @@ export default function ProblemStatusCheckbox({
|
||||||
const handleClick = () => {
|
const handleClick = () => {
|
||||||
setUserProgressOnProblems(problem, NEXT_PROBLEM_STATUS[status]);
|
setUserProgressOnProblems(problem, NEXT_PROBLEM_STATUS[status]);
|
||||||
};
|
};
|
||||||
|
const handleRightClick = e => {
|
||||||
|
e.preventDefault();
|
||||||
|
setUserProgressOnProblems(problem, PREV_PROBLEM_STATUS[status]);
|
||||||
|
};
|
||||||
return (
|
return (
|
||||||
<Tooltip
|
<Tooltip
|
||||||
content={status}
|
content={status}
|
||||||
|
@ -32,7 +40,11 @@ export default function ProblemStatusCheckbox({
|
||||||
type="compact"
|
type="compact"
|
||||||
position="left"
|
position="left"
|
||||||
>
|
>
|
||||||
<span onClick={handleClick} className="inline-block h-6 w-6">
|
<span
|
||||||
|
onClick={handleClick}
|
||||||
|
onContextMenu={handleRightClick}
|
||||||
|
className="inline-block h-6 w-6"
|
||||||
|
>
|
||||||
<span
|
<span
|
||||||
className={
|
className={
|
||||||
'inline-block h-6 w-6 rounded-full cursor-pointer transition duration-100 ease-out ' +
|
'inline-block h-6 w-6 rounded-full cursor-pointer transition duration-100 ease-out ' +
|
||||||
|
|
|
@ -75,12 +75,14 @@ export type ProblemProgress =
|
||||||
| "Can't Solve"
|
| "Can't Solve"
|
||||||
| 'Skipped';
|
| 'Skipped';
|
||||||
|
|
||||||
export const NEXT_PROBLEM_STATUS: {
|
let options = ['Not Attempted', 'Solving', 'Solved', "Can't Solve", 'Skipped'];
|
||||||
[key in ProblemProgress]: ProblemProgress;
|
|
||||||
} = {
|
let NEXT_PROBLEM_STATUS: { [key in ProblemProgress]?: ProblemProgress } = {};
|
||||||
'Not Attempted': 'Solving',
|
let PREV_PROBLEM_STATUS: { [key in ProblemProgress]?: ProblemProgress } = {};
|
||||||
Solving: 'Solved',
|
for (let i = 0; i < options.length; i++) {
|
||||||
Solved: "Can't Solve",
|
NEXT_PROBLEM_STATUS[options[i]] = options[(i + 1) % options.length];
|
||||||
"Can't Solve": 'Skipped',
|
PREV_PROBLEM_STATUS[options[i]] =
|
||||||
Skipped: 'Not Attempted',
|
options[(i - 1 + options.length) % options.length];
|
||||||
};
|
}
|
||||||
|
|
||||||
|
export { NEXT_PROBLEM_STATUS, PREV_PROBLEM_STATUS };
|
||||||
|
|
Reference in a new issue