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

51 lines
1.2 KiB
JavaScript

// Generated by CoffeeScript 1.12.5
var Component;
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', function() {
var state;
if (!(state = this.get('state'))) {
return '-';
}
return t("attributes.state." + state, {
"default": state
});
}),
having_action: Ember.computed.bool('action'),
click: function() {
return typeof this.action === "function" ? this.action() : void 0;
},
ui_class: Ember.computed('state', function() {
switch (this.get('state')) {
case 'overdue':
return 'yellow';
case 'completed':
case 'all_completed':
return 'green';
case 'rejected':
case 'any_rejected':
return 'red';
case 'active':
case 'processing':
return 'blue';
case 'inquiry':
return 'pink';
default:
return 'grey';
}
})
});
Component.reopenClass({
positionalParams: ['state']
});
export default Component;