]> source.dussan.org Git - sonarqube.git/commitdiff
Component Viewer: toggle issues
authorStas Vilchik <vilchiks@gmail.com>
Wed, 30 Apr 2014 06:40:07 +0000 (12:40 +0600)
committerStas Vilchik <vilchiks@gmail.com>
Wed, 30 Apr 2014 06:40:07 +0000 (12:40 +0600)
sonar-server/src/main/coffee/component-viewer/main.coffee
sonar-server/src/main/coffee/component-viewer/source.coffee

index 05d2b035df8ea009c5dc0f5049ba03b38377f927..a060404b11750769a1743277612efe2571340f70 100644 (file)
@@ -39,7 +39,7 @@ define [
       sourceRegion: '.component-viewer-source'
 
 
-    initialize: ->
+    initialize: (options) ->
       @workspace = new Backbone.Collection()
       @component = new Backbone.Model()
       @workspaceView = new WorkspaceView
@@ -57,6 +57,7 @@ define [
         duplications: false
         scm: false
         workspace: false
+      @settings.set options.settings
 
 
     onRender: ->
@@ -143,6 +144,7 @@ define [
         @workspace.where(key: key).forEach (model) =>
           model.set 'component': @component.toJSON()
         @render()
+        if @settings.get('issues') then @showIssues() else @hideIssues()
         if @settings.get('coverage') then @showCoverage() else @hideCoverage()
         if @settings.get('duplications') then @showDuplications() else @hideDuplications()
 
index e338385c399ae67fdb76361856c09240e456ae74..f4716811c7943f895a0895131d236fedde44dc14 100644 (file)
@@ -23,14 +23,13 @@ define [
     expandTemplate: Templates['code-expand']
 
     LINES_AROUND_ISSUE = 4
-    LINES_AROUND_COVERAGE = 4
-    LINES_AROUND_DUPLICATION = 4
     EXPAND_LINES = 20
 
 
     events:
       'click .js-toggle-settings': 'toggleSettings'
       'click .js-toggle-measures': 'toggleMeasures'
+      'change #source-issues': 'toggleIssues'
       'change #source-coverage': 'toggleCoverage'
       'change #source-duplications': 'toggleDuplications'
       'change #source-workspace': 'toggleWorkspace'
@@ -99,24 +98,27 @@ define [
       @$('.component-viewer-measures-section').toggleClass 'brief'
 
 
-    toggleCoverage: (e) ->
+    toggleSetting: (e, show, hide) ->
       @showBlocks = []
       active = $(e.currentTarget).is ':checked'
       @showSettings = true
-      if active then @options.main.showCoverage() else @options.main.hideCoverage()
+      if active then show.call @options.main else hide.call @options.main
+
+
+    toggleIssues: (e) ->
+      @toggleSetting e, @options.main.showIssues, @options.main.hideIssues
+
+
+    toggleCoverage: (e) ->
+      @toggleSetting e, @options.main.showCoverage, @options.main.hideCoverage
 
 
     toggleDuplications: (e) ->
-      @showBlocks = []
-      active = $(e.currentTarget).is ':checked'
-      @showSettings = true
-      if active then @options.main.showDuplications() else @options.main.hideDuplications()
+      @toggleSetting e, @options.main.showDuplications, @options.main.hideDuplications
 
 
     toggleWorkspace: (e) ->
-      active = $(e.currentTarget).is ':checked'
-      @showSettings = true
-      if active then @options.main.showWorkspace() else @options.main.hideWorkspace()
+      @toggleSetting e, @options.main.showWorkspace, @options.main.hideWorkspace
 
 
     showCoveragePopup: (e) ->