@@ -1671,12 +1671,43 @@ 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
+ }
1675
1697
}
1676
1698
} ,
1677
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 ;
1706
+ } ,
1707
+ } ,
1708
+
1678
1709
mounted : function ( ) {
1679
- this . searchRepos ( ) ;
1710
+ this . searchRepos ( this . reposFilter ) ;
1680
1711
1681
1712
var self = this ;
1682
1713
Vue . nextTick ( function ( ) {
@@ -1691,6 +1722,7 @@ function initVueComponents(){
1691
1722
1692
1723
changeReposFilter : function ( filter ) {
1693
1724
this . reposFilter = filter ;
1725
+ this . searchRepos ( filter ) ;
1694
1726
} ,
1695
1727
1696
1728
showRepo : function ( repo , filter ) {
@@ -1708,28 +1740,31 @@ function initVueComponents(){
1708
1740
}
1709
1741
} ,
1710
1742
1711
- searchRepos : function ( ) {
1743
+ searchRepos : function ( reposFilter ) {
1712
1744
var self = this ;
1745
+
1713
1746
this . isLoading = true ;
1747
+
1748
+ var searchedMode = this . repoTypes [ reposFilter ] . searchMode ;
1749
+ var searchedURL = this . searchURL ;
1714
1750
var searchedQuery = this . searchQuery ;
1715
- $ . getJSON ( this . searchURL ( ) , function ( result , textStatus , request ) {
1716
- if ( searchedQuery == self . searchQuery ) {
1751
+
1752
+ $ . getJSON ( searchedURL , function ( result , textStatus , request ) {
1753
+ if ( searchedURL == self . searchURL ) {
1717
1754
self . repos = result . data ;
1718
- if ( searchedQuery == "" ) {
1719
- self . reposTotalCount = request . getResponseHeader ( 'X-Total-Count' ) ;
1755
+ var count = request . getResponseHeader ( 'X-Total-Count' ) ;
1756
+ if ( searchedQuery === '' && searchedMode === '' ) {
1757
+ self . reposTotalCount = count ;
1720
1758
}
1759
+ self . repoTypes [ reposFilter ] . count = count ;
1721
1760
}
1722
1761
} ) . always ( function ( ) {
1723
- if ( searchedQuery == self . searchQuery ) {
1762
+ if ( searchedURL == self . searchURL ) {
1724
1763
self . isLoading = false ;
1725
1764
}
1726
1765
} ) ;
1727
1766
} ,
1728
1767
1729
- searchURL : function ( ) {
1730
- return this . suburl + '/api/v1/repos/search?uid=' + this . uid + '&q=' + this . searchQuery + '&limit=' + this . searchLimit ;
1731
- } ,
1732
-
1733
1768
repoClass : function ( repo ) {
1734
1769
if ( repo . fork ) {
1735
1770
return 'octicon octicon-repo-forked' ;
0 commit comments