MCPcopy Create free account
hub / github.com/StevenLyt/mapf-visualizer / populateOptions

Method populateOptions

src/MAPFVisualizer.jsx:506–623  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

504 }
505
506 populateOptions() {
507 var options = [];
508 for (let key in this.state.options) {
509 let option = this.state.options[key];
510 let sliderDisplay = true;
511 if (option.hasOwnProperty("restrictions")) {
512 for (let key2 in option.restrictions) {
513 option.restrictions[key2].forEach((restriction) => {
514 if (this.state.options[key2].value === restriction) {
515 sliderDisplay = false;
516 }
517 });
518 }
519 }
520 options.push(
521 option.options[0] === false ? (
522 // switch button for true/false options
523 <MKBox px={2} key={key}>
524 <Grid container>
525 <Grid item container xs={12} md={5} alignItems="center">
526 <MKTypography variant="h6">{option.name}</MKTypography>
527 </Grid>
528 <Grid item container xs={12} md={7} alignItems="center">
529 <Switch
530 checked={!!option.value}
531 onChange={(e) => {
532 if (option.hasOwnProperty("restrictions")) {
533 let check = false;
534 for (let key2 in option.restrictions) {
535 option.restrictions[key2].forEach((restriction) => {
536 if (this.state.options[key2].value === restriction) {
537 check = true;
538 }
539 });
540 }
541 if (!check) {
542 option.value = Number(e.target.checked);
543 this.setState({});
544 }
545 } else {
546 option.value = Number(e.target.checked);
547 this.setState({});
548 }
549 }}
550 />
551 </Grid>
552 </Grid>
553 </MKBox>
554 ) : typeof option.options[0] === "number" ? (
555 sliderDisplay ? (
556 // slider for numeric options
557 <MKBox px={2} key={key}>
558 <Grid container justifyContent="center">
559 <Grid item container xs={12} md={11} alignItems="center">
560 <Slider
561 aria-label="Custom marks"
562 getAriaValueText={(value) => {
563 return value;

Callers 1

renderMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected