Comments (10)
You are right, this is something I overlooked. Will work to fix this soon!
Also thank you for the kind works — I can't wait to bring file-relation back to netlify-cms itself.
from netlify-cms-widgets.
I can't wait to bring file-relation back to netlify-cms itself.
Derek, IMHO, with some more work your ncw-file-relation
widget will be ready for primetime :-)
from netlify-cms-widgets.
I've added support for multiple display_fields
+ display_summary
in #41. You can now use a string template via display_summary
:
// data
{
"categories": [{
"name": "Cat",
"desc": "Cats are cool",
"id": "cats-GQnCNUpF2"
}]
}
- label: Category (Single)
name: single
widget: ncw-file-relation
collection: setting
file: cats
target_field: cats
id_field: id
display_fields: ["name", "desc"] # label: "Cat Cats are cool"
display_summary: "{{name}}: {{desc}}" # label: "Cat: Cats are cool"
hint: Same as above, but only with single choice
Please let me know if you find any issues!
from netlify-cms-widgets.
Now the hide: true
option for collections works like a charme with your stuff. Thanks so much
from netlify-cms-widgets.
Or you did not update the release on the CDN (now is 0.7.4), or I did not understand how it works, or there is something wrong. I define del following files collection:
- label: Editable Lookups
name: editables
files:
# Animals file collection for testing display_fields
- label: Animals
name: animals
file: data/animals.json
fields:
- label: Animals
label_singular: Animal
name: animals
widget: list
fields:
- label: Name
name: name # <- name
widget: string
- label: Description # <- description
name: description
widget: string
- label: ID
name: id # <- id
widget: ncw-id
And here is the corresponding animals.json
file after having added a couple of elments to it
{
"animals": [
{
"id": "CrQz63Yu3",
"name": "Cat",
"description": "Cats are cool"
},
{
"id": "-PhfciJqa",
"name": "Dog",
"description": "Dogs are sweety"
}
]
}
How you configure the following folder collection referencing the above file collection to be able to:
- show the display_summary (e.g.
"{{name}}: {{description}}"
) from the file collection in the summary of the folder collection (e.g."{{title}}: {{animal}}")
? - show the
display_fields
from the file collection in theanimal
field of the folder collection?
# Display folder collection for testing display_fields and
# display_summary
- label: Display
name: display
slug: '{{year}}{{month}}{{day}}{{hour}}{{minute}}{{second}}-{{title}}'
summary: '{{title}} ({{animal}})'
folder: content/display
create: true
editor:
preview: false
fields:
- label: Title
name: title
widget: string
- label: Animal
name: animal
widget: ncw-file-relation
collection: editables
file: animals
target_field: animals
id_field: id
display_fields: ["name", "description"]
display_summary: "{{name}}: {{description}}"
Where am I wrong?
Thanks so much
from netlify-cms-widgets.
Hi @magomimmo! We're actually on 0.8.1 now, could you try again on the latest version?
from netlify-cms-widgets.
I just discovered it....I'll try in the afternoon (italian time)
from netlify-cms-widgets.
yep. the display summary works in the folder collection field referencing the file collection, but I would like to show it in the summary of the folder collection summary as well.
I mean how could I set the folder collection summary in such away that it references a field in the entry of the file collection (e.g. name
or description
or both)?
from netlify-cms-widgets.
I mean how could I set the folder collection summary in such away that it references a field in the entry of the file collection (e.g. name or description or both)?
Ohh I think I get it now. Hhhm I think if we store the data of the selected fields, it might work, e.g.
summary: "{{animal.name}}"
Or we may store the summary field itself, so you can do
summary: "{{animal.summary}}"
Is this what you meant?
from netlify-cms-widgets.
Yes, it's what I mean. To me both solutions are ok. Perhaps the summary based solution is less flexible, but more intuitive.
BTW: The same problem applies to relation
widget when using ncw-id
widget as universal unique id of the entries.
Here is a code snippet:
- label: Referenced Folder collection
name: referenced
identifier_field: id
folder: content/referenced
create: true
slug: '{{year}}{{month}}{{day}}{{hour}}{{minute}}{{second}}-{{last}}-{{first}}'
summary: '{{last}}, {{first}}'
editor:
preview: false
fields:
- label: ID
name: id
widget: ncw-id
- label: Last Name
name: last
widget: string
- label: First Name
name: first
widget: string
- label: Referencing Folder Collection
name: referencing
identifier_field: id
folder: content/referencing
create: true
slug: '{{year}}{{month}}{{day}}{{hour}}{{minute}}{{second}}-{{referenced.last}}'
summary: '{{referenced.last}}, {{referenced.first}}-{{referenced}}'
editor:
preview: false
fields:
- label: ID
name: id
widget: ncw-id
- label: Referenced Entry
name: referenced
widget: relation
collection: referenced
searchFields: ['last', 'first']
displayFields: ['{{last}}, {{first}}']
valueField: id
As you can see in the attachment, only the referenced `ncw-id is accessible if the referenced entry. The problems seems to be almost the same as for your file relation widget.
from netlify-cms-widgets.
Related Issues (20)
- Inline widget HOT 14
- Re-order widget – i18n ? HOT 1
- Adding widget script hides existing relations in CMS HOT 2
- Duplicating an item doesn't generate new ID HOT 4
- @ncwidgets/file-relation not working on self assignment HOT 2
- Using `Publish and create new` doesn't create a new ID HOT 9
- Need test + CI
- File location for relation widget HOT 13
- File Location Widget is broken HOT 2
- (file-relation) Support simple list (string only) HOT 1
- Last updated widget
- [netlify-cms] Add ncw-reorder HOT 2
- unselect an item from a parent optional field HOT 3
- hidden option for ncw-id widget HOT 3
- file-relation update
- Form builder widget
- Is it possible to use id widget as js deliver sript?
- Data table widget
- S3 media library
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 netlify-cms-widgets.