Skip to content

Commit

Permalink
Merge pull request #4120 from oat-sa/fix/ADF-1789/small-issues
Browse files Browse the repository at this point in the history
Fix/ADF-1789/small issues
  • Loading branch information
jsconan authored Oct 31, 2024
2 parents 0f46ace + 3ca5379 commit df4a780
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 14 deletions.
4 changes: 4 additions & 0 deletions views/js/form/tpl/translation-languages.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<option value="">--- {{__ 'select'}} ---</option>
{{#each languages}}
<option value="{{uri}}">{{label}}</option>
{{/each}}
7 changes: 1 addition & 6 deletions views/js/form/tpl/translation.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,7 @@
{{#if languages}}
<div class="translations-create">
<label>{{__ 'Language'}}
<select name="language" data-control="select">
<option value="">--- {{__ 'select'}} ---</option>
{{#each languages}}
<option value="{{uri}}">{{label}}</option>
{{/each}}
</select>
<select name="language" data-control="select"></select>
</label>
<button class="btn-info small" data-control="create"><span class="icon-replace"></span> {{__ 'Create
translation'}}</button>
Expand Down
42 changes: 36 additions & 6 deletions views/js/form/translation.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,18 @@ define([
'ui/dialog/confirm',
'services/translation',
'tpl!form/tpl/translation',
'tpl!form/tpl/translation-languages',
'ui/datatable'
], function (__, componentFactory, dialogAlert, dialogConfirm, translationService, translationTpl) {
('use strict');
], function (
__,
componentFactory,
dialogAlert,
dialogConfirm,
translationService,
translationTpl,
translationLanguagesTpl
) {
'use strict';

const defaults = {
sortBy: 'language',
Expand Down Expand Up @@ -174,15 +183,33 @@ define([
*/
refresh() {
return this.getData().then(data => {
this.config.translations = data.translations;
this.updateList();
Object.assign(this.config, data);
this.updateLanguagesList();
this.updateTranslationsList();
});
},

/**
* Updates the list of languages.
*/
updateLanguagesList() {
if (!this.is('rendered')) {
return;
}

const { languages = [] } = this.config;

this.controls.$languageSelect.html(
translationLanguagesTpl({
languages: languages.filter(language => language.uri !== this.config.languageUri)
})
);
},

/**
* Updates the list of translations.
*/
updateList() {
updateTranslationsList() {
if (!this.is('rendered')) {
return;
}
Expand Down Expand Up @@ -276,7 +303,8 @@ define([
);
});

this.updateList();
this.updateLanguagesList();
this.updateTranslationsList();

/**
* @event ready
Expand All @@ -302,9 +330,11 @@ define([
translationService
.getTranslatable(resourceUri)
.then(response => {
const languageUri = translationService.listResourcesLanguages(response.resources);
const config = {
ready: translationService.isReadyForTranslation(response.resources),
renderTo: $container,
languageUri: languageUri && languageUri[0],
languages: [],
translations: []
};
Expand Down
2 changes: 1 addition & 1 deletion views/js/loader/tao.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion views/js/loader/tao.min.js.map

Large diffs are not rendered by default.

0 comments on commit df4a780

Please sign in to comment.