From eebccbd4fbd385e257c0863281c7e576586aa8cb Mon Sep 17 00:00:00 2001 From: serapath Date: Thu, 19 Oct 2017 13:04:08 +0200 Subject: [PATCH] FIX custom modal multiline prompt --- src/app/tabs/run-tab.js | 2 +- src/app/ui/modal-dialog-custom.js | 19 ++++++++++++++----- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/app/tabs/run-tab.js b/src/app/tabs/run-tab.js index ddc50177c1..905751a24f 100644 --- a/src/app/tabs/run-tab.js +++ b/src/app/tabs/run-tab.js @@ -285,7 +285,7 @@ function makeRecorder (appAPI, appEvents) { } 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 = '[]') { + modalDialogCustom.promptMulti(opts, function confirm (json = '[]') { try { var txArray = JSON.parse(json) } catch (e) { diff --git a/src/app/ui/modal-dialog-custom.js b/src/app/ui/modal-dialog-custom.js index f8fa36ee42..07d47e3f12 100644 --- a/src/app/ui/modal-dialog-custom.js +++ b/src/app/ui/modal-dialog-custom.js @@ -11,12 +11,21 @@ module.exports = { alert: function (text) { modal('', yo`
${text}
`, null, { label: null }) }, - prompt: function ({ title, text, inputValue, multiline }, ok, cancel) { + prompt: function (title, text, inputValue, ok, cancel) { if (!inputValue) inputValue = '' - var input = multiline - ? yo`` - : yo`` - + var input = yo`` + modal(title, yo`
${text}
${input}
`, + { + fn: () => { if (typeof ok === 'function') ok(document.getElementById('prompt_text').value) } + }, + { + fn: () => { if (typeof cancel === 'function') cancel() } + } + ) + }, + promptMulti: function ({ title, text, inputValue }, ok, cancel) { + if (!inputValue) inputValue = '' + var input =yo`` modal(title, yo`
${text}
${input}
`, { fn: () => { if (typeof ok === 'function') ok(document.getElementById('prompt_text').value) }