Browse Source

favsList implemented, show user by username filter bug fixed

master
idoctnef 8 years ago
parent
commit
ceef406be9
10 changed files with 64 additions and 18 deletions
  1. +1
    -1
      config.xml
  2. +19
    -4
      www/js/controllers.js
  3. +1
    -0
      www/js/translations.js
  4. +24
    -0
      www/templates/favsList.html
  5. +2
    -1
      www/templates/help.html
  6. +0
    -1
      www/templates/settings.html
  7. +7
    -5
      www/templates/travel.html
  8. +1
    -1
      www/templates/travels.html
  9. +8
    -4
      www/templates/user.html
  10. +1
    -1
      www/templates/users.html

+ 1
- 1
config.xml

@ -1,6 +1,6 @@
<?xml version='1.0' encoding='utf-8'?>
<widget id="com.ionicframework.app751563" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>collectiveCar</name>
<name>CarsInCommon</name>
<description>
CarSharing app, for collective use.
</description>

+ 19
- 4
www/js/controllers.js

@ -648,13 +648,13 @@ console.log($scope.newComment);
};
})
.controller('UserCtrl', function($scope, $stateParams, $http, $filter) {
.controller('UserCtrl', function($scope, $stateParams, $http, $filter, $ionicModal) {
if(localStorage.getItem('c_token')){// adding token to the headers
$http.defaults.headers.common['X-Access-Token'] = localStorage.getItem('c_token');
}
$scope.storageusername=localStorage.getItem("c_username");
$scope.users= JSON.parse(localStorage.getItem('c_users'));
$scope.user = $filter('filter')($scope.users, $stateParams.username, true)[0];
$scope.user = $filter('filter')($scope.users, {username: $stateParams.username}, true)[0];
//$scope.user="";
console.log($stateParams.username);
/*$http.get(urlapi + 'users/byusername/'+$stateParams.username)
@ -706,7 +706,7 @@ console.log($scope.newComment);
$scope.users=response.data;
localStorage.setItem('c_users', JSON.stringify($scope.users));
$scope.user = $filter('filter')($scope.users, $stateParams.username, true)[0];
$scope.user = $filter('filter')($scope.users, {username: $stateParams.username}, true)[0];
},
function(response) { // optional
@ -733,7 +733,7 @@ console.log($scope.newComment);
$scope.users=response.data;
localStorage.setItem('c_users', JSON.stringify($scope.users));
$scope.user = $filter('filter')($scope.users, $stateParams.username, true)[0];
$scope.user = $filter('filter')($scope.users, {username: $stateParams.username}, true)[0];
},
function(response) { // optional
@ -741,6 +741,21 @@ console.log($scope.newComment);
});
};
$ionicModal.fromTemplateUrl('templates/favsList.html', {
scope: $scope
}).then(function(modal) {
$scope.modalFavsList = modal;
});
$scope.closeModalFavsList = function() {
$scope.modalFavsList.hide();
};
$scope.showFavsList = function(){
$scope.modalFavsList.show();
};
$scope.closeModalAndGoUser = function(){
$scope.modalFavsList.hide();
};
$scope.arrayObjectIndexOf = function(myArray, searchTerm, property) {
if(myArray){
for(var i = 0, len = myArray.length; i < len; i++) {

+ 1
- 0
www/js/translations.js

@ -53,6 +53,7 @@ var translations = {
"Pull_from_top_to_refresh": "Pull from top to refresh",
"User": "User",
"history_of": "history of",
"current_publications_of": "current publications of",
"publications": "publications",
},

+ 24
- 0
www/templates/favsList.html

@ -0,0 +1,24 @@
<ion-modal-view view-title="{{'User' | translate}}">
<ion-content>
<h4 class="padding">
<img class='o-imgTitle' src="img/like.png" />
{{'Likes' | translate}} {{newtravel.title}}
<div class="item-note">
<button class="button button-small button-dark" ng-click="closeModalFavsList()">X</button>
</div>
</h4>
<div class="list">
<a ng-repeat="fav in user.favs | orderBy: 'date'" class="item item-avatar" ng-click="closeModalAndGoUser()" ng-href="#/app/users/{{fav.username}}">
<img ng-src="img/avatars/{{fav.avatar}}.png">
<h2>{{fav.username}}</h2>
</a>
</div>
<div class="item-note">
<button class="button button-small button-dark" ng-click="closeModalFavsList()">{{'Close' | translate}}</button>
</div>
</ion-content>
</ion-modal-view>

+ 2
- 1
www/templates/help.html

@ -1,6 +1,5 @@
<ion-view view-title="{{'Help' | translate}}">
<ion-content>
<h1>{{'Help' | translate}}</h1>
<p>
help instructions here
</p>
@ -14,5 +13,7 @@
<img ng-src="img/asking.png" class="o-img-new"/>
<img ng-src="img/offering.png" class="o-img-new"/>
</p>
<br><br>
<p>not yet</p>
</ion-content>
</ion-view>

+ 0
- 1
www/templates/settings.html

@ -1,6 +1,5 @@
<ion-view view-title="{{'Settings' | translate}}">
<ion-content>
<h1>{{'Settings' | translate}}</h1>
<label class="item item-input item-select">
<div class="input-label">
{{'Actual_language' | translate}}

+ 7
- 5
www/templates/travel.html

@ -15,19 +15,21 @@
</div>
<div class="item item-body">
<div class='row'>
<p class="o-bold">{{travel.description}}</p>
</div>
<div class="row">
<p><img class='o-imgTitle' src="img/from-to.png" />{{travel.from}} --> {{travel.to}}</p>
</div>
<div class='row'>
<div class='col'>
<p ng-show="travel.phone">
<img class='o-imgMenu' src="img/smartphone.png" /> {{travel.phone}}
</p>
<p ng-show="travel.telegram">
<a ng-href="https://telegram.me/{{travel.telegram}}" target="_blank" class="button">
<img class='o-imgMenu' src="img/telegram.png" /> @{{travel.telegram}}
</a>
</p>
<p><img class='o-imgTitle' src="img/from-to.png" />{{travel.from}} - {{travel.to}}</p>
</div>
<div class='col o-text-right'>
<p ng-show="travel.collectivized">
@ -49,7 +51,7 @@
<br>
<div ng-show="storageusername && storageusername!=travel.owner">
<div ng-show="storageusername && storageusername!=travel.owner" class="text-right">
<p class='text-right'>
<div ng-show="arrayObjectIndexOf(travel.joins, storageusername, 'joinedUsername')==-1">
<a ng-show="travel.modality=='offering'" ng-click="joinTravel()" class="button button-calm o-pull-right">{{'Ask_to_join' | translate}}</a>
@ -90,7 +92,7 @@
<button ng-click="closeNewComment()" class="button button-small button-assertive">
{{'Cancel' | translate}}
</button>
<button ng-click="doNewComment()" class="button button-small button-calm">
<button ng-click="doNewComment()" ng-show="newComment.comment" class="button button-small button-calm">
{{'Post_comment' | translate}}
</button>
</form>

+ 1
- 1
www/templates/travels.html

@ -36,7 +36,7 @@
</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>-->
<p class="">{{travel.from}} - {{travel.to}}</p>
<p class="">{{travel.from}} --> {{travel.to}}</p>
</a>
</div>
</ion-content>

+ 8
- 4
www/templates/user.html

@ -8,13 +8,17 @@
<p class="o-bold">{{user.description}}</p>
<p>{{user.mail}}</p>
<p>
<a ng-href="https://telegram.me/{{user.telegram}}" target="_blank" class="button">
<img class='o-imgMenu' src="img/telegram.png" /> @{{user.telegram}}
</a>
</p>
<div class="o-text-right">
<b>favs:</b>
<span class="">{{user.favs.length}}</span>
<br><br>
<div ng-click="showFavsList()">
<b>favs:</b>
<span class="">{{user.favs.length}}</span>
</div>
<br>
<div ng-show="storageusername && storageusername!=user.username">
<a ng-show="arrayObjectIndexOf(user.favs, storageusername, 'username')==-1" ng-click="favUser()">
<img class="o-imgMenu" src="img/unlike.png" />
@ -29,7 +33,7 @@
</div>
</div>
<div class="item item-body">
{{'history_of' | translate}} {{user.username}}:
{{'current_publications_of' | translate}} {{user.username}}:
<div class="positive">{{travels.length}} {{'publications' | translate}}</div>
<a ng-repeat="travel in travels | orderBy: 'date'" class="item item-avatar" href="#/app/travels/{{travel._id}}">

+ 1
- 1
www/templates/users.html

@ -12,7 +12,7 @@
</div>
</div>
<a ng-repeat="user in users | orderBy: 'date'" class="item item-avatar" href="#/app/users/{{user.username}}">
<a ng-repeat="user in users | orderBy: 'date'" class="item item-avatar" ng-href="#/app/users/{{user.username}}">
<img ng-src="img/avatars/{{user.avatar}}.png">
<h2>{{user.username}}</h2>
<p>

Loading…
Cancel
Save