From 663effc415399c61d22dadbc235bb7488022d191 Mon Sep 17 00:00:00 2001 From: Zog Date: Wed, 24 Jan 2018 16:56:16 +0100 Subject: Refs #5682 @3h; Use same UI as for timetables --- app/javascript/packs/calendars/edit.js | 74 ++++++++++++++++++++++++++ app/javascript/time_tables/actions/index.js | 5 +- app/javascript/time_tables/components/Metas.js | 12 ++--- 3 files changed, 83 insertions(+), 8 deletions(-) create mode 100644 app/javascript/packs/calendars/edit.js (limited to 'app/javascript') 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( + + + , + 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 {/* color */} -
+ {metas.color !== undefined &&
@@ -69,10 +69,10 @@ export default function Metas({metas, onUpdateDayTypes, onUpdateComment, onUpdat
-
+ } {/* tags */} -
+ {metas.tags !== undefined &&
onUnselect2Tags(e)} />
-
+
} {/* calendar */} -
+ {metas.calendar !== null &&
{metas.calendar ? metas.calendar.name : I18n.time_tables.edit.metas.no_calendar}
-
+
} {/* day_types */}
-- cgit v1.2.3