Keeping selected on reload
This commit is contained in:
1 parent
b7e885a340
commit
49926f7ae4
4 files changed
+33
-16
No files matched your search
@@ -157,4 +157,3 @@ function newCompetitionStorage(pName) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+1
-1
@@ -38,7 +38,7 @@ function newTopSpace() {
|
||||
};
|
||||
|
||||
thisObject.login = newLogin();
|
||||
thisObject.login.initialize(onLoginInitialized);
|
||||
thisObject.login.initialize(sharedStatus, onLoginInitialized);
|
||||
|
||||
thisObject.companyLogo = newCompanyLogo();
|
||||
thisObject.endUser = newEndUser();
|
||||
|
||||
@@ -48,7 +48,8 @@
|
||||
window.EVENTS = storedEvents;
|
||||
window.CURRENT_EVENT_TITLE = storedEvents[sharedStatus.currentEventIndex].title;
|
||||
label = "Event - " + storedEvents[sharedStatus.currentEventIndex].title;
|
||||
sharedStatus.eventHandler.raiseEvent("Event Changed");
|
||||
window.localStorage.setItem('currentEventObject', JSON.stringify(storedEvents[sharedStatus.currentEventIndex]));
|
||||
sharedStatus.eventHandler.raiseEvent('Event Changed');
|
||||
}
|
||||
|
||||
thisObject.container.eventHandler.listenToEvent("onMouseClick", onClick);
|
||||
@@ -77,7 +78,8 @@
|
||||
sharedStatus.currentEventIndex = 0;
|
||||
window.CURRENT_EVENT_TITLE = storedEvents[sharedStatus.currentEventIndex].title;
|
||||
label = "Event - " + storedEvents[sharedStatus.currentEventIndex].title;
|
||||
sharedStatus.eventHandler.raiseEvent("Event Changed");
|
||||
window.localStorage.setItem('currentEventObject', JSON.stringify(storedEvents[sharedStatus.currentEventIndex]));
|
||||
sharedStatus.eventHandler.raiseEvent('Event Changed');
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -86,7 +88,8 @@
|
||||
sharedStatus.currentEventIndex++;
|
||||
window.CURRENT_EVENT_TITLE = storedEvents[sharedStatus.currentEventIndex].title;
|
||||
label = "Event - " + storedEvents[sharedStatus.currentEventIndex].title;
|
||||
sharedStatus.eventHandler.raiseEvent("Event Changed");
|
||||
window.localStorage.setItem('currentEventObject', JSON.stringify(storedEvents[sharedStatus.currentEventIndex]));
|
||||
sharedStatus.eventHandler.raiseEvent('Event Changed');
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
+26
-11
@@ -27,12 +27,14 @@ function newLogin() {
|
||||
|
||||
return thisObject;
|
||||
|
||||
function initialize(callBackFunction) {
|
||||
function initialize(pSharedStatus, callBackFunction) {
|
||||
|
||||
|
||||
const accessToken = window.localStorage.getItem("access_token");
|
||||
let user = window.localStorage.getItem("user");
|
||||
|
||||
sharedStatus = pSharedStatus;
|
||||
|
||||
if (user === null) {
|
||||
|
||||
// if there is no user that means that we are logged off, which means it is time to clean the local storage of things from the last log in.
|
||||
@@ -176,15 +178,6 @@ function newLogin() {
|
||||
uri: window.canvasApp.graphQL.masterAppApiUrl
|
||||
});
|
||||
|
||||
networkInterfaceEvents.use([{
|
||||
applyMiddleware(req, next) {
|
||||
req.options.headers = {
|
||||
authorization: `Bearer ${accessToken}`
|
||||
};
|
||||
next();
|
||||
}
|
||||
}]);
|
||||
|
||||
const apolloClientEvents = new Apollo.lib.ApolloClient({
|
||||
networkInterface: networkInterfaceEvents,
|
||||
connectToDevTools: true,
|
||||
@@ -195,6 +188,17 @@ function newLogin() {
|
||||
events_Events(maxStartDate: $maxStartDate, minEndDate: $minEndDate){
|
||||
id
|
||||
title
|
||||
startDatetime
|
||||
endDatetime
|
||||
participants{
|
||||
participant{
|
||||
name
|
||||
profile{
|
||||
avatar
|
||||
}
|
||||
}
|
||||
operationId
|
||||
}
|
||||
}
|
||||
}
|
||||
`
|
||||
@@ -209,7 +213,18 @@ function newLogin() {
|
||||
variables: { maxStartDate: nowSeconds, minEndDate: twoWeeksAgoSeconds }
|
||||
})
|
||||
.then(response => {
|
||||
window.localStorage.setItem('currentEvents', JSON.stringify(response.data.events_Events));
|
||||
currentEvent = window.localStorage.getItem('currentEventObject');
|
||||
if (currentEvent === null || currentEvent === "[]" || currentEvent === "") {
|
||||
sharedStatus.currentEventIndex = 0;
|
||||
} else {
|
||||
currentEvent = JSON.parse(currentEvent);
|
||||
sharedStatus.currentEventIndex = response.data.events_Events.findIndex(function(element) {
|
||||
return element.id == currentEvent.id;
|
||||
});
|
||||
if ( sharedStatus.currentEventIndex === -1 ) {
|
||||
sharedStatus.currentEventIndex = 0;
|
||||
}
|
||||
}
|
||||
resolve({ currentEvents: response.data.events_Events})
|
||||
})
|
||||
.catch(error => {
|
||||
|
||||
Reference in new issue
Block a user