From fb545e0c678e47e648e1d4b2eb046781ce884606 Mon Sep 17 00:00:00 2001 From: idoctnef Date: Mon, 19 Sep 2016 10:58:44 +0200 Subject: [PATCH] unjoin implemented, and travel display re-organized --- www/css/style.css | 8 +++++ www/js/app.js | 6 ++-- www/js/controllers.js | 57 +++++++++++++++++++++++++++++------- www/templates/menu.html | 6 +++- www/templates/search.html | 5 ---- www/templates/settings.html | 5 ++++ www/templates/travel.html | 58 ++++++++++++++++++++++--------------- www/templates/travels.html | 7 +++++ 8 files changed, 109 insertions(+), 43 deletions(-) delete mode 100644 www/templates/search.html create mode 100644 www/templates/settings.html diff --git a/www/css/style.css b/www/css/style.css index 4c2286e..4b24268 100644 --- a/www/css/style.css +++ b/www/css/style.css @@ -28,3 +28,11 @@ width: 30px!important; height: 30px!important; } +.o-badgeCollectivized{ + background: #33CD5F; + padding: 5px; + border-radius: 5px; + font-size: 12px; + color: #ffffff; + font-weight: bold; +} diff --git a/www/js/app.js b/www/js/app.js index 728be93..4293bf8 100644 --- a/www/js/app.js +++ b/www/js/app.js @@ -32,11 +32,11 @@ angular.module('starter', ['ionic', 'starter.controllers']) controller: 'AppCtrl' }) - .state('app.search', { - url: '/search', + .state('app.settings', { + url: '/settings', views: { 'menuContent': { - templateUrl: 'templates/search.html' + templateUrl: 'templates/settings.html' } } }) diff --git a/www/js/controllers.js b/www/js/controllers.js index c23a15d..a8a5819 100644 --- a/www/js/controllers.js +++ b/www/js/controllers.js @@ -22,6 +22,7 @@ angular.module('starter.controllers', []) $scope.signupData= {}; $scope.storageusername=localStorage.getItem("c_username"); + $scope.storageavatar=localStorage.getItem("c_avatar"); // Create the login modal that we will use later $ionicModal.fromTemplateUrl('templates/login.html', { scope: $scope @@ -317,7 +318,7 @@ angular.module('starter.controllers', []) }; }) -.controller('TravelCtrl', function($scope, $stateParams, $http, $ionicModal) { +.controller('TravelCtrl', function($scope, $stateParams, $http, $ionicModal, $ionicPopup) { if(localStorage.getItem('c_token')){// adding token to the headers $http.defaults.headers.common['X-Access-Token'] = localStorage.getItem('c_token'); } @@ -361,29 +362,66 @@ angular.module('starter.controllers', []) }); $scope.deleteTravel = function(){ - console.log("delete travel: " + $stateParams.travelId); + + var confirmPopup = $ionicPopup.confirm({ + title: 'Deleting publication', + template: 'Are you sure you want to delete '+ $scope.travel.title+'?' + }); + confirmPopup.then(function(res) { + if(res) { + console.log('You are sure'); + console.log("delete travel: " + $stateParams.travelId); + $http({ + url: urlapi + 'travels/' + $stateParams.travelId, + method: "DELETE" + }) + .then(function(response) { + console.log(response); + }, + function(response) { // optional + // failed + }); + } else { + console.log('You are not sure'); + } + }); + + + }; + $scope.joinTravel = function(){ + $scope.newjoin={ + travelId: $stateParams.travelId, + joinedUserId: localStorage.getItem("c_userid"), + joinedUsername: localStorage.getItem("c_username"), + joinedAvatar: localStorage.getItem("c_avatar") + }; $http({ - url: urlapi + 'travels/' + $stateParams.travelId, - method: "DELETE" + url: urlapi + 'travels/join/' + $stateParams.travelId, + method: "POST", + data: $scope.newjoin }) .then(function(response) { + // success + console.log("response: "); console.log(response); + }, function(response) { // optional // failed }); }; - $scope.joinTravel = function(){ - $scope.newjoin={ + $scope.unjoinTravel = function(){ + console.log("unjoin"); + $scope.unjoin={ travelId: $stateParams.travelId, joinedUserId: localStorage.getItem("c_userid"), joinedUsername: localStorage.getItem("c_username"), joinedAvatar: localStorage.getItem("c_avatar") }; $http({ - url: urlapi + 'travels/join/' + $stateParams.travelId, + url: urlapi + 'travels/unjoin/' + $stateParams.travelId, method: "POST", - data: $scope.newjoin + data: $scope.unjoin }) .then(function(response) { // success @@ -395,9 +433,6 @@ angular.module('starter.controllers', []) // failed }); }; - $scope.unjoinTravel = function(){ - console.log("unjoin"); - }; /* adding comment */ $scope.doingNewComment=false; diff --git a/www/templates/menu.html b/www/templates/menu.html index 3d37231..858d090 100644 --- a/www/templates/menu.html +++ b/www/templates/menu.html @@ -32,7 +32,11 @@ Users - + + + {{storageusername}} + + Settings diff --git a/www/templates/search.html b/www/templates/search.html deleted file mode 100644 index 7482416..0000000 --- a/www/templates/search.html +++ /dev/null @@ -1,5 +0,0 @@ - - -

Search

-
-
diff --git a/www/templates/settings.html b/www/templates/settings.html new file mode 100644 index 0000000..6514b9c --- /dev/null +++ b/www/templates/settings.html @@ -0,0 +1,5 @@ + + +

Settings

+
+
diff --git a/www/templates/travel.html b/www/templates/travel.html index 3e4390a..1e22143 100644 --- a/www/templates/travel.html +++ b/www/templates/travel.html @@ -4,33 +4,49 @@

{{travel.title}}

{{travel.date | date:"dd/MM HH:mm a"}}
-
- Collectivized +
-
-
+

{{travel.description}}

+
+
+
+

+ {{travel.phone}} +

+

+ {{travel.telegram}} +

+ +

{{travel.from}} - {{travel.to}}

+
+
+

+ Collectivized +

+

+

can carry package
need to carry package
+

+ +

+

nº car seats: {{travel.seats}}
+
nº people: {{travel.seats}}
+

-

{{travel.from}} - {{travel.to}}

-

-

nº car seats: {{travel.seats}}
-
nº people: {{travel.seats}}
-

-

{{travel.description}}

+

-

- {{travel.phone}} -

-

- {{travel.telegram}} -

+

@@ -46,9 +62,6 @@ Unoffer car

-

- Delete -

@@ -66,18 +79,17 @@
- New comment + New comment
- -
diff --git a/www/templates/travels.html b/www/templates/travels.html index 2f90b73..97a3b3e 100644 --- a/www/templates/travels.html +++ b/www/templates/travels.html @@ -16,6 +16,13 @@
+ +
+
+ No data in memory.
+ Pull from top to refresh +
+

{{travel.title}}