Skip to content

Commit

Permalink
ADD modal popup to execute transactions
Browse files Browse the repository at this point in the history
  • Loading branch information
serapath authored and yann300 committed Dec 6, 2017
1 parent 7974b68 commit 07ec843
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 13 deletions.
30 changes: 20 additions & 10 deletions src/app/tabs/run-tab.js
Original file line number Diff line number Diff line change
Expand Up @@ -278,18 +278,28 @@ function makeRecorder (appAPI, appEvents) {
copy(txJSON)
modalDialogCustom.alert(txJSON)
}
runButton.onclick = () => { // on modal OR run tab
var txArray = recorder.getAll()
udapp.runTx(txArray, CALLBACK) // ???
// OR
// txArray.forEach(tx => udapp.runTx(tx, CALLBACK)) // ???
runButton.onclick = () => {
var opts = { title: `Enter Transactions`, text: `Paste the array of transaction you want to replay here`, inputValue: '', multiline: true }
modalDialogCustom.prompt(opts, function confirm (json = '[]') {
try {
var txArray = JSON.parse(json)
} catch (e) {
modalDialogCustom.alert('Invalid JSON, please try again')
}
if (txArray.length) {
txArray.forEach(tx => udapp.runTx(tx, CALLBACK))
}
}, function cancel () { })
}
function CALLBACK () {
function CALLBACK (...args) {
console.log(args)
/*
at each callback call, if the transaction succeed and if this is a creation transaction, we should call
runtab.addInstance( ... ) which basically do:
instanceContainer.appendChild(appAPI.udapp().renderInstance(contract, address,
selectContractNames.value))
at each callback call, if the transaction succeed and if this is a creation transaction,
we should call
runtab.addInstance( ... ) // which basically do:
instanceContainer.appendChild(appAPI.udapp().renderInstance(contract, address, selectContractNames.value))
*/
}
return el
Expand Down
9 changes: 6 additions & 3 deletions src/app/ui/modal-dialog-custom.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,13 @@ module.exports = {
alert: function (text) {
modal('', yo`<div>${text}</div>`, null, { label: null })
},
prompt: function (title, text, inputValue, ok, cancel) {
prompt: function ({ title, text, inputValue, multiline }, ok, cancel) {
if (!inputValue) inputValue = ''
modal(title,
yo`<div>${text}<div><input type='text' name='prompt_text' id='prompt_text' class="${css['prompt_text']}" value='${inputValue}' ></div></div>`,
var input = multiline
? yo`<textarea id="prompt_text" class=${css.prompt_text} rows="4" cols="50"></textarea>`
: yo`<input type='text' name='prompt_text' id='prompt_text' class="${css['prompt_text']}" value='${inputValue}' >`

modal(title, yo`<div>${text}<div>${input}</div></div>`,
{
fn: () => { if (typeof ok === 'function') ok(document.getElementById('prompt_text').value) }
},
Expand Down

0 comments on commit 07ec843

Please sign in to comment.