Fixed: UI Fixes

This commit is contained in:
Qstick 2018-03-15 22:26:49 -04:00
parent 718e8d7a9e
commit 94cca69e92
17 changed files with 287 additions and 261 deletions

View file

@ -36,27 +36,27 @@ export const defaultState = {
error: null,
items: [],
selectedFilterKey: 'all',
selectedFilterKey: 'monitored',
filters: [
{
key: 'all',
label: 'All',
key: 'monitored',
label: 'Monitored Only',
filters: [
{
key: 'unmonitored',
value: false,
key: 'monitored',
value: true,
type: filterTypes.EQUAL
}
]
},
{
key: 'unmonitored',
label: 'Unmonitored',
label: 'Include Unmonitored',
filters: [
{
key: 'unmonitored',
value: true,
key: 'monitored',
value: false,
type: filterTypes.EQUAL
}
]
@ -66,7 +66,7 @@ export const defaultState = {
export const persistState = [
'calendar.view',
'calendar.showUpcoming',
'calendar.unmonitored',
'calendar.selectedFilterKey'
];
@ -75,8 +75,8 @@ export const persistState = [
export const FETCH_CALENDAR = 'calendar/fetchCalendar';
export const SET_CALENDAR_DAYS_COUNT = 'calendar/setCalendarDaysCount';
export const SET_CALENDAR_INCLUDE_UNMONITORED = 'calendar/setCalendarIncludeUnmonitored';
export const SET_CALENDAR_VIEW = 'calendar/setCalendarView';
export const SET_CALENDAR_FILTER = 'calendar/setCalendarFilter';
export const GOTO_CALENDAR_TODAY = 'calendar/gotoCalendarToday';
export const GOTO_CALENDAR_PREVIOUS_RANGE = 'calendar/gotoCalendarPreviousRange';
export const GOTO_CALENDAR_NEXT_RANGE = 'calendar/gotoCalendarNextRange';
@ -182,8 +182,8 @@ function isRangePopulated(start, end, state) {
export const fetchCalendar = createThunk(FETCH_CALENDAR);
export const setCalendarDaysCount = createThunk(SET_CALENDAR_DAYS_COUNT);
export const setCalendarIncludeUnmonitored = createThunk(SET_CALENDAR_INCLUDE_UNMONITORED);
export const setCalendarView = createThunk(SET_CALENDAR_VIEW);
export const setCalendarFilter = createThunk(SET_CALENDAR_FILTER);
export const gotoCalendarToday = createThunk(GOTO_CALENDAR_TODAY);
export const gotoCalendarPreviousRange = createThunk(GOTO_CALENDAR_PREVIOUS_RANGE);
export const gotoCalendarNextRange = createThunk(GOTO_CALENDAR_NEXT_RANGE);
@ -196,8 +196,7 @@ export const actionHandlers = handleThunks({
[FETCH_CALENDAR]: function(getState, payload, dispatch) {
const state = getState();
const selectedFilter = state.calendar.selectedFilterKey;
const unmonitored = state.calendar.filters.find((f) => f.key === selectedFilter).filters[0].value;
const unmonitored = state.calendar.unmonitored;
const {
time,
@ -274,6 +273,18 @@ export const actionHandlers = handleThunks({
dispatch(fetchCalendar({ time, view }));
},
[SET_CALENDAR_INCLUDE_UNMONITORED]: function(getState, payload, dispatch) {
dispatch(set({
section,
unmonitored: payload.unmonitored
}));
const state = getState();
const { time, view } = state.calendar;
dispatch(fetchCalendar({ time, view }));
},
[SET_CALENDAR_VIEW]: function(getState, payload, dispatch) {
const state = getState();
const view = payload.view;
@ -317,18 +328,6 @@ export const actionHandlers = handleThunks({
const amount = view === calendarViews.FORECAST ? dayCount : 1;
const time = moment(state.calendar.time).add(amount, viewRanges[view]);
dispatch(fetchCalendar({ time, view }));
},
[SET_CALENDAR_FILTER]: function(getState, payload, dispatch) {
dispatch(set({
section,
selectedFilterKey: payload.selectedFilterKey
}));
const state = getState();
const { time, view } = state.calendar;
dispatch(fetchCalendar({ time, view }));
}
});