Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added form readonly prop (#2553) #2554

Merged
merged 5 commits into from
Sep 25, 2021

Conversation

heath-freenome
Copy link
Member

Reasons for making this change

fixes #2553

Updated the playground to add the Readonly whole form flag
Added the form-readonly section in the documentation
Updated the tests to verify the read-only status

Checklist

  • I'm updating documentation
  • I'm adding or updating code
    • I've added and/or updated tests
    • I've updated docs if needed
  • I'm adding a new feature
    • I've updated the playground with an example use of the feature

@heath-freenome
Copy link
Member Author

@epicfaace small feature that I could really use... I know I have a work-around with ui:readonly, but I have to put it everywhere :(

@heath-freenome
Copy link
Member Author

@epicfaace Anyone besides yourself who can review/approve?

@epicfaace
Copy link
Member

@newt10 also has write / reviewer access


render((
<Form schema={schema}
readonly />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think it's better to call this "readOnly", for consistency with the readOnly react prop?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that all the fields and widgets use readonly, I'd rather keep it consistent within the project. Perhaps we can deprecate readonly in favor of readOnly in the future?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, sounds good. I'd note that we did already deprecate autocomplete in favor of autoComplete (see https://github.com/rjsf-team/react-jsonschema-form/blob/master/docs/api-reference/form-props.md#autocomplete), but I guess we don't have an analogous situation there (because autoComplete is not passed down as props to fields / widgets)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you update types?

Done!

Copy link
Member

@epicfaace epicfaace left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you update types?

Copy link
Member

@epicfaace epicfaace left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Can you update the branch with master and then update the changelog.md file before we merge?

Updated the playground to add the `Readonly whole form` flag
Added the `form-readonly` section in the documentation
Updated the tests to verify the `read-only` status
@heath-freenome
Copy link
Member Author

Thanks! Can you update the branch with master and then update the changelog.md file before we merge?

I rebased locally then force pushed... after adding the CHANGELOG.md update

expect(node.querySelectorAll("input:read-only")).to.have.length.of(0);
});

it("should readonly all items", () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add a test just to ensure it works on nested objects / arrays?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure... I originally followed the pattern for the disabled tests above. Should those also be updated?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated the one test to use a nested object

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Screen Shot 2021-09-24 at 4 53 46 PM

The playground works with arrays

@epicfaace
Copy link
Member

epicfaace commented Sep 24, 2021 via email

Copy link
Member

@epicfaace epicfaace left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks!

@epicfaace epicfaace merged commit 8335ad1 into rjsf-team:master Sep 25, 2021
@heath-freenome
Copy link
Member Author

Looks good, thanks!

Thanks for the good review... when are you anticipating releasing the build?

@epicfaace
Copy link
Member

epicfaace commented Sep 25, 2021 via email

@heath-freenome heath-freenome deleted the add-form-level-readonly branch September 25, 2021 00:59
@Icemic
Copy link

Icemic commented Oct 9, 2021

Good. But I must complain it that I've done the same pr months ago without any feedback. #2388

Did I miss something which is a rule that I should create a issue for it or mention someone to review?

@epicfaace
Copy link
Member

@Icemic apologies, I haven't really kept track of all PRs as there's too much, so I probably didn't notice it. In the future, if you don't hear back about a PR review, feel free to ping me. thanks for your other PR!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

NEW FEATURE: Add a top-level readonly flag
3 participants