diff --git a/SAS/TMSS/frontend/tmss_webapp/src/routes/Scheduling/ViewSchedulingUnit.js b/SAS/TMSS/frontend/tmss_webapp/src/routes/Scheduling/ViewSchedulingUnit.js index de5254e5c49a324b35501af578a550775fa6ebc3..8e33edf359ebacb588313dd54a87ed916f8c5d3d 100644 --- a/SAS/TMSS/frontend/tmss_webapp/src/routes/Scheduling/ViewSchedulingUnit.js +++ b/SAS/TMSS/frontend/tmss_webapp/src/routes/Scheduling/ViewSchedulingUnit.js @@ -183,8 +183,8 @@ class ViewSchedulingUnit extends Component{ ); }; - async getSchedulingUnitDetails(schedule_type, schedule_id) { - await ScheduleService.getSchedulingUnitExtended(schedule_type, schedule_id) + getSchedulingUnitDetails(schedule_type, schedule_id) { + ScheduleService.getSchedulingUnitExtended(schedule_type, schedule_id) .then(async(schedulingUnit) =>{ if (schedulingUnit) { ScheduleService.getSchedulingConstraintTemplates().then((response) => { @@ -217,6 +217,7 @@ class ViewSchedulingUnit extends Component{ task.subTaskID = subTaskIds.length ? subTaskIds[0].id : ''; return task; })); + const targetObservation = _.find(tasks, (task)=> {return task.template.type_value==='observation' && task.tasktype.toLowerCase()===schedule_type && task.specifications_doc.station_groups}); this.setState({ scheduleunitId: schedule_id, @@ -228,46 +229,43 @@ class ViewSchedulingUnit extends Component{ redirect: null, dialogVisible: false, ingestGroup}); - this.selectedRows = []; + this.selectedRows = []; + // Add Action menu + this.getActionMenu(schedule_type); } else { this.setState({ isLoading: false, + redirect: "/not-found" }); } }); - if (_.isEmpty(this.state.scheduleunit)){ - this.setState({redirect: "/not-found"}); - } else { - this.actions =[]; - if(schedule_type === 'blueprint' || (schedule_type === 'draft' && this.state.scheduleunit.scheduling_unit_blueprints_ids - && this.state.scheduleunit.scheduling_unit_blueprints_ids.length === 0)) { - this.actions.push({icon: 'fa fa-trash',title:'Delete Scheduling Unit', type: 'button', actOn: 'click', props:{ callback: this.showDeleteSUConfirmation}}); - } - - this.actions.push( - {icon: 'fa-window-close',title:'Click to Close Scheduling Unit View', link: this.props.history.goBack} - ); - - if (this.props.match.params.type === 'draft') { - this.actions.unshift({icon:'fa-file-import', title: 'Data Products To Ingest', type:'button', - actOn:'click', props : { callback: this.showTaskRelationDialog} - }); - this.actions.unshift({icon: 'fa-edit', title: 'Click to edit', props : { pathname:`/schedulingunit/edit/${ this.props.match.params.id}`} - }); - this.actions.unshift({icon:'fa-stamp', title: 'Create Blueprint', type:'button', - actOn:'click', props : { callback: this.checkAndCreateBlueprint}, - }); - - } else { - this.actions.unshift({icon: 'fa-sitemap',title :'View Workflow',props :{pathname:`/schedulingunit/${this.props.match.params.id}/workflow`}}); - this.actions.unshift({icon: 'fa-lock', title: 'Cannot edit blueprint'}); - } - - this.setState({actions: this.actions}); - } - } + /** + * Get action menus for page header + */ + getActionMenu(schedule_type) { + this.actions =[]; + if(schedule_type === 'blueprint' || (schedule_type === 'draft' && this.state.scheduleunit && this.state.scheduleunit.scheduling_unit_blueprints_ids && this.state.scheduleunit.scheduling_unit_blueprints_ids.length === 0)) { + this.actions.push({icon: 'fa fa-trash',title:'Delete Scheduling Unit', type: 'button', actOn: 'click', props:{ callback: this.showDeleteSUConfirmation}}); + } + this.actions.push({icon: 'fa-window-close',title:'Click to Close Scheduling Unit View', link: this.props.history.goBack} ); + if (this.props.match.params.type === 'draft') { + this.actions.unshift({icon:'fa-file-import', title: 'Data Products To Ingest', type:'button', + actOn:'click', props : { callback: this.showTaskRelationDialog} + }); + this.actions.unshift({icon: 'fa-edit', title: 'Click to edit', props : { pathname:`/schedulingunit/edit/${ this.props.match.params.id}`} + }); + this.actions.unshift({icon:'fa-stamp', title: 'Create Blueprint', type:'button', + actOn:'click', props : { callback: this.checkAndCreateBlueprint}, + }); + } else { + this.actions.unshift({icon: 'fa-sitemap',title :'View Workflow',props :{pathname:`/schedulingunit/${this.props.match.params.id}/workflow`}}); + this.actions.unshift({icon: 'fa-lock', title: 'Cannot edit blueprint'}); + } + this.setState({actions: this.actions}); + } + /** * Formatting the task_drafts and task_blueprints in draft view to pass to the ViewTable component * @param {Object} schedulingUnit - scheduling_unit_draft object from extended API call loaded with tasks(draft & blueprint) along with their template and subtasks