From 487e3f8348b27c305a3f12a643530392eca8e65c Mon Sep 17 00:00:00 2001 From: yann300 Date: Mon, 14 Aug 2017 13:20:34 +0200 Subject: [PATCH] fix 'no instance text' --- src/app/tabs/run-tab.js | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/app/tabs/run-tab.js b/src/app/tabs/run-tab.js index c21ffdaa3d..a610e7aab9 100644 --- a/src/app/tabs/run-tab.js +++ b/src/app/tabs/run-tab.js @@ -166,6 +166,7 @@ function runTab (container, appAPI, appEvents, opts) { } fillAccountsList(appAPI, el) instanceContainer.innerHTML = '' // clear the instances list + noInstancesText.style.display = 'block' instanceContainer.appendChild(noInstancesText) }) selectExEnv.value = appAPI.executionContextProvider() @@ -247,7 +248,6 @@ function contractDropdown (appAPI, appEvents, instanceContainer) { selectContractNames.addEventListener('change', setInputParamsPlaceHolder) - var init = false // ADD BUTTONS AT ADDRESS AND CREATE function createInstance () { var contractNames = document.querySelector(`.${css.contractNames.classNames[0]}`) @@ -258,12 +258,13 @@ function contractDropdown (appAPI, appEvents, instanceContainer) { txFormat.buildData(contract, contracts, true, constructor, args, appAPI.udapp(), appAPI.executionContext(), (error, data) => { if (!error) { txExecution.createContract(data, appAPI.udapp(), (error, txResult) => { - var address = appAPI.executionContext().isVM() ? txResult.result.createdAddress : txResult.result.contractAddress - if (!init) { - instanceContainer.innerHTML = '' - init = true + if (!error) { + noInstancesText.style.display = 'none' + var address = appAPI.executionContext().isVM() ? txResult.result.createdAddress : txResult.result.contractAddress + instanceContainer.appendChild(appAPI.udapp().renderInstance(contract, address, selectContractNames.value)) + } else { + modalDialogCustom.alert(error) } - instanceContainer.appendChild(appAPI.udapp().renderInstance(contract, address, selectContractNames.value)) }) } else { modalDialogCustom.alert(error) @@ -272,10 +273,7 @@ function contractDropdown (appAPI, appEvents, instanceContainer) { } function loadFromAddress (appAPI) { - if (!init) { - instanceContainer.innerHTML = '' - init = true - } + noInstancesText.style.display = 'none' var contractNames = document.querySelector(`.${css.contractNames.classNames[0]}`) var contract = appAPI.getContracts()[contractNames.children[contractNames.selectedIndex].innerText] var address = atAddressButtonInput.value