2016-06-30 20:14:25 +02:00
|
|
|
import Component from 'ember-component';
|
|
|
|
import computed from 'ember-computed';
|
|
|
|
import injectService from 'ember-service/inject';
|
2016-01-19 15:25:36 +01:00
|
|
|
|
|
|
|
const FeatureFlagComponent = Component.extend({
|
|
|
|
tagName: 'label',
|
|
|
|
classNames: 'checkbox',
|
|
|
|
attributeBindings: ['for'],
|
|
|
|
_flagValue: null,
|
|
|
|
|
2016-06-30 20:14:25 +02:00
|
|
|
feature: injectService(),
|
2016-01-19 15:25:36 +01:00
|
|
|
|
|
|
|
init() {
|
|
|
|
this._super(...arguments);
|
|
|
|
|
2016-05-05 16:03:09 +02:00
|
|
|
this.set('_flagValue', this.get(`feature.${this.get('flag')}`));
|
2016-01-19 15:25:36 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
value: computed('_flagValue', {
|
|
|
|
get() {
|
|
|
|
return this.get('_flagValue');
|
|
|
|
},
|
|
|
|
set(key, value) {
|
|
|
|
return this.set(`feature.${this.get('flag')}`, value);
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
|
|
|
|
for: computed('flag', function () {
|
|
|
|
return `labs-${this.get('flag')}`;
|
|
|
|
}),
|
2016-05-05 16:03:09 +02:00
|
|
|
|
2016-01-19 15:25:36 +01:00
|
|
|
name: computed('flag', function () {
|
|
|
|
return `labs[${this.get('flag')}]`;
|
|
|
|
})
|
|
|
|
});
|
|
|
|
|
|
|
|
FeatureFlagComponent.reopenClass({
|
|
|
|
positionalParams: ['flag']
|
|
|
|
});
|
|
|
|
|
|
|
|
export default FeatureFlagComponent;
|