@@ -7,6 +7,8 @@ import _ from 'lodash';
77import { Input , Button , Alert } from 'react-bootstrap' ;
88import ReactFireMixin from 'reactfire' ;
99//
10+ import FontAwesome from 'react-fontawesome' ;
11+ //
1012import FilterActions from '../../actions/FilterActions' ;
1113//
1214import Config from '../../config/Config' ;
@@ -24,17 +26,27 @@ const TagsBlock = React.createClass({
2426 this . bindAsArray ( ref , 'tags' ) ;
2527 } ,
2628
27- filterReposByTags ( index , tag ) {
28- let tagSpan = document . getElementById ( 'tag' + index ) ;
29- let isTagsAdding = false ;
30- if ( ! ~ tagSpan . className . indexOf ( 'active' ) ) {
31- tagSpan . className = tagSpan . className + ' active' ;
32- isTagsAdding = true ;
29+ filterReposByTags ( event , index , tag ) {
30+ let isRemoving = ~ event . target . className . indexOf ( 'tag-remove-icon' ) ;
31+ if ( isRemoving ) {
32+ let userID = this . props . userID ;
33+ let itemUrl = Config . FirebaseUrl + 'user' + userID + '/tags/' + tag [ '.key' ] ;
34+ let itemRef = new Firebase ( itemUrl ) ;
35+ itemRef . remove ( ) ;
36+ FilterActions . setFilterTags ( this . props . accessToken , tag , false ) ;
3337 }
3438 else {
35- tagSpan . className = tagSpan . className . replace ( 'active' , '' ) ;
39+ let tagSpan = document . getElementById ( 'tag' + index ) ;
40+ let isTagsAdding = false ;
41+ if ( ! ~ tagSpan . className . indexOf ( 'active' ) ) {
42+ tagSpan . className = tagSpan . className + ' active' ;
43+ isTagsAdding = true ;
44+ }
45+ else {
46+ tagSpan . className = tagSpan . className . replace ( 'active' , '' ) ;
47+ }
48+ FilterActions . setFilterTags ( this . props . accessToken , tag , isTagsAdding ) ;
3649 }
37- FilterActions . setFilterTags ( this . props . accessToken , tag , isTagsAdding ) ;
3850 } ,
3951
4052 render ( ) {
@@ -49,9 +61,13 @@ const TagsBlock = React.createClass({
4961 className = "tag"
5062 key = { 'tag' + index }
5163 id = { 'tag' + index }
52- onClick = { ( ) => this . filterReposByTags ( index , tag ) }
64+ onClick = { ( e ) => this . filterReposByTags ( e , index , tag ) }
5365 >
5466 { tag . title }
67+ < FontAwesome
68+ className = "tag-remove-icon"
69+ name = "times"
70+ />
5571 </ span >
5672 ) ;
5773 } ) ;
0 commit comments