From d91ba26665deb2d2e300d703a63fb848177d491a Mon Sep 17 00:00:00 2001
From: murog
Date: Mon, 18 Dec 2017 10:52:06 -0800
Subject: [PATCH 01/33] created movie model and movie collection.
---
src/collections/movie_list.js | 8 ++++++++
src/models/movie.js | 7 +++++++
2 files changed, 15 insertions(+)
create mode 100644 src/collections/movie_list.js
create mode 100644 src/models/movie.js
diff --git a/src/collections/movie_list.js b/src/collections/movie_list.js
new file mode 100644
index 000000000..c0e72dcc8
--- /dev/null
+++ b/src/collections/movie_list.js
@@ -0,0 +1,8 @@
+import Backbone from 'backbone';
+import Movie from 'models/movie';
+
+const MovieList = Backbone.Collection.extend({
+ model: Movie,
+});
+
+export default MovieList;
diff --git a/src/models/movie.js b/src/models/movie.js
new file mode 100644
index 000000000..2e3c413ca
--- /dev/null
+++ b/src/models/movie.js
@@ -0,0 +1,7 @@
+import Backbone from 'backbone';
+
+const Movie = Backbone.Model.extend({
+
+});
+
+export default Movie;
From 8dfd3632d527565961551151a7928c490cf04eaf Mon Sep 17 00:00:00 2001
From: murog
Date: Mon, 18 Dec 2017 10:52:59 -0800
Subject: [PATCH 02/33] created movie and movie list view with render functions
---
src/views/movie_list_view.js | 30 ++++++++++++++++++++++++++++++
src/views/movie_view.js | 19 +++++++++++++++++++
2 files changed, 49 insertions(+)
create mode 100644 src/views/movie_list_view.js
create mode 100644 src/views/movie_view.js
diff --git a/src/views/movie_list_view.js b/src/views/movie_list_view.js
new file mode 100644
index 000000000..4e6a4bb31
--- /dev/null
+++ b/src/views/movie_list_view.js
@@ -0,0 +1,30 @@
+import Backbone from 'backbone';
+import _ from 'underscore';
+
+import MovieView from '../views/movie_view';
+// import OrderView from '../views/order_view';
+// import Quote from '../models/quote';
+import Movie from '../models/movie';
+
+const MovieListView = Backbone.View.extend({
+ initialize(params) {
+ this.bus = params.bus;
+ this.template = params.template;
+ },
+ render() {
+ this.$('#movies').empty();
+ this.model.each((movie) => {
+ const movieView = new MovieView({
+ model: movie,
+ template: this.template,
+ bus: this.bus,
+ tagname: 'li',
+ className: 'movie',
+ });
+ this.$('#movies').append(movieView.render().$el);
+ });
+ },
+
+});
+
+export default MovieListView;
diff --git a/src/views/movie_view.js b/src/views/movie_view.js
new file mode 100644
index 000000000..379eb1a5b
--- /dev/null
+++ b/src/views/movie_view.js
@@ -0,0 +1,19 @@
+import Backbone from 'backbone';
+import Movie from '../models/movie';
+
+const MovieView = Backbone.View.extend({
+ initialize(params) {
+ this.template = params.template;
+ this.bus = params.bus;
+ },
+ render() {
+ const compiledTemplate = this.template(this.model.attributes);
+ this.$el.html(compiledTemplate);
+ return this;
+ },
+ events: {
+
+ },
+});
+
+export default MovieView;
From b9485debe2d0c859d34faa46299abc843fb9cafe Mon Sep 17 00:00:00 2001
From: murog
Date: Mon, 18 Dec 2017 10:53:12 -0800
Subject: [PATCH 03/33] created movie workspace html
---
dist/index.html | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/dist/index.html b/dist/index.html
index 559b18ecd..f6382ef0b 100644
--- a/dist/index.html
+++ b/dist/index.html
@@ -6,7 +6,19 @@
-
+
+
From 60690669e74ca21631543bd9cf388f515c768a37 Mon Sep 17 00:00:00 2001
From: murog
Date: Mon, 18 Dec 2017 11:03:48 -0800
Subject: [PATCH 04/33] initialized a movieList in app.js, added movies url to
movies collection
---
src/app.js | 9 +++++++++
src/collections/movie_list.js | 5 +++++
2 files changed, 14 insertions(+)
diff --git a/src/app.js b/src/app.js
index 30c00d594..67d1f791a 100644
--- a/src/app.js
+++ b/src/app.js
@@ -6,8 +6,17 @@ import './css/styles.css';
import $ from 'jquery';
import _ from 'underscore';
+//import models and collections
+import MovieList from 'collections/movie_list';
+
+// import views
+import MovieListView from 'views/movie_list_view';
+
+
// ready to go
$(document).ready(function() {
+ const movieList = new MovieList;
+ movieList.fetch();
$('#main-content').append('Hello World!
');
diff --git a/src/collections/movie_list.js b/src/collections/movie_list.js
index c0e72dcc8..5f106f41d 100644
--- a/src/collections/movie_list.js
+++ b/src/collections/movie_list.js
@@ -3,6 +3,11 @@ import Movie from 'models/movie';
const MovieList = Backbone.Collection.extend({
model: Movie,
+ url: 'http://localhost:3000/movies',
+ parse(response) {
+ console.log(response);
+ return response;
+ }
});
export default MovieList;
From 519608414ef671834e0d9cec9216b7f47023127a Mon Sep 17 00:00:00 2001
From: murog
Date: Mon, 18 Dec 2017 11:26:32 -0800
Subject: [PATCH 05/33] created template for movies, intialized movie list and
movie views with template
---
dist/index.html | 12 ++++++++++--
src/app.js | 13 ++++++++++++-
src/views/movie_list_view.js | 3 ++-
3 files changed, 24 insertions(+), 4 deletions(-)
diff --git a/dist/index.html b/dist/index.html
index f6382ef0b..ad0afbd0b 100644
--- a/dist/index.html
+++ b/dist/index.html
@@ -12,7 +12,7 @@
Moviez
@@ -20,7 +20,15 @@ Moviez
-
+
diff --git a/src/app.js b/src/app.js
index 67d1f791a..d723b155a 100644
--- a/src/app.js
+++ b/src/app.js
@@ -15,9 +15,20 @@ import MovieListView from 'views/movie_list_view';
// ready to go
$(document).ready(function() {
+ let bus = {};
+ bus = _.extend(bus, Backbone.Events);
+
const movieList = new MovieList;
+ // tripList.on('update', render, tripList);
movieList.fetch();
+ const movieListView = new MovieListView({
+ model: movieList,
+ template: _.template($('#movie-template').html()),
+ el: 'movies-container',
+ bus: bus,
+ })
+
+ movieListView.render();
- $('#main-content').append('Hello World!
');
});
diff --git a/src/views/movie_list_view.js b/src/views/movie_list_view.js
index 4e6a4bb31..bfc192338 100644
--- a/src/views/movie_list_view.js
+++ b/src/views/movie_list_view.js
@@ -10,6 +10,7 @@ const MovieListView = Backbone.View.extend({
initialize(params) {
this.bus = params.bus;
this.template = params.template;
+ this.listenTo(this.model, 'update', this.render);
},
render() {
this.$('#movies').empty();
@@ -24,7 +25,7 @@ const MovieListView = Backbone.View.extend({
this.$('#movies').append(movieView.render().$el);
});
},
-
+
});
export default MovieListView;
From 513b2eaf6af742b104272e82d7d0415e0d2d3c8f Mon Sep 17 00:00:00 2001
From: murog
Date: Mon, 18 Dec 2017 11:35:09 -0800
Subject: [PATCH 06/33] movie views render, fixed typo to include id
---
dist/index.html | 1 +
src/app.js | 2 +-
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/dist/index.html b/dist/index.html
index ad0afbd0b..5f9db7313 100644
--- a/dist/index.html
+++ b/dist/index.html
@@ -27,6 +27,7 @@ <%- title %>
<%- overview %>
+
diff --git a/src/app.js b/src/app.js
index d723b155a..f3a50708e 100644
--- a/src/app.js
+++ b/src/app.js
@@ -24,7 +24,7 @@ $(document).ready(function() {
const movieListView = new MovieListView({
model: movieList,
template: _.template($('#movie-template').html()),
- el: 'movies-container',
+ el: '#movies-container',
bus: bus,
})
From 652522cbac3f53b404f4fbb3ecc06a002f04c371 Mon Sep 17 00:00:00 2001
From: murog
Date: Mon, 18 Dec 2017 13:02:36 -0800
Subject: [PATCH 07/33] added form to index for finding movie
---
dist/index.html | 17 ++++++++++++++---
1 file changed, 14 insertions(+), 3 deletions(-)
diff --git a/dist/index.html b/dist/index.html
index 5f9db7313..5c7f7e0b3 100644
--- a/dist/index.html
+++ b/dist/index.html
@@ -7,7 +7,18 @@
-
+
+
Moviez
@@ -17,11 +28,11 @@
Moviez
-
+
+