Skip to content

Commit

Permalink
Release 19.1.3
Browse files Browse the repository at this point in the history
  • Loading branch information
viterobk committed May 16, 2019
1 parent dc875df commit 8c2227b
Show file tree
Hide file tree
Showing 57 changed files with 1,565 additions and 763 deletions.
16 changes: 13 additions & 3 deletions js/docEnums.js
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,7 @@

/**
* @typedef {string} Enums.ToolbarItemWidget
* @enum {'dxAutocomplete'|'dxButton'|'dxCheckBox'|'dxDateBox'|'dxMenu'|'dxSelectBox'|'dxTabs'|'dxTextBox'|'dxButtonGroup'}
* @enum {'dxAutocomplete'|'dxButton'|'dxCheckBox'|'dxDateBox'|'dxMenu'|'dxSelectBox'|'dxTabs'|'dxTextBox'|'dxButtonGroup'|'dxDropDownButton'}
*/

/**
Expand Down Expand Up @@ -837,8 +837,18 @@
*/

/**
* @typedef {string} Enums.TextEditorButtonName
* @enum {'clear'|'spins'|'dropDown'}
* @typedef {string} Enums.TextBoxButtonName
* @enum {'clear'}
*/

/**
* @typedef {string} Enums.NumberBoxButtonName
* @enum {'clear'|'spins'}
*/

/**
* @typedef {string} Enums.DropDownEditorButtonName
* @enum {'clear'|'dropDown'}
*/

/**
Expand Down
156 changes: 81 additions & 75 deletions js/ui/diagram/ui.diagram.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,18 +77,25 @@ class Diagram extends Widget {
}
_renderLeftPanel($parent) {
const isServerSide = !hasWindow();
const dataSources = this._getDataSources();

const $leftPanel = $("<div>")
.appendTo($parent);

var customShapes = this.option("customShapes");
this._createComponent($leftPanel, DiagramLeftPanel, {
dataSources,
showCustomShapes: Array.isArray(customShapes) && customShapes.length > 0,
this._leftPanel = this._createComponent($leftPanel, DiagramLeftPanel, {
dataSources: this._getDataSources(),
customShapes: this._getCustomShapes(),
onShapeCategoryRendered: (e) => !isServerSide && this._diagramInstance.createToolbox(e.$element[0], 40, 8, {}, e.category),
onDataToolboxRendered: (e) => !isServerSide && this._diagramInstance.createDataSourceToolbox(e.key, e.$element[0])
});
}
_invalidateLeftPanel() {
if(this._leftPanel) {
this._leftPanel.option({
dataSources: this._getDataSources(),
customShapes: this._getCustomShapes(),
});
}
}

_renderRightPanel($parent) {
const drawer = this._createComponent($parent, Drawer, {
Expand Down Expand Up @@ -129,8 +136,10 @@ class Diagram extends Widget {
this._diagramInstance.onNodeInserted = this._raiseNodeInsertedAction.bind(this);
this._diagramInstance.onNodeUpdated = this._raiseNodeUpdatedAction.bind(this);
this._diagramInstance.onNodeRemoved = this._raiseNodeRemovedAction.bind(this);
this._diagramInstance.onToolboxDragStart = this._raiseToolboxDragStart.bind(this);
this._diagramInstance.onToolboxDragEnd = this._raiseToolboxDragEnd.bind(this);

this._updateCustomShapes(this.option("customShapes"));
this._updateCustomShapes(this._getCustomShapes());
this._refreshDataSources();
}
_refreshDataSources() {
Expand Down Expand Up @@ -177,6 +186,9 @@ class Diagram extends Widget {
});
}

_getDataSources() {
return this.option("dataSources") || {};
}
_createDiagramDataSource(parameters) {
const key = parameters.key || "0";
const title = parameters.title || "Data Source";
Expand All @@ -196,7 +208,9 @@ class Diagram extends Widget {
setType: this._createSetter(nodes.typeExpr || DIAGRAM_TYPE_FIELD),

getParentKey: this._createGetter(nodes.parentKeyExpr || DIAGRAM_PARENT_KEY_FIELD),
getItems: this._createGetter(nodes.itemsExpr || DIAGRAM_ITEMS_FIELD)
setParentKey: this._createSetter(nodes.parentKeyExpr || DIAGRAM_PARENT_KEY_FIELD),
getItems: this._createGetter(nodes.itemsExpr || DIAGRAM_ITEMS_FIELD),
setItems: this._createSetter(nodes.itemsExpr || DIAGRAM_ITEMS_FIELD)
},
edgeDataImporter: {
getKey: this._createGetter(edges.keyExpr || DIAGRAM_KEY_FIELD),
Expand All @@ -208,8 +222,12 @@ class Diagram extends Widget {
},
layoutType: this._getDataSourceLayoutType(parameters.layout)
};
this._addDiagramDataSource(key, data);
this._importDiagramDataSource(key);
const { DiagramCommand } = getDiagram();
this._diagramInstance.commandManager.getCommand(DiagramCommand.ImportDataSource).execute(data);

var dataSources = this._getDataSources();
dataSources[key] = data;
this.option("dataSources", dataSources);
}
_getDataSourceLayoutType(layout) {
const { DataLayoutType } = getDiagram();
Expand All @@ -220,39 +238,16 @@ class Diagram extends Widget {
return DataLayoutType.Sugiyama;
}
}
_getDataSources() {
return this.option("dataSources") || {};
}
_addDiagramDataSource(key, data) {
var dataSources = this._getDataSources();
dataSources[key] = data;
this.option("dataSources", dataSources);
}
_importDiagramDataSource(key) {
const { DiagramCommand } = getDiagram();

var dataSources = this._getDataSources();
if(dataSources[key]) {
this._diagramInstance.commandManager.getCommand(DiagramCommand.ImportDataSource).execute(dataSources[key]);
}
}
_deleteDiagramDataSource(key) {
this._closeDiagramDataSource(key);
this._removeDiagramDataSource(key);
}
_closeDiagramDataSource(key) {
const { DiagramCommand } = getDiagram();

var dataSources = this._getDataSources();
if(dataSources[key]) {
const { DiagramCommand } = getDiagram();
this._diagramInstance.commandManager.getCommand(DiagramCommand.CloseDataSource).execute(key);

delete dataSources[key];
this.option("dataSources", dataSources);
}
}
_removeDiagramDataSource(key) {
var dataSources = this._getDataSources();
delete dataSources[key];
this.option("dataSources", dataSources);
}

_nodesDataSourceChanged(nodes) {
this._nodes = nodes;
Expand Down Expand Up @@ -295,7 +290,9 @@ class Diagram extends Widget {
setType: this._createOptionSetter("nodes.typeExpr"),

getParentKey: this._createOptionGetter("nodes.parentKeyExpr"),
getItems: this._createOptionGetter("nodes.itemsExpr")
setParentKey: this._createOptionSetter("nodes.parentKeyExpr"),
getItems: this._createOptionGetter("nodes.itemsExpr"),
setItems: this._createOptionSetter("nodes.itemsExpr")
},
edgeDataImporter: {
getKey: this._createOptionGetter("edges.keyExpr"),
Expand Down Expand Up @@ -331,6 +328,9 @@ class Diagram extends Widget {
}
}

_getCustomShapes() {
return this.option("customShapes") || [];
}
_updateCustomShapes(customShapes, prevCustomShapes) {
if(Array.isArray(prevCustomShapes)) {
this._diagramInstance.removeCustomShapes(customShapes.map(
Expand Down Expand Up @@ -366,12 +366,12 @@ class Diagram extends Widget {
}
/**
* @name dxDiagramMethods.setData
* @publicName setData(data, keepExistingItems)
* @publicName setData(data, updateExistingItemsOnly)
* @param1 data:string
* @param2 keepExistingItems:boolean
* @param2 updateExistingItemsOnly:boolean
*/
setData(data, keepExistingItems) {
this._setDiagramData(data, keepExistingItems);
setData(data, updateExistingItemsOnly) {
this._setDiagramData(data, updateExistingItemsOnly);
this._raiseDataChangeAction();
}

Expand Down Expand Up @@ -581,39 +581,35 @@ class Diagram extends Widget {

/**
* @name dxDiagramOptions.customShapes
* @type Array<DiagramCustomShapeItem>
* @default null
*/
customShapes: [],
/**
* @name DiagramCustomShapeItem
* @type object
*/
/**
* @name DiagramCustomShapeItem.id
* @type Number
*/
/**
* @name DiagramCustomShapeItem.title
* @type String
*/
/**
* @name DiagramCustomShapeItem.svgUrl
* @type String
*/
/**
* @name DiagramCustomShapeItem.defaultWidth
* @type Number
*/
/**
* @name DiagramCustomShapeItem.defaultHeight
* @type Number
*/
/**
* @name DiagramCustomShapeItem.allowHasText
* @type Boolean
* @type Array<Object>
* @default []
*/

customShapes: [
/**
* @name dxDiagramOptions.customShapes.id
* @type Number
*/
/**
* @name dxDiagramOptions.customShapes.title
* @type String
*/
/**
* @name dxDiagramOptions.customShapes.svgUrl
* @type String
*/
/**
* @name dxDiagramOptions.customShapes.defaultWidth
* @type Number
*/
/**
* @name dxDiagramOptions.customShapes.defaultHeight
* @type Number
*/
/**
* @name dxDiagramOptions.customShapes.allowHasText
* @type Boolean
*/
],
/**
* @name dxDiagramOptions.export
* @type object
Expand Down Expand Up @@ -678,6 +674,16 @@ class Diagram extends Widget {
this._nodesOption.remove(key, callback);
}
}
_raiseToolboxDragStart() {
if(this._leftPanel) {
this._leftPanel.$element().addClass("dx-skip-gesture-event");
}
}
_raiseToolboxDragEnd() {
if(this._leftPanel) {
this._leftPanel.$element().removeClass("dx-skip-gesture-event");
}
}

_optionChanged(args) {
switch(args.name) {
Expand All @@ -692,13 +698,13 @@ class Diagram extends Widget {
break;
case "customShapes":
this._updateCustomShapes(args.value, args.previousValue);
this._invalidate();
this._invalidateLeftPanel();
break;
case "onDataChanged":
this._createDataChangeAction();
break;
case "dataSources":
this._invalidate();
this._invalidateLeftPanel();
break;
case "export":
this._toolbarInstance.option("export", this.option("export"));
Expand Down
33 changes: 23 additions & 10 deletions js/ui/diagram/ui.diagram.leftpanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ const DIAGRAM_LEFT_PANEL_CLASS = "dx-diagram-left-panel";
class DiagramLeftPanel extends Widget {
_init() {
super._init();
this._showCustomShapes = this.option("showCustomShapes");

this._dataSources = this.option("dataSources") || {};
this._customShapes = this.option("customShapes") || [];
this._onShapeCategoryRenderedAction = this._createActionByOption("onShapeCategoryRendered");
this._onDataToolboxRenderedAction = this._createActionByOption("onDataToolboxRendered");
}
Expand All @@ -27,12 +29,9 @@ class DiagramLeftPanel extends Widget {

this._renderAccordion($accordion);
}
_getDataSources() {
return this.option("dataSources") || {};
}
_getAccordionDataSource() {
var result = [];
var categories = ShapeCategories.load(this._showCustomShapes);
var categories = ShapeCategories.load(this._customShapes.length > 0);
for(var i = 0; i < categories.length; i++) {
result.push({
category: categories[i].category,
Expand All @@ -42,12 +41,11 @@ class DiagramLeftPanel extends Widget {
}
});
}
var dataSources = this._getDataSources();
for(var key in dataSources) {
if(dataSources.hasOwnProperty(key)) {
for(var key in this._dataSources) {
if(this._dataSources.hasOwnProperty(key)) {
result.push({
key,
title: dataSources[key].title,
title: this._dataSources[key].title,
onTemplate: (widget, $element, data) => {
this._onDataToolboxRenderedAction({ key: data.key, $element });
}
Expand All @@ -67,11 +65,26 @@ class DiagramLeftPanel extends Widget {
itemTemplate: (data, index, $element) => data.onTemplate(this, $element, data)
});
// TODO option for expanded item
if(this._showCustomShapes || this._hasDataSources) {
if(this._customShapes.length > 0 || this._hasDataSources) {
this._accordionInstance.collapseItem(0);
this._accordionInstance.expandItem(data.length - 1);
}
}

_optionChanged(args) {
switch(args.name) {
case "customShapes":
this._customShapes = args.value || [];
this._invalidate();
break;
case "dataSources":
this._dataSources = args.value || {};
this._invalidate();
break;
default:
super._optionChanged(args);
}
}
}

module.exports = DiagramLeftPanel;
8 changes: 8 additions & 0 deletions js/ui/drop_down_editor/ui.drop_down_editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,14 @@ var DropDownEditor = TextBox.inherit({
*/
showDropDownButton: true,

/**
* @name dxDropDownEditorOptions.buttons
* @type Array<Enums.DropDownEditorButtonName,dxTextEditorButton>
* @default undefined
* @inheritdoc
*/
buttons: void 0,

dropDownOptions: {},
popupPosition: this._getDefaultPopupPosition(),
onPopupInitialized: null,
Expand Down
Loading

0 comments on commit 8c2227b

Please sign in to comment.