Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/ADF-1788/Add the translation list UI #480

Merged
merged 2 commits into from
Oct 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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