2020-04-02 07:21:57 +02:00
|
|
|
import Component from "@ember/component";
|
|
|
|
import { computed } from "@ember/object";
|
2024-11-22 17:11:51 +01:00
|
|
|
import { gt } from "@ember/object/computed";
|
2020-04-15 07:22:21 +02:00
|
|
|
import { later } from "@ember/runloop";
|
2020-05-28 05:06:06 +02:00
|
|
|
import I18n from "I18n";
|
2024-11-22 17:11:51 +01:00
|
|
|
import { defaultConnector } from "../lib/wizard-mapper";
|
2020-04-02 07:21:57 +02:00
|
|
|
|
|
|
|
export default Component.extend({
|
2021-03-28 11:06:49 +02:00
|
|
|
classNameBindings: [
|
|
|
|
":mapper-connector",
|
|
|
|
":mapper-block",
|
|
|
|
"hasMultiple::single",
|
|
|
|
],
|
|
|
|
hasMultiple: gt("connectors.length", 1),
|
|
|
|
connectorLabel: computed(function () {
|
2020-04-02 07:21:57 +02:00
|
|
|
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
|
|
|
}),
|
2021-03-28 11:06:49 +02:00
|
|
|
|
2020-04-15 07:22:21 +02:00
|
|
|
didReceiveAttrs() {
|
2024-11-22 17:11:51 +01:00
|
|
|
this._super();
|
2020-04-15 07:22:21 +02:00
|
|
|
if (!this.connector) {
|
|
|
|
later(() => {
|
|
|
|
this.set(
|
2021-03-28 11:06:49 +02:00
|
|
|
"connector",
|
2020-04-15 07:22:21 +02:00
|
|
|
defaultConnector(this.connectorType, this.inputType, this.options)
|
|
|
|
);
|
2021-03-28 11:06:49 +02:00
|
|
|
});
|
2020-04-15 07:22:21 +02:00
|
|
|
}
|
2020-04-20 11:41:13 +02:00
|
|
|
},
|
2021-03-28 11:06:49 +02:00
|
|
|
|
2020-04-29 03:42:39 +02:00
|
|
|
actions: {
|
|
|
|
changeConnector(value) {
|
2021-03-28 11:06:49 +02:00
|
|
|
this.set("connector", value);
|
|
|
|
this.onUpdate("connector", this.connectorType);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|