Files
ember-panda/addon/components/state-badge.coffee
T
2017-12-21 11:51:55 +01:00

28 lines
906 B
CoffeeScript

import Ember from 'ember'
Component = Ember.Component.extend
tagName: 'span'
classNames: ['ui', 'label', 'state-badge']
classNameBindings: ['ui_class', 'having_action:with-action', 'basic:basic']
action: null
state: '…'
human_state: Ember.computed 'state', ->
return '-' unless state = @get('state')
t("attributes.state.#{state}", default: state)
having_action: Ember.computed.bool 'action'
click: ->
@action?()
ui_class: Ember.computed 'state', ->
switch @get('state')
when 'overdue' then 'yellow'
when 'completed', 'all_completed' then 'green'
when 'rejected', 'any_rejected' then 'red'
when 'active', 'processing' then 'blue'
when 'inquiry' then 'pink'
else 'grey'
Component.reopenClass
positionalParams: ['state']
export default Component