devextreme
Version:
JavaScript/TypeScript Component Suite for Responsive Web Development
128 lines (127 loc) • 4.28 kB
JavaScript
/**
* DevExtreme (esm/__internal/ui/diagram/ui.diagram.dialogs.js)
* Version: 26.1.3
* Build date: Wed Jun 10 2026
*
* Copyright (c) 2012 - 2026 Developer Express Inc. ALL RIGHTS RESERVED
* Read about DevExtreme licensing here: https://js.devexpress.com/Licensing/
*/
import messageLocalization from "../../../common/core/localization/message";
import $ from "../../../core/renderer";
import {
extend
} from "../../../core/utils/extend";
import Widget from "../../core/widget/widget";
import Popup from "../../ui/popup/m_popup";
class DiagramDialog extends Widget {
_init() {
super._init();
this._command = void 0;
this._isShown = false;
this._createOnGetContentOption();
this._createOnHiddenOption()
}
_initMarkup() {
super._initMarkup();
const {
command: command,
title: title,
maxWidth: maxWidth,
height: height,
toolbarItems: toolbarItems
} = this.option();
this._command = command;
this._$popupElement = $("<div>").appendTo(this.$element());
this._popup = this._createComponent(this._$popupElement, Popup, {
title: title,
maxWidth: maxWidth,
height: height,
toolbarItems: toolbarItems,
onHidden: this._onHiddenAction
})
}
_clean() {
var _this$_$popupElement;
delete this._popup;
null === (_this$_$popupElement = this._$popupElement) || void 0 === _this$_$popupElement || _this$_$popupElement.remove()
}
_getDefaultOptions() {
return extend(super._getDefaultOptions(), {
title: "",
maxWidth: 500,
height: "auto",
toolbarItems: this._getToolbarItems()
})
}
_getToolbarItems() {
return [this._getOkToolbarItem(), this._getCancelToolbarItem()]
}
_getOkToolbarItem() {
return {
widget: "dxButton",
location: "after",
toolbar: "bottom",
options: {
text: messageLocalization.format("dxDiagram-dialogButtonOK"),
onClick: () => {
this._command.execute(this._commandParameter);
this._hide()
}
}
}
}
_getCancelToolbarItem() {
return {
widget: "dxButton",
location: "after",
toolbar: "bottom",
options: {
text: messageLocalization.format("dxDiagram-dialogButtonCancel"),
onClick: this._hide.bind(this)
}
}
}
_optionChanged(args) {
var _this$_popup;
switch (args.name) {
case "title":
case "maxWidth":
case "height":
case "toolbarItems":
null === (_this$_popup = this._popup) || void 0 === _this$_popup || _this$_popup.option(args.name, args.value);
break;
case "command":
this._command = args.value;
break;
case "onGetContent":
this._createOnGetContentOption();
break;
case "onHidden":
this._createOnHiddenOption();
break;
default:
super._optionChanged(args)
}
}
_createOnGetContentOption() {
this._onGetContentAction = this._createActionByOption("onGetContent")
}
_createOnHiddenOption() {
this._onHiddenAction = this._createActionByOption("onHidden")
}
_hide() {
var _this$_popup2;
null === (_this$_popup2 = this._popup) || void 0 === _this$_popup2 || _this$_popup2.hide();
this._isShown = false
}
_show() {
var _this$_popup3, _this$_popup4;
null === (_this$_popup3 = this._popup) || void 0 === _this$_popup3 || null === (_this$_popup3 = _this$_popup3.$content()) || void 0 === _this$_popup3 || _this$_popup3.empty().append(this._onGetContentAction());
null === (_this$_popup4 = this._popup) || void 0 === _this$_popup4 || _this$_popup4.show();
this._isShown = true
}
isVisible() {
return this._isShown
}
}
export default DiagramDialog;