Skip to content

Commit

Permalink
#12 Allow all measures to be selected
Browse files Browse the repository at this point in the history
  • Loading branch information
tscz committed Jan 17, 2020
1 parent 83ea346 commit 345b961
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/components/dialogManagement/dialogManagement.tsx
Expand Up @@ -27,6 +27,7 @@ import SectionSelect from "../sectionSelect/sectionSelect";
interface PropsFromState {
type: DialogType;
audioUrl: string;
maxMeasure: number;
}

interface PropsFromDispatch {
Expand Down Expand Up @@ -103,6 +104,7 @@ class DialogManagement extends Component<AllProps> {
case DialogType.ADD_SECTION:
return (
<AddSectionDialog
maxMeasure={this.props.maxMeasure}
onCancel={() => this.props.closedDialog()}
onSubmit={(sectionType, start, end) => {
this.props.addedSection({
Expand Down Expand Up @@ -213,12 +215,13 @@ const OpenDialog: FunctionComponent<{
};

const AddSectionDialog: FunctionComponent<{
maxMeasure: number;
onSubmit: (sectionType: SectionType, start: number, end: number) => void;
onCancel: () => void;
}> = props => {
const [sectionType, setSectionType] = useState(SectionType.UNDEFINED);
const [start, setStart] = useState(1);
const [end, setEnd] = useState(2);
const [sectionType, setSectionType] = useState(SectionType.INTRO);
const [start, setStart] = useState(0);
const [end, setEnd] = useState(0);
const actions: () => DialogAction[] = () => {
return [
{
Expand Down Expand Up @@ -252,7 +255,7 @@ const AddSectionDialog: FunctionComponent<{
<MeasureSelect
value={start}
min={0}
max={42}
max={props.maxMeasure}
onChange={value => setStart(value)}
/>
</FormControl>
Expand All @@ -261,18 +264,19 @@ const AddSectionDialog: FunctionComponent<{
<MeasureSelect
value={end}
min={0}
max={42}
max={props.maxMeasure}
onChange={value => setEnd(value)}
/>
</FormControl>
</ModalDialog>
);
};

const mapStateToProps = ({ dialog, project }: ApplicationState) => {
const mapStateToProps = ({ dialog, project, analysis }: ApplicationState) => {
return {
type: dialog.currentDialog,
audioUrl: project.audioUrl
audioUrl: project.audioUrl,
maxMeasure: analysis.measures.allIds.length - 1
};
};

Expand Down

0 comments on commit 345b961

Please sign in to comment.