2018-10-25 16:51:20 +02:00
|
|
|
/* eslint-disable
|
|
|
|
no-undef,
|
|
|
|
*/
|
|
|
|
// TODO: This file was created by bulk-decaffeinate.
|
|
|
|
// Fix any style issues and re-enable lint.
|
2018-10-25 16:50:16 +02:00
|
|
|
/*
|
|
|
|
* decaffeinate suggestions:
|
|
|
|
* DS102: Remove unnecessary code created because of implicit returns
|
|
|
|
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
|
|
|
*/
|
2018-11-21 11:08:53 +01:00
|
|
|
'use strict';
|
2015-05-05 03:10:25 +02:00
|
|
|
|
2020-01-22 12:23:51 +01:00
|
|
|
Application.Controllers.controller('HomeController', ['$scope', '$stateParams', 'lastMembersPromise', 'upcomingEventsPromise', 'twitterNamePromise',
|
|
|
|
function ($scope, $stateParams, lastMembersPromise, upcomingEventsPromise, twitterNamePromise) {
|
2018-10-25 16:50:16 +02:00
|
|
|
/* PUBLIC SCOPE */
|
2015-05-05 03:10:25 +02:00
|
|
|
|
2018-11-21 10:59:07 +01:00
|
|
|
// The last registered members who confirmed their addresses
|
2018-11-21 11:08:53 +01:00
|
|
|
$scope.lastMembers = lastMembersPromise;
|
2015-05-05 03:10:25 +02:00
|
|
|
|
2018-11-21 10:59:07 +01:00
|
|
|
// The closest upcoming events
|
2018-11-21 11:08:53 +01:00
|
|
|
$scope.upcomingEvents = upcomingEventsPromise;
|
2016-03-23 18:39:41 +01:00
|
|
|
|
2018-11-21 10:59:07 +01:00
|
|
|
// Twitter username
|
2018-11-21 11:08:53 +01:00
|
|
|
$scope.twitterName = twitterNamePromise.setting.value;
|
2016-03-23 18:39:41 +01:00
|
|
|
|
2018-11-21 10:59:07 +01:00
|
|
|
/**
|
2018-11-21 09:42:26 +01:00
|
|
|
* Test if the provided event run on a single day or not
|
|
|
|
* @param event {Object} single event from the $scope.upcomingEvents array
|
|
|
|
* @returns {boolean} false if the event runs on more that 1 day
|
|
|
|
*/
|
2018-11-21 11:08:53 +01:00
|
|
|
$scope.isOneDayEvent = event => moment(event.start_date).isSame(event.end_date, 'day');
|
2015-05-05 03:10:25 +02:00
|
|
|
|
2018-11-21 10:59:07 +01:00
|
|
|
/* PRIVATE SCOPE */
|
2015-05-05 03:10:25 +02:00
|
|
|
|
2018-11-21 10:59:07 +01:00
|
|
|
/**
|
2018-11-21 09:42:26 +01:00
|
|
|
* Kind of constructor: these actions will be realized first when the controller is loaded
|
|
|
|
*/
|
2018-11-21 10:59:07 +01:00
|
|
|
const initialize = function () {
|
|
|
|
// if we recieve a token to reset the password as GET parameter, trigger the
|
|
|
|
// changePassword modal from the parent controller
|
|
|
|
if ($stateParams.reset_password_token) {
|
2018-11-21 11:08:53 +01:00
|
|
|
return $scope.$parent.editPassword($stateParams.reset_password_token);
|
2018-11-21 10:59:07 +01:00
|
|
|
}
|
2018-11-21 11:08:53 +01:00
|
|
|
};
|
2015-05-05 03:10:25 +02:00
|
|
|
|
2018-11-21 10:59:07 +01:00
|
|
|
// !!! MUST BE CALLED AT THE END of the controller
|
2018-11-21 11:08:53 +01:00
|
|
|
return initialize();
|
2018-11-21 10:59:07 +01:00
|
|
|
}
|
2018-11-21 11:08:53 +01:00
|
|
|
]);
|