From 40fb4e0835f4feab8e058e55ccb43f06bb5940ac Mon Sep 17 00:00:00 2001 From: Simon Leech Date: Mon, 13 Nov 2023 15:05:02 +0000 Subject: [PATCH 1/2] Update getLayer.js --- mod/workspace/getLayer.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/mod/workspace/getLayer.js b/mod/workspace/getLayer.js index 8aa9675d9..43f869885 100644 --- a/mod/workspace/getLayer.js +++ b/mod/workspace/getLayer.js @@ -33,21 +33,24 @@ module.exports = async (params) => { return new Error('Unable to validate layer param.') } - const layer = locale.layers[params.layer] + let layer = locale.layers[params.layer] // Assign key value as key on layer object. layer.key ??= params.layer if (Object.hasOwn(workspace.templates, layer.template || layer.key)) { - - merge(layer, await getTemplate(workspace.templates[layer.template || layer.key])) + // Merge the workspace template into the layer. + layer = + merge(await getTemplate(workspace.templates[layer.template || layer.key]),layer) } if (Array.isArray(layer.templates)) { // Merge templates from templates array into layer. layer.templates.forEach(async template => { - merge(layer, await getTemplate(workspace.templates[template])) + // Merge the workspace template into the layer. + layer = + merge(await getTemplate(workspace.templates[template]),layer) }) } From 52fb74d2174149061a4b8c8a4fada4b652f74892 Mon Sep 17 00:00:00 2001 From: dbauszus-glx Date: Mon, 13 Nov 2023 15:19:55 +0000 Subject: [PATCH 2/2] template and locale merge --- mod/workspace/getLayer.js | 8 ++++---- mod/workspace/getLocale.js | 4 ++-- mod/workspace/getTemplate.js | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/mod/workspace/getLayer.js b/mod/workspace/getLayer.js index 43f869885..404bdfccd 100644 --- a/mod/workspace/getLayer.js +++ b/mod/workspace/getLayer.js @@ -39,18 +39,18 @@ module.exports = async (params) => { layer.key ??= params.layer if (Object.hasOwn(workspace.templates, layer.template || layer.key)) { + // Merge the workspace template into the layer. - layer = - merge(await getTemplate(workspace.templates[layer.template || layer.key]),layer) + layer = merge(await getTemplate(workspace.templates[layer.template || layer.key]), layer) } if (Array.isArray(layer.templates)) { // Merge templates from templates array into layer. layer.templates.forEach(async template => { + // Merge the workspace template into the layer. - layer = - merge(await getTemplate(workspace.templates[template]),layer) + layer = merge(await getTemplate(workspace.templates[template]), layer) }) } diff --git a/mod/workspace/getLocale.js b/mod/workspace/getLocale.js index 0ef979cc0..ed21f7fdd 100644 --- a/mod/workspace/getLocale.js +++ b/mod/workspace/getLocale.js @@ -14,7 +14,7 @@ module.exports = async (params) => { return new Error('Unable to validate locale param.') } - const locale = workspace.locales[params.locale] + let locale = workspace.locales[params.locale] const roles = params.user?.roles || [] @@ -26,7 +26,7 @@ module.exports = async (params) => { if (Object.hasOwn(workspace.templates, params.locale)) { // Merge the workspace template into workspace. - merge(locale, await getTemplate(workspace.templates[params.locale])) + locale = merge(await getTemplate(workspace.templates[params.locale]), locale) } return locale diff --git a/mod/workspace/getTemplate.js b/mod/workspace/getTemplate.js index 5b7fcd2af..3418eecc8 100644 --- a/mod/workspace/getTemplate.js +++ b/mod/workspace/getTemplate.js @@ -55,7 +55,7 @@ module.exports = async (template) => { if (typeof response === 'object') { // Get template from src. - merge(template, response) + template = merge(response, template) } else if (typeof response === 'string') {