From 0cf7a3dd1576c79e0d35afe196f1bef8bff74b56 Mon Sep 17 00:00:00 2001 From: LianaHus Date: Thu, 4 Oct 2018 14:40:16 +0200 Subject: [PATCH] Added check all/ uncheck all cheeckbox to StaticAnalysisTab renamed local vars to avoid warning --- src/app/staticanalysis/staticAnalysisView.js | 57 +++++++++++++++++--- 1 file changed, 51 insertions(+), 6 deletions(-) diff --git a/src/app/staticanalysis/staticAnalysisView.js b/src/app/staticanalysis/staticAnalysisView.js index e12d161d49..9303ea0084 100644 --- a/src/app/staticanalysis/staticAnalysisView.js +++ b/src/app/staticanalysis/staticAnalysisView.js @@ -18,7 +18,7 @@ function staticAnalysisView (localRegistry) { this.event = new EventManager() this.view = null this.runner = new StaticAnalysisRunner() - this.modulesView = renderModules(this.runner.modules()) + this.modulesView = this.renderModules() this.lastCompilationResult = null this.lastCompilationSource = null self._components = {} @@ -53,7 +53,23 @@ staticAnalysisView.prototype.render = function () {
- + +
@@ -118,10 +134,34 @@ staticAnalysisView.prototype.run = function () { } } -module.exports = staticAnalysisView +staticAnalysisView.prototype.checkAll = function (event) { + if (!this.view) { + return + } + var all = this.view.querySelectorAll('[name="staticanalysismodule"]') + var isAnySelected = false + for (var i = 0; i < all.length; i++) { + if (all[i].checked === true) { + isAnySelected = true + break + } + } + for (var j = 0; j < all.length; j++) { + all[j].checked = !isAnySelected + } + event.target.checked = !isAnySelected +} -function renderModules (modules) { - var groupedModules = utils.groupBy(preProcessModules(modules), 'categoryId') +staticAnalysisView.prototype.checkModule = function (event) { + var selectAll = this.view.querySelector('[id="checkallstaticanalysis" ]') + if (event.target.checked) { + selectAll.checked = true + } +} + +staticAnalysisView.prototype.renderModules = function () { + var self = this + var groupedModules = utils.groupBy(preProcessModules(self.runner.modules()), 'categoryId') return Object.keys(groupedModules).map((categoryId, i) => { var category = groupedModules[categoryId] var entriesDom = category.map((item, i) => { @@ -131,7 +171,10 @@ function renderModules (modules) { type="checkbox" name="staticanalysismodule" index=${item._index} - checked="true" style="vertical-align:bottom"> + checked="true" + style="vertical-align:bottom" + onclick="${function (event) { self.checkModule(event) }}" + > ${item.name} ${item.description} @@ -144,6 +187,8 @@ function renderModules (modules) { }) } +module.exports = staticAnalysisView + function preProcessModules (arr) { return arr.map((item, i) => { item['_index'] = i