From 884fe363e79f5a5f4f9abb9a07eb8736ac9b53a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christopher=20Collin=20L=C3=B8kken?= Date: Tue, 31 Oct 2023 16:01:11 +0100 Subject: [PATCH] fix: allow multiple ways of defining scope --- packages/dm-core/src/components/ViewCreator/utils.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/dm-core/src/components/ViewCreator/utils.ts b/packages/dm-core/src/components/ViewCreator/utils.ts index 67250759c..ca14d9090 100644 --- a/packages/dm-core/src/components/ViewCreator/utils.ts +++ b/packages/dm-core/src/components/ViewCreator/utils.ts @@ -2,6 +2,14 @@ import { TViewConfig } from '../../types' export const getTarget = (idReference: string, viewConfig: TViewConfig) => { if (viewConfig?.scope && viewConfig.scope !== 'self') - return `${idReference}.${viewConfig.scope}` + if (viewConfig.scope.slice(0, 5) == 'self.') { + return `${idReference}.${viewConfig.scope.slice(5, -1)}` + } else if (viewConfig.scope.slice(0, 1) == '^') { + return `${idReference}.${viewConfig.scope.slice(1, -1)}` + } else if (viewConfig.scope.slice(0, 1) == '.') { + return `${idReference}${viewConfig.scope}` + } else { + return `${idReference}.${viewConfig.scope}` + } return idReference }