Files
ember-panda/addon/components/state-badge.js
T
2023-11-28 14:30:02 -05:00

51 lines
1.2 KiB
JavaScript

// Generated by CoffeeScript 2.7.0
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;