mirror of
https://github.com/arnaucube/commonroutesApp.git
synced 2026-02-06 19:16:45 +01:00
users pagination implemented in infinite scroll
This commit is contained in:
11
README.md
11
README.md
@@ -2,13 +2,4 @@
|
||||
|
||||
server code: https://github.com/arnaucode/carsincommonServer
|
||||
|
||||
|
||||
**ToDos:**
|
||||
```
|
||||
-page for user to view joins that has done
|
||||
-allow travel crator to accept join petitions and reject people
|
||||
-add to travel the date of destination
|
||||
-user comments and system to profile, to valorate users
|
||||
-notifications system syncronized
|
||||
|
||||
```
|
||||

|
||||
|
||||
BIN
carsincommon.png
Normal file
BIN
carsincommon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 512 KiB |
@@ -33,7 +33,7 @@ angular.module('app.offerCar', ['pascalprecht.translate', 'ui-leaflet'])
|
||||
})
|
||||
.then(function(data) {
|
||||
console.log(data);
|
||||
window.location="#app/travels"
|
||||
window.location="#app/travels";
|
||||
},
|
||||
function(data) { // optional
|
||||
// failed
|
||||
|
||||
@@ -5,6 +5,8 @@ var translations = {
|
||||
"Signup": "Signup",
|
||||
"Login": "Login",
|
||||
"Travels": "Travels",
|
||||
"travels": "travels",
|
||||
"likes": "likes",
|
||||
"Travels_feed": "Travels feed",
|
||||
"Users": "Users",
|
||||
"Notifications": "Notifications",
|
||||
@@ -76,7 +78,7 @@ var translations = {
|
||||
"load_more": "load more",
|
||||
"view_likes": "view likes",
|
||||
"Edit_profile": "Edit profile",
|
||||
"Travels_offering": "Travels offering",
|
||||
"Travels_publicated": "Travels publicated",
|
||||
"Travels_joining": "Travels joining"
|
||||
},
|
||||
"catalan": {
|
||||
|
||||
@@ -79,6 +79,7 @@ angular.module('app.travel', ['pascalprecht.translate', 'ui-leaflet'])
|
||||
localStorage.setItem('c_travels', JSON.stringify($scope.travels));
|
||||
localStorage.setItem('c_travelsLastDate', JSON.stringify(new Date()));
|
||||
|
||||
window.location="#app/users/userTravels/" + $scope.storageuser._id;
|
||||
},
|
||||
function(response) { // optional
|
||||
// failed
|
||||
|
||||
@@ -1,34 +1,60 @@
|
||||
angular.module('app.users', ['pascalprecht.translate'])
|
||||
|
||||
.controller('UsersCtrl', function($scope, $http, $ionicModal, $timeout, $ionicLoading, $filter) {
|
||||
$scope.users="";
|
||||
.controller('UsersCtrl', function($scope, $http, $ionicModal, $timeout, $ionicLoading, $filter) {
|
||||
$scope.users = [];
|
||||
$scope.loadMorePagination = true;
|
||||
$scope.page = 0;
|
||||
|
||||
$scope.users=JSON.parse(localStorage.getItem('c_users'));
|
||||
//$scope.users = JSON.parse(localStorage.getItem('c_users'));
|
||||
|
||||
$scope.doRefresh = function() {
|
||||
|
||||
/* users refresh: */
|
||||
$http.get(urlapi + 'users')
|
||||
.success(function(data, status, headers, config){
|
||||
console.log('data success');
|
||||
console.log(data); // for browser console
|
||||
$scope.users = data; // for UI
|
||||
localStorage.setItem('c_users', JSON.stringify($scope.users));
|
||||
$scope.$broadcast('scroll.refreshComplete');//refresher stop
|
||||
/* users refresh: */
|
||||
$http.get(urlapi + 'users?page=' + $scope.page)
|
||||
.then(function(data) {
|
||||
console.log('data success');
|
||||
console.log(data);
|
||||
|
||||
//set userdata
|
||||
$scope.userdata = $filter('filter')($scope.users, {username: $scope.storageusername}, true)[0];
|
||||
console.log("userdata");
|
||||
console.log($scope.userdata);
|
||||
localStorage.setItem("c_userdata", JSON.stringify($scope.userdata));
|
||||
})
|
||||
.error(function(data, status, headers,config){
|
||||
console.log('data error');
|
||||
$scope.$broadcast('scroll.refreshComplete');//refresher stop
|
||||
})
|
||||
.then(function(result){
|
||||
users = result.data;
|
||||
$scope.users = $scope.users.concat(data.data);
|
||||
$scope.$broadcast('scroll.refreshComplete'); //refresher stop
|
||||
$scope.$broadcast('scroll.infiniteScrollComplete');
|
||||
if (data.data.length < 1) {
|
||||
console.log("setting loadMorePagination to false");
|
||||
$scope.loadMorePagination = false;
|
||||
$scope.$broadcast('scroll.infiniteScrollComplete');
|
||||
}
|
||||
|
||||
|
||||
/*localStorage.setItem('c_users', JSON.stringify($scope.users));
|
||||
$scope.$broadcast('scroll.refreshComplete'); //refresher stop
|
||||
|
||||
//set userdata
|
||||
$scope.userdata = $filter('filter')($scope.users, {
|
||||
username: $scope.storageusername
|
||||
}, true)[0];
|
||||
console.log("userdata");
|
||||
console.log($scope.userdata);
|
||||
localStorage.setItem("c_userdata", JSON.stringify($scope.userdata));*/
|
||||
}, function(data) {
|
||||
console.log('data error');
|
||||
$scope.$broadcast('scroll.refreshComplete'); //refresher stop
|
||||
$ionicLoading.show({
|
||||
template: 'Error connecting server',
|
||||
noBackdrop: true,
|
||||
duration: 2000
|
||||
});
|
||||
});
|
||||
};
|
||||
$scope.doRefresh();
|
||||
});
|
||||
|
||||
$scope.paginationNext = function() {
|
||||
if ($scope.loadMorePagination == true) {
|
||||
$scope.page++;
|
||||
console.log($scope.page);
|
||||
$scope.doRefresh();
|
||||
} else {
|
||||
console.log("limit pagination reached");
|
||||
$scope.$broadcast('scroll.infiniteScrollComplete');
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
@@ -1,8 +1,13 @@
|
||||
<ion-view view-title="Main">
|
||||
<ion-content class="has-footer">
|
||||
<a ng-href="#/app/users/{{storageuser._id}}" class="item item-icon-left o_purpleG300to500">
|
||||
<i class="icon ion-person"></i>
|
||||
<a ng-href="#/app/users/{{storageuser._id}}" class="item item-avatar o_purpleG300to500">
|
||||
<!--<i class="icon ion-person"></i>-->
|
||||
<img ng-src="{{storageuser.avatar}}">
|
||||
{{storageuser.username}} {{'profile' | translate}}
|
||||
<p style="color:#ffffff;">
|
||||
{{storageuser.travels.length}} {{'travels' | translate }},
|
||||
{{storageuser.likes.length}} {{'likes' | translate }}
|
||||
</p>
|
||||
</a>
|
||||
<a ng-href="#/app/newTravel" class="item item-icon-left o_purpleG300to500">
|
||||
<i class="icon ion-map"></i>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
</ion-refresher>
|
||||
<div class="list">
|
||||
<div class="item item-divider o_purple300" ng-show="travels[0]">
|
||||
{{'Travels_offering' | translate}}
|
||||
{{'Travels_publicated' | translate}}
|
||||
</div>
|
||||
<a ng-repeat="travel in travels | orderBy: 'date'"
|
||||
class="item item-icon-left" href="#/app/travels/{{travel._id}}">
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<ion-view view-title="{{'Users' | translate}}">
|
||||
<ion-content class="has-footer">
|
||||
<ion-content>
|
||||
<ion-refresher
|
||||
pulling-text="{{'Pull_to_refresh' | translate}}..."
|
||||
on-refresh="doRefresh()">
|
||||
@@ -20,5 +20,10 @@
|
||||
</p>
|
||||
</a>
|
||||
</div>
|
||||
<ion-infinite-scroll
|
||||
ng-if="loadMorePagination"
|
||||
on-infinite="paginationNext()"
|
||||
distance="1%">
|
||||
</ion-infinite-scroll>
|
||||
</ion-content>
|
||||
</ion-view>
|
||||
|
||||
Reference in New Issue
Block a user