From f04b2ef070062207f301b9094fef0ff1c30c58f8 Mon Sep 17 00:00:00 2001 From: Alexander Machehin Date: Wed, 13 May 2015 20:58:54 +0500 Subject: [PATCH] fix activity feed filters; small refactoring --- .../controllers/activity_controller.js.coffee | 15 +++++++++++++-- .../angularjs/templates/get_owners.html.slim | 4 ++++ app/controllers/home_controller.rb | 4 ++-- app/views/home/_activity_tab.html.slim | 2 ++ app/views/home/_filters.html.slim | 13 ++++++++----- app/views/home/_own_activity_tab.html.slim | 1 + app/views/home/get_owners_list.json.jbuilder | 5 +++-- 7 files changed, 33 insertions(+), 11 deletions(-) create mode 100644 app/assets/javascripts/angularjs/templates/get_owners.html.slim diff --git a/app/assets/javascripts/angularjs/controllers/activity_controller.js.coffee b/app/assets/javascripts/angularjs/controllers/activity_controller.js.coffee index ba808c83c..9a100ff07 100644 --- a/app/assets/javascripts/angularjs/controllers/activity_controller.js.coffee +++ b/app/assets/javascripts/angularjs/controllers/activity_controller.js.coffee @@ -12,10 +12,20 @@ ActivityController = ($scope, $http, $timeout, $q, $filter, $location, ActivityF prev_date = cur_date ) + $scope.$watch (-> + vm.current_activity_tab.owner_uname_filter_tmp + ), () -> + vm.selectOwnerFilter({uname: null}, null, null) unless vm.current_activity_tab.owner_uname_filter_tmp + + $scope.$watch (-> + vm.current_activity_tab.project_name_filter_tmp + ), () -> + vm.selectProjectNameFilter({name: null}, null, null) unless vm.current_activity_tab.project_name_filter_tmp + vm = this - + vm.processing = false vm.activity_tab = filter: 'all' all: {} @@ -138,6 +148,7 @@ ActivityController = ($scope, $http, $timeout, $q, $filter, $location, ActivityF vm.getActivityContent() vm.getActivityContent = ()-> + vm.processing = true options = filter: vm.current_activity_tab.filter owner_filter: vm.current_activity_tab.owner_filter @@ -154,6 +165,7 @@ ActivityController = ($scope, $http, $timeout, $q, $filter, $location, ActivityF vm.getCurActivity().feed = feed vm.getCurActivity().next_page_link = res.data.next_page_link calculateChangeDate(feed) + vm.processing = false true vm.setIssuesFilter = (kind, issues_filter)-> @@ -240,7 +252,6 @@ ActivityController = ($scope, $http, $timeout, $q, $filter, $location, ActivityF vm.getActivityContent() true - angular .module("RosaABF") .controller "ActivityController", ActivityController diff --git a/app/assets/javascripts/angularjs/templates/get_owners.html.slim b/app/assets/javascripts/angularjs/templates/get_owners.html.slim new file mode 100644 index 000000000..7c6cadff6 --- /dev/null +++ b/app/assets/javascripts/angularjs/templates/get_owners.html.slim @@ -0,0 +1,4 @@ +- size = Avatar::AVATAR_SIZES[:small] +a + img ng-src= "{{match.model.avatar_path}}" height= size width= size + span< bind-html-unsafe= "match.model.uname | typeaheadHighlight:query" diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb index 93d33e600..170a4b48a 100644 --- a/app/controllers/home_controller.rb +++ b/app/controllers/home_controller.rb @@ -85,8 +85,8 @@ class HomeController < ApplicationController def get_owners_list if params[:term].present? - users = User.opened.search(params[:term]).pluck(:uname).first(5) - groups = Group.opened.search(params[:term]).pluck(:uname).first(5) + users = User.opened.search(params[:term]).first(5) + groups = Group.opened.search(params[:term]).first(5) @owners = users | groups end diff --git a/app/views/home/_activity_tab.html.slim b/app/views/home/_activity_tab.html.slim index d03e86557..200630291 100644 --- a/app/views/home/_activity_tab.html.slim +++ b/app/views/home/_activity_tab.html.slim @@ -8,4 +8,6 @@ tab[ heading= t('activity_menu.activity_feed') = t 'layout.activity_feed.header' = link_to image_tag('rss.ico', width: '15px', height: '15px', class: 'atom_icon'), atom_activity_feeds_path(format: 'atom', token: current_user.authentication_token) + i< class= 'fa fa-spinner fa-spin fa-lg offset10 boffset10' ng-show= 'actCtrl.processing' + == render 'activity_tabsets' diff --git a/app/views/home/_filters.html.slim b/app/views/home/_filters.html.slim index 6110dea32..2b6b34521 100644 --- a/app/views/home/_filters.html.slim +++ b/app/views/home/_filters.html.slim @@ -2,13 +2,16 @@ hr h4 => t('layout.relations.filters') strong.text-danger= t 'new_feature' + .form-group = text_field_tag :owner_uname, nil, - class: 'form-control', - placeholder: t('search.placeholders.owner_filter'), - 'ng-model' => 'actCtrl.current_activity_tab.owner_uname_filter_tmp', - 'typeahead' => 'owner.uname for owner in actCtrl.getOwnersList($viewValue)', - 'typeahead-on-select' => 'actCtrl.selectOwnerFilter($item, $model, $label)' + class: 'form-control', + placeholder: t('search.placeholders.owner_filter'), + 'ng-model' => 'actCtrl.current_activity_tab.owner_uname_filter_tmp', + 'typeahead' => 'owner.uname for owner in actCtrl.getOwnersList($viewValue)', + 'typeahead-on-select' => 'actCtrl.selectOwnerFilter($item, $model, $label)', + 'typeahead-template-url' => "get_owners.html" + .form-group = text_field_tag :project_name, nil, class: 'form-control', diff --git a/app/views/home/_own_activity_tab.html.slim b/app/views/home/_own_activity_tab.html.slim index ee440c2d3..54d29b06f 100644 --- a/app/views/home/_own_activity_tab.html.slim +++ b/app/views/home/_own_activity_tab.html.slim @@ -8,4 +8,5 @@ tab[ active= "actCtrl.own_activity_tab.active" .col-md-9.offset10 h3 = t 'layout.activity_feed.own_header' + i< class= 'fa fa-spinner fa-spin fa-lg offset10 boffset10' ng-show= 'actCtrl.processing' == render 'activity_tabsets' diff --git a/app/views/home/get_owners_list.json.jbuilder b/app/views/home/get_owners_list.json.jbuilder index bd79d6c15..aaa48fe5f 100644 --- a/app/views/home/get_owners_list.json.jbuilder +++ b/app/views/home/get_owners_list.json.jbuilder @@ -1,3 +1,4 @@ -json.array!(@owners) do |uname| - json.uname uname +json.array!(@owners) do |owner| + json.avatar_path avatar_url(owner) + json.uname owner.uname end \ No newline at end of file