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

Laura & Severin - Carets #6

Open
wants to merge 33 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
2810b02
Initial models, collections, and views
LauraAddams Dec 18, 2017
dd726a0
Base templates and HTML naming(ids, classes)
LauraAddams Dec 18, 2017
982512e
Collection default code added
LauraAddams Dec 18, 2017
b8928b3
added basic model code
s-wigg Dec 18, 2017
6de4e3c
Merge branch 'master' of https://github.com/s-wigg/VideoStoreConsumer
s-wigg Dec 18, 2017
460f54f
Reformated templates to be single list elements
LauraAddams Dec 18, 2017
29fc502
Templating setup for MovieListView
LauraAddams Dec 18, 2017
684226c
started trying to display all movies
s-wigg Dec 18, 2017
b61967e
getting api response for all movies
s-wigg Dec 18, 2017
9dd9d22
can display all movies from rails API on All movies button click
s-wigg Dec 18, 2017
39c1791
All customers view added
LauraAddams Dec 18, 2017
b013c1c
Image urls hardcoded to display properly
LauraAddams Dec 18, 2017
db91669
can return search results from API inventory
s-wigg Dec 18, 2017
5bfa3d5
search finds results regardless of case
s-wigg Dec 19, 2017
4feabfe
Form has optiona for searching the database or IMDB
LauraAddams Dec 19, 2017
c523627
added IMDB search functionality
s-wigg Dec 19, 2017
ca3d6aa
Removed hardcoded image url
LauraAddams Dec 19, 2017
be948a4
fixed bug where wasnt ref
s-wigg Dec 19, 2017
9e8e876
Removed li from templates
LauraAddams Dec 19, 2017
10364bf
Add inventory button for IMDB searching
LauraAddams Dec 19, 2017
e02dc8e
Removed button from all movie inventory page
LauraAddams Dec 19, 2017
2ce8ccc
initial functionality to add a movie to inventory
s-wigg Dec 19, 2017
e70a80e
List styling baseline
LauraAddams Dec 19, 2017
193ca75
Summary appears on mouseenter
LauraAddams Dec 19, 2017
d1f117d
Add inventory button creates post call to add movie to API
LauraAddams Dec 20, 2017
439764b
Cleaned up the hover list styling
LauraAddams Dec 20, 2017
13eb6f5
tweak to fix for typeError for movies that don't include a date
s-wigg Dec 20, 2017
a798318
Added movie details styling: like, movie rating, rating
LauraAddams Dec 20, 2017
c5fd6f2
Merge branch 'master' of https://github.com/s-wigg/VideoStoreConsumer
LauraAddams Dec 20, 2017
16a6181
added tests for movie model validations
s-wigg Dec 20, 2017
fbb1fc8
added logic to make rating red/green depending on rating
s-wigg Dec 20, 2017
c3c8b16
Cleaned up files, removed comments, unused templates, and commented o…
LauraAddams Dec 20, 2017
2d78421
Replaced like image with a linked source
LauraAddams 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
Binary file added dist/Like.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
36 changes: 34 additions & 2 deletions dist/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,45 @@
<html lang="en">
<head>
<meta charset="utf-8">
<title>Backbone Baseline</title>
<link href="https://fonts.googleapis.com/css?family=Raleway:400,700,900" rel="stylesheet">
<title>VideoVideo</title>
</head>
<header>
<h1>VideoStore</h1>

<section>
<form class='search-form'>
<input type='text' name='search' placeholder='Search' />
<input type="radio" id='inventory' name="search-type" value="search inventory"><label for="inventory">Search Inventory</label>
<input type="radio" id='imdb' name="search-type" value="search IMDB" checked><label for="imdb">Search IMDB</label>
<input type='submit' value='Search' class='button' id="searchButton"></input>
</form>
</section>
</header>

<body>
<main id="main-content">

<button id='movie-button' class='button'>All movies</button>
<button id='customer-button' class='button'>All customers</button>

<ul id='list'></ul>
</main>

<script type="text/template" id="movie-template" class="movie">
<p><img class='movie-thumbnail' src='<%= image_url %>' /></p>
<h4><%- title %> <%- release_date !== null ? `(${release_date.substr(0,4)})` : release_date %></h4>
<p class='moviehover summary' style="display:none"><%- overview.substr(0,130) %>...</p>
<p class='moviehover details' style="display:none"><span style='color:<%= average_rating > 5 ? 'green' : 'red' %>'><%- average_rating %>/10 </span> <span class='rating'><%- rating %></span></p>
<p class='moviehover thumbs' style="display:none"><img class='like' src='http://res.cloudinary.com/laurarobertson/image/upload/v1513819840/Like_acfu0a.png'/></p>
<p class='moviehover thumbs' style="display:none"><img class='dislike' src='http://res.cloudinary.com/laurarobertson/image/upload/v1513819840/Like_acfu0a.png'/></p>
<button class='button add-inventory'>+</button>
</script>

<script type="text/template" id="customer-template" class="customer">
<h3><%- name %></h3>
<p><%- phone %></p>
</script>

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

</body>
Expand Down
22 changes: 22 additions & 0 deletions spec/models/movie_spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import Movie from 'models/movie';

describe('Movie spec', () => {
let movie;
beforeEach(() => {
movie = new Movie({
title: 'HELLO',
});
});

describe('movie validations', () => {

it('movie is valid with a title', () => {
expect(movie.isValid()).toEqual(true);
});

it('movie invalid without title', () => {
movie.set('title', '');
expect(movie.isValid()).toEqual(false);
});
});
});
42 changes: 39 additions & 3 deletions src/app.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,50 @@
import 'css/_settings.css';
import 'foundation-sites/dist/css/foundation.css';
import './css/styles.css';

// Import jQuery & Underscore
import $ from 'jquery';
import _ from 'underscore';
import Backbone from 'backbone';

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

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

import './css/styles.css';

// ready to go
$(document).ready(function() {

$('#main-content').append('<p>Hello World!</p>');
let bus = {};
bus = _.extend(bus, Backbone.Events);

// movies
const movies = new MovieList();
movies.fetch();

const movieListView = new MovieListView({
model: movies,
template: _.template($('#movie-template').html()),
bus: bus,
el: 'body'
});

// customers
const customers = new CustomerList();
customers.fetch();

const customerListView = new CustomerListView({
model: customers,
template: _.template($('#customer-template').html()),
el: 'main'
});

$('body').on('mouseenter', 'li', function() {
$(this).find('.moviehover').fadeIn(200);
});

$('body').on('mouseleave', 'li', function() {
$(this).find('.moviehover').fadeOut(200);
});
});
12 changes: 12 additions & 0 deletions src/collections/customer_list.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import Backbone from 'backbone';
import Customer from '../models/customer';

const CustomerList = Backbone.Collection.extend({
model: Customer,
url: 'http://localhost:3000/customers',
parse(response) {
return response;
},
});

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

const MovieList = Backbone.Collection.extend({
model: Movie,
url: 'http://localhost:3000/movies',
parse(response) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this isn't doing anything different than the default, overriding parse is unnecessary.

return response;
},

});

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

const RentalList = Backbone.Collection.extend({
model: Rental,
});

export default RentalList;
128 changes: 104 additions & 24 deletions src/css/styles.css
Original file line number Diff line number Diff line change
@@ -1,44 +1,124 @@
@include foundation-everything;

main {
background: lightblue;
/* General styling */

body {
text-align: center;
background: #141414;
}

h1, h2, h3, h4, h5, p,[type='radio'] + label[for] {
font-family: 'Raleway', sans-serif;
color: #e5e5e5;
}

h4 {
height: 80px;
font-size: 1.2em;
overflow: hidden;
}

/* Header */

header {
background-color: lightgreen;
padding: 0.5rem;
max-width: 600px;
margin: 20px auto;
}

/* List styling */

li {
margin: 30px;
display: inline-block;
list-style: none;
position: relative;
max-width: 185px;
transition: all .1s ease-in-out;
}

li:hover {
transform: scale(1.1);
}

#completed-checkbox {
display: inline;
img {
height: 276px;
border-radius: 2px;
}

label {
display: inline;
.summary {
font-size: 0.9em;
line-height: 1.3em;
padding: 80px 10px 0;
border-radius: 2px;
height: 276px;
position:absolute;
overflow: hidden;
top: 0;
left: -1px;
right: -1px;
background: rgba(0,0,0,0.8);
}

button.success {
margin-right: 1.2rem;
display: inline;

/* Movie */

.add-inventory {
font-weight: bolder;
padding: 7px 11px 9px;
background: rgba(255,0,0,0.6);
text-shadow: 2px 2px 5px rgba(0,0,0,0.3);
position: absolute;
top: 5px;
right: 5px;
border-radius: 50%;
}

.add-inventory:hover {
background: rgba(255,0,0,0.85);
}

aside.create-tasklist {
background-color: navy;
color: #FFFFFF;
.details {
font-size: 0.85em;
padding-left: 10px;
text-align: left;
position: absolute;
width: 100%;
bottom: 95px;
font-weight: bold;
}
aside label {
color: #FFFFFF;

.rating {
font-weight: normal;
color: rgba(255,255,255,0.5);
margin-left: 3px;
padding: 2px 3px;
border: 1px solid rgba(255,255,255,0.5);
}

.completed {
text-decoration: line-through;
.thumbs {
position: absolute;
right: 8px;
bottom: 95px;
}

div {
display: inline;
.like, .dislike {
border: 1px solid rgba(255,255,255,0.4);
background: rgba(0,0,0,0.4);
border-radius: 50%;
padding: 5px;
width: 24px;
height: 24px;
}
/*
* {
border-style: solid;

.dislike {
transform: rotate(180deg);
}
*/

.like {
margin-top: -60px;
}

/* Customer */


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


const Customer = Backbone.Model.extend({
initialize(attributes) {
},
validate(attributes) {
}
});

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


const Movie = Backbone.Model.extend({
initialize(attributes) {
this.title = this.attributes.title;
this.bus = this.bus
this.attributes.upperCaseTitle = this.title.toUpperCase();
},
validate(attributes) {
const errors = {};

if (!attributes.title) {
errors['title'] = ['Title is required'];
}
if ( Object.keys(errors).length > 0 ) {
return errors;
} else {
return false;
}
}
});

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


const Rental = Backbone.Model.extend({
initialize(attributes) {
},
validate(attributes) {
const errors = {};

if (!attributes.due_date) {
errors['due_date'] = ['Due Date is required'];
}
}

});

export default Rental;
30 changes: 30 additions & 0 deletions src/views/customer_list_view.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import Backbone from 'backbone';
import CustomerView from './customer_view';

const CustomerListView = Backbone.View.extend({
initialize(params) {
this.template = params.template;

},
render() {
// console.log('IN RENDER');
// console.log(this.model);
this.$('#list').empty();

this.model.each((customer) => {
const customerView = new CustomerView({
model: customer,
template: this.template,
tagName: 'li',
className: 'customer',
});
this.$('#list').append(customerView.render().$el);
})
return this;
},
events: {
'click #customer-button': 'render',
}
});

export default CustomerListView;
Loading