-
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
13 changed files
with
267 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
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.resources.length | ||
}; | ||
} |
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,17 @@ | ||
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 SPECOFFERS_REDUCER = 'specoffers'; | ||
|
||
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'}, | ||
]; |
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 SpecofferInfo extends Component { | ||
render() { | ||
return <div>SpecofferInfo</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,97 @@ | ||
import React, {Component, PropTypes} from 'react'; | ||
import {connect} from 'react-redux'; | ||
import {createSelector} from 'reselect'; | ||
import LinkContainer from 'react-router-bootstrap/lib/LinkContainer'; | ||
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_REDUCER, FIELD_NAMES} from './../constants'; | ||
|
||
class MyLinkCell extends Component { | ||
render() { | ||
const {rowIndex, field, data, ...props} = this.props; | ||
let path = `/specoffers/enrolments?specOfferId=${data[rowIndex][field]}`; | ||
return ( | ||
<Cell {...props}> | ||
<LinkContainer to={{ pathname: path}}> | ||
<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_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 ( | ||
<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} | ||
</Table> | ||
); | ||
} | ||
} | ||
|
||
const mapStateToSpecoffers = createSelector( | ||
(state) => state.specoffers, | ||
(state) => state.dictionaries, | ||
(state, ownProps) => ownProps.location.query, | ||
(specoffers, listOfDict, query) => ({ | ||
decodedSpecoffers: decodeSpecoffers(specoffers, listOfDict), | ||
timePeriodId: query.timePeriodId, | ||
limit: query.limit | ||
}) | ||
); | ||
|
||
export default connect( | ||
mapStateToSpecoffers, | ||
{loadSpecoffersList, loadDictionaries} | ||
)(SpecoffersListPage); |
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,50 @@ | ||
import store from 'store'; | ||
import * as dictConstants from '../dictionaries/constants'; | ||
import {isDictLoaded} from '../dictionaries/helpers'; | ||
|
||
let { | ||
DEPARTMENTS, | ||
ENROLMENTS_TYPES, | ||
ENROLMENTS_STATUS_TYPES | ||
} = dictConstants; | ||
|
||
/** | ||
* check if data is loaded | ||
* @param entityData | ||
* @returns {boolean} | ||
*/ | ||
export function isEntityDataLoaded(entityData) { | ||
return !entityData.isLoading && (entityData.resources && !!entityData.resources.length); | ||
} | ||
|
||
/** | ||
* check if specoffers loaded && dictionaries (used only inside specoffers list container) | ||
* @param reducerName | ||
* @returns {*|boolean} | ||
*/ | ||
export function isDataForSpecoffersLoaded(reducerName) { | ||
let state = store.getState(); | ||
return isDictLoaded([DEPARTMENTS], state.dictionaries) | ||
&& isEntityDataLoaded(state[reducerName]); | ||
} | ||
|
||
/** | ||
* | ||
* @param rowSpecoffers - list of row specoffers | ||
* @returns {Array} - array of decoded specoffers | ||
*/ | ||
export function decodeSpecoffers(rowSpecoffers, dictionaries) { | ||
return rowSpecoffers.resources.map((item)=> { | ||
return decodeOneSpecoffer(item, dictionaries); | ||
}); | ||
} | ||
|
||
export function decodeOneSpecoffer(item, dictionaries) { | ||
if (!item) return {}; | ||
|
||
let {DEPARTMENTS} = dictionaries; | ||
|
||
return Object.assign({}, item, { | ||
departmentId: DEPARTMENTS.resourcesMap[item.departmentId] | ||
}); | ||
} |
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,57 @@ | ||
import * as types from './constants'; | ||
import {LOCATION_CHANGE} from 'react-router-redux'; | ||
import { ignoreActions } from 'redux-ignore'; | ||
import {combineReducers} from 'redux'; | ||
|
||
import lcache from '../../system/lcache'; | ||
import { TIMEPERIODID_CHANGED } from '../settings/widget'; | ||
|
||
const defaultState = { | ||
isLoading: false, | ||
resources: [], | ||
timePeriodId: lcache.get('timePeriodId') || 8, | ||
limit: 300, | ||
error: null | ||
}; | ||
|
||
export function specoffers(state = defaultState, action = {}) { | ||
switch (action.type) { | ||
|
||
case types.LOAD_ALL_SPECOFFERS_START: | ||
return Object.assign({}, state, {isLoading: true, resources: []}); | ||
|
||
case types.LOAD_ALL_SPECOFFERS_SUCCESS: | ||
return Object.assign({}, state, | ||
{ | ||
isLoading: false | ||
}, | ||
action.response | ||
); | ||
|
||
case types.LOAD_ALL_SPECOFFERS_FAIL: | ||
return Object.assign({}, state, {isLoading: false}, {error: action.error.message}); | ||
|
||
case TIMEPERIODID_CHANGED: | ||
return Object.assign({}, state, | ||
{ | ||
isLoading: false, | ||
resources: [] | ||
} | ||
); | ||
|
||
case LOCATION_CHANGE: // listen to query parameters changes | ||
//if (action.payload.pathname !== '/specoffers') return state; | ||
let { | ||
timePeriodId = state.timePeriodId, | ||
limit = state.limit } = action.payload.query; | ||
return Object.assign({}, state, {timePeriodId, limit}); | ||
|
||
default: | ||
return state; | ||
} | ||
} | ||
|
||
export default combineReducers({ | ||
specoffers: ignoreActions(specoffers, | ||
(action) => action.type === LOCATION_CHANGE && action.payload.pathname !== '/specoffers') | ||
}); |
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