Skip to content

Commit

Permalink
Merge pull request #480 from oat-sa/feature/ADF-1788/translation-list-ui
Browse files Browse the repository at this point in the history
Feature/ADF-1788/Add the translation list UI
  • Loading branch information
jsconan authored Oct 14, 2024
2 parents f19f24f + 578e07f commit c2f4adf
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 5 deletions.
2 changes: 1 addition & 1 deletion actions/structures.xml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
<icon id="icon-test"/>
</action>
<action id="test-translate" name="Translate" url="/tao/Translation/translate" context="instance" group="tree" binding="translateTest">
<icon id="icon-spell-check"/>
<icon id="icon-replace"/>
</action>
</actions>
</section>
Expand Down
51 changes: 47 additions & 4 deletions views/js/controller/tests/action.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,60 @@
*/
define([
'i18n',
'layout/actions/binder',
'module',
'uri',
'layout/actions',
'layout/actions/binder',
'layout/section',
'form/translation',
'services/translation',
'ui/feedback',
'core/logger',
'taoTests/previewer/factory',
'module'
], function (__, binder, uri, feedback, loggerFactory, previewerFactory, module) {
'taoTests/previewer/factory'
], function (
__,
module,
uri,
actionManager,
binder,
section,
translationFormFactory,
translationService,
feedback,
loggerFactory,
previewerFactory
) {
'use strict';

const logger = loggerFactory('taoTests/controller/action');

binder.register('translateTest', function (actionContext) {
section.current().updateContentBlock('<div class="main-container flex-container-full"></div>');
const $container = $('.main-container', section.selected.panel);
const { rootClassUri, id: resourceUri } = actionContext;
translationFormFactory($container, { rootClassUri, resourceUri, allowDeletion: true })
.on('edit', (id, language) => {
return actionManager.exec('test-authoring', {
id,
language,
rootClassUri,
originResourceUri: resourceUri,
translation: true,
actionParams: ['originResourceUri', 'language', 'translation']
});
})
.on('delete', function onDelete(id, language) {
return translationService.deleteTranslation(resourceUri, language).then(() => {
feedback().success(__('Translation deleted'));
return this.refresh();
});
})
.on('error', error => {
logger.error(error);
feedback().error(__('An error occurred while processing your request.'));
});
});

binder.register('testPreview', function testPreview(actionContext) {
const config = module.config();
const previewerConfig = Object.fromEntries(
Expand Down

0 comments on commit c2f4adf

Please sign in to comment.