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 - Irene & Lindsey - VideoStore #20

Open
wants to merge 45 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
65c69b6
Finish setup first commit
idevera Dec 18, 2017
b8d804f
Add some view
idevera Dec 18, 2017
7dbb5fe
Add templates to app.js
idevera Dec 18, 2017
7321781
Add url to request from rails API
idevera Dec 18, 2017
04c3bbc
Rendered movie list views
idevera Dec 18, 2017
e2e908f
Change foundation file
idevera Dec 19, 2017
d0201fc
Add url for searching for one movie
idevera Dec 19, 2017
f0d38a5
fixing displays of movie records
VirtualLindsey Dec 19, 2017
ad11f1d
pushing work so far
VirtualLindsey Dec 19, 2017
ae57ed0
saving work so far
VirtualLindsey Dec 19, 2017
9460eee
pushing work for debugging
VirtualLindsey Dec 19, 2017
aa9d938
Fix movie list view
idevera Dec 19, 2017
df3394b
Create views for returned movies
idevera Dec 19, 2017
edcb485
Added search function to the returned movie list views
idevera Dec 19, 2017
4fa805f
Fix url call to api for the matchingMovies method
idevera Dec 19, 2017
eab4625
adding button to search results
VirtualLindsey Dec 19, 2017
ae91528
adding feature to add movies to collection
VirtualLindsey Dec 19, 2017
54cbacf
adding console logging message:
VirtualLindsey Dec 19, 2017
16ed115
so you can see
VirtualLindsey Dec 20, 2017
76e44c6
finishing movie save and add feature
VirtualLindsey Dec 20, 2017
34a5760
Merge pull request #1 from idevera/saveMovie
VirtualLindsey Dec 20, 2017
8807db2
adding search bar
VirtualLindsey Dec 20, 2017
158e989
Merge pull request #2 from idevera/searchTab
VirtualLindsey Dec 20, 2017
2535d4b
validations:
VirtualLindsey Dec 20, 2017
77ae912
adding images
VirtualLindsey Dec 20, 2017
c3dc9dc
Merge pull request #3 from idevera/modelValidations
VirtualLindsey Dec 20, 2017
24b4b76
clearing section before adding new results
VirtualLindsey Dec 20, 2017
f92bdd4
fixing search button display
VirtualLindsey Dec 20, 2017
87776b0
Add styling to header
idevera Dec 20, 2017
90d8bb5
adding model.isValid() checks
VirtualLindsey Dec 20, 2017
e39e5d6
Fix show images on load for current movies
idevera Dec 20, 2017
c8044fb
Add tables to available movies list
idevera Dec 20, 2017
825cae0
Add tables to the returned search movies view
idevera Dec 20, 2017
1399ab3
Merge pull request #4 from idevera/validations
VirtualLindsey Dec 20, 2017
6d664bc
Add meta tag
idevera Dec 20, 2017
88f83cf
Merging branches to styling_id
idevera Dec 20, 2017
819de7e
Fix styling
idevera Dec 20, 2017
9937725
Fix styling on radio buttons and header
idevera Dec 20, 2017
450a375
Switch to other branch that is not master
idevera Dec 20, 2017
754bb0d
Fix comments, clean up code
idevera Dec 20, 2017
c84b417
Removed creation of a ReturnedMovie
idevera Dec 20, 2017
4badf8d
Movie persists in returned collection
idevera Dec 20, 2017
8efec68
Clean up functions
idevera Dec 20, 2017
d6cedd8
Add notification to user if a movie is added
idevera Dec 20, 2017
89c3950
Add comment in app.js
idevera Dec 20, 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
107 changes: 105 additions & 2 deletions dist/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,116 @@
<head>
<meta charset="utf-8">
<title>Backbone Baseline</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>

<body>
<header class="main-header">
<div class="main-h1-wrapper">
<h1>Video Store Plus</h1>
</div>
</header>

<main id="main-content">

<section id="returned-movies-view" class="small-12 large-6 columns">
<header class="section-header align-center">
<h4>Search for Movies to Add</h4>
</header>
<section id="returned-movies-errors">
</section>

<form id="movie-search">
<label for="title">Search for a movie by clicking MoviesDB</label>
<input type="text" name="title"/>
<input type="radio" name="searchLocation" value="imdb" id="imdb"/><label for="imdb">MoviesDB</label>
<input type="radio" name="searchLocation" value="local" id="local" checked/><label for="local">Movies in Store</label>
<br/>
<button id="search-btn" class="button">Get Movies!</button>
<div id="success-movie-add">
</div>
</form>

<section id="imdb-section">
<header class="section-header align-center">
<h4>Movies that Match your Search</h4>
</header>
<table class="striped stack">
<thead class="aqua-bg">
<th width="150">Movie</th>
<th width="100" class="align-center">Release Date</th>
<th width="200">Overview</th>
<th width="50" class="align-center">Add</th>
</thead>

<!-- Append Movies that match the search -->

<tbody id="matching-movies">
</tbody>
</table>
</section>
</section>

<section id="current-rentals-view" class="small-12 large-6 columns">
<header class="section-header align-center">
<h4>Available Movies for Checkout</h4>
</header>

<section id="available-movies-errors">
</section>

<table class="striped stack">
<thead class="aqua-bg">
<th width="150">Movie</th>
<th width="100">Release Date</th>
<th width="200">Overview</th>
</thead>

<!-- Append current Movies in the rental store -->
<tbody id="movies-in-store">
</tbody>
</table>
</section>
</main>

<!-- Templates -->

<script type="text/template" id="movie-template">
<td class="align-center">
<img src = '<%- image_url %>' alt='<%- title%>'/>
<br>
<%- title %>
</td>
<td class="align-center">
<%- release_date %>
</td>
<td>
<%- overview %>
</td>
</script>

<script type="text/template" id="returned-movie-template">
<td class="align-center">
<img src = '<%- image_url %>' alt='<%- title%>'/>
<br>
<%- title %>
</td>
<td>
<%- release_date %>
</td>
<td height="100" class="overflow-auto">
<div class="overflow-auto">
<%- overview %>
</td>
<td>
<button class="button btn-add">Add</button>
</td>
</script>

<script type="text/template" id="error-template">

</script>

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

</body>
</html>
</html>
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
33 changes: 33 additions & 0 deletions spec/models/movie_spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import Movie from 'models/movie';

describe('Quote spec', () => {
let movie;
beforeEach(() => {
movie = new movie({
title: 'Test Movie',
release_date: '1998-10-10',
overview: 'some overview text here',
image_url: 'https://image.tmdb.org/t/p/w185/eruhq6kmjV7wopA7GjNDHrmAl89.jpg'
});
});

describe('Buy function', () => {
it('increases the price by $1.00', () => {
const startPrice = quote.get('price');

quote.buy();

expect(quote.get('price')).toEqual(startPrice + 1.00);
});
});

describe('Sell function', () => {
it('decreases the price by $1.00', () => {
const startPrice = quote.get('price');

quote.sell();

expect(quote.get('price')).toEqual(startPrice - 1.00);
});
});
});
68 changes: 65 additions & 3 deletions src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,71 @@ import './css/styles.css';
import $ from 'jquery';
import _ from 'underscore';

// ready to go
// Models and Collection
import Movie from 'models/movie';
import ReturnedMovie from 'models/returned_movie';
import MovieList from 'collections/movie_list';
import ReturnedMovieList from 'collections/returned_movie_list';

// Views
import MovieView from 'views/movie_view';
import MovieListView from 'views/movie_list_view';
import ReturnedMovieView from 'views/returned_movie_view'; // TODO: Do I need this?
import ReturnedMovieListView from 'views/returned_movie_list_view';

const movieList = new MovieList();
const returnedList = new ReturnedMovieList();

let movieTemplate;
let returnedMovieTemplate;


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

movieTemplate = _.template($('#movie-template').html());
returnedMovieTemplate = _.template($('#returned-movie-template').html());

$('#imdb-section, #search-btn').hide();

// Fetches all movies currently in the rental store
movieList.fetch({
success: (model, response) => {
response.forEach((movie) => {
movieList.add(movie);
});
},
error: (model, response) => {
console.log(`This is the model: ${model} in the app.js`);
console.log(`This is the response: ${response} in the app.js`);
},
})

const movieListView = new MovieListView({
el: '#current-rentals-view',
template: movieTemplate,
model: movieList,
bus: bus,
});

$('#main-content').append('<p>Hello World!</p>');
const returnedMovieListView = new ReturnedMovieListView({
el: '#returned-movies-view',
template: returnedMovieTemplate,
model: returnedList,
bus: bus,
});

});
// TODO: Event if the button to search is not showing, it is still possible to
// Search for a movie if you press center
// Need to figure out how to prevent this from happening
$('input[type=radio][name=searchLocation]').change(function(){
if (this.value === 'imdb'){
$('#imdb-section, #search-btn').show();
$('#current-rentals-view').hide();
} else {
$('#imdb-section, #search-btn').hide();
$('#current-rentals-view').show();
}
});
}); // DOCUMENT READY
12 changes: 12 additions & 0 deletions src/collections/movie_list.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import Backbone from 'backbone';
import Movie from '../models/movie';

const MovieList = Backbone.Collection.extend({
model: Movie,
url: 'http://localhost:3000/movies',
parse: function(response){
return response['responseJSON'];
}
});

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

const returnedMovieList = Backbone.Collection.extend({
model: ReturnedMovie,
url: 'http://localhost:3000/movies/?query=',
});

export default returnedMovieList;
67 changes: 65 additions & 2 deletions src/css/styles.css
Original file line number Diff line number Diff line change
@@ -1,6 +1,69 @@
@include foundation-everything;
@import url('https://fonts.googleapis.com/css?family=Secular+One');
@import url('https://fonts.googleapis.com/css?family=Open+Sans');

main {
/*********** ALL STYLES ***********/

h1, h2, h3, h4 {
font-family: 'Secular One', sans-serif;
}

body {
font-family: 'Open Sans', sans-serif;
font-size: 12px;
}

.align-center {
text-align: center;
}

.aqua-bg {
background-color: #ABEBC6;
}

.button {
background-color: #ABEBC6;
color: #232f3e;
border-radius: 5px;
}

td .overflow-auto {
overflow: scroll;
height: 220px;
}
/*********** HEADER ***********/

.main-header {
text-align: center;
background-color: #232f3e;
color: #E8E8E8;
padding: 10px;
}

.main-h1-wrapper {
border: 2px #ABEBC6 solid;
}

.main-h1-wrapper h1 {
margin: 0;
}

/******* MAIN SECTION HEADERS *******/

.section-header {
border: 1px #B8B8B8 solid;
border-radius: 5px;
margin: 20px 0 20px 0;

}

.section-header h4 {
padding: 10px;
margin: 0;
}


/* main {
background: lightblue;
}

Expand Down Expand Up @@ -36,7 +99,7 @@ aside label {

div {
display: inline;
}
} */
/*
* {
border-style: solid;
Expand Down
39 changes: 39 additions & 0 deletions src/models/movie.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import Backbone from 'backbone';

const Movie = Backbone.Model.extend({
initialize(attributes){
this.title = attributes.title,
this.overview = attributes.overview,
this.release_date = attributes.release_date,
this.image_url = attributes.image_url,
this.bus = attributes.bus,
this.url = 'http://localhost:3000/movies'
},
validate(attributes){
const errors = {}

if (!attributes.title) {
errors['title'] = 'The title can not be blank';
}

if (!attributes.overview) {
errors['overview'] = 'The overview can not be blank';
}

if (!attributes.release_date) {
errors['release_date'] = 'The release date can not be blank';
}

if (!attributes.image_url) {
errors['image_url'] = 'The image url can not be blank';
}

if ( Object.keys(errors).length > 0 ) {
return errors;
} else {
return false;
}
},
});

export default Movie;
Loading