Skip to content

Commit

Permalink
Fix project vocabularies.
Browse files Browse the repository at this point in the history
  • Loading branch information
robgietema committed Oct 5, 2023
1 parent 7a17d4b commit e6d29e3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
- Fix addable in types endpoint @robgietema
- Fix import order of profiles @robgietema
- Fix test runner for projects @robgietema
- Fix project vocabularies @robgietema

### Internal

Expand Down
10 changes: 8 additions & 2 deletions src/routes/vocabularies/vocabularies.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import { Vocabulary } from '../../models';
import { vocabularies } from '../../vocabularies';
import { RequestException, getUrl } from '../../helpers';

const { config } = require(`${process.cwd()}/config`);

export default [
{
op: 'get',
Expand Down Expand Up @@ -38,8 +40,10 @@ export default [
view: '/@vocabularies/:id',
permission: 'View',
handler: async (req, trx) => {
console.log(config.vocabularies);
// Check if vocabulary is available
if (!includes(keys(vocabularies), req.params.id)) {
if (!includes(keys(vocabularies, req.param.id)) &&
!includes(keys(config.vocabularies), req.params.id)) {
const vocabulary = await Vocabulary.fetchById(req.params.id, {}, trx);
if (!vocabulary) {
throw new RequestException(404, { error: req.i18n('Not found.') });
Expand All @@ -56,7 +60,9 @@ export default [
}

// Get items
const items = await vocabularies[req.params.id](req);
const items = includes(keys(vocabularies), req.param.id) ?
await vocabularies[req.params.id](req) :
await config.vocabularies[req.params.id](req);

// Return data
return {
Expand Down

0 comments on commit e6d29e3

Please sign in to comment.