From cdab7c36cb64704237faf1bafd042f1638a99849 Mon Sep 17 00:00:00 2001 From: Aniket-Engg Date: Mon, 22 Nov 2021 13:50:14 +0530 Subject: [PATCH] select all --- .../src/lib/solidity-unit-testing.tsx | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/libs/remix-ui/solidity-unit-testing/src/lib/solidity-unit-testing.tsx b/libs/remix-ui/solidity-unit-testing/src/lib/solidity-unit-testing.tsx index 8515bf0ae6..d7d928ac2b 100644 --- a/libs/remix-ui/solidity-unit-testing/src/lib/solidity-unit-testing.tsx +++ b/libs/remix-ui/solidity-unit-testing/src/lib/solidity-unit-testing.tsx @@ -249,21 +249,17 @@ export const SolidityUnitTesting = (props: any) => { } const checkAll = (event: any) => { - console.log('checkAll --event.target.checked-->', event.target.checked) - const checkBoxes = document.getElementsByClassName('singleTest') - const checkboxesLabels = document.getElementsByClassName('singleTestLabel') - // checks/unchecks all - for (let i = 0; i < checkBoxes.length; i++) { - if(event.target.checked) checkBoxes[i].setAttribute('checked', 'checked') - else checkBoxes[i].removeAttribute('checked') - toggleCheckbox(event.target.checked, checkboxesLabels[i].innerHTML) - } + testFiles.forEach((testFileObj) => testFileObj.checked = event.target.checked) + setTestFiles(testFiles) + setCheckSelectAll(event.target.checked) } const updateTestFileList = () => { console.log('updateTestFileList--tests->', allTests) - if(allTests?.length) + if(allTests?.length) { testFiles = allTests.map((testFile) => { return {'fileName': testFile, 'checked': true }}) + setCheckSelectAll(true) + } else testFiles = [] setTestFiles(testFiles) @@ -360,7 +356,7 @@ export const SolidityUnitTesting = (props: any) => { const elemId = `singleTest${testFileObj.fileName}` return (
- toggleCheckbox(e.target.checked, testFileObj.fileName)} type="checkbox" checked={testFileObj.fileName}/> + toggleCheckbox(e.target.checked, testFileObj.fileName)} type="checkbox" checked={testFileObj.checked}/>
)