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

Pipes - Anders + SRB - VideoStoreConsumer #17

Open
wants to merge 66 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
f8d33bb
Initial commit. Branching
anderschenders Dec 18, 2017
6a7c558
Adds basic LibMovie model and LibMovieList view files and imports the…
SRBusiness Dec 18, 2017
39e45c3
Merge branch 'master' of https://github.com/SRBusiness/VideoStoreCons…
SRBusiness Dec 18, 2017
8a7283d
Add foundation? Tried to add some styling
anderschenders Dec 18, 2017
2ae0d41
need to save to change branch
SRBusiness Dec 18, 2017
56072d5
Add underscore template for library-movies
anderschenders Dec 18, 2017
d0171d3
minor changes to movie_list
SRBusiness Dec 18, 2017
b3437d7
Merge conflicts
anderschenders Dec 18, 2017
6568d35
fixing merge conflict
SRBusiness Dec 18, 2017
664cd7f
Adds both views for libMovie and successful fetch in initialize
SRBusiness Dec 18, 2017
a043fb7
moved collection fetch back to app.js and added listener for collecti…
SRBusiness Dec 18, 2017
57f8c11
filled out both libMovieViews so that they draw all the movies
SRBusiness Dec 18, 2017
7401596
Foundation working
anderschenders Dec 18, 2017
200f968
Create models and views for searching
anderschenders Dec 18, 2017
df3491c
Commiting to switch to new branch
anderschenders Dec 18, 2017
9ae3556
Create Views for search - searchMovieView and searchMovieListView
anderschenders Dec 19, 2017
dc48b15
Working on getting form to submit
anderschenders Dec 19, 2017
80abb9a
Fix bug for submit
anderschenders Dec 19, 2017
11cbbfd
Can get search term out of form
anderschenders Dec 19, 2017
319d3c3
Working on searchMovies. Not there
anderschenders Dec 19, 2017
d96f4df
updating foundations
SRBusiness Dec 19, 2017
e65ec3c
Merge pull request #1 from SRBusiness/search
SRBusiness Dec 19, 2017
b1ff0ee
Able to change the url in search movie method
SRBusiness Dec 19, 2017
73f192b
clean ups
SRBusiness Dec 19, 2017
397d5d6
updates html and added search move underscore template
SRBusiness Dec 19, 2017
7464ef6
Add functionality to render search results
anderschenders Dec 19, 2017
1753c1c
Changes template to use for search movie view and adds style border
SRBusiness Dec 19, 2017
8ff7b38
added an events bus to both of our larger views and have them listeni…
SRBusiness Dec 19, 2017
e1ee52c
Add functionality to add a movie
anderschenders Dec 19, 2017
acb1dfa
add error handling to search movie large view
SRBusiness Dec 20, 2017
6482e16
adds error handling messages for adding a movie to the libary
SRBusiness Dec 20, 2017
2009cf6
Seemsto be working only using libMovie model and collection
SRBusiness Dec 20, 2017
0a87151
Also changed things so we are only using libMovie search view, search…
SRBusiness Dec 20, 2017
b47f242
commented out all of the redundant files to make sure we could go on …
SRBusiness Dec 20, 2017
d72cf07
Merge pull request #2 from SRBusiness/testOneModel
anderschenders Dec 20, 2017
e7c300c
Basic redesign layout. Add forms for check in and check out
anderschenders Dec 20, 2017
0a0fe5b
Basic styling. Centering things
anderschenders Dec 20, 2017
632eecb
Merge pull request #3 from SRBusiness/design-change
SRBusiness Dec 20, 2017
5ba04b7
Starting populating dropdown. Switching to branch
anderschenders Dec 20, 2017
bc081c3
Add functionality to populate dropdown menus for all customers
anderschenders Dec 20, 2017
2b8d1e3
Merge branch 'master' of https://github.com/SRBusiness/VideoStoreCons…
anderschenders Dec 20, 2017
99396d1
On rental button click can send movie title from large lib movie view…
SRBusiness Dec 20, 2017
31c5c7b
Trying to figure out the way to add title to the form value
SRBusiness Dec 20, 2017
e61e71f
Making a random change to push
SRBusiness Dec 20, 2017
ed16264
Add rental model. Create new rental, ready to be sent to API
anderschenders Dec 20, 2017
229bcbb
Rental model ready for POST to API
anderschenders Dec 20, 2017
93e9fd8
Able to send POST request for rental
anderschenders Dec 20, 2017
cf35e82
Trying to get scrolling to work
anderschenders Dec 20, 2017
c1c7c99
fixed add movie button bug
SRBusiness Dec 20, 2017
76847c0
Server side validation and error handling for checking out a rental
SRBusiness Dec 20, 2017
f73bb4d
Client side validations, and displaying to user
anderschenders Dec 20, 2017
4de945d
cleaned up some old comments and blank spaces
SRBusiness Dec 20, 2017
0314cee
Complete rental model tests
anderschenders Dec 20, 2017
6cb75db
Merge branch 'master' of https://github.com/SRBusiness/VideoStoreCons…
anderschenders Dec 20, 2017
2475b92
Change layout, change color scheme
anderschenders Dec 20, 2017
c74b37e
Add some styling
anderschenders Dec 21, 2017
f7a6158
Merge pull request #4 from SRBusiness/styling
SRBusiness Dec 21, 2017
83be1b6
pushing up again
anderschenders Dec 21, 2017
b9169e0
Merge pull request #5 from SRBusiness/styling
SRBusiness Dec 21, 2017
7b9282e
changed id for forms so that the buttons act appropriatley
SRBusiness Dec 21, 2017
ef01c8b
Minor adjustment in styling
anderschenders Dec 21, 2017
d1d5cfd
Merge branch 'master' of https://github.com/SRBusiness/VideoStoreCons…
anderschenders Dec 21, 2017
830ef6f
updated name
SRBusiness Dec 21, 2017
c6637ed
Fix bug
anderschenders Dec 21, 2017
0b5f49c
Merge branch 'master' of https://github.com/SRBusiness/VideoStoreCons…
anderschenders Dec 21, 2017
c9e3603
remove space and old comments
SRBusiness Dec 21, 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
123 changes: 121 additions & 2 deletions dist/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,132 @@
<html lang="en">
<head>
<meta charset="utf-8">
<title>Backbone Baseline</title>
<title>anderserbia</title>
</head>
<body>
<main id="main-content">

<header>
<h1>anderserbia Video Store</h1>
</header>

<div id="wrapper">

<div class="row">
<section id="rental-view">
<div id="rental-messages">
</div>

<div class="columns large-6 small-12">
<div id="check-out-container">
<h2>Check-out</h2>
<form id="check-out-form">
<label for="customer-name">Name</label>
<select name="customer-name">
<!-- Option entries should be added here using JavaScript -->
</select>
<input id="movie-title-selector" type="text" name="movie-title" placeholder="Moonlight" value="">
<input class="button btn-check-out" type="submit" value="Check-out movie">
</form>
</div>
</div>

<div class="columns large-6 small-12">
<div id="check-in-container">
<h2>Check-in</h2>
<form id="check-in-form">
<label for="customer-name">Name</label>
<select name="customer-name">
<!-- Option entries should be added here using JavaScript -->
</select>
<input type="text" name="movie-title" placeholder="Moonlight">
<button type="submit" class="button" value="Check-in movie">Check-in Movie</button>
</form>
</div>
</div>
</section>

<hr>

<div class="row">
<div class="row">
<div id="messages">
<!-- error handling messages live here -->
</div>
</div>
<div class="columns large-6 small-12">
<div id='search-movies-container'>
<h2>All Movies</h2>
<form id="movie-search-form">
<label for="movie-title">Movie Title</label>
<input id="search-movie-title" type="text" name="movie-title" placeholder="Moonlight">
<input type="submit" class="button" value="Search movie database">
</form>

<div id="search-movies-list-container" class="movies-list-container">
<h4>Search Results</h4>
<div id="search-movies" class="movies">
</div>
<!-- </div> -->
</div>
</div>
</div>

<div class="columns large-6 small-12">
<div id="library-movies-container">
<h2>Library</h2>
<div id="library-movies" class="library-movies">
<!-- library-movie-template stuff-->

</div>
</div>
</div>
</div>

</div>
</div>

</main>

<script type="text/template" id="library-movie-template">
<div id="library-movie-container">
<img src="https://image.tmdb.org/t/p/w185<%- image_url %>" alt="movie image">
</div>
<div id="library-movie-details">
<p>
<strong>Title: </strong> <%- title %>
</p>
<p>
<strong>Description: </strong> <%- overview %>
</p>
<p>
<strong>Release Date: </strong> <%- release_date %>
</p>
<!-- <div id="button-button"> -->
<button class="button btn-add-checkout" value="<%- title %>">Add to check-out</button>
<!-- </div> -->

</div>
</script>

<script type="text/template" id="search-movie-template">
<div id="search-movie-container">
<img src="<%- image_url %>" alt="movie image">
</div>
<div id="search-movie-details">
<p>
<strong>Title: </strong> <%- title %>
</p>
<p>
<strong>Description: </strong> <%- overview %>
</p>
<p>
<strong>Release Date: </strong> <%- release_date %>
</p>
<button class="button btn-add-movie <%- external_id %>">Add To Library</button>
</div>

</script>

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

</body>
Expand Down
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
},
"dependencies": {
"backbone": "^1.3.3",
"foundation-sites": "^6.4.4-rc1",
"foundation-sites": "^6.3.1",
"jquery": "^3.2.1",
"underscore": "^1.8.3"
}
Expand Down
58 changes: 58 additions & 0 deletions spec/rental_spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import Rental from 'models/rental';

describe('Rental spec', () => {

describe('Initialize function', () => {
it('should exhibit attibutes', () => {
const rentalDate = new Date();
const rental = new Rental({
title: 'Jaws',
customer_id: 1,
due_date: rentalDate,
});

expect(rental.get('title'))
.toEqual('Jaws');
expect(rental.get('customer_id'))
.toEqual(1);
expect(rental.get('due_date'))
.toEqual(rentalDate);
});
});

describe('Validate function', () => {
it('should set isValid() to false and return an object with correct message if missing title', () => {
const rental = new Rental({
// title: 'Jaws',
customer_id: 1,
due_date: new Date(),
});

// order.set({"targetPrice": '0'});
expect(rental.isValid()).toBeFalsy();
expect(rental.validationError).toEqual({'title': ['cannot be blank']})
});

it('should set isValid() to false and return an object with correct message if missing customer_id', () => {
const rental = new Rental({
title: 'Jaws',
// customer_id: 1,
due_date: new Date(),
});

expect(rental.isValid()).toBeFalsy();
expect(rental.validationError).toEqual({'customer_id': ['cannot be blank']})
});

it('should set isValid() to false and return an object with correct message if missing due_date', () => {
const rental = new Rental({
title: 'Jaws',
customer_id: 1,
// due_date: new Date(),
});

expect(rental.isValid()).toBeFalsy();
expect(rental.validationError).toEqual({'due_date': ['cannot be blank']})
});
});
});
53 changes: 52 additions & 1 deletion src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,60 @@ import './css/styles.css';
import $ from 'jquery';
import _ from 'underscore';

// Our Components - Project Models, Collections, Views
import LibMovie from './models/lib_movie';
import LibMovieList from './collections/lib_movie_list';
import LibMovieView from './views/lib_movie_view';
import LibMovieListView from './views/lib_movie_list_view';
import SearchMovieListView from './views/search_movie_list_view';
import RentalView from './views/rental_view';
import Rental from './models/rental';

// template varibles
let libraryMovieTemplate;
let searchMovieTemplate;

// new instances of models
const libMovieList = new LibMovieList();
const searchMovieList = new LibMovieList();
const rental = new Rental();

// ready to go
$(document).ready(function() {
// events bus
let bus = {};
bus = _.extend(bus, Backbone.Events);

// underscore templates
libraryMovieTemplate = _.template($('#library-movie-template').html());
searchMovieTemplate = _.template($('#search-movie-template').html());

const rentalView = new RentalView({
el: '#rental-view',
bus: bus,
model: rental,
})

rentalView.render();

const searchMovieListView = new SearchMovieListView({
el: 'main',
model: searchMovieList,
template: searchMovieTemplate,
bus: bus,
});

searchMovieListView.render();

$('#main-content').append('<p>Hello World!</p>');
libMovieList.fetch();
// new instance of LibMovieListView
const libMovieListView = new LibMovieListView({
el: 'main',
model: libMovieList,
template: libraryMovieTemplate,
bus: bus,
});

libMovieListView.render();
// console.log(libMovieList);
});
10 changes: 10 additions & 0 deletions src/collections/lib_movie_list.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import Backbone from 'backbone';
import LibMovie from '../models/lib_movie';

const LibMovieList = Backbone.Collection.extend({
model: LibMovie,
url: 'http://localhost:3000/movies/',
comparator: 'title',
});

export default LibMovieList;
16 changes: 16 additions & 0 deletions src/collections/search_movie_list.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// import BackBone from 'backbone';
// import SearchMovie from '../models/search_movie';
//
// const SearchMovieList = Backbone.Collection.extend({
// // defaults: {
// // 'searchMovieTitle': null,
// // },
// url: 'http://localhost:3000/movies?query=',
// model: SearchMovie,
// // urlRoot: `http://localhost:3000/movies?query=${this.get('searchTerm')}`,
// // urlRoot: `http://localhost:3000/movies?query=Jaws`
// // + this.get('searchMovieTitle'),
//
// });
//
// export default SearchMovieList;
Loading