Skip to content

Instantly share code, notes, and snippets.

@ryanto
Last active October 29, 2015 12:04
Show Gist options
  • Save ryanto/a3ae9cc8119ca0f2f235 to your computer and use it in GitHub Desktop.
Save ryanto/a3ae9cc8119ca0f2f235 to your computer and use it in GitHub Desktop.
Declarative CPs
import Ember from 'ember';
export default Ember.Component.extend({
channelTalk: null,
classNames: 'Channel-table-row',
channel: Ember.computed.readOnly('channelTalk.channel'),
talk: Ember.computed.readOnly('channelTalk.talk'),
confirmRemoveChannelTalkAction: "confirmRemoveChannelTalk",
hasTalkMedia: Ember.computed.bool('talk.media'),
hasTalkContext: Ember.computed.bool('talk.talkContext'),
primaryPhoto: Ember.computed.readOnly('talk.primaryTalkPhoto'),
hasPrimaryPhoto: Ember.computed.bool('talk.primaryTalkPhoto'),
expectedAspectRatios: Ember.computed.readOnly('channel.aspectRatios'),
photoSizes: Ember.computed.readOnly('primaryPhoto.photoSizes'),
photoSizeAspectRatios: Ember.computed.mapBy('photoSizes', 'apsectRatio'),
missingAspectRatios: Ember.computed.setDiff(
'expectedAspectRatios',
'photoSizeAspectRatios'
),
hasAllAspectRatios: Ember.computed.equal('missingAspectRatios.length', 0),
speakers: Ember.computed.readOnly('talk.speakers'),
symfonySpeakers: Ember.computed.filterBy('speakers', 'isSymfonySpeaker'),
nonSymfonySpeakers: Ember.computed.setDiff('speakers', 'symfonySpeakers'),
hasAllSymfonySpeakers: Ember.computed.equal('nonSymfonySpeakers.length', 0),
canPublishTalk: Ember.computed.and(
'hasTalkMedia',
'hasTalkContext',
'hasPrimaryPhoto',
'hasAllAspectRatios',
'hasAllSymfonySpeakers'
),
cannotPublishTalk: Ember.computed.not('canPublishTalk'),
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment