Last active
October 15, 2015 22:34
-
-
Save samselikoff/c2b27bb3fa81b229be6f to your computer and use it in GitHub Desktop.
Declarative CPs in Ember (c/o ryanto)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Component.extend({ | |
channelTalk: null, | |
talk: null, | |
channel: Ember.computed.readOnly('channelTalk.channel'), | |
tagName: 'tr', | |
classNames: 'Channel-table-row', | |
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'), | |
actions: { | |
confirmRemoveChannelTalk() { | |
const channelTalk = this.get('channelTalk.content'); | |
this.sendAction('confirmRemoveChannelTalkAction', channelTalk); | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment