Giter Club home page Giter Club logo

Comments (10)

d4rekanguok avatar d4rekanguok commented on September 23, 2024 1

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.

magomimmo avatar magomimmo commented on September 23, 2024 1

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.

d4rekanguok avatar d4rekanguok commented on September 23, 2024 1

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.

magomimmo avatar magomimmo commented on September 23, 2024

Now the hide: true option for collections works like a charme with your stuff. Thanks so much

from netlify-cms-widgets.

magomimmo avatar magomimmo commented on September 23, 2024

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:

  1. show the display_summary (e.g. "{{name}}: {{description}}") from the file collection in the summary of the folder collection (e.g. "{{title}}: {{animal}}")?
  2. show the display_fields from the file collection in the animal 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.

d4rekanguok avatar d4rekanguok commented on September 23, 2024

Hi @magomimmo! We're actually on 0.8.1 now, could you try again on the latest version?

from netlify-cms-widgets.

magomimmo avatar magomimmo commented on September 23, 2024

I just discovered it....I'll try in the afternoon (italian time)

from netlify-cms-widgets.

magomimmo avatar magomimmo commented on September 23, 2024

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.

d4rekanguok avatar d4rekanguok commented on September 23, 2024

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.

magomimmo avatar magomimmo commented on September 23, 2024

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.


sample

from netlify-cms-widgets.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.