Skip to content

Commit

Permalink
feat: add the action for managing the test translations
Browse files Browse the repository at this point in the history
  • Loading branch information
jsconan committed Oct 14, 2024
1 parent 3b808a6 commit 578e07f
Showing 1 changed file with 47 additions and 4 deletions.
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 578e07f

Please sign in to comment.