trc-client-core
Version:
The core of the TRC Client
109 lines (102 loc) • 4.12 kB
JSX
import Col from 'trc-client-core/src/components/Col';
import _ from 'lodash';
import GapReport from 'trc-client-core/src/report/GapReport';
import GapReportChart from 'trc-client-core/src/report/GapReportChart';
import Grid from 'trc-client-core/src/components/Grid';
import Input from 'trc-client-core/src/components/Input';
import Label from 'bd-stampy/components/Label';
import Button from 'bd-stampy/components/Button';
import Markdown from 'trc-client-core/src/components/Markdown';
import Permissions from 'trc-client-core/src/user/Permissions';
import React from 'react';
import Select from 'trc-client-core/src/components/Select';
import ToyotaForLifeIntro from 'trc-client-core/src/copy/learningPlan/ToyotaForLifeIntro.md';
import RegionSelect from 'trc-client-core/src/components/RegionSelect';
import DealerSelect from 'trc-client-core/src/components/DealerSelect';
var GapReportViewIncompletePrerequisites = React.createClass({
displayName: 'GapReportViewIncompletePrerequisites',
contextTypes: {
location: React.PropTypes.object
},
onGenerate() {
this.childGapReportChart.getWrappedInstance().generateReport();
},
getId() {
return (this.props.view === 'pt') ? 'incomplete_pt_prerequisites' : 'incomplete_prerequisites'
},
getQuery() {
var defaults = {
certification: 'ST_STC',
regionCode: 'ALL_REGIONS',
dealerCode: 'ALL_DEALERS'
};
if (this.props.view === 'pt') {
defaults = {
certification: 'PT_PTC',
regionCode: 'ALL_REGIONS',
dealerCode: 'ALL_DEALERS'
};
}
return _.assign({}, defaults, this.context.location.query);
},
render() {
var title = (this.props.view === 'pt') ? 'Incomplete PT Prerequisites' : 'Incomplete Prerequisites';
return <GapReport
name={title}
toolbar={this.renderToolbar()}
gapReport={this.renderGapReport()}
/>
},
renderToolbar() {
var {query} = this.context.location;
return <Grid >
{this.renderCertificationSelect()}
<Col width={2}>
<RegionSelect value={query.regionCode || "ALL_REGIONS"} />
</Col>
<Col width={4}>
<DealerSelect
value={query.dealerCode || "ALL_DEALERS"}
region={query.regionCode}
allDealers
/>
</Col>
<Col width={2}>
<Button onClick={this.onGenerate} className="w100">Generate</Button>
</Col>
</Grid>
},
renderCertificationSelect() {
var {query} = this.context.location;
if(this.props.view !== 'pt') {
return <Col width={3}>
<Select
name="certification"
queryString
value={query.certification || "ST_STC"}
options={[
{value: 'ST_STC', label: 'Service Tech'},
{value: 'PT_PTC', label: 'Pro Tech'},
{value: 'DT_HYBC', label: 'Diagnosis Tech Hybrid'},
{value: 'DT_ELC', label: 'Diagnosis Tech Electrical'},
{value: 'DT_ENC', label: 'Diagnosis Tech Engine'},
{value: 'DT_CHC', label: 'Diagnosis Tech Chassis'},
{value: 'MT_CERT', label: 'Master Tech Certification'}
]} />
</Col>;
}
},
renderGapReport() {
var {location} = this.context;
return (
<GapReportChart
autoRequest={false}
learningPlanId={this.getId()}
query={this.getQuery()}
ref={(child) => this.childGapReportChart = child}
{...location.query}
/>
);
}
});
export default GapReportViewIncompletePrerequisites;