var __extends = (this && this.__extends) || function (d, b) {
    for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
    function __() { this.constructor = d; }
    d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var Settings;
(function (Settings) {
    var Gadget;
    (function (Gadget) {
        // Settings.Gadget.SettingGroup.Summary
        Gadget.SettingGroup = $.extend(Gadget.SettingGroup, {
            ParetoSetup: "71519cf5-1425-4727-9fde-34747292a7c3"
        });
        Gadget.ParetoMarkerPosition = { id: Settings.Gadget.SettingGroup.ParetoSetup, name: "MarkerPosition" };
        Gadget.LegendName = { id: Settings.Gadget.SettingGroup.ParetoSetup, name: "LegendName" };
        Gadget.ShowLegend = { id: Settings.Gadget.SettingGroup.ParetoSetup, name: "ShowLegend" };
        Gadget.ShowTotal = { id: Settings.Gadget.SettingGroup.ParetoSetup, name: "ShowTotal" };
    })(Gadget = Settings.Gadget || (Settings.Gadget = {}));
})(Settings || (Settings = {}));
var Dashboards;
(function (Dashboards) {
    var SetupControl;
    (function (SetupControl) {
        var ParetoSetup = (function (_super) {
            __extends(ParetoSetup, _super);
            function ParetoSetup() {
                _super.call(this, Settings.Gadget.SettingGroup.ParetoSetup);
                this.title = i18n.loc.s('ISO50001Gadgets', 'Pareto_Chart_Setup');
            }
            ParetoSetup.CreateInstance = function () {
                var instance = new ParetoSetup();
                return instance;
            };
            ParetoSetup.prototype.draw = function () {
                var _this = this;
                this.$container.empty();
                TemplateUtil.LocAndLoad(ParetoSetup.SetupControlTemplateUri, new Core.CallBack(function (template) {
                    _this.$container.html(template);
                    _this.render();
                }, this));
            };
            ParetoSetup.prototype.isConfigured = function () {
                return true;
            };
            ParetoSetup.prototype.isManagedSetting = function (name) {
                var managed = false;
                switch (name) {
                    case Settings.Gadget.ParetoMarkerPosition.name:
                    case Settings.Gadget.LegendName.name:
                    case Settings.Gadget.ShowLegend.name:
                    case Settings.Gadget.ShowTotal.name:
                        managed = true;
                        break;
                }
                ;
                return managed;
            };
            ParetoSetup.prototype.beforeCommit = function () {
                var paretoPosition = this.$container.find('#marker-position').val();
                this.setting(Settings.Gadget.ParetoMarkerPosition.name, paretoPosition);
                var legendName = this.$container.find('#legend-name').val();
                this.setting(Settings.Gadget.LegendName.name, legendName);
                var showTotal = this.$container.find('#show-total').prop('checked');
                this.setting(Settings.Gadget.ShowTotal.name, showTotal.toString());
            };
            ParetoSetup.prototype.render = function () {
                var paretoPosition = this.$container.find('#marker-position');
                paretoPosition.val(this.setting(Settings.Gadget.ParetoMarkerPosition.name).toString());
                if (this.setting(Settings.Gadget.ShowLegend.name).toString() === 'true') {
                    var legendName = this.$container.find('#legend-name');
                    legendName.val(this.setting(Settings.Gadget.LegendName.name).toString());
                }
                else {
                    this.$container.find('#legend-name').hide();
                    this.$container.find('#legend-name-label').hide();
                }
                var showTotalChecked = this.setting(Settings.Gadget.ShowTotal.name);
                var showTotal = _.isUndefined(showTotalChecked) || _.isNull(showTotalChecked) ? true : showTotalChecked.toString().toLowerCase() === 'true';
                this.$container.find('#show-total').prop('checked', showTotal);
            };
            ParetoSetup.SetupControlTemplateUri = 'Content/Gadgets/ParetoChart/ParetoChartSetup.html';
            return ParetoSetup;
        }(Dashboards.Models.SetupControl));
        SetupControl.ParetoSetup = ParetoSetup;
    })(SetupControl = Dashboards.SetupControl || (Dashboards.SetupControl = {}));
})(Dashboards || (Dashboards = {}));
// Register the Setup Control
Dashboards.Controllers.SetupControl.Register({
    create: Dashboards.SetupControl.ParetoSetup.CreateInstance,
    id: Settings.Gadget.SettingGroup.ParetoSetup
});
//# sourceMappingURL=ParetoChartSetup.js.map