Skip to content

Commit

Permalink
#6344 Rename the fastCopyQuestion() method and the `onLogicItemDisp…
Browse files Browse the repository at this point in the history
…layText` and `onConditionQuestionsGetList` events

Fixes #6344
  • Loading branch information
novikov82 committed Jan 10, 2025
1 parent 5bd264b commit 48f52cf
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 9 deletions.
2 changes: 1 addition & 1 deletion packages/survey-creator-core/src/components/question.ts
Original file line number Diff line number Diff line change
Expand Up @@ -760,7 +760,7 @@ export class QuestionAdornerViewModel extends SurveyElementAdornerBase {
}
protected duplicate(): void {
setTimeout(() => {
this.creator.fastCopyQuestion(this.surveyElement, true);
this.creator.copyQuestion(this.surveyElement, true);
}, 1);
}
addNewQuestion = () => {
Expand Down
32 changes: 25 additions & 7 deletions packages/survey-creator-core/src/creator-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,12 @@ export class SurveyCreatorModel extends Base
/**
* An event that is raised when a condition editor renders a list of questions and variables available for selection. Use this event to modify this list.
*/
public onConditionQuestionsGetList: EventBase<SurveyCreatorModel, ConditionGetQuestionListEvent> = this.addCreatorEvent<SurveyCreatorModel, ConditionGetQuestionListEvent>();
public onConditionGetQuestionList: EventBase<SurveyCreatorModel, ConditionGetQuestionListEvent> = this.addCreatorEvent<SurveyCreatorModel, ConditionGetQuestionListEvent>();
/**
* This event is obsolete. Use the [`onConditionGetQuestionList`](https://surveyjs.io/survey-creator/documentation/api-reference/survey-creator#onConditionGetQuestionList) event instead.
* @deprecated
*/
public onConditionQuestionsGetList: EventBase<SurveyCreatorModel, ConditionGetQuestionListEvent> = this.onConditionGetQuestionList;

public onConditionGetTitle: EventBase<SurveyCreatorModel, any> = this.addCreatorEvent<SurveyCreatorModel, any>();
/**
Expand All @@ -606,7 +611,12 @@ export class SurveyCreatorModel extends Base
/**
* An event that is raised when the Logic tab constructs a user-friendly display text for a logic rule. Use this event to modify this display text.
*/
public onLogicItemDisplayText: EventBase<SurveyCreatorModel, LogicRuleGetDisplayTextEvent> = this.addCreatorEvent<SurveyCreatorModel, LogicRuleGetDisplayTextEvent>();
public onLogicRuleGetDisplayText: EventBase<SurveyCreatorModel, LogicRuleGetDisplayTextEvent> = this.addCreatorEvent<SurveyCreatorModel, LogicRuleGetDisplayTextEvent>();
/**
* This event is obsolete. Use the [`onLogicRuleGetDisplayText`](https://surveyjs.io/survey-creator/documentation/api-reference/survey-creator#onLogicRuleGetDisplayText) event instead.
* @deprecated
*/
public onLogicItemDisplayText: EventBase<SurveyCreatorModel, LogicRuleGetDisplayTextEvent> = this.onLogicRuleGetDisplayText;
/**
* An event that is raised when users modify survey or theme settings.
* @see state
Expand Down Expand Up @@ -2729,7 +2739,7 @@ export class SurveyCreatorModel extends Base
* @param selectCopy *(Optional)* Pass `true` if you want to select the copy on the design surface. Default value: `false`.
* @returns The instance of a new question.
*/
public fastCopyQuestion(question: Base, selectCopy?: boolean): IElement {
public copyQuestion(question: Base, selectCopy?: boolean): IElement {
var newElement = this.copyElement(question);
var index = !!question["parent"]
? question["parent"].elements.indexOf(question) + 1
Expand All @@ -2746,6 +2756,14 @@ export class SurveyCreatorModel extends Base
}
return newElement;
}
/**
* Obsolete. Use the [`copyQuestion`](https://surveyjs.io/survey-creator/documentation/api-reference/survey-creator#copyQuestion) method instead.
* @deprecated
*/
public fastCopyQuestion(question: Base, selectCopy?: boolean): IElement {
return this.copyQuestion(question, selectCopy);
}

/**
* Gets or sets the focused survey element: a question, panel, page, or the survey itself.
* @see onSelectedElementChanging
Expand Down Expand Up @@ -3508,7 +3526,7 @@ export class SurveyCreatorModel extends Base
list: any[],
variables: string[]
): string {
if (this.onConditionQuestionsGetList.isEmpty) return settings.logic.questionSortOrder;
if (this.onConditionGetQuestionList.isEmpty) return settings.logic.questionSortOrder;
var options = {
propertyName: propertyName,
obj: obj,
Expand All @@ -3517,7 +3535,7 @@ export class SurveyCreatorModel extends Base
list: list,
variables: variables
};
this.onConditionQuestionsGetList.fire(this, options);
this.onConditionGetQuestionList.fire(this, options);
if (options.list !== list) {
list.splice(0, list.length);
for (var i = 0; i < options.list.length; i++) {
Expand All @@ -3544,14 +3562,14 @@ export class SurveyCreatorModel extends Base
text: string,
logicItem: any
): string {
if (this.onLogicItemDisplayText.isEmpty) return text;
if (this.onLogicRuleGetDisplayText.isEmpty) return text;
var options = {
expression: expression,
expressionText: expressionText,
text: text,
logicItem: logicItem
};
this.onLogicItemDisplayText.fire(this, options);
this.onLogicRuleGetDisplayText.fire(this, options);
return options.text;
}
getProcessedTranslationItemText(locale: string, locString: ILocalizableString, newText: string, obj: any): string {
Expand Down
2 changes: 1 addition & 1 deletion packages/survey-creator-core/tests/tabs/logic.tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,7 @@ test("SurveyLogicUI: Test creator onLogicItemDisplayText event", () => {
{ type: "text", name: "q5" }
]
};
creator.onLogicItemDisplayText.add((sender, options) => {
creator.onLogicRuleGetDisplayText.add((sender, options) => {
let text = options.expressionText;
text = text.replace(new RegExp("({|})", "gm"), "'");
options.text = text;
Expand Down

0 comments on commit 48f52cf

Please sign in to comment.