2020-03-21 18:30:11 +01:00
|
|
|
import { newPair } from '../lib/custom-wizard';
|
2020-03-23 06:41:04 +01:00
|
|
|
import { computed } from "@ember/object";
|
2018-05-24 07:34:58 +02:00
|
|
|
|
2017-10-17 15:17:53 +02:00
|
|
|
export default Ember.Component.extend({
|
2018-05-24 07:34:58 +02:00
|
|
|
classNames: 'custom-input',
|
2020-03-23 06:41:04 +01:00
|
|
|
outputConnector: computed(function() {
|
|
|
|
return I18n.t(this.outputConnectorKey || 'admin.wizard.output.connector').toLowerCase();
|
|
|
|
}),
|
2020-03-21 18:30:11 +01:00
|
|
|
|
|
|
|
actions: {
|
|
|
|
addPair() {
|
2020-03-23 06:41:04 +01:00
|
|
|
const pairs = this.get('input.pairs');
|
|
|
|
|
|
|
|
const pairCount = pairs.length + 1;
|
|
|
|
pairs.forEach(p => (p.set('pairCount', pairCount)));
|
|
|
|
|
|
|
|
pairs.pushObject(
|
|
|
|
newPair(Object.assign(
|
|
|
|
{},
|
|
|
|
this.options,
|
|
|
|
{
|
|
|
|
index: pairs.length,
|
|
|
|
pairCount,
|
|
|
|
}
|
|
|
|
))
|
2020-03-21 18:30:11 +01:00
|
|
|
);
|
|
|
|
},
|
|
|
|
|
|
|
|
removePair(pair) {
|
2020-03-23 06:41:04 +01:00
|
|
|
const pairs = this.get('input.pairs');
|
|
|
|
const pairCount = pairs.length - 1;
|
|
|
|
pairs.forEach(p => (p.set('pairCount', pairCount)));
|
|
|
|
pairs.removeObject(pair);
|
2017-10-17 15:17:53 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|