<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">define(["dojo/_base/declare",
        "dojo/_base/lang",
        "dojo/on",
        "dojo/dom-construct",
        "app/ui/dashboard/bi/BiEditor",
        "app/base/dashboard/kpi/kpi-util",
        "app/ui/dashboard/kpi/KpiEditor",
        "dijit/_WidgetBase",
        "dojo/i18n!app/nls/resources",
        "app/ui/util/ModalBase",
        "app/ui/util/OkCancelBar"],
function(declare, lang, on, domConstruct, BiEditor, kpiUtil, KpiEditor,
         _WidgetBase, i18n, ModalBase, OkCancelBar) {

  var oThisClass = declare("app.ui.dashboard.kpi.KpiDialog", [_WidgetBase], {

    i18n: i18n,
    dialog: null,
    dialogTitle: null,
    kpiEditor: null,
    kpiLocalId: null,
    okCancelBar: null,
    deleteButton: null,

    postCreate: function() {
      this.inherited(arguments);
      this.dialogTitle = i18n.kpi.dialogTitle;
      if (this.isBi) {
        this.dialogTitle = i18n.bi.dialogTitle;
      }
    },

    getDeleteButton: function() {
      return this.deleteButton;
    },

    getOkButton: function() {
      if (this.okCancelBar) return this.okCancelBar.__okButton;
      return null;
    },

    hide: function() {
      this.dialog.hide();
    },

    makeContent: function() {
      if (!this.kpiEditor) this.kpiEditor = this.newKpiEditor();
      return this.kpiEditor.domNode;
    },

    makeFooter: function() {
      if (!this.okCancelBar) this.okCancelBar = this.newOkCancelBar();
      this.kpiEditor.updateActionButtons();

      return this.okCancelBar.domNode;
    },

    newKpiEditor: function() {
      if (this.isBi) {
        return new BiEditor({
          parentDialog: this,
          activeLocalId: this.kpiLocalId
        });
      } else {
        return new KpiEditor({
          parentDialog: this,
          activeLocalId: this.kpiLocalId
        });
      }
    },

    newOkCancelBar: function() {
      var okCancel = new OkCancelBar({
        showOk: true,
        showCancel: true,
      });
      this.deleteButton = domConstruct.create("button", {
        type: "button",
        "class": "btn btn-sm btn-danger",
        innerHTML: i18n.kpi.deletion.launchDeleteButton,
        onClick: lang.hitch(this,function(){
          if (this.kpiEditor) this.kpiEditor.deleteButtonClicked();
        })
      });
      var refNode = okCancel.__okButton;
      domConstruct.place(this.deleteButton,refNode,"after");
      return okCancel;
    },

    onHide: function() {},

    show: function() {
      this.dialog = new ModalBase({
        "class": "kpi-editor-dialog",
        "title": this.dialogTitle,
        "content": this.makeContent(),
        "footer": this.makeFooter()
      });

      var dialog = this.dialog;
      var okCancel = this.okCancelBar;
      this.kpiEditor.okCancelBar = okCancel;

      var h1 = null, h2 = null, h3 = null;
      h1 = on(okCancel,"OkClicked",lang.hitch(this,function() {
        this.kpiEditor.validateAndApply(okCancel.__okButton);
      }));
      h2 = on(okCancel,"CancelClicked",lang.hitch(this,function() {
        dialog.hide();
      }));
      h3 = dialog.on("hide",lang.hitch(this,function() {
        h1.remove();
        h2.remove();
        h3.remove();
        setTimeout(lang.hitch(this,function(){
          dialog.destroyRecursive(false);
          this.destroyRecursive(false);
          this.onHide();
        },300));
      }));

      dialog.show();
    }

  });

  return oThisClass;
});
</pre></body></html>