2018-09-25 16:28:26 +00:00
|
|
|
import { computed } from '@ember/object';
|
|
|
|
import Component from '@ember/component';
|
2018-04-03 14:16:57 +00:00
|
|
|
|
2018-09-25 16:28:26 +00:00
|
|
|
export default Component.extend({
|
2018-04-03 14:16:57 +00:00
|
|
|
onDataUpdate: () => {},
|
2018-09-25 16:28:26 +00:00
|
|
|
listData: computed('listLength', function() {
|
2018-04-03 14:16:57 +00:00
|
|
|
let num = this.get('listLength');
|
|
|
|
if (num) {
|
|
|
|
num = parseInt(num, 10);
|
|
|
|
}
|
|
|
|
return Array(num || 0).fill(null).map(() => ({ value: '' }));
|
|
|
|
}),
|
|
|
|
listLength: 0,
|
|
|
|
actions: {
|
|
|
|
setKey(index, key) {
|
|
|
|
let listData = this.get('listData');
|
|
|
|
listData.replace(index, 1, key);
|
|
|
|
this.get('onDataUpdate')(listData.compact().map(k => k.value));
|
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|