All Downloads are FREE. Search and download functionalities are using the official Maven repository.

js.factoryEditing.utility.FactorySelectDialog.js Maven / Gradle / Ivy

There is a newer version: 4.0.2
Show newest version
import { BootstrapUtility } from "../BootstrapUtility";
export class FactorySelectDialog {
    constructor(parent, possibleValues, selectCallback) {
        this.parent = parent;
        this.possibleValues = possibleValues;
        this.selectCallback = selectCallback;
    }
    show() {
        let dialog = document.createElement("dialog");
        dialogPolyfill.registerDialog(dialog);
        this.parent.appendChild(dialog);
        let list = document.createElement("ul");
        list.className = "list-group";
        dialog.appendChild(list);
        for (let possibleValue of this.possibleValues) {
            let li = document.createElement("li");
            list.appendChild(li);
            li.className = "list-group-item";
            let selectButton = BootstrapUtility.createButtonSuccess();
            li.appendChild(selectButton);
            selectButton.style.marginLeft = "6px";
            selectButton.onclick = (e) => {
                this.selectCallback(possibleValue);
                dialog.close();
            };
            selectButton.textContent = possibleValue.getDisplayText();
        }
        let closeButton = BootstrapUtility.createButtonSecondary();
        dialog.appendChild(closeButton);
        closeButton.style.marginTop = "6px";
        closeButton.onclick = (e) => {
            dialog.close();
        };
        closeButton.textContent = "Cancel";
        dialog.showModal();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy