Skip to content

Instantly share code, notes, and snippets.

@thomaswrenn
Created September 13, 2017 01:05
Show Gist options
  • Save thomaswrenn/dddab4383dafe4a5cc1de25c6243b3e8 to your computer and use it in GitHub Desktop.
Save thomaswrenn/dddab4383dafe4a5cc1de25c6243b3e8 to your computer and use it in GitHub Desktop.

controller.hbs:

<div class="pad-xs-30b">
  {{thing-collection
    title=title
    things=things

    doAwesomeThingToThing=(action "doAwesomeThingToThing")
  }}
</div>

<div>
  {{thing-collection
    title=title
    things=things

    doAwesomeThingToThing=(action "doAwesomeThingToThing")
    archiveThing=(action "archive")
  }}
</div>

thing-collection.js:

export default Ember.Component.extend({
  // required params
  things: null,

  // optional params
  doAwesomeThingToThing: Ember.K,
  archiveThing: null,
});

thing-collection.hbs:

{{#each things as |thing|}}
  {{thing-collection/item
    thing=thing

    doAwesomeThingToThing=doAwesomeThingToThing
    archiveThing=archiveThing
  }}
{{/each}}

thing-collection/item.js:

export default Ember.Component.extend({
  // required params
  thing: null,

  // optional params
  doAwesomeThingToThing: Ember.K,
  archiveThing: null,
});

thing-collection/item.hbs:

<div>
  <div>{{ thing.name }}</div>

  {{#more-options-dropdown}}
    <a class="DropDownOptions-item" {{action doAwesomeThingToThing thing}}>
        Do Awesome Thing
    </a>

    {{#if archiveThing}}
      <a class="DropDownOptions-item" {{action archiveThing thing}}>
        Archive
      </a>
    {{/if}}
  {{/more-options-dropdown}}
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment