Skip to content
Snippets Groups Projects
Commit 8199ee7d authored by Ramesh Kumar's avatar Ramesh Kumar
Browse files

TMSS-215: Scheduling Unit creation from observtion strategy added. Option in...

TMSS-215: Scheduling Unit creation from observtion strategy added. Option in Project view & Scheduling Unit list to create scheduling unit added.
parent aa10f889
No related branches found
No related tags found
1 merge request!210Resolve TMSS-215
......@@ -4,6 +4,7 @@ import moment from 'moment';
import _ from 'lodash';
import { Chips } from 'primereact/chips';
import { TieredMenu } from 'primereact/tieredmenu';
import ResourceDisplayList from './ResourceDisplayList';
......@@ -28,6 +29,10 @@ export class ProjectView extends Component {
}
this.state.redirect = this.state.projectId?"":'/project' // If no project id is passed, redirect to Project list page
this.resourceUnitMap = UnitConverter.resourceUnitMap; // Resource unit conversion factor and constraints
this.optionsMenu = React.createRef();
this.menuOptions = [ {label:'Add Scheduling Unit', icon: "fa fa-", command: () => {this.selectOptionMenu('Add SU')}} ];
this.selectOptionMenu = this.selectOptionMenu.bind(this);
}
componentDidMount() {
......@@ -68,6 +73,18 @@ export class ProjectView extends Component {
}
selectOptionMenu(menuName) {
switch(menuName) {
case 'Add SU': {
this.setState({redirect: `/project/${this.state.project.name}/schedulingunit/create`});
break;
}
default: {
break;
}
}
}
render() {
if (this.state.redirect) {
return <Redirect to={ {pathname: this.state.redirect} }></Redirect>
......@@ -86,8 +103,14 @@ export class ProjectView extends Component {
</Link>
<Link to={{ pathname: `/project/edit/${this.state.project.name}`, state: {id: this.state.project?this.state.project.name:''}}} title="Edit Project"
style={{float: "right"}}>
<i className="fa fa-edit" style={{marginTop: "10px"}}></i>
<i className="fa fa-edit" style={{marginTop: "10px", marginLeft: "5px"}}></i>
</Link>
<TieredMenu model={this.menuOptions} popup ref={el => this.optionsMenu = el} />
<button className="p-link" style={{float: "right"}}>
<i className="fa fa-bars" label="Toggle Columns" style={{marginTop: "10px", marginLeft: "5px"}}
onMouseOver={(e) => this.optionsMenu.toggle(e)} />
</button>
</div>
}
</div>
......
import React, {Component} from 'react';
import { Link } from 'react-router-dom';
import SchedulingUnitList from './SchedulingUnitList';
export class Scheduling extends Component {
......@@ -14,7 +15,16 @@ export class Scheduling extends Component {
render() {
return (
<>
<h2>Scheduling Unit - List</h2>
<div className="p-grid">
<div className="p-col-10 p-lg-10 p-md-10">
<h2>Scheduling Unit - List</h2>
</div>
<div className="p-col-2 p-lg-2 p-md-2">
<Link to={{ pathname: '/schedulingunit/create'}} title="Add New Scheduling Unit" style={{float: "right"}}>
<i className="fa fa-plus-square" style={{marginTop: "10px"}}></i>
</Link>
</div>
</div>
{this.state.scheduleunit &&
<SchedulingUnitList /> }
</>
......
......@@ -136,6 +136,31 @@ const ScheduleService = {
console.error(error);
return [];
};
},
saveSUDraftFromObservStrategy: async function(observStrategy, schedulingUnit) {
try {
const url = `/api/scheduling_unit_observing_strategy_template/${observStrategy.id}/create_scheduling_unit/?scheduling_set_id=${schedulingUnit.scheduling_set_id}&name=${schedulingUnit.name}&description=${schedulingUnit.description}`
const suObsResponse = await axios.get(url);
schedulingUnit = suObsResponse.data;
if (schedulingUnit && schedulingUnit.id) {
schedulingUnit.requirements_doc = observStrategy.template;
delete schedulingUnit['duration'];
const suUpdateResponse = await axios.put(`/api/scheduling_unit_draft/${schedulingUnit.id}/`, schedulingUnit);
schedulingUnit = suUpdateResponse.data;
if (!schedulingUnit || !schedulingUnit.id) {
return null;
}
const suCreateTaskResponse = await axios.get(`/api/scheduling_unit_draft/${schedulingUnit.id}/create_task_drafts/`);
schedulingUnit = suCreateTaskResponse.data;
if (schedulingUnit && schedulingUnit.task_drafts.length > 0) {
return schedulingUnit;
}
}
return null;
} catch(error) {
console.error(error);
return null;
};
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment