From b2baf6361c4755c72f601bb0842b6371fc45de87 Mon Sep 17 00:00:00 2001 From: Catouse Date: Mon, 20 Jan 2020 11:04:13 +0800 Subject: [PATCH] * improve contextmenu in flowchart. --- docs/examples/flowchart.fsm.js | 1 - src/js/flowchart.js | 31 +++++++++++++++++-------------- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/docs/examples/flowchart.fsm.js b/docs/examples/flowchart.fsm.js index 655c4b228..12df30cff 100644 --- a/docs/examples/flowchart.fsm.js +++ b/docs/examples/flowchart.fsm.js @@ -242,7 +242,6 @@ if ($.zui.FlowChart) { $.zui.FlowChart.addPlugin('fsm', { defaultOptions: defaultOptions, style: [ - '.flowchart-contextmenu {min-width: 360px}', '.flowchart-contextmenu .col-xs-4 {width: 25%}', '#{id} .flowchart-element-fsm_fork, #{id} .flowchart-element-fsm_merge {align-items: flex-start!important;}', '#{id} .flowchart-element-FSM_ActState:before {content: " "; position: absolute; width: 30px; height: 30px; top: 4px; left: 4px; background: #888; border-radius: 50%; border: 1px solid #333}' diff --git a/src/js/flowchart.js b/src/js/flowchart.js index 468b5627f..2125cc855 100644 --- a/src/js/flowchart.js +++ b/src/js/flowchart.js @@ -2631,6 +2631,17 @@ e.returnValue = false; return false; }); + + $(document).on('change', '.flowchart-' + that.id + '-type-selector', function() { + var $select = $(this); + var nodeID = $select.data('id'); + var node = that.getElement(nodeID); + if (node) { + node.changeType($select.val()); + that.render(node); + } + $.zui.ContextMenu.hide(); + }); } $canvas.on('click', function(e) { @@ -2970,30 +2981,22 @@ } var items = []; if (!that.options.readonly) { - var typeButtonsHTML = []; + var typeOptions = []; $.each(that.types, function(name, typeInfo) { if ((typeInfo.isNode === ele.isNode) && !typeInfo.internal) { - typeButtonsHTML.push('
' + (typeInfo.displayName || typeInfo.name) + '
'); + typeOptions.push('' + (typeInfo.displayName || typeInfo.name) + ''); } }); items.push({ id: 'type', html: [ - '
', - '' + that.lang.type + '', - '
', - typeButtonsHTML.join(''), + '
', + '' + that.lang.type + '', + '