Added undefined check when building object

dropdown
This commit is contained in:
NWalker4483 2021-06-21 12:50:19 -04:00
parent 4aa0bdd133
commit 235339a77c
4 changed files with 15 additions and 11 deletions

View File

@ -124,13 +124,13 @@ Editor.prototype.init = function () {
<nav> <nav>
<ul> <ul>
<li><a id="run_btn"></a></li> <li><a id="run_btn"></a></li>
<li class="submenu"><a>Scripts</a> <li class="submenu"><a>Validate to Load Scripts...</a>
<ul id="scripts_list"> <ul id="scripts_list">
</ul> </ul>
</li> </li>
<li class="submenu"><a>Data</a> <li class="submenu"><a>Data</a>
<ul id="objects_list"> <ul id="objects_list">
<li><a>Scripts</a></li> <li><a>Validate to Load Data...</a></li>
</ul> </ul>
</li> </li>
</ul> </ul>
@ -272,10 +272,15 @@ var triggerEvent = function (element, eventType) {
function recurseObject(data) { function recurseObject(data) {
var html = ""; var html = "";
for (const [key, value] of Object.entries(data)) { for (const [key, value] of Object.entries(data)) {
if (typeof value == 'object') {
if (typeof value == 'object' && value != undefined) {
html += `<li class="submenu"><a>${key}</a><ul>` + recurseObject(value) + `</ul><li>`; html += `<li class="submenu"><a>${key}</a><ul>` + recurseObject(value) + `</ul><li>`;
} else { } else {
html += `<li><a>${key}</a><div class="data-type">${typeof value}</div></li>`; let type = typeof value
if (value == undefined){
type = "undefined";
}
html += `<li><a>${key}</a><div class="data-type">${type}</div></li>`;
} }
} }
return html return html

View File

@ -1,8 +1,6 @@
import Editor from './Editor'; import Editor from './Editor';
import CoreModule from 'diagram-js/lib/core';
export default { export default {
// __depends__: [ CoreModule ], // {2} __init__: [ 'editor' ],
__init__: [ 'editor' ], // {3} editor: [ 'type', Editor ]
editor: [ 'type', Editor ] // {1}
}; };

2
package-lock.json generated
View File

@ -1,6 +1,6 @@
{ {
"name": "diagram-js-code-editor", "name": "diagram-js-code-editor",
"version": "1.0.6", "version": "1.0.7",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {

View File

@ -1,6 +1,6 @@
{ {
"name": "diagram-js-code-editor", "name": "diagram-js-code-editor",
"version": "1.0.6", "version": "1.1.0",
"description": "A code-editor for diagram-js", "description": "A code-editor for diagram-js",
"main": "dist/index.js", "main": "dist/index.js",
"module": "dist/index.esm.js", "module": "dist/index.esm.js",
@ -13,7 +13,8 @@
"test": "", "test": "",
"distro": "run-s build test:build", "distro": "run-s build test:build",
"build": "rollup -c", "build": "rollup -c",
"test:build": "" "test:build": "",
"bump": "npm run build; npm publish"
}, },
"repository": { "repository": {
"type": "git", "type": "git",