Submission notice now saves on submission

This commit is contained in:
Ajay Ramachandran
2020-04-02 14:38:33 -04:00
parent 6fa67088bc
commit b6c243236b

View File

@@ -26,6 +26,7 @@ class SubmissionNoticeComponent extends React.Component<SubmissionNoticeProps, S
callback: () => any; callback: () => any;
noticeRef: React.MutableRefObject<NoticeComponent>; noticeRef: React.MutableRefObject<NoticeComponent>;
timeEditRefs: React.RefObject<SponsorTimeEditComponent>[];
constructor(props: SubmissionNoticeProps) { constructor(props: SubmissionNoticeProps) {
super(props); super(props);
@@ -95,18 +96,24 @@ class SubmissionNoticeComponent extends React.Component<SubmissionNoticeProps, S
getSponsorTimeMessages(): JSX.Element[] | JSX.Element { getSponsorTimeMessages(): JSX.Element[] | JSX.Element {
let elements: JSX.Element[] = []; let elements: JSX.Element[] = [];
this.timeEditRefs = [];
let sponsorTimes = this.props.contentContainer().sponsorTimesSubmitting; let sponsorTimes = this.props.contentContainer().sponsorTimesSubmitting;
for (let i = 0; i < sponsorTimes.length; i++) { for (let i = 0; i < sponsorTimes.length; i++) {
let timeRef = React.createRef<SponsorTimeEditComponent>();
elements.push( elements.push(
<SponsorTimeEditComponent key={i} <SponsorTimeEditComponent key={i}
idSuffix={this.state.idSuffix} idSuffix={this.state.idSuffix}
index={i} index={i}
contentContainer={this.props.contentContainer} contentContainer={this.props.contentContainer}
submissionNotice={this}> submissionNotice={this}
ref={timeRef}>
</SponsorTimeEditComponent> </SponsorTimeEditComponent>
) );
this.timeEditRefs.push(timeRef);
} }
return elements; return elements;
@@ -134,6 +141,11 @@ class SubmissionNoticeComponent extends React.Component<SubmissionNoticeProps, S
} }
submit() { submit() {
// save all items
for (const ref of this.timeEditRefs) {
ref.current.saveEditTimes();
}
this.props.callback(); this.props.callback();
this.cancel(); this.cancel();