2017-08-18 04:36:14 -07:00
|
|
|
import Ember from 'ember';
|
|
|
|
|
2017-08-18 11:10:08 -07:00
|
|
|
const { Component, computed, getProperties } = Ember;
|
2017-08-18 04:36:14 -07:00
|
|
|
|
|
|
|
export default Component.extend({
|
|
|
|
tagName: 'button',
|
|
|
|
|
|
|
|
classNames: ['compliance-auto-suggester-action'],
|
|
|
|
|
|
|
|
classNameBindings: ['isAffirmative:compliance-auto-suggester-action--accept'],
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Determines the type of suggestion action this is
|
|
|
|
* if type property is passed in
|
|
|
|
*/
|
2017-08-18 11:10:08 -07:00
|
|
|
isAffirmative: computed.equal('type', 'accept'),
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Action handler for click event, invokes closure action with type as argument
|
|
|
|
*/
|
|
|
|
click() {
|
2017-08-20 16:46:43 -07:00
|
|
|
const { type: intent, action } = <{ type: string | void; action: Function | void }>getProperties(
|
|
|
|
this,
|
|
|
|
'type',
|
|
|
|
'action'
|
|
|
|
);
|
2017-08-18 11:10:08 -07:00
|
|
|
|
|
|
|
if (typeof action === 'function') {
|
|
|
|
return action(intent);
|
|
|
|
}
|
|
|
|
}
|
2017-08-18 04:36:14 -07:00
|
|
|
});
|