Skip to content

Commit

Permalink
✨ Select languages per election (#219) (#220)
Browse files Browse the repository at this point in the history
Parent issue: sequentech/meta#306
  • Loading branch information
edulix authored Nov 16, 2023
1 parent 37359bf commit 9a21e08
Showing 1 changed file with 35 additions and 8 deletions.
43 changes: 35 additions & 8 deletions avElection/public-controller/public-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,44 @@ angular
*/
$scope.autoreloadResultsTimer = null;


function reloadTranslations(force, ms) {
setTimeout(
function () {
var election = $scope.election;

// reset $window.i18nOverride
var overrides = (
election &&
election.presentation &&
election.presentation.i18n_override
) ? election.presentation.i18n_override : null;

var languagesConf = (
election &&
election.presentation &&
election.presentation.i18n_languages_conf
) ? election.presentation.i18n_languages_conf : null;

I18nOverride(
/* overrides = */ overrides,
/* force = */ force,
/* languagesConf = */ languagesConf
);
},
ms || 1000
);
}

$scope.autoReloadReceive = function (value)
{
var presentation = value.data.payload.configuration.presentation;

if (presentation && presentation.theme && presentation.theme !== ConfigService.theme) {
if (
presentation &&
presentation.theme &&
presentation.theme !== ConfigService.theme
) {
$("#theme")
.attr("href", "election/themes/" + presentation.theme + "/app.min.css");
ConfigService.theme = presentation.theme;
Expand Down Expand Up @@ -102,13 +135,7 @@ angular
return;
}

if (presentation && presentation.i18n_override)
{
I18nOverride(
/* overrides = */ presentation.i18n_override,
/* force = */ false
);
}
reloadTranslations(false);

var newJson = angular.fromJson(value.data.payload.results);
if (!$scope.results || angular.toJson($scope.results) !== angular.toJson(newJson)) {
Expand Down

0 comments on commit 9a21e08

Please sign in to comment.