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
911 stars 373 forks source link

V2: String editor controls are editable on designer page with creator.readOnly = true; #1581

Closed AbhishekKS closed 3 years ago

AbhishekKS commented 3 years ago

Are you requesting a feature, reporting a bug or ask a question?

Bug

What is the current behavior?

In React V2, on setting creator.readOnly=true; some actions are still allowed on designer page. 1) String editor controls for Survey Title, Survey Desc, Page Title, Page Desc, Choices, etc are editable. 2) On selecting a question type from the Question button selector on the page, the question button text is changed to the selected question type. Though the question is not added, should we stop changing the question button text? 3) Drag-drop question from toolbox creates a new page and adds a question. 4) Clicking on Add Question button on a new page, creates an empty page without any question.

There could be other actions also which I could be missing now.

What is the expected behavior?

No actions should be allowed to be performed if the survey is marked as readonly.

How would you reproduce the current behavior (if this is a bug)?

Can be reproduced here: https://plnkr.co/edit/iQ45FsWZcmFsD3H1

Provide the test code and the tested page URL (if applicable)

Tested page URL: https://plnkr.co/edit/iQ45FsWZcmFsD3H1

Test code var creator = new SurveyCreator.SurveyCreator(options); creator.JSON = json; creator.readOnly = true;

your_code_here

Specify your

andrewtelnov commented 3 years ago

@AbhishekKS thank you for reporting this. We will take a look.

Thank you, Andrew

andrewtelnov commented 3 years ago

@tsv2013 for selectbase I have added canShowOptionItemCallback

question.canShowOptionItemCallback = (item: ItemValue): boolean => {
      return !creator.isReadOnly && (item.value !== "newitem"
|| question.choices.length < options.maximumChoicesCount);
    };
andrewtelnov commented 3 years ago

@tsv2013 I have implemented the code for choices adorners.

Thank you, Andrew

tsv2013 commented 3 years ago
tsv2013 commented 3 years ago
tsv2013 commented 3 years ago

I've implemented main part of the read only mode support. If you find other issues, please open a separate thread.