From b658a969b49a11daf592bec378c265650e294d70 Mon Sep 17 00:00:00 2001 From: Estela Silva Date: Fri, 24 May 2024 17:20:34 -0300 Subject: [PATCH 1/2] feat: field/question name is now editable --- libs/shared/src/lib/survey/creator.ts | 1 - .../src/lib/survey/global-properties/others.ts | 14 ++++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/libs/shared/src/lib/survey/creator.ts b/libs/shared/src/lib/survey/creator.ts index 23e5bed807..a64d68956b 100644 --- a/libs/shared/src/lib/survey/creator.ts +++ b/libs/shared/src/lib/survey/creator.ts @@ -8,7 +8,6 @@ import { Question } from './types'; export const initCreatorSettings = (): void => { const serializer: JsonMetadata = Serializer; - serializer.findProperty('question', 'name').readOnly = true; serializer.findProperty('question', 'name').onGetValue = (obj: Question) => obj.valueName ? obj.valueName : obj.name; serializer.findProperty('question', 'valueName').isRequired = true; diff --git a/libs/shared/src/lib/survey/global-properties/others.ts b/libs/shared/src/lib/survey/global-properties/others.ts index 4ee0b196c6..6aea6dcf5b 100644 --- a/libs/shared/src/lib/survey/global-properties/others.ts +++ b/libs/shared/src/lib/survey/global-properties/others.ts @@ -63,6 +63,20 @@ export const init = (environment: any): void => { } return newValue; }; + // When updating the question name, we need to inform that's a new name + Serializer.addProperty('question', { + name: 'oldName', + visible: false, + }); + // When updating the question name, sets the question valueName as well + serializer.getProperty('question', 'name').onSettingValue = ( + question: Question, + newValue: string + ) => { + question.setPropertyValue('oldName', question.name); + question.setPropertyValue('valueName', newValue); + return newValue; + }; // Adds valueExpression to questions, that when set pretty much transforms it into an expression question // whilst still keeping normal question behaviors Serializer.addProperty('question', { From b4bbd083613836f8606b2879a58142abb4e65119 Mon Sep 17 00:00:00 2001 From: Estela Silva Date: Wed, 5 Jun 2024 16:06:09 +0200 Subject: [PATCH 2/2] don't always set oldName property --- libs/shared/src/lib/survey/global-properties/others.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/libs/shared/src/lib/survey/global-properties/others.ts b/libs/shared/src/lib/survey/global-properties/others.ts index 6aea6dcf5b..15064ff207 100644 --- a/libs/shared/src/lib/survey/global-properties/others.ts +++ b/libs/shared/src/lib/survey/global-properties/others.ts @@ -73,7 +73,11 @@ export const init = (environment: any): void => { question: Question, newValue: string ) => { - question.setPropertyValue('oldName', question.name); + if (newValue && question.name && newValue !== question.name) { + question.setPropertyValue('oldName', question.name); + } else { + question.setPropertyValue('oldName', undefined); + } question.setPropertyValue('valueName', newValue); return newValue; };