From 8c24c0dcec0cd12f36a3965fdf801da098a9fa0b Mon Sep 17 00:00:00 2001 From: ZhangGe6 Date: Thu, 28 Apr 2022 14:21:15 +0800 Subject: [PATCH] fix the bug of `output missing` after delete-refresh-reset, gonna to polish the layout --- static/view-sidebar.js | 10 ++++++++++ static/view.js | 21 ++++++++++++++++----- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/static/view-sidebar.js b/static/view-sidebar.js index e55b795..a1b14aa 100644 --- a/static/view-sidebar.js +++ b/static/view-sidebar.js @@ -209,6 +209,7 @@ sidebar.NodeSidebar = class { this._addButton('Recover'); this._addButton('Download'); this._addButton('RefreshGraph'); + this._addButton('Reset'); // console.log(this._host._view._graph._nodes) // console.log(node) @@ -342,6 +343,15 @@ sidebar.NodeSidebar = class { this._host._view._updateGraph(); }); } + + if (title === 'Reset') { + // console.log('pressed') + buttonElement.addEventListener('click', () => { + this._host._view._graph.resetGraph(); + this._host._view._updateGraph(); + }); + } + } toggleInput(name) { diff --git a/static/view.js b/static/view.js index f433a79..5a5d48b 100644 --- a/static/view.js +++ b/static/view.js @@ -1026,11 +1026,11 @@ view.Graph = class extends grapher.Graph { } for (const output of graph.outputs) { - // My code - if (this._modelNodeName2State.get(output.name) == 'Deleted') { - // console.log(this._modelNodeName2State.get(node.name)) - continue; - } + // // My code + // if (this._modelNodeName2State.get(output.name) == 'Deleted') { + // // console.log(this._modelNodeName2State.get(node.name)) + // continue; + // } const viewOutput = this.createOutput(output); for (const argument of output.arguments) { @@ -1074,6 +1074,17 @@ view.Graph = class extends grapher.Graph { } } + resetGraph() { + for (const nodeId of this.nodes.keys()) { + const node = this.node(nodeId); + console.log(node.label.modelNodeName) + this._modelNodeName2State.set(node.label.modelNodeName, 'Exist') + } + + console.log(this._modelNodeName2State) + + } + build(document, origin) { for (const argument of this._arguments.values()) {