-
Notifications
You must be signed in to change notification settings - Fork 10
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
Feature/464 permission admin view slow #508
base: master
Are you sure you want to change the base?
Conversation
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.
I was thinking of the following to make it possible to fetch the fields via the frontend (such that the form doesn't have to be saved to fetch them):
- make an endpoint on the admin (that requires admin authentication) that performs the request for a specific object_type_id to retrieve the
data_fields
(e.g./admin/objecttypes/<id>
). That way we don't have to expose the token to the frontend and we only need to pass theid
to the frontend - in react, call this new endpoint for the currently selected objecttype and display the result
@annashamray what do you think about this?
return ( | ||
<div className="errornote"> | ||
<p>To be able to select fields, first you must save the instance and then you can edit the fields!</p> | ||
<p>Click on button <strong>'Save and continue editing'</strong></p> |
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.
This message is now untranslated, I think this should probably be defined as a translatable string in the backend and then passed to the frontend to display it
<p>Click on button <strong>'Save and continue editing'</strong></p> | |
<p>Click on the <strong>'Save and continue editing'</strong> button</p> |
@@ -61,6 +61,14 @@ const authFields = (object_fields, dataFields, fields, setFields) => { | |||
}; | |||
|
|||
const versionAuthFields = (objectType, objectFields, dataFieldChoices, fields, setFields) => { | |||
if (!(objectType in dataFieldChoices)) { | |||
return ( | |||
<div className="errornote"> |
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.
I'm not sure about making this display as an error message, maybe a warning or info message is more appropriate? Now at first glance it seems as if you can't save the form due to an error
Fixes #464
Changes
From the comments of the ticket to solve the problem of slow page loading, the option was chosen not to load all fields of each
objecttype
unnecessarily, but only the fields for a selectedobjecttype
and only if theuse_fields
flag is also enabled.The initial option I had thought of was to do this on the FE side so that I could make individual requests for each
objecttype
each time a new value is selected, but this is more difficult because I would have to pass to the view context more elements such asuuid
,service_data
,token
etc.. of theobjecttype
to then form, for a correctly and secure request;So I decided to add a simple check to the admin page view, so that if this control passes, a single request is made to retrieve all the
fields data
from theobjecttype.
This way, when the page is reloaded, the permission has all the data and can directly retrieve the information about the fields choices.