Skip to content

Commit

Permalink
Issue #28: Specoffer list - bugfixing 2
Browse files Browse the repository at this point in the history
  • Loading branch information
ormus2002 committed Apr 9, 2016
1 parent 3a1fc58 commit 84d70fa
Show file tree
Hide file tree
Showing 10 changed files with 33 additions and 19 deletions.
2 changes: 1 addition & 1 deletion src/modules/enrolments/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down
4 changes: 2 additions & 2 deletions src/modules/enrolments/list/EnrolmentsListPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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}
>
Expand Down
3 changes: 2 additions & 1 deletion src/modules/enrolments/list/reducer.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import * as types from '../constants';
import {ENROLMENTS_FIELD_NAMES} from '../constants';

const defaultState = {
isLoading: true,
count: 0,
limit: 50,
offset: 0,
resources: [],
enrolmentsFieldNames: types.ENROLMENTS_FIELD_NAMES,
enrolmentsFieldNames: ENROLMENTS_FIELD_NAMES,
error: null
};

Expand Down
7 changes: 4 additions & 3 deletions src/modules/specoffers/actions.js
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down Expand Up @@ -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
}
Expand All @@ -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
}
Expand Down
11 changes: 6 additions & 5 deletions src/modules/specoffers/components/Enrolments.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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);
}
Expand All @@ -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 <Column
columnKey={field}
header={<Cell>{enrolmentsFieldNames[field].name}</Cell>}
Expand All @@ -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}
Expand All @@ -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,
Expand Down
3 changes: 2 additions & 1 deletion src/modules/specoffers/components/SpecofferInfoMain.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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) => ({
Expand Down
4 changes: 2 additions & 2 deletions src/modules/specoffers/containers/SpecoffersListPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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}
Expand Down
7 changes: 4 additions & 3 deletions src/modules/specoffers/helpers.js
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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
Expand Down Expand Up @@ -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'];
}
3 changes: 2 additions & 1 deletion src/modules/specoffers/reducers/list.js
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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
Expand Down
8 changes: 8 additions & 0 deletions src/modules/specoffers/reducers/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {},
Expand Down Expand Up @@ -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: {},
Expand Down

0 comments on commit 84d70fa

Please sign in to comment.