From 6cdd2ff5c3fd6f1ffd0d33105685ab152a762c6a Mon Sep 17 00:00:00 2001 From: dcore94 Date: Wed, 21 Jun 2023 15:10:57 +0200 Subject: [PATCH 1/6] avoid resetting method after first save --- ccp/js/methodeditorcontroller.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ccp/js/methodeditorcontroller.js b/ccp/js/methodeditorcontroller.js index a2970ef..b340c0a 100644 --- a/ccp/js/methodeditorcontroller.js +++ b/ccp/js/methodeditorcontroller.js @@ -205,10 +205,10 @@ class CCPMethodEditorController extends HTMLElement{ return resp.text() }else throw "Error saving process: " + resp.status }).then(data=>{ - if(!this.#isupdate){ - this.resetMethod() - } this.unlockRender() + if(!this.#isupdate){ + this.editMethod(this.#current.id) + } }).catch(err=>{ alert(err) this.unlockRender() From 4f89d5e8f1bfb041b23b026579763119fa73ab0e Mon Sep 17 00:00:00 2001 From: dcore94 Date: Wed, 21 Jun 2023 15:27:42 +0200 Subject: [PATCH 2/6] reuse return from save operation to switch to updatable form --- ccp/js/methodeditorcontroller.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/ccp/js/methodeditorcontroller.js b/ccp/js/methodeditorcontroller.js index b340c0a..e534c30 100644 --- a/ccp/js/methodeditorcontroller.js +++ b/ccp/js/methodeditorcontroller.js @@ -205,10 +205,13 @@ class CCPMethodEditorController extends HTMLElement{ return resp.text() }else throw "Error saving process: " + resp.status }).then(data=>{ - this.unlockRender() if(!this.#isupdate){ - this.editMethod(this.#current.id) + this.#current = data + this.#isupdate = true + this.#tmp_inputs = Object.keys(this.#current.inputs).map(k=>this.#current.inputs[k]) + this.#tmp_outputs = Object.keys(this.#current.outputs).map(k=>this.#current.outputs[k]) } + this.unlockRender() }).catch(err=>{ alert(err) this.unlockRender() @@ -353,7 +356,7 @@ class CCPMethodEditorController extends HTMLElement{ this.#rootdoc.querySelector(".plexiglass").classList.toggle("d-none") this.render() this.#locked = false - this.parentElement.scrollIntoViewIfNeeded() + if(this.parentElement) this.parentElement.scrollIntoViewIfNeeded(); } render(){ From 0b32d8115bef6eb0bb69dbc8f0a20a9c844b39ed Mon Sep 17 00:00:00 2001 From: dcore94 Date: Wed, 21 Jun 2023 15:38:31 +0200 Subject: [PATCH 3/6] expected data is now json --- ccp/js/methodeditorcontroller.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ccp/js/methodeditorcontroller.js b/ccp/js/methodeditorcontroller.js index e534c30..84fe2f8 100644 --- a/ccp/js/methodeditorcontroller.js +++ b/ccp/js/methodeditorcontroller.js @@ -202,7 +202,7 @@ class CCPMethodEditorController extends HTMLElement{ this.#boot.secureFetch(url, args).then( (resp)=>{ if(resp.status === 201 || resp.status === 204){ - return resp.text() + return resp.json() }else throw "Error saving process: " + resp.status }).then(data=>{ if(!this.#isupdate){ From 771294e02cc08e1a6bd32916ccb28c144c7654d2 Mon Sep 17 00:00:00 2001 From: dcore94 Date: Wed, 21 Jun 2023 15:42:11 +0200 Subject: [PATCH 4/6] expected data is now json but only for first creation --- ccp/js/methodeditorcontroller.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ccp/js/methodeditorcontroller.js b/ccp/js/methodeditorcontroller.js index 84fe2f8..c738577 100644 --- a/ccp/js/methodeditorcontroller.js +++ b/ccp/js/methodeditorcontroller.js @@ -202,11 +202,11 @@ class CCPMethodEditorController extends HTMLElement{ this.#boot.secureFetch(url, args).then( (resp)=>{ if(resp.status === 201 || resp.status === 204){ - return resp.json() + return resp.text() }else throw "Error saving process: " + resp.status }).then(data=>{ if(!this.#isupdate){ - this.#current = data + this.#current = JSon.parse(data) this.#isupdate = true this.#tmp_inputs = Object.keys(this.#current.inputs).map(k=>this.#current.inputs[k]) this.#tmp_outputs = Object.keys(this.#current.outputs).map(k=>this.#current.outputs[k]) From 6d779e3862dcd93ff16e354b124e76074164f314 Mon Sep 17 00:00:00 2001 From: dcore94 Date: Wed, 21 Jun 2023 15:44:31 +0200 Subject: [PATCH 5/6] properly reset after deletion --- ccp/js/methodeditorcontroller.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ccp/js/methodeditorcontroller.js b/ccp/js/methodeditorcontroller.js index c738577..5619af7 100644 --- a/ccp/js/methodeditorcontroller.js +++ b/ccp/js/methodeditorcontroller.js @@ -236,6 +236,8 @@ class CCPMethodEditorController extends HTMLElement{ return null }else throw "Error deleting method: " + resp.status }).then(data=>{ + this.#isupdate = false + this.initMethod() this.unlockRender() }).catch(err=>{ alert(err) From 5d3d3542cbcbd2820e6e72eae6ba87d06ccce6a3 Mon Sep 17 00:00:00 2001 From: dcore94 Date: Wed, 21 Jun 2023 15:46:34 +0200 Subject: [PATCH 6/6] fixed typo --- ccp/js/methodeditorcontroller.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ccp/js/methodeditorcontroller.js b/ccp/js/methodeditorcontroller.js index 5619af7..bac2927 100644 --- a/ccp/js/methodeditorcontroller.js +++ b/ccp/js/methodeditorcontroller.js @@ -206,7 +206,7 @@ class CCPMethodEditorController extends HTMLElement{ }else throw "Error saving process: " + resp.status }).then(data=>{ if(!this.#isupdate){ - this.#current = JSon.parse(data) + this.#current = JSON.parse(data) this.#isupdate = true this.#tmp_inputs = Object.keys(this.#current.inputs).map(k=>this.#current.inputs[k]) this.#tmp_outputs = Object.keys(this.#current.outputs).map(k=>this.#current.outputs[k])