import AbsTable from '/js/libs/js-AbsTable.js'

export default class AListBox extends AbsTable {
    constructor(e) {
        super(e);
        this.absContainer.setAttribute("data-style", "AListBox");
        this.multiSelect = false;
        this.selectedID = -1;
        this.selectedIDs = [];
        this.selectedItem = null;
        this.selectedItems = [];
        this.absRows.addEventListener("click", this.RowClick.bind(this), false);
    }
    RemoveItem(id) {

    }
    CheckSelected(row) {
        var id = row.getAttribute("data-id");
        if (this.multiSelect) {

        } else {
            if (this.selectedID != id) {
                (this.selectedItem != null)?this.selectedItem.classList.remove("active"):null;
                this.selectedItem = row;
                this.selectedID = id;
                this.selectedItem.classList.add("active");
            }
        }
    }
    checkMultiSeleted(id, ele, f) {
        if (this.multiSelect) {
            if (f) {

            } else {

            }
        } else {
            if (f) {
                this.selectedID = id;
                this.selectedItem = ele;
            } else {
                this.selectedID = null;
                this.selectedItem = null;
            }
        }
    }
    RowClick(e) {
        var target = e.target;
        var row = target.closest("tr");
        if (row != null) {
            this.CheckSelected(row);
        }
    }
    LoadDataAuto() {

    }
}