@@ -1671,12 +1671,46 @@ function initVueComponents(){
1671
1671
reposTotalCount : 0 ,
1672
1672
reposFilter : 'all' ,
1673
1673
searchQuery : '' ,
1674
- isLoading : false
1674
+ isLoading : false ,
1675
+ repoTypes : {
1676
+ 'all' : {
1677
+ count : 0 ,
1678
+ searchMode : '' ,
1679
+ } ,
1680
+ 'forks' : {
1681
+ count : 0 ,
1682
+ searchMode : 'fork' ,
1683
+ } ,
1684
+ 'mirrors' : {
1685
+ count : 0 ,
1686
+ searchMode : 'mirror' ,
1687
+ } ,
1688
+ 'sources' : {
1689
+ count : 0 ,
1690
+ searchMode : 'source' ,
1691
+ } ,
1692
+ 'collaborative' : {
1693
+ count : 0 ,
1694
+ searchMode : 'collaborative' ,
1695
+ } ,
1696
+ }
1697
+ }
1698
+ } ,
1699
+
1700
+ computed : {
1701
+ showMoreReposLink : function ( ) {
1702
+ return this . repos . length > 0 && this . repos . length < this . repoTypes [ this . reposFilter ] . count ;
1703
+ } ,
1704
+ searchURL : function ( ) {
1705
+ return this . suburl + '/api/v1/repos/search?uid=' + this . uid + '&q=' + this . searchQuery + '&limit=' + this . searchLimit + '&mode=' + this . repoTypes [ this . reposFilter ] . searchMode + ( this . reposFilter !== 'all' ? '&exclusive=1' : '' ) ;
1706
+ } ,
1707
+ repoTypeCount : function ( ) {
1708
+ return this . repoTypes [ this . reposFilter ] . count ;
1675
1709
}
1676
1710
} ,
1677
1711
1678
1712
mounted : function ( ) {
1679
- this . searchRepos ( ) ;
1713
+ this . searchRepos ( this . reposFilter ) ;
1680
1714
1681
1715
var self = this ;
1682
1716
Vue . nextTick ( function ( ) {
@@ -1691,6 +1725,9 @@ function initVueComponents(){
1691
1725
1692
1726
changeReposFilter : function ( filter ) {
1693
1727
this . reposFilter = filter ;
1728
+ this . repos = [ ] ;
1729
+ this . repoTypes [ filter ] . count = 0 ;
1730
+ this . searchRepos ( filter ) ;
1694
1731
} ,
1695
1732
1696
1733
showRepo : function ( repo , filter ) {
@@ -1708,28 +1745,31 @@ function initVueComponents(){
1708
1745
}
1709
1746
} ,
1710
1747
1711
- searchRepos : function ( ) {
1748
+ searchRepos : function ( reposFilter ) {
1712
1749
var self = this ;
1750
+
1713
1751
this . isLoading = true ;
1752
+
1753
+ var searchedMode = this . repoTypes [ reposFilter ] . searchMode ;
1754
+ var searchedURL = this . searchURL ;
1714
1755
var searchedQuery = this . searchQuery ;
1715
- $ . getJSON ( this . searchURL ( ) , function ( result , textStatus , request ) {
1716
- if ( searchedQuery == self . searchQuery ) {
1756
+
1757
+ $ . getJSON ( searchedURL , function ( result , textStatus , request ) {
1758
+ if ( searchedURL == self . searchURL ) {
1717
1759
self . repos = result . data ;
1718
- if ( searchedQuery == "" ) {
1719
- self . reposTotalCount = request . getResponseHeader ( 'X-Total-Count' ) ;
1760
+ var count = request . getResponseHeader ( 'X-Total-Count' ) ;
1761
+ if ( searchedQuery === '' && searchedMode === '' ) {
1762
+ self . reposTotalCount = count ;
1720
1763
}
1764
+ self . repoTypes [ reposFilter ] . count = count ;
1721
1765
}
1722
1766
} ) . always ( function ( ) {
1723
- if ( searchedQuery == self . searchQuery ) {
1767
+ if ( searchedURL == self . searchURL ) {
1724
1768
self . isLoading = false ;
1725
1769
}
1726
1770
} ) ;
1727
1771
} ,
1728
1772
1729
- searchURL : function ( ) {
1730
- return this . suburl + '/api/v1/repos/search?uid=' + this . uid + '&q=' + this . searchQuery + '&limit=' + this . searchLimit ;
1731
- } ,
1732
-
1733
1773
repoClass : function ( repo ) {
1734
1774
if ( repo . fork ) {
1735
1775
return 'octicon octicon-repo-forked' ;
0 commit comments