settings: Challenge can never ends

This commit is contained in:
nemunaire 2023-05-12 14:53:15 +02:00
parent d4f69059bf
commit aad95f1e53
12 changed files with 36 additions and 22 deletions

View file

@ -545,7 +545,8 @@ angular.module("FICApp")
response.enableExerciceDepend = response.unlockedChallengeDepth >= 0;
response.disabledsubmitbutton = response.disablesubmitbutton && response.disablesubmitbutton.length > 0;
$rootScope.settings.start = new Date(response.start);
$rootScope.settings.end = new Date(response.end);
if (response.end) $rootScope.settings.end = new Date(response.end);
else $rootScope.settings.end = null;
$rootScope.settings.generation = new Date(response.generation);
$rootScope.settings.activateTime = new Date(response.activateTime);
})
@ -581,8 +582,10 @@ angular.module("FICApp")
}
$scope.saveSettings = function(msg) {
if (msg === undefined) { msg = 'New settings saved!'; }
var nStart = this.config.start;
var nEnd = this.config.end;
if (this.config.end == "") this.config.end = null;
var nStart = this.config.start;
var nEnd = this.config.end;
var nGen = this.config.generation;
var state = this.config.enableExerciceDepend;
this.config.unlockedChallengeDepth = (this.config.enableExerciceDepend?this.config.unlockedChallengeDepth:-1)
@ -602,7 +605,11 @@ angular.module("FICApp")
response.enableExerciceDepend = response.unlockedChallengeDepth >= 0;
response.disabledsubmitbutton = response.disablesubmitbutton && response.disablesubmitbutton.length > 0;
$rootScope.settings.start = new Date(nStart);
$rootScope.settings.end = new Date(nEnd);
if (nEnd) {
$rootScope.settings.end = new Date(nEnd);
} else {
$rootScope.settings.end = null;
}
$rootScope.settings.generation = new Date(nGen);
}, function(response) {
$scope.addToast('danger', 'An error occurs when saving settings:', response.data.errmsg);

View file

@ -263,7 +263,7 @@ angular.module("FICApp")
}
function updTime() {
if (time && $rootScope.settings) {
if (time && $rootScope.settings && $rootScope.settings.end) {
var srv_cur = new Date(Date.now() + (time.cu - time.he));
// Refresh on start/activate time reached