Skip to content

Commit

Permalink
Preset editor: remove complete button and always show next button
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewtelnov committed Aug 13, 2024
1 parent a6f6d39 commit e43bde5
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
19 changes: 12 additions & 7 deletions packages/creator-presets-core/src/presets-editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,18 @@ export class CreatorPresetEditorModel extends Base implements ICreatorPresetEdit
model.editablePresets = editablePresets;
model.keepIncorrectValues = true;
model.showPrevButton = false;
model.completeText = "Apply Preset Changes";
model.showCompleteButton = false;
model.registerFunctionOnPropertyValueChanged("isShowNextButton", () => {
model.setPropertyValue("isShowNextButton", true);
});
const nextButton = model.navigationBar.getActionById("sv-nav-next");
nextButton.action = (): void => {
if(!model.isLastPage) {
model.nextPageUIClick();
} else {
model.currentPageNo = 0;
}
};
editablePresets.forEach(item => item.setupQuestions(model, this));
const json = this.preset.getJson() || {};
editablePresets.forEach(item => item.setupQuestionsValue(model, json[item.path], this.creator));
Expand All @@ -121,12 +132,6 @@ export class CreatorPresetEditorModel extends Base implements ICreatorPresetEdit
editablePresets.forEach(item => item.onLocaleChanged(model, json[item.path], this.creator));
}
});
model.onCompleting.add((sender, options) => {
options.allow = false;
if(this.applyFromSurveyModel()) {
this.activeTab = "creator";
}
});
model.onMatrixDetailPanelVisibleChanged.add((sender, options) => {
editablePresets.forEach(item => item.updateOnMatrixDetailPanelVisibleChanged(model, this.creator, options));
});
Expand Down
11 changes: 7 additions & 4 deletions packages/creator-presets-core/tests/presets-editor.tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -833,8 +833,11 @@ test("Preset edit model, tabs page with creator, default items", () => {
const survey = editor.model;
const itemsQuestion = survey.getQuestionByName("tabs_items");
itemsQuestion.value = ["preview", "logic"];
survey.completeLastPage();
const creator = editor.creator;
expect(creator.tabs).toHaveLength(2);
expect(editor.activeTab).toBe("creator");
const nextBtn = survey.navigationBar.getActionById("sv-nav-next");
expect(nextBtn.isVisible).toBeTruthy();
survey.currentPageNo = survey.visiblePages.length - 1;
expect(survey.isLastPage).toBeTruthy();
expect(nextBtn.isVisible).toBeTruthy();
nextBtn.action();
expect(survey.isFirstPage).toBeTruthy();
});

0 comments on commit e43bde5

Please sign in to comment.