/// class PD.Manage.Modules.Rules.RuleScriptPropertiesDialogCommand
// using PD.Commands.Command

PD.Manage.Modules.Rules.RuleScriptPropertiesDialogCommand =
PD.Commands.Command.extend({

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

    setDefaults: function () {

        this.props("id", "rule-script/properties-dialog");
        this.props("enabled", false);
        this.props("icon", PD.Path.to16x16("pencil.png"));
        this.props("label", "Edit");
        this.props("tooltip", "Edit the properties of the selected Rule Script.");

        this.state("rulescript", null);

    },

    setState: function (e) {
        this._super(e);
        this.props("enabled", this.state("rulescript") != null);
    },

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

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

    _showDialog: function () {

        var ruleScript = this.state("rulescript");

        PDJS.Shared.Features.FeatureDialogForNhib.open({
            title: `Rule Script | ${ruleScript.name}`,
            height: "400px",
            width: "450px",
            args: {
                targetId: ruleScript.id,
                targetType: "ProspectDirector.Web.Manage.Modules.Rules.RuleScriptUIO",
                arbiterType: "ProspectDirector.Web.Manage.Modules.Rules.RuleScriptArbiter"
            },
            callbacks: {
                "ok": (sender, e) => {

                    PD.context
                        .get_default()
                        .get_events()
                        .publish("rule-script/update");

                }
            }
        });

    }

});