/// 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);

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

        ProspectDirector.Web.UI.FeatureSets.NHibTargetEditorDialog.open({
            config: {
                title: "Edit Selection List Item - " + selectionListItem.name,
                height: "450px",
                width: "500px"
            },
            data: {
                targetArbiter: "ProspectDirector.Web.Manage.Modules.Extensions.SelectionListItemArbiter",
                targetType: "ProspectDirector.Web.Manage.Modules.Extensions.SelectionListItemUIO",
                layoutType: ProspectDirector.Web.UI.FeatureSets.Layouts.TabStripLayout,
                targetId: selectionListItem.id
            },
            callbacks: {
                ok: function (sender, e) {
                    PD.context.get_default().get_events().publish("selection-list-item/edit", {
                        id: selectionListItem.id
                    });
                }
            }
        });

    }

});