Comments (9)
We ran into that as well. We have two options:
- Make the response return the order in the "right" order
- Provide a "position" attribute
I'd go with 1 if possible. @lukasgraf @ebrehault opinions?
from plone.restapi.
That's part of the things JSON Schema does not address (because it focuses on schemas, not on forms).
In angular2-schema-form, I have decided to use an order
attribute which is an array of field ids: https://github.com/makinacorpus/angular2-schema-form#fields-presentation-and-ordering
I think it is a more solid approach than assuming the fields will be in the right order in properties
.
We have a similar solution for fieldset by the way.
from plone.restapi.
I like choice 1 better, but some quick googling turns up a few sources saying one shouldn't rely on JSON object properties being ordered, so yeah, I guess we shouldn't.
@ebrehault I guess you mean something like this for fieldsets:
"fieldsets": [
{
"name": "default",
"label": "Default",
"fields": ["title", "description", ...]
}
}
With fieldsets like that, do we really need a separate order
?
from plone.restapi.
Yeah, exposing an API that implies that keys in JSON objects are order is something we should avoid (that is, for any order that is actually relevant to the data - controlling the order of keys with the purpose of making it convenient to read for humans (list id and title early, stable sort order) is something different).
When I used JSON schema for something else in our own projects and needed this, I went exactly with the solution that @ebrehault described (I went with field_order
). Yes, it's a bit cumbersome, but it works and it avoids misuse of data structures.
So I prefer 2.
from plone.restapi.
@davisagli having a separate order field is useful for forms without fieldset, but I agree having order
in one case and fields
in the other case is strange. So maybe we should use the same property name to order the form fields and the fieldset fields, and field_order
sounds nice as proposed by @lukasgraf
from plone.restapi.
I would consider a form without any explicitly declared fieldsets to contain one fieldset, the default fieldset. But if you disagree and want to support listing field order both at the schema level and within fieldsets, then I agree it's good to be consistent and call it field_order
in both cases.
from plone.restapi.
Oh, sorry, I didn't mean I want to support field ordering at schema level and within fieldsets at the same time. I just meant schema level ordering is useful when we do not have any fieldset declared (else, schema level ordering should obviously be ignored or not allowed).
So it is pretty much equivalent to consider that the default fieldset is implicit (and consequently we must use the same property name to order fields in an explicit fieldset and in the implicit default fieldset).
from plone.restapi.
We also discussed this again at the Beethoven Sprint:
At this point, I'm leaning towards the style @davisagli outlined above:
Always include a toplevel fieldsets
:
"fieldsets": [
{
"name": "default",
"label": "Default",
"fields": ["title", "description", "..."]
},
{
"name": "address",
"label": "Address",
"fields": ["fistname", "lastname", "..."]
}
]
No need to track field order separately, both the order of fieldsets and their individual fields would be well defined that way. If no explicit plone.autoform
fieldset directives have been used, fields will end up in the default
fieldset. Empty fieldsets may occur.
Field moves as indicated by plone.autoform
order_before
/ order_after
should also be processed if possible, and may therefore affect the final resulting position of fields in their respective fieldsets. So field moves would be abstracted away by the API, and only the final resulting order will be dumped.
/cc @ebrehault
from plone.restapi.
Solved in #237
from plone.restapi.
Related Issues (20)
- relatedItems field returns None in the serializer if the related item is deleted HOT 1
- Site Administrator cannot add user to group
- Add remote_url(getRemoteUrl) to link content-types in navigation HOT 4
- Include release notes in Plone 6 Documentation
- Authentication error messages from PAS Plugins aren't returned by the restapi HOT 1
- restapi double parameter is broking code. HOT 8
- In content that uses the plone.blocks behavior, it is not possible to add fields to SearchableText with "plone.app.dexterity.textindexer" HOT 6
- Community Forum App Icon Not Filling Correctly. HOT 1
- Add plone.app.discussion control panel
- Types control panel does not allow to enable/disable discussion for a content type
- Implement SummaryDiscussionListingTemplate to fix Discussion url in listings HOT 1
- Documentation of event content type does not return a timezone
- NoneType' object has no attribute 'getProperty': when searching users HOT 1
- @querystring shouldn't list userids
- Test with Plone 6.1 HOT 1
- Require plone.app.iterate on test extras
- Require plone.app.upgrade in test extras
- @aliases endpoint should allow to filter by how an alias has been added (automatically, manually)
- @aliases endpoint should support filtering by date (from, to) HOT 3
- @aliases endpoint should allow to upload/download all aliases and allow to download filtered aliases as CSV file
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from plone.restapi.