From e6d29e3a964494f7facb64e4320746fae580528c Mon Sep 17 00:00:00 2001 From: Rob Gietema Date: Thu, 5 Oct 2023 11:10:13 +0200 Subject: [PATCH] Fix project vocabularies. --- CHANGELOG.md | 1 + src/routes/vocabularies/vocabularies.js | 10 ++++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f1502b5..72c0065 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/src/routes/vocabularies/vocabularies.js b/src/routes/vocabularies/vocabularies.js index a4df898..c57233d 100644 --- a/src/routes/vocabularies/vocabularies.js +++ b/src/routes/vocabularies/vocabularies.js @@ -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', @@ -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.') }); @@ -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 {