/// class PD.Manage.Modules.SelectionListItemCreateDialogCommand

PD.Manage.Modules.SelectionListItemCreateDialogCommand =
PD.Commands.Command.extend({

    //===================================
    // PUBLIC METHODS
    //===================================

    setDefaults: function () {

        this.props("id", "selection-list-item/create-dialog");
        this.props("enabled", true);
        this.props("icon", PD.Path.to16x16("plus.png"));
        this.props("label", "New");
        this.props("tooltip", "Add a new Item to the selected Selection List.");

        this.state("selectionList", null);

    },

    setState: function (state) {
        this._super(state);
        this.props("enabled", this.isEnabled());
    },

    isEnabled: function () {
        return this.state("selectionList") != null
            && this.state("selectionList").id != null;
    },

    execute: function (e) {
        this._super(e);

        var selectionList = this.state("selectionList");

        PDJS.Shared.Features.FeatureDialogForNhib.open({
            title: "New Selection List Item",
            height: "450px",
            width: "450px",
            args: {
                targetType: "ProspectDirector.Web.Manage.Modules.Extensions.SelectionListItemUIO",
                arbiterType: "ProspectDirector.Web.Manage.Modules.Extensions.SelectionListItemArbiter",
                properties: {
                    listId: parseInt(selectionList.id)
                }
            },
            callbacks: {
                "ok": (sender, e) => {

                    PD.context
                        .get_default()
                        .get_events()
                        .publish("selection-list-item/create", {
                            id: e.target.id
                        });

                }
            }
        });

    }

});