Skip to content

Commit

Permalink
Fix oppia#4528:Sets default language to the last selected language fo…
Browse files Browse the repository at this point in the history
…r audio translations in creator view. (oppia#4673)

* set default language to last selected

* fixed indentation and renamed key

* fixed linting error
  • Loading branch information
Aashish683 authored and tjiang11 committed Feb 12, 2018
1 parent 05dd8ff commit f81f025
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,19 +98,21 @@ oppia.directive('audioTranslationsEditor', [
}
},
controller: [
'$scope', '$uibModalInstance', 'LanguageUtilService',
'$scope', '$window', '$uibModalInstance', 'LanguageUtilService',
'allowedAudioLanguageCodes', 'AlertsService',
'ExplorationContextService', 'IdGenerationService',
'componentName',
function(
$scope, $uibModalInstance, LanguageUtilService,
$scope, $window, $uibModalInstance, LanguageUtilService,
allowedAudioLanguageCodes, AlertsService,
ExplorationContextService, IdGenerationService,
componentName) {
var ERROR_MESSAGE_BAD_FILE_UPLOAD = (
'There was an error uploading the audio file.');
var BUTTON_TEXT_SAVE = 'Save';
var BUTTON_TEXT_SAVING = 'Saving...';
var prevLanguageCode = $window.localStorage.getItem(
'last_uploaded_audio_lang');

$scope.languageCodesAndDescriptions = (
allowedAudioLanguageCodes.map(function(languageCode) {
Expand All @@ -126,8 +128,9 @@ oppia.directive('audioTranslationsEditor', [
$scope.errorMessage = null;
$scope.saveButtonText = BUTTON_TEXT_SAVE;
$scope.saveInProgress = false;

$scope.languageCode = allowedAudioLanguageCodes[0];
$scope.languageCode =
allowedAudioLanguageCodes.indexOf(prevLanguageCode) !== -1 ?
prevLanguageCode : allowedAudioLanguageCodes[0];
var uploadedFile = null;

$scope.isAudioTranslationValid = function() {
Expand Down Expand Up @@ -160,6 +163,8 @@ oppia.directive('audioTranslationsEditor', [
$scope.saveButtonText = BUTTON_TEXT_SAVING;
$scope.saveInProgress = true;
var generatedFilename = generateNewFilename();
$window.localStorage.setItem(
'last_uploaded_audio_lang', $scope.languageCode);
var explorationId = (
ExplorationContextService.getExplorationId());
AssetsBackendApiService.saveAudio(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ oppia.directive('topNavigationBar', [
$window.location = GLOBALS.loginUrl;
}, 150);
};
$scope.onLogoutButtonClicked = function() {
$window.localStorage.removeItem('last_uploaded_audio_lang');
};

$scope.profileDropdownIsActive = false;
$scope.onMouseoverProfilePictureOrDropdown = function(evt) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@
<hr class="oppia-top-right-menu-item-separator">

<li>
<a ng-click="onMouseoutProfilePictureOrDropdown($event)" ng-href="<[logoutUrl]>">
<a ng-click="onMouseoutProfilePictureOrDropdown($event);onLogoutButtonClicked()" ng-href="<[logoutUrl]>">
<span translate="I18N_TOPNAV_LOGOUT"></span>
</a>
</li>
Expand Down

0 comments on commit f81f025

Please sign in to comment.