diff --git a/client/app/components/movies-connector/moviesConnector.factory.js b/client/app/components/movies-connector/moviesConnector.factory.js index 5cd3886..f5daafb 100644 --- a/client/app/components/movies-connector/moviesConnector.factory.js +++ b/client/app/components/movies-connector/moviesConnector.factory.js @@ -21,7 +21,8 @@ topRatedMovies: topRatedMovies, configuration: configuration, search: search, - movieInfo: movieInfo + movieInfo: movieInfo, + reviewAdd: reviewAdd }; function topRatedMovies() { @@ -44,6 +45,10 @@ }); } + function reviewAdd(data){ + return $http.post('/api/movies/review/', data) + } + return service; } diff --git a/client/app/pages/movie/movie-page.controller.js b/client/app/pages/movie/movie-page.controller.js index d37511e..e05bf9d 100644 --- a/client/app/pages/movie/movie-page.controller.js +++ b/client/app/pages/movie/movie-page.controller.js @@ -11,10 +11,46 @@ ]; /* @ngInject */ - function MoviePageController(movie, topMovies, moviesConnector){ + function MoviePageController(movie, moviesConnector){ var vm = this; vm.movie = movie; + vm.user = {}; + vm.review = {}; + vm.msg = null; + + vm.addReview = function(isValid){ + + vm.submitted = true; + + if (isValid) { + + var data = {}; + data.user = vm.user; + data.movieId = vm.movie.id; + data.rating = vm.review.rate; + data.comment = vm.review.comment; + + console.debug(data); + + moviesConnector.reviewAdd(data) + .then(function () { + vm.msg = 'Your review has been saved successfully'; + console.debug('success'); + }) + .catch(function (response) { + vm.msg = 'There was an error submiting your review'; + console.debug('error'); + }); + } + }; + + vm.back = function(){ + vm.msg = null; + vm.user = {}; + vm.review = {}; + vm.review = {}; + }; } })(); diff --git a/client/app/pages/movie/movie-page.html b/client/app/pages/movie/movie-page.html index c8642da..aaf718b 100644 --- a/client/app/pages/movie/movie-page.html +++ b/client/app/pages/movie/movie-page.html @@ -14,6 +14,7 @@
| Date | +Type | +Description | +Amount | + + +|
|---|---|---|---|---|
| {{ exp.date | date: 'dd/MM/yy'}} | +{{ exp.type }} | +{{ exp.description }} | +{{ exp.amount }} | ++ + + | +
| Type | +Total | + + +
|---|---|
| {{type}} | +{{ exp.amount + total }} + | +
{{ exp.amount + total}}
+| Date | +Type | +Description | +Amount | +Action | +
|---|---|---|---|---|
| {{item.date}} | +{{item.type}} | +{{item.description}} | +{{item.amount}} | ++ + + + | +
| Type | +Total | +
|---|---|
| {{type}} | +{{total + item.amout * 1}} | +
| Date | +Type | +Description | +Amount | + + +|
|---|---|---|---|---|
| {{ expen.date | date: 'MM/dd/yy'}} | +{{ expen.type }} | +{{ expen.description }} | +{{ expen.amount }} | ++ + + | +
| Type | +Total | + + +
|---|---|
| {{ type }} | +{{ exp.getTotalByType(type) }} | +
Total: {{ exp.getTotal() }}
+