diff --git a/src/modules/enrolments/constants.js b/src/modules/enrolments/constants.js index 1b4c1f9..c035aa8 100644 --- a/src/modules/enrolments/constants.js +++ b/src/modules/enrolments/constants.js @@ -19,7 +19,7 @@ export const ENROLMENTS_LIST_PAGE_WIDTH_CHANGED = 'ENROLMENTS_LIST_PAGE_WIDTH_CH export const ENROLMENTS_FIELD_NAMES = { id: {'name': '№', 'width': 40}, personId: {'name': 'Персона (id)', 'width': 70}, - specOfferId: {'name': 'Пропозиція (id)', 'width': 90}, + specofferId: {'name': 'Пропозиція (id)', 'width': 90}, isState: {'name': 'Бюджет', 'width': 70}, isContract: {'name': 'Контракт', 'width': 80}, departmentId: {'name': 'Підрозділ', 'width': 80}, diff --git a/src/modules/enrolments/list/EnrolmentsListPage.jsx b/src/modules/enrolments/list/EnrolmentsListPage.jsx index 0355a48..10c10b6 100644 --- a/src/modules/enrolments/list/EnrolmentsListPage.jsx +++ b/src/modules/enrolments/list/EnrolmentsListPage.jsx @@ -21,7 +21,7 @@ class EnrolmentsListPage extends Component { this.props.setFieldWidthEnrolments(newColumnWidth, columnKey); } - _goToDetailed = (e, index) => { + _onClickRow = (e, index) => { let id = getEnrolmentIdByIndex(index); this.props.goToDetailed(id); } @@ -61,7 +61,7 @@ class EnrolmentsListPage extends Component { headerHeight={70} onColumnResizeEndCallback={this._onColumnResizeEndCallback} isColumnResizing={false} - onRowClick={this._goToDetailed} + onRowClick={this._onClickRow} width={950} height={420} > diff --git a/src/modules/enrolments/list/reducer.js b/src/modules/enrolments/list/reducer.js index 1c1bf90..23f3651 100644 --- a/src/modules/enrolments/list/reducer.js +++ b/src/modules/enrolments/list/reducer.js @@ -1,4 +1,5 @@ import * as types from '../constants'; +import {ENROLMENTS_FIELD_NAMES} from '../constants'; const defaultState = { isLoading: true, @@ -6,7 +7,7 @@ const defaultState = { limit: 50, offset: 0, resources: [], - enrolmentsFieldNames: types.ENROLMENTS_FIELD_NAMES, + enrolmentsFieldNames: ENROLMENTS_FIELD_NAMES, error: null }; diff --git a/src/modules/specoffers/actions.js b/src/modules/specoffers/actions.js index 8d89676..99d9d09 100644 --- a/src/modules/specoffers/actions.js +++ b/src/modules/specoffers/actions.js @@ -1,5 +1,6 @@ import {REQUEST_API} from '../../system/constants'; import * as types from './constants'; +import {getSpecofferEnrolmentsBySpecofferId, getSpecofferInfoMain} from './reducers/view.js' export function loadSpecoffersList(params) { return { @@ -30,7 +31,7 @@ export function loadOneSpecoffer(specofferId) { }, cache: true }, - interrupt: (store) => !!store.getState().specoffers.view.mainInfo.data[specofferId], + interrupt: (store) => !!getSpecofferInfoMain(store.getState(), specofferId), payload: { specofferId: specofferId } @@ -47,10 +48,10 @@ export function loadEnrolmentsListBySpecoffer(params) { success: {type: types.LOAD_ENROLMENTS_BY_SPECOFFERS_SUCCESS}, fail: {type: types.LOAD_ENROLMENTS_BY_SPECOFFERS_FAIL} }, - params, + params: {specOfferId: params.specofferId}, cache: true }, - interrupt: (store) => !!store.getState().specoffers.view.specofferEnrolments.data[params.specofferId], + interrupt: (store) => !!getSpecofferEnrolmentsBySpecofferId(store.getState(), params.specofferId), payload: { specofferId: params.specofferId } diff --git a/src/modules/specoffers/components/Enrolments.jsx b/src/modules/specoffers/components/Enrolments.jsx index 02e8b56..e1787fc 100644 --- a/src/modules/specoffers/components/Enrolments.jsx +++ b/src/modules/specoffers/components/Enrolments.jsx @@ -13,6 +13,7 @@ import {getEnrolmentIdByIndex} from '../helpers'; import {loadEnrolmentsListBySpecoffer, setFieldWidthEnrolments} from './../actions'; import {isDataForEnrolmentLoaded, decodeOneSpecoffer} from './../helpers'; +import {getSpecofferEnrolments, getSpecofferEnrolmentsBySpecofferId} from '../reducers/view.js'; class SpecofferEnrolments extends Component { constructor(props) { @@ -23,7 +24,7 @@ class SpecofferEnrolments extends Component { this.props.setFieldWidthEnrolments(newColumnWidth, columnKey); } - _goToDetailed = (e, index) => { + _onClickRow = (e, index) => { let id = getEnrolmentIdByIndex(this.props.specofferId, index); this.props.goToDetailed(id); } @@ -44,7 +45,7 @@ class SpecofferEnrolments extends Component { } let cells = Object.keys(enrolmentsFieldNames).map((field) => { - if (field === 'specOfferId') return null; + if (field === 'specofferId') return null; return {enrolmentsFieldNames[field].name}} @@ -66,7 +67,7 @@ class SpecofferEnrolments extends Component { headerHeight={70} onColumnResizeEndCallback={this._onColumnResizeEndCallback} isColumnResizing={false} - onRowClick={this._goToDetailed} + onRowClick={this._onClickRow} width={950} height={380}> {cells} @@ -76,10 +77,10 @@ class SpecofferEnrolments extends Component { } const mapStateToSpecofferEnrolments = createSelector( - (state, ownProps) => state.specoffers.view.specofferEnrolments.data[ownProps.params.id], + (state, ownProps) => getSpecofferEnrolmentsBySpecofferId(state, ownProps.params.id), (state) => state.dictionaries, (state, ownProps) => ownProps.params.id, - (state) => state.specoffers.view.specofferEnrolments.enrolmentsFieldNames, + (state) => getSpecofferEnrolments(state).enrolmentsFieldNames, (enrolments, listOfDict, specofferId, enrolmentsFieldNames) => ({ decodedEnrolments: decodeEnrolments(enrolments, listOfDict), specofferId: specofferId, diff --git a/src/modules/specoffers/components/SpecofferInfoMain.jsx b/src/modules/specoffers/components/SpecofferInfoMain.jsx index c427eab..66f496b 100644 --- a/src/modules/specoffers/components/SpecofferInfoMain.jsx +++ b/src/modules/specoffers/components/SpecofferInfoMain.jsx @@ -6,6 +6,7 @@ import {isDataForSpecoffersLoaded, decodeOneSpecoffer} from './../helpers'; import loadDictionaries from '../../dictionaries/actions'; import * as dictConst from '../../dictionaries/constants'; import {loadOneSpecoffer} from '../actions' +import {getSpecofferInfoMain} from '../reducers/view.js' export class SpecofferInfoMain extends Component { componentDidMount() { @@ -19,7 +20,7 @@ export class SpecofferInfoMain extends Component { } const mapStateToSpecofferInfoMain = createSelector( - (state, ownProps) => state.specoffers.view.mainInfo.data[ownProps.params.id], + (state, ownProps) => getSpecofferInfoMain(state, ownProps.params.id), (state) => state.dictionaries, (state, ownProps) => ownProps.params.id, (specoffer, listOfDict, specofferId) => ({ diff --git a/src/modules/specoffers/containers/SpecoffersListPage.jsx b/src/modules/specoffers/containers/SpecoffersListPage.jsx index 800f1c7..80a69ba 100644 --- a/src/modules/specoffers/containers/SpecoffersListPage.jsx +++ b/src/modules/specoffers/containers/SpecoffersListPage.jsx @@ -26,7 +26,7 @@ class SpecoffersListPage extends Component { this.props.setSpecofferFieldWidth(newColumnWidth, columnKey); } - _goToDetailed = (e, index) => { + _onClickRow = (e, index) => { let id = getSpecofferIdByIndex(index); this.props.goToDetailed(id); } @@ -63,7 +63,7 @@ class SpecoffersListPage extends Component { headerHeight={50} onColumnResizeEndCallback={this._onColumnResizeEndCallback} isColumnResizing={false} - onRowClick={this._goToDetailed} + onRowClick={this._onClickRow} width={950} height={420} {...this.props} diff --git a/src/modules/specoffers/helpers.js b/src/modules/specoffers/helpers.js index b8f0dbc..5009c3b 100644 --- a/src/modules/specoffers/helpers.js +++ b/src/modules/specoffers/helpers.js @@ -1,6 +1,7 @@ import store from 'store'; import * as dictConstants from '../dictionaries/constants'; import {isDictLoaded} from '../dictionaries/helpers'; +import {getSpecofferEnrolments, getSpecofferEnrolmentsBySpecofferId} from './reducers/view.js'; let { DEPARTMENTS, @@ -15,7 +16,7 @@ let { */ export function isDataForEnrolmentLoaded(specofferId) { let state = store.getState(); - let entity = state.specoffers.view.specofferEnrolments; + let entity = getSpecofferEnrolments(state); return isDictLoaded([DEPARTMENTS, ENROLMENTS_TYPES, ENROLMENTS_STATUS_TYPES], state.dictionaries) && !entity.isLoading @@ -62,6 +63,6 @@ export function getSpecofferIdByIndex(index) { export function getEnrolmentIdByIndex(specofferId, index) { let state = store.getState(); - let entity = state.specoffers.view.specofferEnrolments; - return entity.data[specofferId].resources[index]['id']; + let entity = getSpecofferEnrolmentsBySpecofferId(state, specofferId); + return entity.resources[index]['id']; } \ No newline at end of file diff --git a/src/modules/specoffers/reducers/list.js b/src/modules/specoffers/reducers/list.js index 5e1eabb..a69931e 100644 --- a/src/modules/specoffers/reducers/list.js +++ b/src/modules/specoffers/reducers/list.js @@ -1,4 +1,5 @@ import * as types from '../constants'; +import {SPECOFFERS_FIELD_NAMES} from '../constants'; import {LOCATION_CHANGE} from 'react-router-redux'; import lcache from '../../../system/lcache'; @@ -7,7 +8,7 @@ import { TIMEPERIODID_CHANGED } from '../../settings/duck'; const defaultState = { isLoading: false, resources: [], - specoffersFieldNames: types.SPECOFFERS_FIELD_NAMES, + specoffersFieldNames: SPECOFFERS_FIELD_NAMES, timePeriodId: lcache.get('timePeriodId') || 8, limit: 300, error: null diff --git a/src/modules/specoffers/reducers/view.js b/src/modules/specoffers/reducers/view.js index 2e83e83..340a410 100644 --- a/src/modules/specoffers/reducers/view.js +++ b/src/modules/specoffers/reducers/view.js @@ -3,6 +3,12 @@ import {ENROLMENTS_FIELD_NAMES} from '../../enrolments/constants'; import {combineReducers} from 'redux'; import {LOCATION_CHANGE} from 'react-router-redux'; +export let getSpecofferEnrolmentsBySpecofferId = (state, specofferId) => { + return state.specoffers.view.specofferEnrolments.data[specofferId] +} + +export let getSpecofferEnrolments = (state) => state.specoffers.view.specofferEnrolments + const enrolmentsDefaultState = { isLoading: false, data: {}, @@ -46,6 +52,8 @@ export default function specofferEnrolments(state = enrolmentsDefaultState, acti } } +export let getSpecofferInfoMain = (state, specofferId) => state.specoffers.view.mainInfo.data[specofferId] + const mainInfoDefaultState = { isLoading: false, data: {},