Skip to content

Commit bafae24

Browse files
committed
add button to show more then 10 results
1 parent c8e1075 commit bafae24

File tree

5 files changed

+27
-9
lines changed

5 files changed

+27
-9
lines changed

i18n/locale-de.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
"SEARCH": {
2121
"PLACEHOLDER": "Ist mein Projekt bei metacollect?",
2222
"NO_MATCHES": "Es wurden keine Einträge gefunden.",
23-
"REGISTER": "Jetzt anmelden"
23+
"REGISTER": "Jetzt anmelden",
24+
"MORE_MATCHES": "Mehr Ergebnisse anzeigen"
2425
}
2526
},
2627

i18n/locale-en.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
"SEARCH": {
2121
"PLACEHOLDER": "Is my project with metacollect?",
2222
"NO_MATCHES": "No results found.",
23-
"REGISTER": "Enter your information now."
23+
"REGISTER": "Enter your information now.",
24+
"MORE_MATCHES": "Show more results"
2425
}
2526
},
2627

js/controllers.js

+13-5
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,33 @@ angular.module('mcControllers', [])
66
'$http',
77

88
function($scope, $http){
9-
$scope.data = undefined
10-
$scope.search = ''
9+
$scope.data = undefined;
10+
$scope.search = '';
11+
12+
// number of shown result-items
13+
$scope.limitResults = 10;
14+
15+
// increase number of shown items
16+
$scope.moreResults = function(){
17+
$scope.limitResults += 10;
18+
}
1119

1220

1321
$scope.getData = function(){
1422

1523
var search = $scope.search.replace(/[^a-zA-Z0-9 ]/g, " ")
1624

17-
$scope.data = true
25+
$scope.data = true;
1826

1927
var long_search = (" "+search).replace(/\s+/g,"&title*icontains=")
2028

2129
$http.get('http://django.dsini20.schedar.uberspace.de/api/search/project?format=json'+long_search)
2230
.then(
2331
function(result){
24-
$scope.data = result.data
32+
$scope.data = result.data;
2533
},
2634
function(error){
27-
$scope.data = []
35+
$scope.data = [];
2836
}
2937
)
3038
}

partials/database.html

+3-2
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ <h1 translate = "DATABASE.HEADING"></h2>
3737
>
3838
</a>
3939
</li>
40-
<li ng-repeat = "item in data | limitTo:10">
40+
<li ng-repeat = "item in data | limitTo:limitResults">
4141
<span class ="logo" style ="background-image: url('{{item.logo}}')"></span><!--
4242
--><span class ="title"><a href ="http://django.dsini20.schedar.uberspace.de/mainApp/{{item.id}}/">{{item.title | htmlToPlaintext}}</a></span>
4343
<div class ="description">
@@ -50,6 +50,7 @@ <h1 translate = "DATABASE.HEADING"></h2>
5050
</div>
5151
</li>
5252
</ul>
53+
<button ng-if="data.length > 10" ng-hide="data.length > 10 && data.length < limitResults" id="button__more-results" ng-click="moreResults()" translate = "DATABASE.SEARCH.MORE_MATCHES"></button>
5354
</div>
54-
</articlle>
55+
</article>
5556

styles/styles.css

+7
Original file line numberDiff line numberDiff line change
@@ -853,4 +853,11 @@ a.logo:hover{
853853
width: 24rem;
854854
}
855855

856+
/* show more result button */
857+
#button__more-results{
858+
line-height: 30px;
859+
border: 1px solid #333;
860+
width: 100%;
861+
}
862+
856863

0 commit comments

Comments
 (0)