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

@ -137,29 +137,26 @@ module.exports = class TestTab {
}
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)
self.data.selectedTests = selectedTests
var selectAll = document.querySelector('[id="checkAllTests"]')
let checkAll = document.querySelector('[id="checkAllTests"]')
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) {
var checkBoxes = document.querySelectorAll('input.singleTest')
var isAnySelected = document.querySelectorAll('input.singleTest:checked').length !== 0
const checkBoxes = document.querySelectorAll('.singleTest')
const selectionsCount = document.querySelectorAll('.singleTest:checked').length
// checks/unchecks all
checkBoxes.forEach(function (checkBox) {
checkBox.checked = !isAnySelected
})
event.target.checked = !isAnySelected
checkBoxes.forEach(checkbox => checkbox.checked = !selectionsCount)
event.target.checked = !selectionsCount
}
var runTests = function () {
testsOutput.innerHTML = ''
testsSummary.innerHTML = ''
@ -195,12 +192,12 @@ module.exports = class TestTab {
<br/>
For more details, see
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 class="${css.tests}">
${self.testList}
<div class=${css.buttons}>
<div class=${css.runButton} onclick=${runTests}>Run Tests</div>
<div class="${css.buttons}">
<div class="${css.runButton}" onclick="${runTests}">Run Tests</div>
<label class="${css.label}" for="checkAllTests">
<input id="checkAllTests"
type="checkbox"

Loading…
Cancel
Save