/// class PD.Manage.Modules.SyncEditDialogCommand

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

    //===================================
    // PROPERTIES
    //===================================

    get_selections: function () {
        return this.state("selections");
    },

    get_selection: function () {
        return _.first(this.get_selections());
    },

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

    setDefaults: function () {
        this.props("id", "sync/edit-dialog");
        this.props("enabled", false);
        this.props("icon", PD.Path.to16x16("pencil.png"));
        this.props("label", "Edit");
        this.props("tooltip", "Edit the selected Tag.");
        this.state("selections", null);
    },

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

    execute: function (e) {
        this._super(e);
        this._showDialog(this.get_selection().id);
    },

    //===================================
    // PRIVATE METHODS
    //===================================

    _isEnabled: function () {
        return this.get_selection() != null && this.get_selections().length === 1;
    },

    _showDialog: function (id) {

        PDJS.Shared.Features.FeatureDialogForNhib.open({
            title: "Edit | Active Directory Sync",
            height: 500,
            width: 500,
            args: {
                targetType: "ProspectDirector.Web.Manage.Modules.Security.SyncSettingsUIO",
                arbiterType: "ProspectDirector.Web.Manage.Modules.Security.SyncSettingsArbiter",
                targetId: id
            },
            callbacks: {
                "ok": (sender, e) => {

                    PD.context
                        .get_default()
                        .get_events()
                        .publish("sync/edit", {
                            id: e.target.id
                        });

                }
            }
        });

    }

});