Skip to content
This repository has been archived by the owner on Jun 5, 2019. It is now read-only.

Introduced FieldData #81

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

rubenvereecken
Copy link
Contributor

FieldData is an object nested inside an Entry's content.
Most implementation was on the client side, there's no FieldDataSchema in use right now because mongoose does not supported subdocuments outside of an Array. Having all FieldData in an array felt bad, what with not being able to access the data easily.

Every FieldData has a default value field inside its data object. This will contain default values. Future field types may populate the data object even further. Appropriate methods have been created.

User templates can still use {{body}} to access the value for a body. When the Markdown plugin middleware is finished, templates can also start using {{body_html}}.

FieldData is an object nested inside an Entry's content.
Most implementation was on the client side, there's no FieldDataSchema in use right now because mongoose does not supported subdocuments outside of an Array. Having all FieldData in an array felt bad, what with not being able to access the data easily.

Every FieldData has a default `value` field inside its `data` object. This will contain default values. Future field types may populate the `data` object even further. Appropriate methods have been created.

User templates can still use `{{body}}` to access the value for a body. If however the Markdown plugin middleware is finished, templates can also start using `{{body_html}}`.
@davidkaneda
Copy link
Contributor

Hey @rubenvereecken — All seems fine, I didn't realize the inability to embed documents outside of an array :/

Just one small note on the Markdown field: I still think fields should be sandboxed to their slug. In the case of Markdown, I think the HTML should be the default, so {{body}} would be the rendered markdown. In this case, I think something like body.source would be the Markdown source. Similarly, something like {{location}} might spit out "{{location.latitude}}, {{location.longitude}}" by default.

@rubenvereecken
Copy link
Contributor Author

Hmm so should the Field model have a method that defines how to extract values out of it? That would be a good approach. A Markdown Field would return its data.html when one the name of the field, in this case {{body}}. I like that. Trying to completely avoid hardcoding as well.

@davidkaneda
Copy link
Contributor

@rubenvereecken Yes, but this should be provided by the FieldType/plugin-

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

Successfully merging this pull request may close these issues.

2 participants