diff options
| author | jpl | 2017-04-18 15:27:22 +0200 |
|---|---|---|
| committer | jpl | 2017-04-18 15:29:46 +0200 |
| commit | eb42e4f75c4d2a706ffb723196e673c10be1fbae (patch) | |
| tree | cacc3644a76b36902ec2fb1fc59ff69934df87b1 | |
| parent | 06ac16fea1acb7facdc9ec034c65b0a0fc957862 (diff) | |
| download | chouette-core-eb42e4f75c4d2a706ffb723196e673c10be1fbae.tar.bz2 | |
Refs #2982: adding synthesis display for tt#edit
4 files changed, 56 insertions, 6 deletions
diff --git a/app/assets/javascripts/es6_browserified/time_tables/actions/index.js b/app/assets/javascripts/es6_browserified/time_tables/actions/index.js index 185a9eac9..1b800e547 100644 --- a/app/assets/javascripts/es6_browserified/time_tables/actions/index.js +++ b/app/assets/javascripts/es6_browserified/time_tables/actions/index.js @@ -1,3 +1,5 @@ +const _ = require('lodash') + const actions = { strToArrayDayTypes: (str) =>{ let weekDays = ['Di', 'Lu', 'Ma', 'Me', 'Je', 'Ve', 'Sa'] @@ -5,7 +7,7 @@ const actions = { }, fetchingApi: () =>({ - type: 'FETCH_API' + type: 'FETCH_API' }), unavailableServer: () => ({ type: 'UNAVAILABLE_SERVER' @@ -40,6 +42,42 @@ const actions = { name: selectedTag.name } }), + + updateSynthesis: (state) => { + let periods = state.time_table_periods + + let isInPeriod = function(data){ + let currentMonth = state.current_periode_range.split('-') + let currentDate = new Date(currentMonth[0] + '-' + currentMonth[1] + '-' + data.mday) + + // Exception wins anyway + if(data.excluded_date) { + return false + } else if(data.include_date) { + return true + } else { + // We compare periods & currentdate, to determine if it is included or not + let testDate = false + periods.map((p, i) => { + let begin = new Date(p.period_start) + let end = new Date(p.period_end) + + if(currentDate >= begin && currentDate <= end) { + testDate = true + } + }) + return testDate + } + } + + let improvedCM = state.current_month.map((d, i) => { + return _.assign({}, state.current_month[i], { + in_periods: isInPeriod(state.current_month[i]) + }) + }) + return improvedCM + }, + fetchTimeTables: (dispatch, currentPage, nextPage) => { let urlJSON = window.location.pathname.split('/', 5).join('/') + '.json' let hasError = false diff --git a/app/assets/javascripts/es6_browserified/time_tables/components/TimeTableDay.js b/app/assets/javascripts/es6_browserified/time_tables/components/TimeTableDay.js index dff64ba80..cc47c2052 100644 --- a/app/assets/javascripts/es6_browserified/time_tables/components/TimeTableDay.js +++ b/app/assets/javascripts/es6_browserified/time_tables/components/TimeTableDay.js @@ -17,7 +17,7 @@ class TimeTableDay extends Component { {((this.props.value.day).charAt(0) == 'm') ? (this.props.value.day).substr(0, 2) : (this.props.value.day).charAt(0)} </span> <span - className={'daynumber' + ((this.props.value.include_date && !this.props.value.excluded_date) ? ' included' : '')} + className={'daynumber' + (this.props.value.in_periods ? ' included' : '')} > {this.props.value.mday} </span> diff --git a/app/assets/javascripts/es6_browserified/time_tables/reducers/timetable.js b/app/assets/javascripts/es6_browserified/time_tables/reducers/timetable.js index 538e72d2c..0e7f84590 100644 --- a/app/assets/javascripts/es6_browserified/time_tables/reducers/timetable.js +++ b/app/assets/javascripts/es6_browserified/time_tables/reducers/timetable.js @@ -1,14 +1,16 @@ const _ = require('lodash') +var actions = require('../actions') const timetable = (state = {}, action) => { switch (action.type) { case 'RECEIVE_TIME_TABLES': - return _.assign({}, state, { + let fetchedState = _.assign({}, state, { current_month: action.json.current_month, current_periode_range: action.json.current_periode_range, periode_range: action.json.periode_range, time_table_periods: action.json.time_table_periods }) + return _.assign({}, fetchedState, {current_month: actions.updateSynthesis(fetchedState)}) default: return state } diff --git a/app/assets/stylesheets/modules/_timetables.sass b/app/assets/stylesheets/modules/_timetables.sass index e020242ae..7b44c854a 100644 --- a/app/assets/stylesheets/modules/_timetables.sass +++ b/app/assets/stylesheets/modules/_timetables.sass @@ -4,10 +4,10 @@ #periods .t2e-head > .th - height: 127px + height: 134px > .strong - padding-top: 113px + padding-top: 122px transform: translateY(-1.4em) .t2e-item @@ -31,7 +31,7 @@ &:before content: attr(data-wday) display: block - text-align: center + text-align: left color: rgba($grey, 0.5) padding-bottom: 10px @@ -39,8 +39,18 @@ display: block text-align: center text-transform: capitalize + padding-bottom: 2px .daynumber display: block + margin: 0 auto + width: 24px + height: 24px + line-height: 24px text-align: center font-weight: bold + border-radius: 50% + background-color: transparent + + &.included + background-color: $gold |
