surveyjs / survey-creator

Scalable open-source survey software to generate dynamic JSON-driven forms within your JavaScript application. The form builder features a drag-and-drop UI, CSS Theme Editor, and GUI for conditional logic and form branching.
https://surveyjs.io/open-source
Other
923 stars 378 forks source link

When the creator.syncSaveButtons option is enabled, the Save button should activate the saveSurveyFunc/saveTheme functions regardless of whether the Save button is clicked from within the Designer or Theme Tab #5244

Closed JaneSjs closed 9 months ago

JaneSjs commented 9 months ago

T15531 - How to merge save theme and save survey buttons to one button? (save event and modified state) https://surveyjs.answerdesk.io/internal/ticket/details/T15531

Currently, when the creator.syncSaveButtons option is enabled, the Save button invokes the saveThemeFunc or saveSurveyFunc depending on whether a user modified a survey or theme JSON definition (View Demo).

However, the Save button should have a single entry point from which a developer could save both theme and survey JSON definitions to avoid additional POST requests to save those definitions separately.

When the creator.syncSaveButtons option is enabled, the Save button should activate the saveSurveyFunc/saveThemeFunc functions regardless of whether changes were made to a survey or theme JSON definitions.

JaneSjs commented 9 months ago

To implement a single entry point for saving a survey and theme whenever a survey or theme receives modifications, implement a single saving function and call it from saveSurveyFunc and saveThemeFunc.

function saveSurveyAndTheme(){
      const surveyJson = creator.JSON;
      const themeJson = creator.theme;
      //.. Save
      alert("Everything is Saved!");
}
creator.saveThemeFunc = () => {
      saveSurveyAndTheme();
}
creator.saveSurveyFunc = () => {
      saveSurveyAndTheme();
}