1 import {Component} from "./component.js";
2 import Sortable from "sortablejs";
3 import {buildListActions, sortActionClickListener} from "../services/dual-lists";
6 export class SortSetManager extends Component {
8 protected input!: HTMLInputElement;
9 protected configuredList!: HTMLElement;
10 protected availableList!: HTMLElement;
13 this.input = this.$refs.input as HTMLInputElement;
14 this.configuredList = this.$refs.configuredOperationsList;
15 this.availableList = this.$refs.availableOperationsList;
19 const listActions = buildListActions(this.availableList, this.configuredList);
20 const sortActionListener = sortActionClickListener(listActions, this.onChange.bind(this));
21 this.$el.addEventListener('click', sortActionListener);
25 const scrollBoxes = [this.configuredList, this.availableList];
26 for (const scrollBox of scrollBoxes) {
27 new Sortable(scrollBox, {
28 group: 'sort-set-operations',
29 ghostClass: 'primary-background-light',
32 onSort: this.onChange.bind(this),
38 const configuredOpEls = Array.from(this.configuredList.querySelectorAll('[data-id]'));
39 this.input.value = configuredOpEls.map(elem => elem.getAttribute('data-id')).join(',');