check all for tests

pull/1/head
LianaHus 6 years ago
parent 1b3c35788e
commit b5660d263f
  1. 39
      src/app/staticanalysis/staticAnalysisView.js
  2. 29
      src/app/tabs/test-tab.js

@ -50,7 +50,7 @@ staticAnalysisView.prototype.render = function () {
${this.modulesView} ${this.modulesView}
</div> </div>
<div class="${css.buttons}"> <div class="${css.buttons}">
<button class=${css.buttonRun} onclick=${function () { self.run() }} >Run</button> <button class="${css.buttonRun}" onclick="${function () { self.run() }}" >Run</button>
<label class="${css.label}" for="autorunstaticanalysis"> <label class="${css.label}" for="autorunstaticanalysis">
<input id="autorunstaticanalysis" <input id="autorunstaticanalysis"
type="checkbox" type="checkbox"
@ -59,8 +59,8 @@ staticAnalysisView.prototype.render = function () {
> >
Auto run Auto run
</label> </label>
<label class="${css.label}" for="checkallstaticanalysis"> <label class="${css.label}" for="checkAllTests">
<input id="checkallstaticanalysis" <input id="checkAllTests"
type="checkbox" type="checkbox"
onclick="${function (event) { self.checkAll(event) }}" onclick="${function (event) { self.checkAll(event) }}"
style="vertical-align:bottom" style="vertical-align:bottom"
@ -135,27 +135,25 @@ staticAnalysisView.prototype.run = function () {
} }
} }
staticAnalysisView.prototype.checkAll = function (event) { staticAnalysisView.prototype.checkModule = function (event) {
if (!this.view) { let selected = document.querySelectorAll('[name="staticanalysismodule"]:checked')
return let checkAll = document.querySelector('[id="checkAllTests"]')
} if (event.target.checked) {
var all = this.view.querySelectorAll('[id="staticanalysismodule]"') checkAll.checked = true
var isAnySelected = this.view.querySelectorAll('[id="staticanalysismodule]":checked').length !== 0; } else if (!selected.length) {
checkAll.checked = false
for (var j = 0; j < all.length; j++) {
all[j].checked = !isAnySelected
} }
event.target.checked = !isAnySelected
} }
staticAnalysisView.prototype.checkModule = function (event) { staticAnalysisView.prototype.checkAll = function (event) {
var selectAll = this.view.querySelector('[id="checkallstaticanalysis"]') if (!this.view) {
var selected = this.view.querySelectorAll('[id="staticanalysismodule]":checked') return
if (event.target.checked) {
selectAll.checked = true
} else if (selected.length === 0) {
selectAll.checked = false
} }
var checkBoxes = this.view.querySelectorAll('[name="staticanalysismodule"]')
var selectionsCount = this.view.querySelectorAll('[name="staticanalysismodule"]:checked').length;
// checks/unchecks all
checkBoxes.forEach(checkbox => checkbox.checked = !selectionsCount)
event.target.checked = !selectionsCount
} }
staticAnalysisView.prototype.renderModules = function () { staticAnalysisView.prototype.renderModules = function () {
@ -168,6 +166,7 @@ staticAnalysisView.prototype.renderModules = function () {
<label class="${css.label}"> <label class="${css.label}">
<input id="staticanalysismodule_${categoryId}_${i}" <input id="staticanalysismodule_${categoryId}_${i}"
type="checkbox" type="checkbox"
class="staticAnalysisItem"
name="staticanalysismodule" name="staticanalysismodule"
index=${item._index} index=${item._index}
checked="true" checked="true"

@ -137,29 +137,26 @@ module.exports = class TestTab {
} }
function toggleCheckbox (e, test) { function toggleCheckbox (e, test) {
var selectedTests = self.data.selectedTests let selectedTests = self.data.selectedTests
selectedTests = e.target.checked ? [...selectedTests, test] : selectedTests.filter(el => el !== test) selectedTests = e.target.checked ? [...selectedTests, test] : selectedTests.filter(el => el !== test)
self.data.selectedTests = selectedTests self.data.selectedTests = selectedTests
var selectAll = document.querySelector('[id="checkAllTests"]') let checkAll = document.querySelector('[id="checkAllTests"]')
if (e.target.checked) { if (e.target.checked) {
selectAll.checked = true checkAll.checked = true
} else if (!selectedTests.length) {
checkAll.checked = false
} }
if (selectedTests.length === 0) {
selectAll.checked = false
}
} }
function checkAll (event) { function checkAll (event) {
var checkBoxes = document.querySelectorAll('input.singleTest') const checkBoxes = document.querySelectorAll('.singleTest')
var isAnySelected = document.querySelectorAll('input.singleTest:checked').length !== 0 const selectionsCount = document.querySelectorAll('.singleTest:checked').length
// checks/unchecks all // checks/unchecks all
checkBoxes.forEach(function (checkBox) { checkBoxes.forEach(checkbox => checkbox.checked = !selectionsCount)
checkBox.checked = !isAnySelected event.target.checked = !selectionsCount
})
event.target.checked = !isAnySelected
} }
var runTests = function () { var runTests = function () {
testsOutput.innerHTML = '' testsOutput.innerHTML = ''
testsSummary.innerHTML = '' testsSummary.innerHTML = ''
@ -195,12 +192,12 @@ module.exports = class TestTab {
<br/> <br/>
For more details, see For more details, see
How to test smart contracts guide in our documentation. How to test smart contracts guide in our documentation.
<div class=${css.generateTestFile} onclick=${generateTestFile}>Generate test file</div> <div class="${css.generateTestFile}" onclick="${generateTestFile}">Generate test file</div>
</div> </div>
<div class="${css.tests}"> <div class="${css.tests}">
${self.testList} ${self.testList}
<div class=${css.buttons}> <div class="${css.buttons}">
<div class=${css.runButton} onclick=${runTests}>Run Tests</div> <div class="${css.runButton}" onclick="${runTests}">Run Tests</div>
<label class="${css.label}" for="checkAllTests"> <label class="${css.label}" for="checkAllTests">
<input id="checkAllTests" <input id="checkAllTests"
type="checkbox" type="checkbox"

Loading…
Cancel
Save