/// class PD.Manage.Modules.SelectionListItemEditDialogCommand

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

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

    setDefaults: function () {

        this.props("id", "selection-list-item/edit-dialog");
        this.props("enabled", false);
        this.props("icon", PD.Path.to16x16("pencil.png"));
        this.props("label", "Edit");
        this.props("tooltip", "Edit the selected List Item.");

        this.state("selectionListItems", null);

    },

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

    isEnabled: function () {

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

        return _.isArray(selectionListItems)
            && selectionListItems.length === 1;

    },

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

        let selectionListItems = this.state("selectionListItems");
        let selectionListItem = _.first(selectionListItems);

        PDJS.Shared.Features.FeatureDialogForNhib.open({
            title: "Edit Selection List Item - " + selectionListItem.name,
            height: "450px",
            width: "450px",
            args: {
                targetId: selectionListItem.id,
                targetType: "ProspectDirector.Web.Manage.Modules.Extensions.SelectionListItemUIO",
                arbiterType: "ProspectDirector.Web.Manage.Modules.Extensions.SelectionListItemArbiter"
            },
            callbacks: {
                "ok": (sender, e) => {

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

                }
            }
        });

    }

});