Development: Frontend: Stores - zhaw-timetable/zhawo GitHub Wiki

Content

GlobalStore

Global Flux Store

Kind: global class

Values

Name Inital Value
theme 'lightTheme'
currentUser ''
currentUserType ''
possibleNames []
possibleLoginNames []
drawerOpen false
isDayView true
viewState 0

globalStore.handleActions(action)

Function that is called after action is dispatched Uses switch to filter actions

Kind: instance method of GlobalStore

Param Type
action FluxAction

globalStore.initializeStore()

Function that calls functions that initialize store with info found in idb

Kind: instance method of GlobalStore

globalStore.setTheme(value)

Function that sets theme in both store and calls for it to be set in idb

Kind: instance method of GlobalStore

Param Type
value *

globalStore.getUserFromDB()

Function that uses idbAdapter get user that is saved in idb

Kind: instance method of GlobalStore

globalStore.getThemeFromDB()

Function that uses idbAdapter get theme that is saved in idb

Kind: instance method of GlobalStore

globalStore.setThemeInDB()

Function that uses idbAdapter set theme in idb

Kind: instance method of GlobalStore

globalStore.setCurrentUser()

Function that uses idbAdapter set user in idb

Kind: instance method of GlobalStore

globalStore.removeCurrentUser()

Function that uses idbAdapter remove user in idb

Kind: instance method of GlobalStore

globalStore.setViewStateInDB()

Function that uses idbAdapter set ViewState in idb

Kind: instance method of GlobalStore

globalStore.getViewStateFromDB()

Function that uses idbAdapter get ViewState that is saved in idb

Kind: instance method of GlobalStore

globalStore.removeViewStateFromDB()

Function that uses idbAdapter remove ViewState in idb

Kind: instance method of GlobalStore

MensaStore

Flux Store MensaStore

Kind: global class

Values

Name Inital Value
allMensas []
selectedMensaId ''
selectedMensaName ''
currentMenuPlan null
currentMenuDay null
currentDate new Date()
displayDay this.currentDate
displayStartOfWeek startOfWeek(this.displayDay)
displayWeek this.createDisplayWeek(this.displayDay)
emptyMenuMessage ''

mensaStore.handleActions(action)

Function that is called after action is dispatched Uses switch to filter actions

Kind: instance method of MensaStore

Param Type
action FluxAction

mensaStore.createDisplayWeek(date) ⇒ Array.<Date>

Creates array with dates for all days of week of displayDay

Kind: instance method of MensaStore
Returns: Array.<Date> - weekArray

Param Type
date Date

mensaStore.convertSunday(date) ⇒ Date

Checks if passed date is a Sunday and converts it to a Monday if true

Kind: instance method of MensaStore
Returns: Date - date

Param Type
date Date

mensaStore.updateMenu(isNewFacility)

Sets currentMenuPlan to menu plan of displayDay

Kind: instance method of MensaStore

Param Type
isNewFacility boolean

mensaStore.findCurrentMenuDay() ⇒ Object

Finds and returns menu offered on displayDay

Kind: instance method of MensaStore
Returns: Object - currentMenuDay

mensaStore.doSwipeLeft()

Performs swipe left by subtracting days from displayDay and updating displayWeek

Kind: instance method of MensaStore

mensaStore.doSwipeRight()

Performs swipe right by adding days from displayDay and updating displayWeek

Kind: instance method of MensaStore

mensaStore.handleError(err)

Handles errors

Kind: instance method of MensaStore

Param Type
err Error

RoomSearchStore

Flux Store RoomSearchStore

Kind: global class

Values

Name Inital Value
allRooms []
currentFreeRooms []
currentBuildingFloors []
currentFloor 'SOE'
allFloors {SOE: SOE,TB2: TB2,TB3: TB3,TB4: TB4,TB5: TB5,TB6: TB6,TE2: TE2,TE3: TE3,TE4: TE4,TE5: TE5,TE6: TE6,TH2: TH2,TH3: TH3,TH4: TH4,TH5: TH5,TL2: TL2,TL3: TL3,TL4: TL4,TP2: TP2,TP4: TP4}

roomSearchStore.handleActions(action)

Function that is called after action is dispatched Uses switch to filter actions

Kind: instance method of RoomSearchStore

Param Type
action FluxAction

roomSearchStore.fetchFreeRoomData() ⇒ Promise.<Array.<Floor>>

Fetches all available rooms from backend api

Kind: instance method of RoomSearchStore
Returns: Promise.<Array.<Floor>> - allRooms

roomSearchStore.getCurrentFreeRooms(startTime, endTime, currentFreeRooms)

Kind: instance method of RoomSearchStore

Param Type
startTime string
endTime string
currentFreeRooms Array.<string>

roomSearchStore.getCommonElements(array1, array2) ⇒ Array.<string>

Takes two arrays of strings and returns new array with elements that are in both arrays

Kind: instance method of RoomSearchStore
Returns: Array.<string> - filteredArray

Param Type
array1 Array.<string>
array2 Array.<string>

roomSearchStore.getTimeSlotsBetweenTimes(startTime, endTime) ⇒ Array.<number>

Returns all indices of timeslot array that are between startTime and endTime

Kind: instance method of RoomSearchStore
Returns: Array.<number> - slotIndices

Param Type
startTime string
endTime string

roomSearchStore.getBuildingFloors(selectedFloor) ⇒ Array.<JSX.Element>

Returns all floors that match the building identifier of the selected floor

Kind: instance method of RoomSearchStore
Returns: Array.<JSX.Element> - currentBuildingFloors

Param Type
selectedFloor string

roomSearchStore.handleError(err)

Handles errors

Kind: instance method of RoomSearchStore

Param Type
err Error

ScheduleStore

Schedule Flux Store

Kind: global class

Values

Name Inital Value
currentAction ''
currentDate this.getCurrentDate()
slots defaultSlots
displayDay this.currentDate
displayWeek this.createDisplayWeek(this.displayDay)
displayMonth this.createDisplayMonth(this.displayDay)
currentSearch ''
schedule null
scheduleForCurrentUser null
scheduleForSearchUser null

scheduleStore.initializeStore()

Functions sets default values for variables

Kind: instance method of ScheduleStore

scheduleStore.clearStore()

Functions resets all variables in store

Kind: instance method of ScheduleStore

scheduleStore.createDisplayWeek(date)

Function that creates array for the week of the given date

Kind: instance method of ScheduleStore

Param Type
date *

scheduleStore.createDisplayMonth(date)

Function that creates array for the month of the given date

Kind: instance method of ScheduleStore

Param Type
date *

scheduleStore.getCurrentDate()

Function that return the current day unless its a sunday (by using convertSunday)

Kind: instance method of ScheduleStore

scheduleStore.convertSunday(date)

Function that returns current day unless is Sunday, then return Monday after

Kind: instance method of ScheduleStore

Param Type
date Date

scheduleStore.handleActions(action)

Function that is called after action is dispatched Uses switch to filter actions

Kind: instance method of ScheduleStore

Param Type
action FluxAction

VszhawStore

Vszhaw Flux Store

Kind: global class

Values

Name Inital Value
feed ''
events []

vszhawStore.handleActions(action)

Function that is called after action is dispatched Uses switch to filter actions

Kind: instance method of VszhawStore

Param Type
action FluxAction
⚠️ **GitHub.com Fallback** ⚠️