-
-
Notifications
You must be signed in to change notification settings - Fork 185
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
[change] Allow multiple jsonschema widgets in one page #333
base: master
Are you sure you want to change the base?
Conversation
Earlier the schema.json was bound to each view. No matter how many different switcher were present, it was only loading one of them. With this patch, fetching schema.json is bound to each switcher element. This allows fetching different JSONSchemas on the same page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pandafy I found a minor issue while testing the widget in the credentials edit page, can you replicate it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pandafy you're right, so I think we can merge this one. Do you agree? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pandafy shouldn't this line also be removed as part of this change?
openwisp-controller/openwisp_controller/config/templates/admin/config/jsonschema-widget.html
Line 5 in fcfa337
<script>django._jsonSchemaWidgetUrl = "{% url schema_view_name %}";</script> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pandafy shouldn't this line also be removed as part of this change?
openwisp-controller/openwisp_controller/config/templates/admin/config/jsonschema-widget.html
Line 5 in fcfa337
<script>django._jsonSchemaWidgetUrl = "{% url schema_view_name %}";</script>
Yes @nemesisdesign , you are right! 😄
We should than also remove this, otherwise test suite will fail.
openwisp-controller/openwisp_controller/connection/tests/test_admin.py
Lines 101 to 107 in fb6aa7e
def test_credentials_jsonschema_widget_presence(self): | |
url = reverse(f'admin:{self.app_label}_credentials_add') | |
schema_url = reverse(CredentialsSchemaWidget.schema_view_name) | |
expected = f'<script>django._jsonSchemaWidgetUrl = "{schema_url}";</script>' | |
self._login() | |
response = self.client.get(url) | |
self.assertContains(response, expected) |
@pandafy Thanks for your integration. I have also noticed the advanced mode code in the JS refers to an ID, but the CSS paths should be converted to use classes. |
Earlier the schema.json was bound to each view. No matter how many
different switcher were present, it was only loading one of them.
With this patch, fetching schema.json is bound to each switcher element.
This allows fetching different JSONSchemas on the same page.