Skip to content

Commit

Permalink
Merge pull request #1538 from eciis/fix-events-page-not-follow
Browse files Browse the repository at this point in the history
Show events on institution page that user is not follower
  • Loading branch information
JuliePessoa authored Mar 15, 2019
2 parents b094292 + 74bfc73 commit 4fd6207
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 12 deletions.
4 changes: 4 additions & 0 deletions frontend/event/event.css
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,10 @@
justify-content: center;
}

.event-content-grid {
display: grid;
}

#menu-button {
margin-left: auto;
width: 0.8em;
Expand Down
25 changes: 16 additions & 9 deletions frontend/event/eventController.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,20 @@
eventCtrl.institutionsFilter = [];

eventCtrl.loadMoreEvents = function loadMoreEvents() {

if (eventCtrl._moreEvents) {
const getEventsFunction = EventService.getEvents;
return eventCtrl._loadEvents(getEventsFunction,
_.get(eventCtrl.selectedMonth, 'month'),
eventCtrl.selectedYear);
const getEventsFunction = (eventCtrl.institutionKey) ?
EventService.getInstEvents : EventService.getEvents;
const params = (eventCtrl.institutionKey) ?
{
page: eventCtrl._actualPage,
institutionKey:eventCtrl.institutionKey
} :
{
page: eventCtrl._actualPage,
month: _.get(eventCtrl.selectedMonth, 'month'),
year: eventCtrl.selectedYear
};
return eventCtrl._loadEvents(getEventsFunction, params);
}
return $q.when();
};
Expand All @@ -37,12 +45,11 @@
* Get events from backend
* @param {*} deferred The promise to resolve before get events from backend
* @param {*} getEvents The function received to call and get events
* @param {*} month The month to filter the get of events
* @param {*} year The year to filter the get of events
* @param {*} params The params used of service
* @private
*/
eventCtrl._loadEvents = (getEvents, month, year) => {
return getEvents({ page: eventCtrl._actualPage, month: month, year: year})
eventCtrl._loadEvents = (getEvents, params) => {
return getEvents(params)
.then(function success(response) {
eventCtrl._actualPage += 1;
eventCtrl._moreEvents = response.next;
Expand Down
2 changes: 1 addition & 1 deletion frontend/event/events_mobile.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<div style="overflow: scroll;" class="custom-scrollbar hide-scrollbar-mobile" ng-if="!eventCtrl.isFiltering">
<div flex layout="column">
<load-circle flex add-layout-fill="true" ng-if="eventCtrl.isLoadingEvents"></load-circle>
<div ng-if="!eventCtrl.isLoadingEvents" class="centralized-event-content">
<div ng-if="!eventCtrl.isLoadingEvents" class="event-content-grid">
<entity-showcase
class="fill-width"
ng-if="eventCtrl.institutionKey"
Expand Down
10 changes: 8 additions & 2 deletions frontend/test/specs/event/eventControllerSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -306,18 +306,24 @@

it('Should call _loadEvents with eventService.getEvents when key is null', () => {
spyOn(eventCtrl, '_loadEvents');
const params = {
page: eventCtrl._actualPage, month: december, year: testYear
}
eventCtrl.institutionKey = null;
eventCtrl.loadMoreEvents();
expect(eventCtrl._loadEvents)
.toHaveBeenCalledWith(eventService.getEvents, december, testYear);
.toHaveBeenCalledWith(eventService.getEvents, params);
});

it("Should call _loadEvents with eventService.getEvents when key isn't null", () => {
spyOn(eventCtrl, '_loadEvents');
eventCtrl.institutionKey = institution.key;
const params = {
page: eventCtrl._actualPage, institutionKey: eventCtrl.institutionKey
}
eventCtrl.loadMoreEvents();
expect(eventCtrl._loadEvents)
.toHaveBeenCalledWith(eventService.getEvents, december, testYear);
.toHaveBeenCalledWith(eventService.getInstEvents, params);
});
});

Expand Down

0 comments on commit 4fd6207

Please sign in to comment.