diff options
Diffstat (limited to 'app/javascript')
| -rw-r--r-- | app/javascript/packs/calendars/edit.js | 74 | ||||
| -rw-r--r-- | app/javascript/time_tables/actions/index.js | 5 | ||||
| -rw-r--r-- | app/javascript/time_tables/components/Metas.js | 12 |
3 files changed, 83 insertions, 8 deletions
diff --git a/app/javascript/packs/calendars/edit.js b/app/javascript/packs/calendars/edit.js new file mode 100644 index 000000000..bd09657ec --- /dev/null +++ b/app/javascript/packs/calendars/edit.js @@ -0,0 +1,74 @@ +import React from 'react' +import { render } from 'react-dom' +import { Provider } from 'react-redux' +import { createStore } from 'redux' +import timeTablesApp from '../../time_tables/reducers' +import App from '../../time_tables/containers/App' +import clone from '../../helpers/clone' + +const actionType = clone(window, "actionType", true) + +// logger, DO NOT REMOVE +// var applyMiddleware = require('redux').applyMiddleware +// var createLogger = require('redux-logger') +// var thunkMiddleware = require('redux-thunk').default +// var promise = require('redux-promise') + +let initialState = { + status: { + actionType: actionType, + policy: window.perms, + fetchSuccess: true, + isFetching: false + }, + timetable: { + current_month: [], + current_periode_range: '', + periode_range: [], + time_table_periods: [], + time_table_dates: [] + }, + metas: { + comment: '', + day_types: [], + initial_tags: [] + }, + pagination: { + stateChanged: false, + currentPage: '', + periode_range: [] + }, + modal: { + type: '', + modalProps: { + active: false, + begin: { + day: '01', + month: '01', + year: String(new Date().getFullYear()) + }, + end: { + day: '01', + month: '01', + year: String(new Date().getFullYear()) + }, + index: false, + error: '' + }, + confirmModal: {} + } +} +// const loggerMiddleware = createLogger() + +let store = createStore( + timeTablesApp, + initialState, + // applyMiddleware(thunkMiddleware, promise, loggerMiddleware) +) + +render( + <Provider store={store}> + <App /> + </Provider>, + document.getElementById('periods') +) diff --git a/app/javascript/time_tables/actions/index.js b/app/javascript/time_tables/actions/index.js index 87c7a3e8d..70f548174 100644 --- a/app/javascript/time_tables/actions/index.js +++ b/app/javascript/time_tables/actions/index.js @@ -246,7 +246,8 @@ const actions = { return error }, fetchTimeTables: (dispatch, nextPage) => { - let urlJSON = window.location.pathname.split('/', 5).join('/') + let urlJSON = window.timetablesUrl || window.location.pathname.split('/', 5).join('/') + if(nextPage) { urlJSON += "/month.json?date=" + nextPage }else{ @@ -277,7 +278,7 @@ const actions = { let strDayTypes = actions.arrayToStrDayTypes(metas.day_types) metas.day_types = strDayTypes let sentState = assign({}, timetable, metas) - let urlJSON = window.location.pathname.split('/', 5).join('/') + let urlJSON = window.timetablesUrl || window.location.pathname.split('/', 5).join('/') let hasError = false fetch(urlJSON + '.json', { credentials: 'same-origin', diff --git a/app/javascript/time_tables/components/Metas.js b/app/javascript/time_tables/components/Metas.js index 4170ba493..3c6848d27 100644 --- a/app/javascript/time_tables/components/Metas.js +++ b/app/javascript/time_tables/components/Metas.js @@ -27,7 +27,7 @@ export default function Metas({metas, onUpdateDayTypes, onUpdateComment, onUpdat </div> {/* color */} - <div className="form-group"> + {metas.color !== undefined && <div className="form-group"> <label htmlFor="" className="control-label col-sm-4">{I18n.activerecord.attributes.time_table.color}</label> <div className="col-sm-8"> <div className="dropdown color_selector"> @@ -69,10 +69,10 @@ export default function Metas({metas, onUpdateDayTypes, onUpdateComment, onUpdat </div> </div> </div> - </div> + </div>} {/* tags */} - <div className="form-group"> + {metas.tags !== undefined && <div className="form-group"> <label htmlFor="" className="control-label col-sm-4">{I18n.activerecord.attributes.time_table.tag_list}</label> <div className="col-sm-8"> <TagsSelect2 @@ -82,15 +82,15 @@ export default function Metas({metas, onUpdateDayTypes, onUpdateComment, onUpdat onUnselect2Tags={(e) => onUnselect2Tags(e)} /> </div> - </div> + </div>} {/* calendar */} - <div className="form-group"> + {metas.calendar !== null && <div className="form-group"> <label htmlFor="" className="control-label col-sm-4">{I18n.activerecord.attributes.time_table.calendar}</label> <div className="col-sm-8"> <span>{metas.calendar ? metas.calendar.name : I18n.time_tables.edit.metas.no_calendar}</span> </div> - </div> + </div>} {/* day_types */} <div className="form-group"> |
