1
0
Fork 0
discourse-custom-wizard-unl.../assets/javascripts/discourse/components/wizard-custom-input-chooser.js.es6
2020-03-22 04:30:11 +11:00

46 Zeilen
Kein EOL
1,2 KiB
JavaScript

import { alias, equal } from "@ember/object/computed";
import { computed } from "@ember/object";
import {
default as discourseComputed,
observes
} from "discourse-common/utils/decorators";
export default Ember.Component.extend({
@observes('activeType')
clearValue() {
this.set('value', null);
},
@discourseComputed('customPlaceholder')
textPlaceholder(customPlaceholder) {
return customPlaceholder || 'admin.wizard.text';
},
@discourseComputed('activeType', 'userEnabled')
showUser(activeType, userEnabled) {
return activeType === 'user' && userEnabled;
},
@discourseComputed('activeType', 'wizardEnabled')
showWizard(activeType, wizardEnabled) {
return activeType === 'wizard' && wizardEnabled;
},
showText: equal('activeType', 'text'),
@discourseComputed('options.allowWizardField', 'inputType')
wizardEnabled(allowWizardField, inputType) {
return allowWizardField === true || allowWizardField === inputType;
},
@discourseComputed('options.allowUserField', 'inputType')
userEnabled(allowUserField, inputType) {
return allowUserField === true || allowUserField === inputType;
},
actions: {
toggleType(type) {
this.set('activeType', type);
}
}
})