Skip to content

Commit

Permalink
#6341 Rename isAutoSave, showSurveyTitle, inplaceEditForValues,…
Browse files Browse the repository at this point in the history
… and `makeNewViewActive`

Fixes #6341
  • Loading branch information
novikov82 committed Jan 9, 2025
1 parent 7274a6f commit 8aabeae
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ export class TabDesignerPlugin implements ICreatorPlugin {
iconName: "icon-preview",
iconSize: "auto",
action: () => {
this.creator.makeNewViewActive(this.creator.showThemeTab ? "theme" : "test");
this.creator.switchTab(this.creator.showThemeTab ? "theme" : "test");
},
visible: this.createVisibleUpdater(),
locTitleName: "tabs.preview",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ export class TabTestPlugin implements ICreatorPlugin {
id: "svd-designer",
iconName: "icon-config",
iconSize: "auto",
action: () => { this.creator.makeNewViewActive("designer"); },
action: () => { this.creator.switchTab("designer"); },
visible: this.createVisibleUpdater(),
locTitleName: "ed.designer",
showTitle: false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ export class ThemeTabPlugin implements ICreatorPlugin {
id: "svd-designer",
iconName: "icon-config",
iconSize: "auto",
action: () => { this.creator.makeNewViewActive("designer"); },
action: () => { this.creator.switchTab("designer"); },
visible: this.createVisibleUpdater(),
locTitleName: "ed.designer",
showTitle: false
Expand Down
52 changes: 44 additions & 8 deletions packages/survey-creator-core/src/creator-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,18 @@ export class SurveyCreatorModel extends Base
* If you enable this property, users cannot edit choice texts because the Property Grid hides the Text column for choices, rate values, columns and rows in [Single-Select Matrix](https://surveyjs.io/form-library/documentation/api-reference/matrix-table-question-model), and rows in [Multi-Select Matrix](https://surveyjs.io/form-library/documentation/api-reference/matrix-table-with-dropdown-list) questions.
* @see useElementTitles
*/
@property({ defaultValue: false }) inplaceEditForValues: boolean;
@property({ defaultValue: false }) inplaceEditChoiceValues: boolean;
/**
* Obsolete. Use the [`inplaceEditChoiceValues`](https://surveyjs.io/survey-creator/documentation/api-reference/survey-creator#inplaceEditChoiceValues) property instead.
* @deprecated
*/
get inplaceEditForValues() {
return this.inplaceEditChoiceValues;
}
set inplaceEditForValues(val) {
this.inplaceEditChoiceValues = val;
}

/**
* Specifies whether to display a table with survey results after completing a survey in the Preview tab.
*
Expand Down Expand Up @@ -233,6 +244,16 @@ export class SurveyCreatorModel extends Base
*
* Default value: `true`
*/
get showSurveyHeader(): boolean {
return this.allowEditSurveyTitle;
}
set showSurveyHeader(val: boolean) {
this.allowEditSurveyTitle = val;
}
/**
* Obsolete. Use the [`showSurveyHeader`](https://surveyjs.io/survey-creator/documentation/api-reference/survey-creator#showSurveyHeader) property instead.
* @deprecated
*/
get showSurveyTitle(): boolean {
return this.allowEditSurveyTitle;
}
Expand All @@ -259,7 +280,17 @@ export class SurveyCreatorModel extends Base
*
* If you enable this property, Survey Creator calls the [`saveSurveyFunc`](#saveSurveyFunc) or [`saveThemeFunc`](#saveThemeFunc) function to save the survey or theme JSON schema. The schemas are saved with a 500-millisecond delay after users change settings. You can specify the [`autoSaveDelay`](#autoSaveDelay) property to increase or decrease the delay.
*/
@property({ defaultValue: false }) isAutoSave: boolean;
@property({ defaultValue: false }) autoSaveEnabled: boolean;
/**
* Obsolete. Use the [`autoSaveEnabled`](https://surveyjs.io/survey-creator/documentation/api-reference/survey-creator#autoSaveEnabled) property instead.
* @deprecated
*/
get isAutoSave() {
return this.autoSaveEnabled;
}
set isAutoSave(val) {
this.autoSaveEnabled = val;
}
@property() showOptions: boolean;
@property({ defaultValue: false }) showSearch: boolean;
@property({ defaultValue: true }) generateValidJSON: boolean;
Expand Down Expand Up @@ -1265,13 +1296,13 @@ export class SurveyCreatorModel extends Base
}
/**
* An event that is raised before the [active tab](#activeTab) is switched. Use this event to allow or cancel the switch.
* @see makeNewViewActive
* @see switchTab
*/
public onActiveTabChanging: EventBase<SurveyCreatorModel, ActiveTabChangingEvent> = this.addCreatorEvent<SurveyCreatorModel, ActiveTabChangingEvent>();

/**
* An event that is raised after the [active tab](#activeTab) is switched.
* @see makeNewViewActive
* @see switchTab
*/
public onActiveTabChanged: EventBase<SurveyCreatorModel, ActiveTabChangedEvent> = this.addCreatorEvent<SurveyCreatorModel, ActiveTabChangedEvent>();
/**
Expand All @@ -1285,20 +1316,20 @@ export class SurveyCreatorModel extends Base
* - [`"editor"`](#showJSONEditorTab)
* - [`"logic"`](#showLogicTab)
* - [`"translation"`](#showLogicTab)
* @see makeNewViewActive
* @see switchTab
*/
public get activeTab(): string {
return this.viewType;
}
public set activeTab(val: string) {
this.makeNewViewActive(val);
this.switchTab(val);
}
/**
* Switches the [active tab](#activeTab). Returns `false` if the tab cannot be switched.
* @param tabName A tab that you want to make active: `"designer"`, `"test"`, `"theme"`, `"editor"`, `"logic"`, or `"translation"`.
* @returns `false` if the active tab cannot be switched, `true` otherwise.
*/
public makeNewViewActive(tabName: string): boolean {
public switchTab(tabName: string): boolean {
if (tabName == this.viewType) return false;
const plugin: ICreatorPlugin = this.currentPlugin;
if (!!plugin && !!plugin.canDeactivateAsync) {
Expand All @@ -1309,6 +1340,11 @@ export class SurveyCreatorModel extends Base
}
return this.switchViewType(tabName);
}
/**
* Obsolete. Use the [`switchTab`](https://surveyjs.io/survey-creator/documentation/api-reference/survey-creator#switchTab) method instead.
* @deprecated
*/
public makeNewViewActive = this.switchTab;
private switchViewType(viewName: string): boolean {
let allow = true;
if (!!this.currentPlugin?.defaultAllowingDeactivate) {
Expand Down Expand Up @@ -1643,7 +1679,7 @@ export class SurveyCreatorModel extends Base
}
}
if (this.tabs.length > 0) {
this.makeNewViewActive(this.tabs[0].id);
this.switchTab(this.tabs[0].id);
}
}
private initPlugins(): void {
Expand Down
12 changes: 11 additions & 1 deletion packages/survey-creator-core/src/creator-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ export interface ICreatorOptions {
*
* Default value: `false`
*/
autoSaveEnabled?: boolean;
/**
* Obsolete. Use the [`autoSaveEnabled`](https://surveyjs.io/survey-creator/documentation/api-reference/icreatoroptions#autoSaveEnabled) property instead.
* @deprecated
*/
isAutoSave?: boolean;
/**
* Specifies whether to enable support for right-to-left languages.
Expand All @@ -66,10 +71,15 @@ export interface ICreatorOptions {
*/
isRTL?: boolean;
/**
* Specifies whether users can see and edit the survey title and related survey properties.
* Specifies whether users can see and edit the survey header and related survey properties.
*
* Default value: `true`
*/
showSurveyHeader?: boolean;
/**
* Obsolete. Use the [`showSurveyHeader`](https://surveyjs.io/survey-creator/documentation/api-reference/icreatoroptions#showSurveyHeader) property instead.
* @deprecated
*/
showSurveyTitle?: boolean;
/**
* Specifies whether users can edit expressions in the Logic tab as plain text.
Expand Down
2 changes: 1 addition & 1 deletion packages/survey-creator-core/src/tabbed-menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export class TabbedMenuContainer extends AdaptiveActionContainer<TabbedMenuItem>
componentContent: componentName ? componentName : "svc-tab-" + name,
data: plugin,
iconName: tabsIcons[tabName] || tabsIcons["default"],
action: () => { this.creator.makeNewViewActive(name); },
action: () => { this.creator.switchTab(name); },
active: this.creator.viewType === name,
disableHide: this.creator.viewType === name
});
Expand Down

0 comments on commit 8aabeae

Please sign in to comment.