Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Queues- 2*Anna - VideoStore #12

Open
wants to merge 34 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
e7b0b7c
added movie-list function
amb54 Jun 13, 2017
af1c34a
implemented search function
annaewolf Jun 14, 2017
db90ec1
deleted unnecessary views
annaewolf Jun 14, 2017
133e7e0
removed a couple lines
annaewolf Jun 14, 2017
538ff82
Added form for adding a movie to the rental library.
amb54 Jun 14, 2017
4e7eac5
PUSHING ON THE RIGHT REPO THIS TIME
annaewolf Jun 14, 2017
e3a8766
added a home button
annaewolf Jun 14, 2017
8e0a8a9
Added sorted by title to the movie_list collection.
amb54 Jun 15, 2017
edcd8bb
Added .hide() and .show() to the #add-form to make it pop up when to …
amb54 Jun 15, 2017
b90e946
Added table tags to arrange the movies in a table instead of as a lis…
amb54 Jun 15, 2017
5e4f45f
In styles.css added set rules for .table-list, .button, and #add-form.
amb54 Jun 15, 2017
70c6866
fixed merge conflict
annaewolf Jun 15, 2017
65da85d
added hide-form
annaewolf Jun 15, 2017
162de0d
fixed render function
annaewolf Jun 15, 2017
0586717
Added import MovieList to movie_list_view
amb54 Jun 15, 2017
72f5309
added success callback
annaewolf Jun 15, 2017
b3564e5
this-self update of the render funtion in the movie-view.
amb54 Jun 16, 2017
23bda19
Updated the getInput function in the movie_list_view with regards to …
amb54 Jun 16, 2017
dead927
Updated the templates rental-library-template and search-library-temp…
amb54 Jun 16, 2017
1f3ca08
removed substr in index for release_date.
amb54 Jun 20, 2017
cffb0b0
Added linkt to image in the inventory list. Added click event to the …
amb54 Jun 20, 2017
3bb4791
Added moviecheckout template and holder ti index. Added template to t…
amb54 Jun 20, 2017
a99735a
added checkout function
annaewolf Jun 20, 2017
3b82226
MERGE Merge branch 'master' of https://github.com/amb54/VideoStoreCon…
annaewolf Jun 20, 2017
1523ddb
added more form info
annaewolf Jun 20, 2017
063d3f0
added customer render
annaewolf Jun 20, 2017
fa104a5
fixed the checkout post
annaewolf Jun 21, 2017
71fd336
Added code tofetch information about a specific movie in the checkotF…
amb54 Jun 21, 2017
1113ad6
Resolved merge conflicts
amb54 Jun 21, 2017
59fe50e
removed periods from titles
annaewolf Jun 21, 2017
af95f30
Changed the with and heigth for the selectors #add-form, #movie-check…
amb54 Jun 23, 2017
e2051d8
Cleared the #search form after a movie has been saved to the rental l…
amb54 Jun 23, 2017
de3d2c7
Sorted the customer list by name.
amb54 Jun 23, 2017
1cce48f
Reworked the addto-rental-library-template
amb54 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
31 changes: 31 additions & 0 deletions build/css/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,34 @@ div {
border-style: solid;
}
*/
.table-list {
margin-bottom: 0.25rem;
background-color: white;
}

.button {
margin: 0;
}

#add-form, #movie-checkout-form {
z-index: 10;
position: fixed;
width: 80%;
/*height: 600px;*/
top: 8%;
right: 15%;
background-color: lightgreen;
text-align: left;
border: 0.1em solid white;
margin-left: 10%;
border-radius: 1rem;
padding: 1rem;
}

table.table-list {
padding: 1rem;
}

img {
border-radius: 1rem;
}
125 changes: 125 additions & 0 deletions build/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,131 @@
<title>Backbone Baseline</title>
</head>
<body>
<header>
<h3 id="home"><a>Video Store</a></h3>
</header>
<main>
<section id='add-form'></section>
<section id='movie-checkout-form'> </section>
<section class="row">
<section id="form">
<label for="search">Search for Movie</label>
<input type="text" name="search" id="search" />
</section>
<section id="buttons">
<button id="submit-button" class="button success">Search</button>
</section>
<section id='rental-library'> </section>
<section id='rental-library' class='row'> </section>

</main>


<!-- TEMPLATES -->
<script id="rental-library-template" type="text/template">
<tr>
<td class='large-2 medium-2 column'><a id= 'to-movie-checkout'><img src= '<%-movie.image_url%>'/></a></td>
<td class='large-3 medium-3 column'>
<h5><%-movie.title%></h5>
<p><%-movie.release_date%></p>
</td>
<td class='large-7 medium-7 column'>
<%-movie.overview%>
</td>
</tr>

</script>

<script id="search-library-template" type="text/template">
<tr>
<td class='large-7 medium-7 column'><%-movie.title%></td>
<td class='large-2 medium-2 column'><%-movie.release_date%></td>
<td class='large-3 medium-3 column'><button class="button tiny alert" id= 'open-add-form'>Add To Rental Library</button></td>
</tr>
</script>




<script id="addto-rental-library-template" type="text/template">
<section class="contact-form">

<section class="row">
<h4 class="columns">Save to the rental library</h4>
</section>

<section class = 'row'>
<div class="large-3 medium-3 columns">
<img src= '<%-movie.image_url%>'/>
</div>
<div class = 'large-4 medium-4 columns'>

<div class="columns">
<h5>
<%-movie.title%>
</h5>
<h5>
<%-movie.release_date%>
</h5>
</div>

<div class="columns">
<label>
<input type="hidden" name="title" value="<%-movie.title%>" id = 'title'>
</label>
<label>
<input type="hidden" name="overview" value="<%-movie.overview%>" id = 'overview'>
</label>
<label>
<input type="hidden" name="release_date" value="<%-movie.release_date%>" id = 'release_date'>
</label>
<label>
<input type="hidden" name="image_url" value="<%-movie.image_url%>" id = 'image_url'>
</label>
<label>
Number of copies
<input type="number" name="inventory" id = 'inventory'>
</label>
</div>

<div class='column'>
<h3 class="button btn-save">Save</h3>
<h3 class="button btn-cancel">Cancel</h3>
</div>
</div>

<div class = 'large-5 medium-5 columns'>
<%-movie.overview%>
</div>

</section>
</section>
</script>

<script id="movie-checkout-template" type = 'text/template'>
<section>
<h4>Check Out: <%-movie.title%></h4>
<p>Total inventory: <%-movie.inventory%></p>
<p>Copies Left: <%-movie.available_inventory%> </p>
<div>
<label>
Due Date
<input type="date" name="due_date" id="due_date" />
</label>
<input type="hidden" name="title" value="<%-movie.title%>" id="movie_title" />
<select id="customer-dropdown" name="customer">
</select>

<h3 class="button btn-save">Save</h3>
<h3 class="button co-btn-cancel">Cancel</h3>
</div>
</section>
</script>

<script id="customer-checkout-template" type = 'text/template'>
<option value="<%-customer.id%>"> <%-customer.name%> </option>
</script>


<script src="/app.bundle.js"></script>

Expand Down
71 changes: 70 additions & 1 deletion src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,78 @@
import $ from 'jquery';
import _ from 'underscore';

// MODELS
import MovieList from './collections/movie_list';
import CustomerList from './collections/customer_list';

// VIEWS
import MovieListView from './views/movie_list_view';
import CustomerListView from './views/customer_list_view';

var movieTemplate;
var searchTemplate;
var addFormTemplate;
var movieCheckoutFormTemplate;
var customerTemplate;
// ready to go
var rentalLibrary = function() {
var movieList = new MovieList();
movieList.fetch();
var params = {
movieTemplate: movieTemplate,
movieCheckoutFormTemplate: movieCheckoutFormTemplate,
customerShowMethod: customerShow,
el: $('main'),
model: movieList
};
var application = new MovieListView(params);
application.render();
};

var customerShow = function() {
var customerList = new CustomerList();
customerList.fetch();
var params = {
customerTemplate: customerTemplate,
el: $('main'),
model: customerList
};
var application = new CustomerListView(params);
application.render();
};

var movieLibrary = function() {
var search = {data: $.param({query: $('#search').val()})};
var searchList = new MovieList();
searchList.fetch(search);
var params = {
movieTemplate: searchTemplate,
addFormTemplate: addFormTemplate,
el: $('main'),
model: searchList,
renderRentalLibraryCallback: rentalLibrary
};
var searchApp = new MovieListView(params);
searchApp.render();
};

$(document).ready(function() {
$('#add-form').hide();
$('#movie-checkout-form').hide();

movieTemplate = _.template($('#rental-library-template').html());
searchTemplate = _.template($('#search-library-template').html());
addFormTemplate = _.template($('#addto-rental-library-template').html());
movieCheckoutFormTemplate = _.template($('#movie-checkout-template').html());
customerTemplate = _.template($('#customer-checkout-template').html());

rentalLibrary();

$('section.main-content').append('<p>Hello World!</p>');
$('#home').click(function(event) {
rentalLibrary();
});

$('#submit-button').click(function(event) {
movieLibrary();
});
});
14 changes: 14 additions & 0 deletions src/collections/customer_list.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import Backbone from 'backbone';
import Customer from '../models/customer';
import $ from 'jquery';

var CustomerList = Backbone.Collection.extend({
model: Customer,
url: 'http://localhost:3000/customers',
comparator: function (model) {
return model.get("name");
}
});


export default CustomerList;
26 changes: 26 additions & 0 deletions src/collections/movie_list.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import Backbone from 'backbone';
import Movie from '../models/movie';
import $ from 'jquery';
import _ from 'underscore';

var MovieList = Backbone.Collection.extend({
model: Movie,
url: 'http://localhost:3000/movies',
parse: function(data) { // The parsing migth not be needed in this case
return data;
},
comparator: function (model) {
return model.get("title");
},
checkOut: function(data) {
var url = "http://localhost:3000/rentals/" + data['movie_title'] + "/check-out";
var rental = new Backbone.Model(data)

return (this.sync || Backbone.sync).call(this, "create", rental, _.extend({
url: url
}));
}
});


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

var Customer = Backbone.Model.extend({


initialize: function(params){
// console.log("Movie initialized: " + this.get("title"));
}
});


export default Customer;
12 changes: 12 additions & 0 deletions src/models/movie.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import Backbone from 'backbone';

var Movie = Backbone.Model.extend({


initialize: function(params){
// console.log("Movie initialized: " + this.get("title"));
}
});


export default Movie;
35 changes: 35 additions & 0 deletions src/views/customer_list_view.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import Backbone from 'backbone';
import _ from 'underscore';
import $ from 'jquery';
import CustomerView from './customer_view';
import Customer from '../models/customer.js';
// import MovieList from '../collections/movie_list';

var CustomerListView = Backbone.View.extend({
tagName: 'option',
initialize: function(params){
this.customerTemplate = params.customerTemplate;

this.listenTo(this.model, 'update' , this.render);
},

render: function(){
console.log(' Customer list View in render>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>')
var self = this;
self.$('#customer-dropdown').empty();

self.model.each(function(customer){
var customerView = new CustomerView({
model: customer,
customerTemplate: self.customerTemplate
});
self.$('#customer-dropdown').append(customerView.render().$el.html());
});
return this;
}


});


export default CustomerListView;
24 changes: 24 additions & 0 deletions src/views/customer_view.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import Backbone from 'backbone';
import _ from 'underscore';
import $ from 'jquery';
import Customer from '../models/customer.js';

var CustomerView = Backbone.View.extend({
initialize: function(params){
this.customerTemplate = params.customerTemplate;
this.listenTo(this.model, "change", this.render);
},

render: function(){
console.log("made it here CUSTOMER VIEW");
var self = this;
var compiledTemplate = this.customerTemplate({
customer: self.model.toJSON()
});
this.$el.html(compiledTemplate);
return this;
}
});


export default CustomerView;
Loading