-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
452 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import {REQUEST_API} from '../../system/constants'; | ||
import * as types from './constants'; | ||
|
||
export function loadSpecoffersList(params) { | ||
return { | ||
type: REQUEST_API, | ||
request: { | ||
url: `/specoffers?timePeriodId=${params.timePeriodId}&limit=${params.limit}`, | ||
actions: { | ||
start: {type: types.LOAD_ALL_SPECOFFERS_START}, | ||
success: {type: types.LOAD_ALL_SPECOFFERS_SUCCESS}, | ||
fail: {type: types.LOAD_ALL_SPECOFFERS_FAIL} | ||
}, | ||
params, | ||
cache: true | ||
}, | ||
interrupt: (store) => !!store.getState().specoffers.list.resources.length | ||
}; | ||
} | ||
|
||
export function loadEnrolmentsListBySpecoffer(params) { | ||
return { | ||
type: REQUEST_API, | ||
request: { | ||
url: `/enrolments?specOfferId=${params.specOfferId}`, | ||
actions: { | ||
start: {type: types.LOAD_ENROLMENTS_BY_SPECOFFERS_START}, | ||
success: {type: types.LOAD_ENROLMENTS_BY_SPECOFFERS_SUCCESS}, | ||
fail: {type: types.LOAD_ENROLMENTS_BY_SPECOFFERS_FAIL} | ||
}, | ||
params, | ||
cache: true | ||
}, | ||
interrupt: (store) => !!store.getState().specoffers.specofferEnrolments.data[params.specOfferId], | ||
payload: { | ||
specOfferId: params.specOfferId | ||
} | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import React, {Component, PropTypes} from 'react'; | ||
import find from 'lodash/find' | ||
import {createSelector} from 'reselect'; | ||
import {connect} from 'react-redux'; | ||
|
||
import Loading from 'loading'; | ||
import * as dictConst from '../../dictionaries/constants'; | ||
import loadDictionaries from '../../dictionaries/actions'; | ||
import {decodeEnrolments} from '../../enrolments/helpers'; | ||
|
||
import {loadEnrolmentsListBySpecoffer} from './../actions'; | ||
import {isDataForSpecoffersLoaded, decodeOneSpecoffer} from './../helpers'; | ||
import {SPECOFFERS_LIST_REDUCER} from './../constants'; | ||
|
||
class SpecofferEnrolments extends Component { | ||
constructor(props) { | ||
super(props); | ||
} | ||
|
||
componentDidMount() { | ||
const {specOfferId} = this.props; | ||
this.props.loadDictionaries([dictConst.DEPARTMENTS]); | ||
this.props.loadEnrolmentsListBySpecoffer({specOfferId: specOfferId}); | ||
} | ||
|
||
render() { | ||
if (!isDataForSpecoffersLoaded(SPECOFFERS_LIST_REDUCER)) { | ||
return <Loading/>; | ||
} | ||
|
||
return ( | ||
<div> | ||
SpecofferEnrolments | ||
</div> | ||
); | ||
} | ||
} | ||
|
||
const mapStateToSpecofferEnrolments = createSelector( | ||
(state, ownProps) => state.specoffers.specofferEnrolments.data[ownProps.location.query.specOfferId], | ||
(state, ownProps) => find(state.specoffers.list, {id: ownProps.location.query.specOfferId}), | ||
(state) => state.dictionaries, | ||
(state, ownProps) => ownProps.location.query.specOfferId, | ||
(enrolments, specoffer, listOfDict, specOfferId) => ({ | ||
decodedEnrolments: decodeEnrolments(enrolments, listOfDict), | ||
decodedOneSpecoffer: decodeOneSpecoffer(specoffer, listOfDict), | ||
specOfferId: specOfferId | ||
}) | ||
); | ||
|
||
export default connect( | ||
mapStateToSpecofferEnrolments, | ||
{loadEnrolmentsListBySpecoffer, loadDictionaries} | ||
)(SpecofferEnrolments); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import React, {Component, PropTypes} from 'react'; | ||
|
||
export default class SpecofferInfoMain extends Component { | ||
render() { | ||
return <div>SpecofferInfoMain</div>; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import React, {Component, PropTypes} from 'react'; | ||
import Button from 'react-bootstrap/lib/Button'; | ||
import {LinkContainer} from 'react-router-bootstrap'; | ||
|
||
class SpecofferInfoPage extends Component { | ||
render() { | ||
return ( | ||
<div> | ||
<div className="btn-group"> | ||
<LinkContainer to={{ pathname: `/specoffers-info/enrolments`, query: this.props.location.query }}> | ||
<Button eventKey={1} className="btn btn-default"> Заяви </Button> | ||
</LinkContainer> | ||
<LinkContainer to={{ pathname: `/specoffers-info/info`, query: this.props.location.query }}> | ||
<Button eventKey={2} className="btn btn-default"> Info </Button> | ||
</LinkContainer> | ||
<LinkContainer to={{ pathname: `/specoffers/${this.props.params.id}/statuses`}}> | ||
<Button eventKey={3} className="btn btn-default"> Statuses </Button> | ||
</LinkContainer> | ||
<LinkContainer to={{ pathname: `/specoffers/${this.props.params.id}/subjects`}}> | ||
<Button eventKey={4} className="btn btn-default"> Subjects </Button> | ||
</LinkContainer> | ||
</div> | ||
{this.props.children} | ||
</div> | ||
); | ||
} | ||
} | ||
|
||
SpecofferInfoPage.propTypes = { | ||
children: PropTypes.any | ||
}; | ||
|
||
export default SpecofferInfoPage; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
export const LOAD_ALL_SPECOFFERS_START = 'LOAD_ALL_SPECOFFERS_START'; | ||
export const LOAD_ALL_SPECOFFERS_SUCCESS = 'LOAD_ALL_SPECOFFERS_SUCCESS'; | ||
export const LOAD_ALL_SPECOFFERS_FAIL = 'LOAD_ALL_SPECOFFERS_START'; | ||
|
||
export const LOAD_ENROLMENTS_BY_SPECOFFERS_START = 'LOAD_ENROLMENTS_BY_SPECOFFERS_START'; | ||
export const LOAD_ENROLMENTS_BY_SPECOFFERS_SUCCESS = 'LOAD_ENROLMENTS_BY_SPECOFFERS_SUCCESS'; | ||
export const LOAD_ENROLMENTS_BY_SPECOFFERS_FAIL = 'LOAD_ENROLMENTS_BY_SPECOFFERS_FAIL'; | ||
|
||
export const SPECOFFERS_REDUCER = 'specoffers'; | ||
export const SPECOFFERS_LIST_REDUCER = 'list'; | ||
|
||
|
||
export const FIELD_NAMES = [ | ||
{'name': 'Спеціальність', 'field': 'specialtyId'}, | ||
{'name': 'Структурний підрозділ', 'field': 'departmentId'}, | ||
{'name': 'Тип пропозиції', 'field': 'specofferTypeId'}, | ||
{'name': 'docNum', 'field': 'docNum'}, | ||
{'name': 'weightCertificate', 'field': 'weightCertificate'}, | ||
{'name': 'weightAward', 'field': 'weightAward'}, | ||
{'name': 'Форма навчання', 'field': 'educationFormTypeId'}, | ||
{'name': 'Ліцензований обсяг', 'field': 'licCount'}, | ||
{'name': 'Державне замовлення', 'field': 'stateCount'}, | ||
]; |
113 changes: 113 additions & 0 deletions
113
src/modules/specoffers/containers/SpecoffersListPage.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
import React, {Component, PropTypes} from 'react'; | ||
import {connect} from 'react-redux'; | ||
import {createSelector} from 'reselect'; | ||
import LinkContainer from 'react-router-bootstrap/lib/LinkContainer'; | ||
import Button from 'react-bootstrap/lib/Button'; | ||
import {Table, Column, Cell} from 'fixed-data-table'; | ||
|
||
import Loading from 'loading'; | ||
import {loadSpecoffersList} from './../actions'; | ||
import {isDataForSpecoffersLoaded, decodeSpecoffers} from './../helpers'; | ||
import * as dictConst from '../../dictionaries/constants'; | ||
import loadDictionaries from '../../dictionaries/actions'; | ||
import {SPECOFFERS_LIST_REDUCER, FIELD_NAMES} from './../constants'; | ||
|
||
class MyLinkCell extends Component { | ||
render() { | ||
const {rowIndex, field, data, ...props} = this.props; | ||
let path = `/specoffers-info/enrolments`; | ||
let query = {specOfferId: data[rowIndex][field]}; | ||
return ( | ||
<Cell {...props}> | ||
<LinkContainer to={{ pathname: path, query: query }}> | ||
<a>{data[rowIndex][field]}</a> | ||
</LinkContainer> | ||
</Cell> | ||
); | ||
} | ||
} | ||
|
||
class SpecoffersListPage extends Component { | ||
constructor(props) { | ||
super(props); | ||
} | ||
|
||
componentDidMount() { | ||
const {timePeriodId, limit} = this.props; | ||
this.props.loadDictionaries([dictConst.DEPARTMENTS]); | ||
this.props.loadSpecoffersList({timePeriodId, limit}); | ||
} | ||
|
||
render() { | ||
if (!isDataForSpecoffersLoaded(SPECOFFERS_LIST_REDUCER)) { | ||
return <Loading/>; | ||
} | ||
|
||
let {decodedSpecoffers} = this.props; | ||
|
||
let cells = FIELD_NAMES.map((item) => { | ||
return <Column | ||
header={<Cell>{item.name}</Cell>} | ||
cell={props => ( | ||
<Cell {...props}> | ||
{decodedSpecoffers[props.rowIndex][item.field]} | ||
</Cell> | ||
) | ||
} | ||
flexGrow={1} | ||
width={20} | ||
/> | ||
}); | ||
|
||
return ( | ||
<div> | ||
<Table | ||
rowsCount={decodedSpecoffers.length} | ||
rowHeight={50} | ||
headerHeight={50} | ||
width={950} | ||
height={420}> | ||
<Column | ||
header={<Cell>№</Cell>} | ||
cell={ | ||
<MyLinkCell | ||
data={decodedSpecoffers} | ||
field="id" | ||
/> | ||
} | ||
width={40} | ||
/> | ||
{cells} | ||
<Column | ||
header='' | ||
cell={props => ( | ||
<Cell {...props}> | ||
<LinkContainer to={{ pathname: `/specoffers/${decodedSpecoffers[props.rowIndex]['id']}/info`}}> | ||
<Button eventKey={1} bsStyle="info" bsSize="xsmall"> M </Button> | ||
</LinkContainer> | ||
</Cell> | ||
) | ||
} | ||
width={50} | ||
/> | ||
</Table> | ||
</div> | ||
); | ||
} | ||
} | ||
|
||
const mapStateToSpecoffers = createSelector( | ||
(state) => state.specoffers.list, | ||
(state) => state.dictionaries, | ||
(state, ownProps) => ownProps.location.query, | ||
(list, listOfDict, query) => ({ | ||
decodedSpecoffers: decodeSpecoffers(list, listOfDict), | ||
timePeriodId: query.timePeriodId, | ||
limit: query.limit | ||
}) | ||
); | ||
|
||
export default connect( | ||
mapStateToSpecoffers, | ||
{loadSpecoffersList, loadDictionaries} | ||
)(SpecoffersListPage); |
Oops, something went wrong.