Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
5e9eb8e
Created model/view files
ricecakemonster Jun 13, 2017
58d4843
added template for movie list in index
cynthiacd Jun 13, 2017
2825a41
request for all movies in rental library working
cynthiacd Jun 14, 2017
e299be1
playing with css of list
cynthiacd Jun 14, 2017
56def4e
have movieViews rendering in initialize - will help with memory/load …
cynthiacd Jun 14, 2017
530f71c
merging
ricecakemonster Jun 14, 2017
2811224
playing with css of homepage
cynthiacd Jun 14, 2017
9ce6260
showing inventory or add to library button
cynthiacd Jun 14, 2017
064c45b
click on add movie is responding
cynthiacd Jun 14, 2017
e56b972
made it to the trigger function
cynthiacd Jun 14, 2017
f658d0a
Adding a movie working
ricecakemonster Jun 15, 2017
8aa09d6
Adding a movie with stock # and gives error/success message
ricecakemonster Jun 15, 2017
5157e98
added error handling for fetch calls
cynthiacd Jun 15, 2017
93ecc77
styling of movie lists
cynthiacd Jun 15, 2017
e2a91c1
changed html element to li for movie list
cynthiacd Jun 15, 2017
5eeb6a0
added button and click handler for single movie search
cynthiacd Jun 16, 2017
bf05454
fixed styling issue - each movie view in its own li box - not overflo…
cynthiacd Jun 19, 2017
71fc71a
merging
ricecakemonster Jun 19, 2017
96aec94
fixed bug with toggle of search bar
cynthiacd Jun 19, 2017
e54611c
added buttons for checkout/checkin feature
cynthiacd Jun 19, 2017
0d6e037
merging
ricecakemonster Jun 19, 2017
144808a
Created rental model/view. Create a rental with given inputs
ricecakemonster Jun 19, 2017
1f2ebfe
it hides rental forms when you click on other buttons
ricecakemonster Jun 19, 2017
ce50394
more styling of movie list
cynthiacd Jun 20, 2017
e784dfe
added available inventory to movie list view
cynthiacd Jun 20, 2017
a1a8151
Checkout working / no double checkouts
ricecakemonster Jun 20, 2017
4eff3e2
Merge branch 'master' of https://github.com/cynthiacd/VideoStoreConsumer
ricecakemonster Jun 20, 2017
2c16323
showing error messages if rental fails
cynthiacd Jun 20, 2017
bb9c95a
working on bug with adding new movies
cynthiacd Jun 20, 2017
6950b58
ctn to figure out why add new movie is broke
cynthiacd Jun 20, 2017
7fb5a22
Adding a movie/Alert working ok.
ricecakemonster Jun 21, 2017
7714592
Merge branch 'master' of https://github.com/cynthiacd/VideoStoreConsumer
ricecakemonster Jun 21, 2017
8acf7a4
preparing for merge - hyunji fixed post movie bug
cynthiacd Jun 21, 2017
ffd79e6
merging movie post fix
cynthiacd Jun 21, 2017
5bdf6aa
Adding a movie error message(detailed response) working
ricecakemonster Jun 21, 2017
61d92f2
cleaned up spacing
cynthiacd Jun 21, 2017
1ff9ec4
Merge branch 'master' of https://github.com/cynthiacd/VideoStoreConsumer
ricecakemonster Jun 21, 2017
cc8722e
merging
ricecakemonster Jun 21, 2017
3a6a8ff
merging changes with add movie to lib
cynthiacd Jun 21, 2017
de2612e
merging again
ricecakemonster Jun 21, 2017
2fbe57c
Check-in is working well
ricecakemonster Jun 21, 2017
c7b93fa
get request for overdue working - created files needed to show results
cynthiacd Jun 21, 2017
6ca155d
showing overdue rentals working
cynthiacd Jun 21, 2017
53d8cc9
fix bug with overdue rentals table
cynthiacd Jun 21, 2017
09f35ee
cleaned up code
cynthiacd Jun 21, 2017
3f0f331
pushing to remote origin
ricecakemonster Jun 21, 2017
98ef7ac
merging overdue feature
cynthiacd Jun 21, 2017
7218959
fixed bug with overdue table
cynthiacd Jun 21, 2017
2e79713
edited id for rentals form
cynthiacd Jun 21, 2017
c8ec70f
list of rentals only shows rentals that are have not been checked in
cynthiacd Jun 21, 2017
1d118be
cleaning code - adding styleing of table
cynthiacd Jun 21, 2017
4c49a38
ctn to play with overall styling
cynthiacd Jun 21, 2017
dbc763b
more styling of movie list
cynthiacd Jun 21, 2017
f386598
added a rental button to movie list
cynthiacd Jun 23, 2017
24bbede
index on master: f386598 added a rental button to movie list
cynthiacd Jun 23, 2017
be660db
WIP on master: f386598 added a rental button to movie list
cynthiacd Jun 23, 2017
696c62c
fixing checkout from movie list
cynthiacd Jun 23, 2017
619981b
can checkout movie from list
cynthiacd Jun 23, 2017
f096741
dryed up rental view code
cynthiacd Jun 23, 2017
a482c30
dyred up code in app js
cynthiacd Jun 23, 2017
3127fc0
cleaned up spacing
cynthiacd Jun 23, 2017
4bbc3ec
rental list updating when you post a rental from list
cynthiacd Jun 23, 2017
b033f95
error alerts show response
cynthiacd Jun 23, 2017
3a087f4
final version - ready for pull request
cynthiacd Jun 23, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 59 additions & 7 deletions build/css/styles.css
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
@include foundation-everything;

main {
background: lightblue;
background: white;
}

header {
background-color: lightgreen;
background-color: lightgrey;
padding: 0.5rem;
text-align: center;
}

#completed-checkbox {
Expand Down Expand Up @@ -35,10 +36,61 @@ aside label {
}

div {
display: inline;
display: block;
}

li {
/*border: solid;*/
background-color: lightgrey;
/*height: 27em;*/
padding: 2%;
margin: 3%
}

#movie-text {
/*border: solid;*/
}

.columns {
float: none;
}

.button {
margin-top: 1%;
}

#search-bar {
display: none;
}

h4 {
font-weight: bold;
}
/*
* {
border-style: solid;

li {
list-style: none;
}
#rental-form {
display: none;
}

#rentals {
display: none;
}

th {
text-align: left;
}

h2 {
border-bottom: solid;
}

.button.btn-checkin,
.button.btn-checkout {
margin: 0;
}

#form {
width: 100%;
}
*/
86 changes: 84 additions & 2 deletions build/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,93 @@
<link rel="stylesheet" type="text/css" href="css/_settings.css">
<link rel="stylesheet" type="text/css" href="css/foundation.css">
<link rel="stylesheet" type="text/css" href="css/styles.css">
<title>Backbone Baseline</title>
<title>Video Store</title>
</head>
<body>
<header>
<h1>Video Store</h1>
</header>

<script src="/app.bundle.js"></script>
<main class="row">
<button class="button" id="rental-list">Rental Movies</button>
<button class="button" id="new-movies-list">Search For New Movies</button>
<button class="button" id="rental-movie">Checkout</button>
<button class="button" id="rental-overdue">Overdue Movies</button>
<button class="button" id="rental-all">All Oustanding Rentals</button>

<section class="row" id="search-bar">
<label>
Search
<input type="text" name="search" id="search" placeholder="Search..">
</label>
<button class="button btn-search">Search</button>
</section>

<section id="movie-list" class="row"></section>
<section id="rental-form" class="row"></section>
<section id="rentals" class="row">
<table>
<tr>
<th>Movie</th>
<th>Customer</th>
<th>Customer ID</th>
<th>Checkout Date</th>
<th>Due Date</th>
<th>Returned</th>
<th>Check In</th>
</tr>
<tbody id="overdue-info"></tbody>
</table>
</section>
</main>

<!-- Templates -->

<script id="movie-card-template" type="text/template">
<img alt="movie image" class="columns large-2 small-2" src=<%- image_url %> >
<div class="columns large-10 small-10" id="movie-text">
<h2><strong><%- title %></strong></h2>
<p><strong>Summary: </strong><%- overview %></p>
<p><strong>Release Date: </strong><%- release_date %></p>
<% if ( inventory === null ) { %>
<p>
<strong>Quantity: </strong>
<input type="number" name="inventory" id='inventory' min="1" max="5" value="1">
</p>
<button class="button btn-add-lib">Add to Library</button>
<% } else { %>
<p><strong>Inventory: </strong><%- inventory%></p>
<p><strong>Available Inventory: </strong><%- available_inventory %></p>
<button class="button btn-rental">Check Out This Movie</button>
<% } %>
</div>
</script>

<script id="rental-form-template" type="text/template">
<section class="columns large-12 small-12">
<label>
Movie Title
<input type="text" name="rental-movie-title" id="rental-movie-title" placeholder="Search..">
</label>
<label>
Customer ID
<input type="text" name="rental-customer-id" id="rental-customer-id" placeholder="Search..">
</label>
<button class="button btn-checkout">Checkout</button>
<button class="button btn-checkin">Checkin</button>
</section>
</script>

<script id="overdue-table" type="text/template">
<td><%- title %></td>
<td><%- name %></td>
<td><%- customer_id %></td>
<td><%- checkout_date %></td>
<td><%- due_date %></td>
<td><%- returned %></td>
<td><button class="button btn-checkin-from-list">Check In</button></td>
</script>

<script src="/app.bundle.js"></script>
</body>
</html>
107 changes: 104 additions & 3 deletions src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,110 @@
import $ from 'jquery';
import _ from 'underscore';

// ready to go
$(document).ready(function() {
import MovieList from './collections/movie_list';
import Movie from './models/movie';
import MovieListView from './views/movie_list_view';
import MovieView from './views/movie_view';
import Rental from './models/rental';
import RentalList from './collections/rental_list';
import RentalView from './views/rental_view';
import RentalListView from './views/rental_list_view';

var buildMovieList = function(event){
hideEverything();
console.log("Getting the Library Movies");
var movieList = new MovieList();
getMovies(movieList);
};

var buildMovieListTMDb = function(event) {
hideEverything();
console.log("Getting movies from TMDb!");
var searchText = $('#search').val();
var movieList = new MovieList();
movieList.cumstomUrl(searchText);
getMovies(movieList);
};

var getMovies = function(movieList) {
movieList.fetch(
{ error: function(model, response) { alert("Server Error - Try Again Later") },
success: function(model, response) { console.log( "API success - got movies" ) }
}
);

var movieListView = new MovieListView({
model: movieList,
templateForm: _.template( $('#movie-card-template').html() ),
el: 'main'
});

$("#movie-list").show();
};

var showSearchBar = function(event) {
hideEverything();
$("#search-bar").show();
};

var showRentalForm = function(event) {
hideEverything();

$('section.main-content').append('<p>Hello World!</p>');
var rental = new Rental;
var rentalView = new RentalView({
templateInfo: _.template( $('#rental-form-template').html() ),
tagName: "div",
model: rental,
});

$("#rental-form").empty();
$('#rental-form').html( rentalView.$el );
$("#rental-form").show();
};

var buildOverdueRentalsList = function(event) {
hideEverything();
console.log("Getting overdue movies");
var overdueRentals = new RentalList ();
overdueRentals.overdueUrl();
getRentals(overdueRentals);
};

var buildRentalsList = function(event) {
hideEverything();
console.log("Getting all outstanding rentals");
var rentals = new RentalList ();
getRentals(rentals);
};

var getRentals = function(rentals) {
rentals.fetch(
{ error: function(model, response) { alert("Server Error - Try Again Later") },
success: function(model, response) { console.log( "API success - got overdue rentals" ) }
}
);

var rentalListView = new RentalListView({
model: rentals,
templateInfo: _.template( $("#overdue-table").html() ),
el: '#rentals'
});

$("#rentals").show();
};

var hideEverything = function () {
$("#rentals").hide();
$("#search-bar").hide();
$("#rental-form").hide();
$("#movie-list").hide();
};

$(document).ready(function() {
$('#rental-list').click( buildMovieList );
$('.btn-search').click( buildMovieListTMDb );
$('#new-movies-list').click( showSearchBar);
$('#rental-movie').click( showRentalForm );
$('#rental-overdue').click( buildOverdueRentalsList );
$('#rental-all').click( buildRentalsList)
});
15 changes: 15 additions & 0 deletions src/collections/movie_list.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import Backbone from 'backbone';
import Movie from '../models/movie';

var MovieList = Backbone.Collection.extend({
model: Movie,
url: 'http://localhost:3000/movies',

cumstomUrl: function(searchText){
this.url = this.url + "?query=" + searchText;
// console.log(this.url);
return this;
}
});

export default MovieList;
14 changes: 14 additions & 0 deletions src/collections/rental_list.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import Backbone from 'backbone';
import Rental from '../models/rental';

var RentalsList = Backbone.Collection.extend({
model: Rental,
url: 'http://localhost:3000/rentals/',

overdueUrl: function() {
this.url = this.url + "overdue";
return this;
}
});

export default RentalsList;
Loading