Skip to content

Commit

Permalink
Merge pull request #4119 from oat-sa/feature/ADF-1789/side-by-side-au…
Browse files Browse the repository at this point in the history
…thoring

Feature/adf 1789/side by side authoring
  • Loading branch information
jsconan authored Oct 30, 2024
2 parents d9eb1ab + b4f4f7a commit 9aba5cb
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ public function getByRequest(ServerRequestInterface $request): ResourceCollectio
throw new ResourceTranslationException('Resource id is required');
}

return $this->resourceTranslationRepository->find(new ResourceTranslationQuery([$id], $languageUri));
if (!is_array($id)) {
$id = explode(',', $id);
}
return $this->resourceTranslationRepository->find(new ResourceTranslationQuery($id, $languageUri));
}
}
20 changes: 16 additions & 4 deletions views/js/services/translation.js
Original file line number Diff line number Diff line change
Expand Up @@ -286,13 +286,25 @@ define(['i18n', 'core/request', 'util/url'], function (__, request, urlUtil) {

/**
* Queries the list of translations for a resource.
* @param {string} id - The URI of the resource.
* @param {function} [filter] - A filter function for the translations.
* @param {string|string[]} id - The URI of the resource. It may also be a list of URIs, but in this case the languageUri must also be provided.
* @param {string|function} [languageUri] - The URI of the language to filter the translations. It may also be a filter function.
* @param {function} [filter] - A filter function for the translations. When not provided through the languageUri parameter.
* @returns {Promise<ResourceList>}
*/
getTranslations(id, filter) {
getTranslations(id, languageUri, filter) {
if (Array.isArray(id)) {
id = id.join(',');
}
const params = { id };
if (languageUri) {
if ('function' === typeof languageUri) {
filter = languageUri;
} else {
params.languageUri = languageUri;
}
}
return request({
url: urlUtil.route('translations', 'Translation', 'tao', { id }),
url: urlUtil.route('translations', 'Translation', 'tao', params),
method: 'GET',
noToken: true
})
Expand Down

0 comments on commit 9aba5cb

Please sign in to comment.