2017-08-22 10:53:26 +03:00
|
|
|
import Component from '@ember/component';
|
|
|
|
import {computed} from '@ember/object';
|
2017-10-30 12:38:01 +03:00
|
|
|
import {inject as service} from '@ember/service';
|
2016-01-19 17:25:36 +03:00
|
|
|
|
|
|
|
const FeatureFlagComponent = Component.extend({
|
2018-01-11 20:43:23 +03:00
|
|
|
feature: service(),
|
|
|
|
|
2016-01-19 17:25:36 +03:00
|
|
|
tagName: 'label',
|
|
|
|
classNames: 'checkbox',
|
|
|
|
attributeBindings: ['for'],
|
|
|
|
_flagValue: null,
|
|
|
|
|
|
|
|
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 17:03:09 +03:00
|
|
|
|
2016-01-19 17:25:36 +03:00
|
|
|
name: computed('flag', function () {
|
|
|
|
return `labs[${this.get('flag')}]`;
|
2018-01-11 20:43:23 +03:00
|
|
|
}),
|
|
|
|
|
|
|
|
init() {
|
|
|
|
this._super(...arguments);
|
|
|
|
|
|
|
|
this.set('_flagValue', this.get(`feature.${this.get('flag')}`));
|
|
|
|
}
|
2016-01-19 17:25:36 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
FeatureFlagComponent.reopenClass({
|
|
|
|
positionalParams: ['flag']
|
|
|
|
});
|
|
|
|
|
|
|
|
export default FeatureFlagComponent;
|