0
0
Fork 1
Spiegel von https://github.com/paviliondev/discourse-custom-wizard.git synchronisiert 2024-11-23 18:00:29 +01:00
discourse-custom-wizard/assets/javascripts/discourse/components/wizard-mapper-connector.js.es6

35 Zeilen
1 KiB
Text

2020-04-02 07:21:57 +02:00
import Component from "@ember/component";
2020-04-06 10:36:38 +02:00
import { gt } from '@ember/object/computed';
2020-04-02 07:21:57 +02:00
import { computed } from "@ember/object";
2020-04-15 07:22:21 +02:00
import { defaultConnector } from '../lib/wizard-mapper';
import { later } from "@ember/runloop";
2020-04-20 11:41:13 +02:00
import { observes } from "discourse-common/utils/decorators";
2020-05-28 05:06:06 +02:00
import I18n from "I18n";
2020-04-02 07:21:57 +02:00
export default Component.extend({
2020-04-06 10:36:38 +02:00
classNameBindings: [':mapper-connector', ':mapper-block', 'hasMultiple::single'],
hasMultiple: gt('connectors.length', 1),
2020-04-02 07:21:57 +02:00
connectorLabel: computed(function() {
let key = this.connector;
let path = this.inputTypes ? `input.${key}.name` : `connector.${key}`;
return I18n.t(`admin.wizard.${path}`);
2020-04-15 07:22:21 +02:00
}),
didReceiveAttrs() {
if (!this.connector) {
later(() => {
this.set(
'connector',
defaultConnector(this.connectorType, this.inputType, this.options)
);
});
}
2020-04-20 11:41:13 +02:00
},
actions: {
changeConnector(value) {
this.set('connector', value);
this.onUpdate('connector', this.connectorType);
}
2020-04-15 07:22:21 +02:00
}
2020-04-02 07:21:57 +02:00
});