ADD modal popup to execute transactions

pull/1/head
serapath 7 years ago committed by yann300
parent 7974b685fc
commit 07ec843256
  1. 30
      src/app/tabs/run-tab.js
  2. 9
      src/app/ui/modal-dialog-custom.js

@ -278,18 +278,28 @@ function makeRecorder (appAPI, appEvents) {
copy(txJSON) copy(txJSON)
modalDialogCustom.alert(txJSON) modalDialogCustom.alert(txJSON)
} }
runButton.onclick = () => { // on modal OR run tab runButton.onclick = () => {
var txArray = recorder.getAll() var opts = { title: `Enter Transactions`, text: `Paste the array of transaction you want to replay here`, inputValue: '', multiline: true }
udapp.runTx(txArray, CALLBACK) // ??? modalDialogCustom.prompt(opts, function confirm (json = '[]') {
// OR try {
// txArray.forEach(tx => udapp.runTx(tx, CALLBACK)) // ??? 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 at each callback call, if the transaction succeed and if this is a creation transaction,
runtab.addInstance( ... ) which basically do: we should call
instanceContainer.appendChild(appAPI.udapp().renderInstance(contract, address,
selectContractNames.value)) runtab.addInstance( ... ) // which basically do:
instanceContainer.appendChild(appAPI.udapp().renderInstance(contract, address, selectContractNames.value))
*/ */
} }
return el return el

@ -11,10 +11,13 @@ module.exports = {
alert: function (text) { alert: function (text) {
modal('', yo`<div>${text}</div>`, null, { label: null }) 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 = '' if (!inputValue) inputValue = ''
modal(title, var input = multiline
yo`<div>${text}<div><input type='text' name='prompt_text' id='prompt_text' class="${css['prompt_text']}" value='${inputValue}' ></div></div>`, ? 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) } fn: () => { if (typeof ok === 'function') ok(document.getElementById('prompt_text').value) }
}, },

Loading…
Cancel
Save