File tree 2 files changed +20
-0
lines changed
2 files changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,16 @@ issues.AllLabels = Backbone.Model.extend({
9
9
url : function ( ) {
10
10
return '/api/issues/labels' ;
11
11
} ,
12
+ // See also issues.Issue#removeNamespaces
13
+ removeNamespaces : function ( labelsArray ) {
14
+ // Return a copy of labelsArray with the namespaces removed.
15
+ var namespaceRegex = / ( b r o w s e r | c l o s e d | o s | s t a t u s ) - / i;
16
+ var labelsCopy = _ . cloneDeep ( labelsArray ) ;
17
+ return _ . map ( labelsCopy , function ( labelObject ) {
18
+ labelObject . name = labelObject . name . replace ( namespaceRegex , '' ) ;
19
+ return labelObject ;
20
+ } ) ;
21
+ } ,
12
22
parse : function ( response ) {
13
23
this . set ( { labels : response } ) ;
14
24
}
Original file line number Diff line number Diff line change 48
48
this . set ( 'stateClass' , 'new' ) ;
49
49
return 'New Issue' ;
50
50
} ,
51
+ // See also issues.AllLabels#removeNamespaces
52
+ removeNamespaces : function ( labelsArray ) {
53
+ // Return a copy of labelsArray with the namespaces removed.
54
+ var namespaceRegex = / ( b r o w s e r | c l o s e d | o s | s t a t u s ) - / i;
55
+ var labelsCopy = _ . cloneDeep ( labelsArray ) ;
56
+ return _ . map ( labelsCopy , function ( labelObject ) {
57
+ labelObject . name = labelObject . name . replace ( namespaceRegex , '' ) ;
58
+ return labelObject ;
59
+ } ) ;
60
+ } ,
51
61
parse : function ( response ) {
52
62
this . set ( {
53
63
body : md . render ( response . body ) ,
You can’t perform that action at this time.
0 commit comments