Skip to content

Commit be5cd31

Browse files
committed
Remove tag from tag block
1 parent b371e8f commit be5cd31

4 files changed

Lines changed: 44 additions & 11 deletions

File tree

js/actions/FilterActions.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ const FilterActions = Reflux.createActions([
99
'getFilters',
1010
'setFilter',
1111
'setFilterTags',
12-
'loadMoreWithFilters'
12+
'loadMoreWithFilters',
13+
'removeTag'
1314
]);
1415

1516
module.exports = FilterActions;

js/actions/ReposActions.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const ReposActions = Reflux.createActions([
99
'getRepos',
1010
'getStars',
1111
'setTag',
12-
'removeTag'
12+
'removeRepoTag'
1313
]);
1414

1515
module.exports = ReposActions;

js/components/blocks/TagsBlock.js

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import _ from 'lodash';
77
import { Input, Button, Alert } from 'react-bootstrap';
88
import ReactFireMixin from 'reactfire';
99
//
10+
import FontAwesome from 'react-fontawesome';
11+
//
1012
import FilterActions from '../../actions/FilterActions';
1113
//
1214
import 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
});

less/components.less

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,28 @@
8585
color: darken(@brand-primary, 10%);
8686
padding: 4px 10px 5px;
8787
cursor: pointer;
88+
position: relative;
8889
&:hover, &.active {
8990
color: #fff;
9091
background: @brand-primary;
9192
}
9293
}
9394

95+
.tag {
96+
.tag-remove-icon {
97+
visibility: hidden;
98+
position: absolute;
99+
right: 3px;
100+
top: 3px;
101+
font-size: 10px;
102+
}
103+
&:hover {
104+
.tag-remove-icon {
105+
visibility: initial;
106+
}
107+
}
108+
}
109+
94110
.repo-tag {
95111
font-size: @font-size-h5;
96112
margin: 5px 5px 0 0;

0 commit comments

Comments
 (0)