Browse Source

pull refreshing travels feed implemented

pull/1/head
nau 8 years ago
parent
commit
a6950029b0
4 changed files with 70 additions and 26 deletions
  1. +48
    -12
      app/www/js/controllers.js
  2. +4
    -7
      app/www/templates/newaskingtravel.html
  3. +10
    -5
      app/www/templates/travel.html
  4. +8
    -2
      app/www/templates/travels.html

+ 48
- 12
app/www/js/controllers.js

@ -44,20 +44,25 @@ angular.module('starter.controllers', [])
.controller('TravelsCtrl', function($scope, $http, $ionicModal, $timeout) {
$scope.travels="";
$http.get('http://localhost:3000/api/travels')
.success(function(data, status, headers,config){
console.log('data success');
console.log(data); // for browser console
$scope.travels = data; // for UI
})
.error(function(data, status, headers,config){
console.log('data error');
})
.then(function(result){
travels = result.data;
});
$scope.doRefresh = function() {
$http.get('http://localhost:3000/api/travels')
.success(function(data, status, headers,config){
console.log('data success');
console.log(data); // for browser console
$scope.travels = data; // for UI
$scope.$broadcast('scroll.refreshComplete');//refresher stop
})
.error(function(data, status, headers,config){
console.log('data error');
$scope.$broadcast('scroll.refreshComplete');//refresher stop
})
.then(function(result){
travels = result.data;
});
};
$scope.newtravel={};
// Create the login modal that we will use later
@ -123,6 +128,37 @@ angular.module('starter.controllers', [])
$scope.closeNewOfferingTravel();
}, 1000);
};
$scope.doNewAskingTravel = function() {
console.log('Doing new travel', $scope.newtravel);
$scope.newtravel.icon="lorry";
$scope.newtravel.generateddate=$scope.newtravel.date;
$scope.newtravel.owner="user";
$scope.newtravel.modality="asking";
console.log($scope.newtravel);
$http({
url: 'http://localhost:3000/api/travels',
method: "POST",
data: $scope.newtravel
})
.then(function(response) {
// success
console.log("response: ");
console.log(response);
$scope.newtravel._id=response.data._id;
$scope.travels.push($scope.newtravel);
},
function(response) { // optional
// failed
});
// Simulate a login delay. Remove this and replace with your login
// code if using a login system
$timeout(function() {
$scope.closeNewAskingTravel();
}, 1000);
};
})
.controller('TravelCtrl', function($scope, $stateParams, $http) {

+ 4
- 7
app/www/templates/newaskingtravel.html

@ -23,12 +23,12 @@
</label>
<label class="item item-input">
<span class="input-label">Seats</span>
<span class="input-label"> people</span>
<input ng-model="newtravel.seats" type="number" placeholder="">
</label>
<ion-toggle ng-model="newtravel.package" toggle-class="toggle-calm">
<img class='o-imgMenu' src="img/package.png" />
Can carry package
Need to carry package
</ion-toggle>
<label class="item item-input">
<span class="input-label">Date</span>
@ -46,18 +46,15 @@
<span class="input-label">telegram user</span>
<input ng-model="newtravel.telegram" type="text" placeholder="">
</label>
<ion-toggle ng-model="newtravel.collectivized" toggle-class="toggle-calm">
Collectivized car
</ion-toggle>
<label class="item item-input item-floating-label">
<span class="input-label">Description</span>
<input ng-model="newtravel.description" type="text" placeholder="Description">
</label>
<button ng-click="closeNewOfferingTravel()" class="button button-assertive">
<button ng-click="closeNewAskingTravel()" class="button button-assertive">
Cancel
</button>
<button ng-click="doNewOfferingTravel()" class="button button-calm">
<button ng-click="doNewAskingTravel()" class="button button-calm">
Create travel
</button>
</form>

+ 10
- 5
app/www/templates/travel.html

@ -10,12 +10,16 @@
<div class='o-float-right o-text-right'>
<div class="">{{travel.date | date:"dd/MM HH:mm a"}}</div>
<br>
<div class="royal" ng-show="travel.package">[periodic travel]</div>
<br>
<div class="o-mini-text" ng-show="travel.package">can carry package<img src="img/package.png" class="o-imgMenu" /></div>
<div class="o-mini-text" ng-show="travel.package">
<div ng-show="travel.modality=='offering'">can carry package <img src="img/package.png" class="o-imgMenu" /></div>
<div ng-show="travel.modality=='asking'">need to carry package <img src="img/package.png" class="o-imgMenu" /></div>
</div>
</div>
<p><img class='o-imgTitle' src="img/from-to.png" />{{travel.from}} - {{travel.to}}</p>
<p>nº car seats: {{trave.seats}}</p>
<p>
<div ng-show="travel.modality=='offering'">nº car seats: {{travel.seats}}</div>
<div ng-show="travel.modality=='asking'">nº people: {{travel.seats}}</div>
</p>
<p class="o-bold">{{travel.description}}</p>
<br>
<p>
@ -26,7 +30,8 @@
</p>
<p class='text-right'>
<a href="#" class="button button-calm o-pull-right">Ask to join</a>
<a ng-show="travel.modality=='offering'" href="#" class="button button-calm o-pull-right">Ask to join</a>
<a ng-show="travel.modality=='asking'" href="#" class="button button-calm o-pull-right">Offer car</a>
</p>
</div>
</ion-content>

+ 8
- 2
app/www/templates/travels.html

@ -1,18 +1,24 @@
<ion-view view-title="Travels">
<ion-content>
<ion-refresher
pulling-text="Pull to refresh..."
on-refresh="doRefresh()">
</ion-refresher>
<div class="list">
<div class="o-float-right">
<a ng-click="showNewAskingTravel()" class="button icon ion-email"></a>
<a ng-click="showNewAskingTravel()" class="button icon ion-help"></a>
<a ng-click="showNewOfferingTravel()" class="button icon ion-plus"></a>
</div>
<a ng-repeat="travel in travels | orderBy: 'date'" class="item item-avatar" href="#/app/travels/{{travel._id}}">
<img ng-src="img/{{travel.modality}}.png">
<h2>{{travel.title}}</h2>
<p>
{{travel.description}}
</p>
<p class="">nºseats: {{travel.seats}}</p>
<p class="" ng-show="travel.modality=='offering'">nºseats: {{travel.seats}}</p>
<p class="" ng-show="travel.modality=='asking'">nºpeople: {{travel.seats}}</p>
<div class="badge badge-calm item-note">{{travel.owner}}</div>
<div class="badge badge-calm item-note">{{travel.date | date:"dd/MM HH:mm a"}}</div>
</a>

Loading…
Cancel
Save