From 5092b1b8d1630382d6e3c37e6a6b2dab51304eca Mon Sep 17 00:00:00 2001 From: Stas Vilchik Date: Thu, 21 Aug 2014 15:58:48 +0600 Subject: [PATCH] SONAR-4407 Refactor the libraries page in order to drop GWT --- .../src/main/coffee/libraries/view.coffee | 62 +++++++++++++++++++ .../src/main/hbs/libraries/libraries.hbs | 17 ++--- server/sonar-web/src/main/less/libraries.less | 47 ++++++++++++++ 3 files changed, 119 insertions(+), 7 deletions(-) diff --git a/server/sonar-web/src/main/coffee/libraries/view.coffee b/server/sonar-web/src/main/coffee/libraries/view.coffee index f135af43f5d..f3d01c9ce30 100644 --- a/server/sonar-web/src/main/coffee/libraries/view.coffee +++ b/server/sonar-web/src/main/coffee/libraries/view.coffee @@ -12,3 +12,65 @@ define [ class extends Marionette.ItemView template: Templates['libraries'] + + + ui: + filter: '.js-libraries-filter' + collapseAll: '.js-libraries-collapse-all' + expandAll: '.js-libraries-expand-all' + + + events: + 'change .js-test-libraries': 'toggleTestLibraries' + 'click @ui.collapseAll': 'collapseAll' + 'click @ui.expandAll': 'expandAll' + 'click .libraries-tree-with-subtree > .libraries-tree-name': 'toggleSubTree' + + + onRender: -> + @toggleActions() + filterFn = _.bind @filter, @ + debouncedFilterFn = _.debounce filterFn, 250 + @ui.filter.off('keyup').on 'keyup', debouncedFilterFn + + + filter: (e) -> + term = $(e.currentTarget).val() + @expandAll() + @$('.libraries-tree li').addClass 'libraries-tree-subtree-hidden' + @$('.libraries-tree li').each (index, el) => + name = $(el).children('.libraries-tree-name').text() + @showTree $(el) if name.match new RegExp(term, 'i') + + + showTree: (el) -> + el.removeClass 'libraries-tree-subtree-hidden' + el.parents('.libraries-tree-subtree-hidden').removeClass 'libraries-tree-subtree-hidden' + + + toggleTestLibraries: -> + @$('.libraries-tree').toggleClass 'libraries-tree-show-tests' + + + collapseAll: -> + @$('.libraries-tree-with-subtree').addClass 'libraries-tree-subtree-collapsed' + @toggleActions() + + + expandAll: -> + @$('.libraries-tree-with-subtree').removeClass 'libraries-tree-subtree-collapsed' + @toggleActions() + + + toggleSubTree: (e) -> + tree = $(e.currentTarget).parent() + tree.toggleClass 'libraries-tree-subtree-collapsed' + @toggleActions() + + + toggleActions: -> + subTreesCount = @$('.libraries-tree-with-subtree').length + subTreesCollapsedCount = @$('.libraries-tree-subtree-collapsed').length + @ui.collapseAll.toggle subTreesCount > subTreesCollapsedCount + @ui.expandAll.toggle subTreesCollapsedCount > 0 + diff --git a/server/sonar-web/src/main/hbs/libraries/libraries.hbs b/server/sonar-web/src/main/hbs/libraries/libraries.hbs index e97a22cf7f9..138dfdfd362 100644 --- a/server/sonar-web/src/main/hbs/libraries/libraries.hbs +++ b/server/sonar-web/src/main/hbs/libraries/libraries.hbs @@ -1,17 +1,20 @@
- - + +
- +
+ +
@@ -24,8 +27,8 @@ {{lname}}