Added button to add a program item
This commit is contained in:
parent
4a5b5ae7d9
commit
8fc64824c9
@ -121,16 +121,23 @@ class ProgramSequenceView extends React.Component<{
|
||||
const editing = this.props.editing || false;
|
||||
const className = classNames("programSequence", { editing });
|
||||
return (
|
||||
<ProgramSequenceList
|
||||
className={className}
|
||||
useDragHandle
|
||||
list={sequence}
|
||||
sections={sections}
|
||||
editing={editing}
|
||||
onChange={this.changeItem}
|
||||
onRemove={this.removeItem}
|
||||
onSortEnd={this.onSortEnd}
|
||||
/>
|
||||
<div>
|
||||
<ProgramSequenceList
|
||||
className={className}
|
||||
useDragHandle
|
||||
helperClass="dragging"
|
||||
list={sequence}
|
||||
sections={sections}
|
||||
editing={editing}
|
||||
onChange={this.changeItem}
|
||||
onRemove={this.removeItem}
|
||||
onSortEnd={this.onSortEnd}
|
||||
/>
|
||||
<Button onClick={this.addItem}>
|
||||
<Icon name="add"/>
|
||||
Add item
|
||||
</Button>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@ -142,6 +149,24 @@ class ProgramSequenceView extends React.Component<{
|
||||
this.props.sequence.splice(index, 1);
|
||||
}
|
||||
|
||||
private addItem = () => {
|
||||
let sectionId = 0;
|
||||
for (const section of this.props.sections) {
|
||||
const sectionNotIncluded = this.props.sequence
|
||||
.every((sequenceItem) =>
|
||||
sequenceItem.section !== section.id);
|
||||
if (sectionNotIncluded) {
|
||||
sectionId = section.id;
|
||||
break;
|
||||
}
|
||||
}
|
||||
const item = new ProgramItem({
|
||||
section: sectionId,
|
||||
duration: new Duration(5, 0).toSeconds(),
|
||||
});
|
||||
this.props.sequence.push(item);
|
||||
}
|
||||
|
||||
private onSortEnd = ({oldIndex, newIndex}: SortEnd) => {
|
||||
const { sequence: array } = this.props;
|
||||
if (newIndex >= array.length) {
|
||||
|
@ -115,6 +115,7 @@ class ProgramPage extends React.Component<ProgramPageProps> {
|
||||
}
|
||||
} else {
|
||||
if (this.programView != null) {
|
||||
this.programView.reset();
|
||||
this.programView = null;
|
||||
}
|
||||
}
|
||||
@ -185,6 +186,9 @@ class ProgramPage extends React.Component<ProgramPageProps> {
|
||||
|
||||
private close = () => {
|
||||
const { deviceId } = this.props.match.params;
|
||||
if (this.programView) {
|
||||
this.programView.reset();
|
||||
}
|
||||
this.props.history.push({ pathname: rp.device(deviceId) });
|
||||
}
|
||||
|
||||
|
@ -7,9 +7,11 @@
|
||||
|
||||
.programSequence-item {
|
||||
list-style-type: none;
|
||||
z-index: 2000;
|
||||
display: flex;
|
||||
margin-bottom: .5em;
|
||||
&.dragging {
|
||||
z-index: 1010;
|
||||
}
|
||||
.fields {
|
||||
margin: 0em 0em 1em !important;
|
||||
}
|
||||
@ -22,4 +24,4 @@
|
||||
.durationInputs {
|
||||
width: 20em;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user