{"action":"created","issue":{"url":"https://api.github.com/repos/netlify/netlify-cms/issues/1857","repository_url":"https://api.github.com/repos/netlify/netlify-cms","labels_url":"https://api.github.com/repos/netlify/netlify-cms/issues/1857/labels{/name}","comments_url":"https://api.github.com/repos/netlify/netlify-cms/issues/1857/comments","events_url":"https://api.github.com/repos/netlify/netlify-cms/issues/1857/events","html_url":"https://github.com/netlify/netlify-cms/pull/1857","id":377672657,"node_id":"MDExOlB1bGxSZXF1ZXN0MjI4NTU5OTE2","number":1857,"title":"Added \"types\" option to list widget","user":{"login":"smnh","id":97896,"node_id":"MDQ6VXNlcjk3ODk2","avatar_url":"https://avatars3.githubusercontent.com/u/97896?v=4","gravatar_id":"","url":"https://api.github.com/users/smnh","html_url":"https://github.com/smnh","followers_url":"https://api.github.com/users/smnh/followers","following_url":"https://api.github.com/users/smnh/following{/other_user}","gists_url":"https://api.github.com/users/smnh/gists{/gist_id}","starred_url":"https://api.github.com/users/smnh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/smnh/subscriptions","organizations_url":"https://api.github.com/users/smnh/orgs","repos_url":"https://api.github.com/users/smnh/repos","events_url":"https://api.github.com/users/smnh/events{/privacy}","received_events_url":"https://api.github.com/users/smnh/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":38,"created_at":"2018-11-06T03:00:08Z","updated_at":"2018-12-22T03:19:09Z","closed_at":null,"author_association":"NONE","pull_request":{"url":"https://api.github.com/repos/netlify/netlify-cms/pulls/1857","html_url":"https://github.com/netlify/netlify-cms/pull/1857","diff_url":"https://github.com/netlify/netlify-cms/pull/1857.diff","patch_url":"https://github.com/netlify/netlify-cms/pull/1857.patch"},"body":"update: I've changed the `widget` to `types`, and `widget` item property to `type`.\r\n\r\nThe list's \"widgets\" option allows defining lists of different item types.\r\n\r\n**Summary**\r\n\r\nThe current list widget does not allow adding items of different types. Assume having a home page with different type sections - \"carousel\" and \"spotlight\". Each of these sections can have a different set of fields and both of these sections can be repeated multiple times:\r\n\r\n![home-sections](https://user-images.githubusercontent.com/97896/48040257-eca75500-e12c-11e8-80af-096030820f93.jpg)\r\n\r\nFollowing frontmatter example demonstrates a `sections` list with three sections (1. carousel, 2. spotlight, 3. carousel). Every section defines its widget type using the `widget` field.\r\n\r\n```yaml\r\n---\r\ntitle: Home\r\nlayout: home\r\nsections:\r\n  - widget: carousel\r\n    header: Image Gallery 1\r\n    template: carousel.html\r\n    images:\r\n      - images/image01.png\r\n      - images/image02.png\r\n      - images/image03.png\r\n  - widget: spotlight\r\n    header: Spotlight\r\n    template: spotlight.html\r\n    text: Hello World\r\n  - widget: carousel\r\n    header: Image Gallery 2\r\n    template: carousel.html\r\n    images:\r\n      - images/image04.png\r\n      - images/image05.png\r\n      - images/image06.png\r\n---\r\n```\r\n\r\nIn order to allow such list to be rendered inside the CMS and to allow adding new items of different types, a new option for `list` widget called `widgets` was defined. The `widgets` option allows defining list of widgets a list could possible have (in other words, array of widgets).\r\n\r\nFollowing example demonstrates how a list from the previous example could be defined:\r\n\r\n```yaml\r\n- label: \"Home Section\"\r\n  name: \"sections\"\r\n  widget: \"list\"\r\n  widgets:\r\n    - label: \"Carousel\"\r\n      name: \"carousel\"\r\n      widget: object\r\n      fields:\r\n        - {label: Header, name: header, widget: string, default: \"Image Gallery\"}\r\n        - {label: Template, name: template, widget: string, default: \"carousel.html\"}\r\n        - label: Images\r\n          name: images\r\n          widget: list\r\n          field: {label: Image, name: image, widget: image}\r\n    - label: \"Spotlight\"\r\n      name: \"spotlight\"\r\n      widget: object\r\n      fields:\r\n        - {label: Header, name: header, widget: string, default: \"Spotlight\"}\r\n        - {label: Template, name: template, widget: string, default: \"spotlight.html\"}\r\n        - {label: Text, name: text, widget: text, default: \"Hello World\"}\r\n```\r\n\r\n**Test plan**\r\n\r\nUsing the above example for field configuration and data from page file the editor renders as following:\r\n\r\n![image](https://user-images.githubusercontent.com/97896/48039787-40b13a00-e12b-11e8-91e9-ae8c04692eb6.png)\r\n\r\nTo the left of the \"Add home section\" button there is a `<select>` control that allows selecting one of the available widget types that were defined using list's `widgets` option.\r\n\r\nRe-ordering, object creation/read/editing/deletion works as expected.\r\n\r\n**A picture of a cute animal (not mandatory but encouraged)**\r\n\r\n![blacky](https://user-images.githubusercontent.com/97896/48039984-0005f080-e12c-11e8-8d72-cdb2785b9e70.jpg)\r\n"},"comment":{"url":"https://api.github.com/repos/netlify/netlify-cms/issues/comments/449541350","html_url":"https://github.com/netlify/netlify-cms/pull/1857#issuecomment-449541350","issue_url":"https://api.github.com/repos/netlify/netlify-cms/issues/1857","id":449541350,"node_id":"MDEyOklzc3VlQ29tbWVudDQ0OTU0MTM1MA==","user":{"login":"erquhart","id":2112202,"node_id":"MDQ6VXNlcjIxMTIyMDI=","avatar_url":"https://avatars3.githubusercontent.com/u/2112202?v=4","gravatar_id":"","url":"https://api.github.com/users/erquhart","html_url":"https://github.com/erquhart","followers_url":"https://api.github.com/users/erquhart/followers","following_url":"https://api.github.com/users/erquhart/following{/other_user}","gists_url":"https://api.github.com/users/erquhart/gists{/gist_id}","starred_url":"https://api.github.com/users/erquhart/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/erquhart/subscriptions","organizations_url":"https://api.github.com/users/erquhart/orgs","repos_url":"https://api.github.com/users/erquhart/repos","events_url":"https://api.github.com/users/erquhart/events{/privacy}","received_events_url":"https://api.github.com/users/erquhart/received_events","type":"User","site_admin":false},"created_at":"2018-12-22T03:19:09Z","updated_at":"2018-12-22T03:19:09Z","author_association":"MEMBER","body":"Update:\r\n\r\nSpent time on this today, and I think the CMS isn't ready for it (architecturally). But you all clearly are 😄. I don't disagree with the aim of the PR at all, I'm more in disagreement with how we're currently processing widgets and values in the editor, and this very awesome feature puts a lot of stress on that exact point.\r\n\r\nI'm going on break for three weeks starting today, but I don't want to hold this up any longer. I also don't want to roll back to the commit that added unordered list tags to our core. **So I propose we merge this as is as a beta feature.** We've done this in the past, it puts a disclaimer on the whole thing so we can still change the introduced API without a major release, and there's no guarantee it won't break during usage.\r\n\r\nThat also means previews won't work, so we'll be pending a PR to get that going. But at least you'll have the functionality, and I'll keep an eye out in case a previews PR comes through so it doesn't have to wait longer than necessary.\r\n\r\nLooking for feedback here. Yay? Nay?"}}
{"actor":{"display_login":"erquhart"}}