{"action":"created","comment":{"url":"https://api.github.com/repos/vTrip/away_mvp/pulls/comments/53387625","id":53387625,"diff_hunk":"@@ -73,16 +76,176 @@ angular.module('awayapp')\n     // or directly here)\n     TripService.add(newTrip).then(function(t) {\n       trips.value.push(t);\n-      return addModalPromise;\n+      return addTripModalPromise;\n     }).then(function(m) {\n       m.hide();\n     });\n+\n+    var newDestination = {\n+      tripId: newTrip.id,\n+      destinationId: 0,\n+      countryCode: '',\n+      cityName: newTrip.departureLocation,\n+      departureDate: null,\n+      durationOfStay: 0,\n+      isDeparturePoint: true,\n+    }\n+\n+    DestinationService.add(newDestination);\n+\n   }\n \n   //Cleanup the modal when we're done with it!\n   $scope.$on('$destroy', function() {\n+    console.log(\"destroying\");\n     addTripModalPromise.then(function(m) {\n       m.remove();\n     })\n   });\n+\n+  // Trip Info modal\n+  var tripInfoModalPromise = $ionicModal.fromTemplateUrl('templates/trip-info.html', {\n+    scope: $scope,\n+    animation: 'slide-in-up'\n+  }).catch(function(err) {\n+    //TODO(vince): handle any errors that might occur here (Not even sure what\n+    // the right thing to do is...)\n+    console.log(err);\n+  });\n+\n+  var tripInfo = $scope.tripInfo = {\n+    $isReadMode: true\n+  };\n+\n+  $scope.showReadView = function showReadView() {\n+    return tripInfo.$isReadMode;\n+  }\n+\n+  $scope.getStateLabel = function getStateLabel() {\n+    if (tripInfo.$isReadMode) {\n+      return \"Edit\";\n+    } else {\n+      return \"Done\";\n+    }\n+  }\n+\n+  $scope.changeState = function changeState($index) {\n+    if (tripInfo.$isReadMode) {\n+      tripInfo.$isReadMode = false;\n+    } else {\n+      tripInfo.$isReadMode = true;\n+      TripService.update(tripInfo).then(function() {\n+        $scope.cancelTripInfo();\n+      }).catch(function(err) {\n+        //TODO(vince): handle errors here that might occur\n+        console.log(err);\n+      });\n+    }\n+\n+    console.log(tripInfo);\n+  }\n+\n+  $scope.showInfo = function showInfo($index) {\n+    tripInfoModalPromise.then(function(m) {\n+      tripInfo = _.extend(tripInfo, trips.value[$index]);\n+      m.show();\n+    });\n+  };\n+\n+  $scope.cancelTripInfo = function cancelTripInfo() {\n+    tripInfoModalPromise.then(function(m) {\n+      m.hide();\n+    });\n+  };\n+\n+  //Cleanup the modal when we're done with it!\n+  $scope.$on('$destroy', function() {\n+    tripInfoModalPromise.then(function(m) {\n+      m.remove();\n+    })\n+  });\n+\n+})\n+\n+.controller('DestinationCtrl', function($scope, $q, $stateParams, DestinationService, TripService) {\n+\n+  var trip = {\n+    $loading: true,\n+    value: null,\n+    $error: false,\n+  };\n+\n+  var destinations = $scope.destinations = {\n+    $loading: true,\n+    value: [],\n+    $error: false\n+  };\n+\n+  $scope.reload = function reload() {\n+\n+    // $q.all(DestinationService.list($stateParams.tripId), TripService.findTrip($stateParams.tripId)).then(function(vals) {\n+    //   console.log(vals);\n+    // }).catch(function(err) {\n+    //\n+    // }).finally(function() {\n+    //    $scope.$broadcast('scroll.refreshComplete');\n+    // });\n+\n+    DestinationService.list($stateParams.tripId).then(function(result) {\n+      destinations.$loading = false;\n+      destinations.value = result;\n+    }).catch(function(err) {\n+      destinations.$loading = false;\n+      destinations.$error = true;\n+    }).finally(function() {\n+       $scope.$broadcast('scroll.refreshComplete');\n+    });\n+\n+    TripService.list().then(function(result) {\n+      trip.$loading = false;\n+      for (var index = 0; index < result.length; ++index) {\n+        if (result[index].id == $stateParams.tripId) {\n+          trip.value = result[index];\n+        }\n+      }\n+    }).catch(function(err) {\n+      trip.$loading = false;\n+      trip.$error = true;\n+    }).finally(function() {\n+       $scope.$broadcast('scroll.refreshComplete');\n+    });\n+  }\n+  $scope.reload();\n+\n+  $scope.deleteDestination = function deleteDestination(index) {\n+    DestinationService.delete(destinations.value[index].destinationId);\n+    destinations.value.splice(index, 1);\n+  };\n+\n+  $scope.addDestination = function addDestination(departurePoint) {\n+    var newTrip = $scope.newTrip = {\n+      tripId: trip.value.id,\n+      destinationId: destinations.value.length,\n+      countryCode: 'AUS',\n+      cityName: 'Gold Coast',\n+      departureDate: \"\",\n+      durationOfStay: 0,\n+      isDeparturePoint: departurePoint,\n+    }\n+\n+    DestinationService.add(newTrip).then(function(t) {\n+      destinations.value.push(t);\n+    });\n+  }\n+\n+  $scope.increaseDay = function increaseDay(index) {\n+    destinations.value[index].durationOfStay += 1;\n+    DestinationService.update(destinations.value[index]);","path":"www/js/controllers.js","position":201,"original_position":201,"commit_id":"0cb1d92da1b5be0e19bf1426a3267d1aeffc16ab","original_commit_id":"0cb1d92da1b5be0e19bf1426a3267d1aeffc16ab","user":{"login":"jsuresh","id":157815,"avatar_url":"https://avatars.githubusercontent.com/u/157815?v=3","gravatar_id":"","url":"https://api.github.com/users/jsuresh","html_url":"https://github.com/jsuresh","followers_url":"https://api.github.com/users/jsuresh/followers","following_url":"https://api.github.com/users/jsuresh/following{/other_user}","gists_url":"https://api.github.com/users/jsuresh/gists{/gist_id}","starred_url":"https://api.github.com/users/jsuresh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jsuresh/subscriptions","organizations_url":"https://api.github.com/users/jsuresh/orgs","repos_url":"https://api.github.com/users/jsuresh/repos","events_url":"https://api.github.com/users/jsuresh/events{/privacy}","received_events_url":"https://api.github.com/users/jsuresh/received_events","type":"User","site_admin":false},"body":"Stuff like this can get spammy (We are hitting the server every time the user clicks up or down!). Further, there are race conditions here out of our control.\r\n\r\nFor example, if I hit up twice, and the two requests take different IP routes, it's possible the first request arrives at the server latter, in which case the wrong update will be applied.\r\n\r\nFor now this is okay, but please add a TODO in the service handlers to throttle requests (see lodash debounce and throttle doco, handy trick to have in your toolkit)","created_at":"2016-02-18T21:44:52Z","updated_at":"2016-02-18T21:44:52Z","html_url":"https://github.com/vTrip/away_mvp/pull/19#discussion_r53387625","pull_request_url":"https://api.github.com/repos/vTrip/away_mvp/pulls/19","_links":{"self":{"href":"https://api.github.com/repos/vTrip/away_mvp/pulls/comments/53387625"},"html":{"href":"https://github.com/vTrip/away_mvp/pull/19#discussion_r53387625"},"pull_request":{"href":"https://api.github.com/repos/vTrip/away_mvp/pulls/19"}}},"pull_request":{"url":"https://api.github.com/repos/vTrip/away_mvp/pulls/19","id":59737544,"html_url":"https://github.com/vTrip/away_mvp/pull/19","diff_url":"https://github.com/vTrip/away_mvp/pull/19.diff","patch_url":"https://github.com/vTrip/away_mvp/pull/19.patch","issue_url":"https://api.github.com/repos/vTrip/away_mvp/issues/19","number":19,"state":"open","locked":false,"title":"departure destination","user":{"login":"vTrip","id":15204972,"avatar_url":"https://avatars.githubusercontent.com/u/15204972?v=3","gravatar_id":"","url":"https://api.github.com/users/vTrip","html_url":"https://github.com/vTrip","followers_url":"https://api.github.com/users/vTrip/followers","following_url":"https://api.github.com/users/vTrip/following{/other_user}","gists_url":"https://api.github.com/users/vTrip/gists{/gist_id}","starred_url":"https://api.github.com/users/vTrip/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vTrip/subscriptions","organizations_url":"https://api.github.com/users/vTrip/orgs","repos_url":"https://api.github.com/users/vTrip/repos","events_url":"https://api.github.com/users/vTrip/events{/privacy}","received_events_url":"https://api.github.com/users/vTrip/received_events","type":"User","site_admin":false},"body":"- Disabled delete button on the destination list item if it is a\ndeparture point","created_at":"2016-02-18T01:26:01Z","updated_at":"2016-02-18T21:44:53Z","closed_at":null,"merged_at":null,"merge_commit_sha":"6d20da7fa537b1d4e93ed84e6f3a012be93f508a","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/vTrip/away_mvp/pulls/19/commits","review_comments_url":"https://api.github.com/repos/vTrip/away_mvp/pulls/19/comments","review_comment_url":"https://api.github.com/repos/vTrip/away_mvp/pulls/comments{/number}","comments_url":"https://api.github.com/repos/vTrip/away_mvp/issues/19/comments","statuses_url":"https://api.github.com/repos/vTrip/away_mvp/statuses/0cb1d92da1b5be0e19bf1426a3267d1aeffc16ab","head":{"label":"vTrip:departure-destination","ref":"departure-destination","sha":"0cb1d92da1b5be0e19bf1426a3267d1aeffc16ab","user":{"login":"vTrip","id":15204972,"avatar_url":"https://avatars.githubusercontent.com/u/15204972?v=3","gravatar_id":"","url":"https://api.github.com/users/vTrip","html_url":"https://github.com/vTrip","followers_url":"https://api.github.com/users/vTrip/followers","following_url":"https://api.github.com/users/vTrip/following{/other_user}","gists_url":"https://api.github.com/users/vTrip/gists{/gist_id}","starred_url":"https://api.github.com/users/vTrip/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vTrip/subscriptions","organizations_url":"https://api.github.com/users/vTrip/orgs","repos_url":"https://api.github.com/users/vTrip/repos","events_url":"https://api.github.com/users/vTrip/events{/privacy}","received_events_url":"https://api.github.com/users/vTrip/received_events","type":"User","site_admin":false},"repo":{"id":51053061,"name":"away_mvp","full_name":"vTrip/away_mvp","owner":{"login":"vTrip","id":15204972,"avatar_url":"https://avatars.githubusercontent.com/u/15204972?v=3","gravatar_id":"","url":"https://api.github.com/users/vTrip","html_url":"https://github.com/vTrip","followers_url":"https://api.github.com/users/vTrip/followers","following_url":"https://api.github.com/users/vTrip/following{/other_user}","gists_url":"https://api.github.com/users/vTrip/gists{/gist_id}","starred_url":"https://api.github.com/users/vTrip/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vTrip/subscriptions","organizations_url":"https://api.github.com/users/vTrip/orgs","repos_url":"https://api.github.com/users/vTrip/repos","events_url":"https://api.github.com/users/vTrip/events{/privacy}","received_events_url":"https://api.github.com/users/vTrip/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/vTrip/away_mvp","description":"Travel planning application","fork":false,"url":"https://api.github.com/repos/vTrip/away_mvp","forks_url":"https://api.github.com/repos/vTrip/away_mvp/forks","keys_url":"https://api.github.com/repos/vTrip/away_mvp/keys{/key_id}","collaborators_url":"https://api.github.com/repos/vTrip/away_mvp/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/vTrip/away_mvp/teams","hooks_url":"https://api.github.com/repos/vTrip/away_mvp/hooks","issue_events_url":"https://api.github.com/repos/vTrip/away_mvp/issues/events{/number}","events_url":"https://api.github.com/repos/vTrip/away_mvp/events","assignees_url":"https://api.github.com/repos/vTrip/away_mvp/assignees{/user}","branches_url":"https://api.github.com/repos/vTrip/away_mvp/branches{/branch}","tags_url":"https://api.github.com/repos/vTrip/away_mvp/tags","blobs_url":"https://api.github.com/repos/vTrip/away_mvp/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/vTrip/away_mvp/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/vTrip/away_mvp/git/refs{/sha}","trees_url":"https://api.github.com/repos/vTrip/away_mvp/git/trees{/sha}","statuses_url":"https://api.github.com/repos/vTrip/away_mvp/statuses/{sha}","languages_url":"https://api.github.com/repos/vTrip/away_mvp/languages","stargazers_url":"https://api.github.com/repos/vTrip/away_mvp/stargazers","contributors_url":"https://api.github.com/repos/vTrip/away_mvp/contributors","subscribers_url":"https://api.github.com/repos/vTrip/away_mvp/subscribers","subscription_url":"https://api.github.com/repos/vTrip/away_mvp/subscription","commits_url":"https://api.github.com/repos/vTrip/away_mvp/commits{/sha}","git_commits_url":"https://api.github.com/repos/vTrip/away_mvp/git/commits{/sha}","comments_url":"https://api.github.com/repos/vTrip/away_mvp/comments{/number}","issue_comment_url":"https://api.github.com/repos/vTrip/away_mvp/issues/comments{/number}","contents_url":"https://api.github.com/repos/vTrip/away_mvp/contents/{+path}","compare_url":"https://api.github.com/repos/vTrip/away_mvp/compare/{base}...{head}","merges_url":"https://api.github.com/repos/vTrip/away_mvp/merges","archive_url":"https://api.github.com/repos/vTrip/away_mvp/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/vTrip/away_mvp/downloads","issues_url":"https://api.github.com/repos/vTrip/away_mvp/issues{/number}","pulls_url":"https://api.github.com/repos/vTrip/away_mvp/pulls{/number}","milestones_url":"https://api.github.com/repos/vTrip/away_mvp/milestones{/number}","notifications_url":"https://api.github.com/repos/vTrip/away_mvp/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/vTrip/away_mvp/labels{/name}","releases_url":"https://api.github.com/repos/vTrip/away_mvp/releases{/id}","deployments_url":"https://api.github.com/repos/vTrip/away_mvp/deployments","created_at":"2016-02-04T04:56:32Z","updated_at":"2016-02-04T05:57:42Z","pushed_at":"2016-02-18T07:13:20Z","git_url":"git://github.com/vTrip/away_mvp.git","ssh_url":"git@github.com:vTrip/away_mvp.git","clone_url":"https://github.com/vTrip/away_mvp.git","svn_url":"https://github.com/vTrip/away_mvp","homepage":null,"size":11281,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":6,"forks":0,"open_issues":6,"watchers":0,"default_branch":"master"}},"base":{"label":"vTrip:master","ref":"master","sha":"9bd13ae7e57d8dcc997dea075dca9ec97c98fafd","user":{"login":"vTrip","id":15204972,"avatar_url":"https://avatars.githubusercontent.com/u/15204972?v=3","gravatar_id":"","url":"https://api.github.com/users/vTrip","html_url":"https://github.com/vTrip","followers_url":"https://api.github.com/users/vTrip/followers","following_url":"https://api.github.com/users/vTrip/following{/other_user}","gists_url":"https://api.github.com/users/vTrip/gists{/gist_id}","starred_url":"https://api.github.com/users/vTrip/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vTrip/subscriptions","organizations_url":"https://api.github.com/users/vTrip/orgs","repos_url":"https://api.github.com/users/vTrip/repos","events_url":"https://api.github.com/users/vTrip/events{/privacy}","received_events_url":"https://api.github.com/users/vTrip/received_events","type":"User","site_admin":false},"repo":{"id":51053061,"name":"away_mvp","full_name":"vTrip/away_mvp","owner":{"login":"vTrip","id":15204972,"avatar_url":"https://avatars.githubusercontent.com/u/15204972?v=3","gravatar_id":"","url":"https://api.github.com/users/vTrip","html_url":"https://github.com/vTrip","followers_url":"https://api.github.com/users/vTrip/followers","following_url":"https://api.github.com/users/vTrip/following{/other_user}","gists_url":"https://api.github.com/users/vTrip/gists{/gist_id}","starred_url":"https://api.github.com/users/vTrip/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vTrip/subscriptions","organizations_url":"https://api.github.com/users/vTrip/orgs","repos_url":"https://api.github.com/users/vTrip/repos","events_url":"https://api.github.com/users/vTrip/events{/privacy}","received_events_url":"https://api.github.com/users/vTrip/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/vTrip/away_mvp","description":"Travel planning application","fork":false,"url":"https://api.github.com/repos/vTrip/away_mvp","forks_url":"https://api.github.com/repos/vTrip/away_mvp/forks","keys_url":"https://api.github.com/repos/vTrip/away_mvp/keys{/key_id}","collaborators_url":"https://api.github.com/repos/vTrip/away_mvp/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/vTrip/away_mvp/teams","hooks_url":"https://api.github.com/repos/vTrip/away_mvp/hooks","issue_events_url":"https://api.github.com/repos/vTrip/away_mvp/issues/events{/number}","events_url":"https://api.github.com/repos/vTrip/away_mvp/events","assignees_url":"https://api.github.com/repos/vTrip/away_mvp/assignees{/user}","branches_url":"https://api.github.com/repos/vTrip/away_mvp/branches{/branch}","tags_url":"https://api.github.com/repos/vTrip/away_mvp/tags","blobs_url":"https://api.github.com/repos/vTrip/away_mvp/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/vTrip/away_mvp/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/vTrip/away_mvp/git/refs{/sha}","trees_url":"https://api.github.com/repos/vTrip/away_mvp/git/trees{/sha}","statuses_url":"https://api.github.com/repos/vTrip/away_mvp/statuses/{sha}","languages_url":"https://api.github.com/repos/vTrip/away_mvp/languages","stargazers_url":"https://api.github.com/repos/vTrip/away_mvp/stargazers","contributors_url":"https://api.github.com/repos/vTrip/away_mvp/contributors","subscribers_url":"https://api.github.com/repos/vTrip/away_mvp/subscribers","subscription_url":"https://api.github.com/repos/vTrip/away_mvp/subscription","commits_url":"https://api.github.com/repos/vTrip/away_mvp/commits{/sha}","git_commits_url":"https://api.github.com/repos/vTrip/away_mvp/git/commits{/sha}","comments_url":"https://api.github.com/repos/vTrip/away_mvp/comments{/number}","issue_comment_url":"https://api.github.com/repos/vTrip/away_mvp/issues/comments{/number}","contents_url":"https://api.github.com/repos/vTrip/away_mvp/contents/{+path}","compare_url":"https://api.github.com/repos/vTrip/away_mvp/compare/{base}...{head}","merges_url":"https://api.github.com/repos/vTrip/away_mvp/merges","archive_url":"https://api.github.com/repos/vTrip/away_mvp/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/vTrip/away_mvp/downloads","issues_url":"https://api.github.com/repos/vTrip/away_mvp/issues{/number}","pulls_url":"https://api.github.com/repos/vTrip/away_mvp/pulls{/number}","milestones_url":"https://api.github.com/repos/vTrip/away_mvp/milestones{/number}","notifications_url":"https://api.github.com/repos/vTrip/away_mvp/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/vTrip/away_mvp/labels{/name}","releases_url":"https://api.github.com/repos/vTrip/away_mvp/releases{/id}","deployments_url":"https://api.github.com/repos/vTrip/away_mvp/deployments","created_at":"2016-02-04T04:56:32Z","updated_at":"2016-02-04T05:57:42Z","pushed_at":"2016-02-18T07:13:20Z","git_url":"git://github.com/vTrip/away_mvp.git","ssh_url":"git@github.com:vTrip/away_mvp.git","clone_url":"https://github.com/vTrip/away_mvp.git","svn_url":"https://github.com/vTrip/away_mvp","homepage":null,"size":11281,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":6,"forks":0,"open_issues":6,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/vTrip/away_mvp/pulls/19"},"html":{"href":"https://github.com/vTrip/away_mvp/pull/19"},"issue":{"href":"https://api.github.com/repos/vTrip/away_mvp/issues/19"},"comments":{"href":"https://api.github.com/repos/vTrip/away_mvp/issues/19/comments"},"review_comments":{"href":"https://api.github.com/repos/vTrip/away_mvp/pulls/19/comments"},"review_comment":{"href":"https://api.github.com/repos/vTrip/away_mvp/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/vTrip/away_mvp/pulls/19/commits"},"statuses":{"href":"https://api.github.com/repos/vTrip/away_mvp/statuses/0cb1d92da1b5be0e19bf1426a3267d1aeffc16ab"}}}}