From c05d06254dce4f05ca337acd72ec2f1b9e510531 Mon Sep 17 00:00:00 2001 From: Jocelyn Gonzalez Date: Tue, 28 Nov 2017 17:00:04 -0800 Subject: [PATCH 1/6] added trips column --- dist/index.html | 61 ++++++++++++++++++++++++++++++-- src/app.js | 25 +++++++++++++ src/app/collections/trip_list.js | 13 +++++++ src/app/models/trip.js | 7 ++++ 4 files changed, 104 insertions(+), 2 deletions(-) create mode 100644 src/app/collections/trip_list.js create mode 100644 src/app/models/trip.js diff --git a/dist/index.html b/dist/index.html index b873b1e..1ee7f96 100644 --- a/dist/index.html +++ b/dist/index.html @@ -9,9 +9,66 @@
-
+
-
+ + + + + + + + + + +
nameidcontinentcategoryweeks
+ + + + diff --git a/src/app.js b/src/app.js index e7af594..b4a5abd 100644 --- a/src/app.js +++ b/src/app.js @@ -6,8 +6,33 @@ import _ from 'underscore'; import './css/foundation.css'; import './css/style.css'; +import Trip from './app/models/trip'; +import TripList from './app/collections/trip_list' + console.log('it loaded!'); +const tripList = new TripList(); + + console.log(tripList); + +let tripTemplate; + +const render = function render(tripList) { + + const $tripList = $('#trip-list'); + $tripList.empty(); + tripList.forEach((trip) => { + $tripList.append(tripTemplate(trip.attributes)); + }); + +}; + + $(document).ready( () => { + tripTemplate = _.template($('#trip-template').html()); $('main').html('

Hello World!

'); + + tripList.on('update', render, tripList); + tripList.fetch(); + }); diff --git a/src/app/collections/trip_list.js b/src/app/collections/trip_list.js new file mode 100644 index 0000000..baf3d96 --- /dev/null +++ b/src/app/collections/trip_list.js @@ -0,0 +1,13 @@ +import Backbone from 'backbone'; +import Trip from '../models/trip'; + +const TripList = Backbone.Collection.extend({ + model: Trip, + url: 'https://ada-backtrek-api.herokuapp.com/trips', + parse(response) { + return response; + } + +}); + +export default TripList; diff --git a/src/app/models/trip.js b/src/app/models/trip.js new file mode 100644 index 0000000..2926af8 --- /dev/null +++ b/src/app/models/trip.js @@ -0,0 +1,7 @@ +import Backbone from 'backbone'; + +const Trip = Backbone.Model.extend({ + +}); + +export default Trip; From e05543c4bb2df21a4da03df082459d2ba1e4e4a0 Mon Sep 17 00:00:00 2001 From: Jocelyn Gonzalez Date: Wed, 29 Nov 2017 14:07:08 -0800 Subject: [PATCH 2/6] creating load details function --- dist/index.html | 19 ++++++------------- src/app.js | 31 ++++++++++++++++++++++++------- src/app/collections/trip_list.js | 4 +--- src/app/models/trip.js | 2 ++ src/css/style.css | 11 +++++++++-- 5 files changed, 42 insertions(+), 25 deletions(-) diff --git a/dist/index.html b/dist/index.html index 1ee7f96..7bf3888 100644 --- a/dist/index.html +++ b/dist/index.html @@ -9,6 +9,7 @@
+
@@ -24,16 +25,10 @@
+
diff --git a/src/app.js b/src/app.js index ed9614c..766e54f 100644 --- a/src/app.js +++ b/src/app.js @@ -12,7 +12,7 @@ import TripList from './app/collections/trip_list' console.log('it loaded!'); const tripList = new TripList(); - +let trip; let tripTemplate; const render = function render(tripList) { @@ -20,26 +20,53 @@ const render = function render(tripList) { $tripList.empty(); tripList.forEach((trip) => { $tripList.append(tripTemplate(trip.attributes)); - console.log(trip.attributes); + // console.log(trip.attributes); }); - }; +// const renderTrip = function renderTrip(trip) { +// console.log('first line of renderTrip'); +// const $summary = $('#summary'); +// $summary.empty(); +// $summary.append(infoTemplate(trip.attributes)); +// console.log('last line of renderTrip'); +// +// }; + const loadTrips = function loadTrips(){ tripList.on('update', render, tripList); tripList.fetch(); }; + let infoTemplate; const loadTripDetails = function loadTripDetails(tId) { - let trip = new Trip({id: tId}).fetch().done(); - const $summary = $('#summary'); - $summary.empty(); - $summary.append(infoTemplate(trip.attributes)); + // tripList.on('update', renderTrip, trip); + trip = tripList.get(tId); + trip.fetch( { + success: events.successfulRender, + error: events.failedRender, + }); console.log(trip); }; +const events = { + successfulRender(trip, response) { + console.log('success render::::'); + console.log(response) + + const $summary = $('#summary'); + $summary.empty(); + $summary.append(infoTemplate(trip.attributes)); + console.log('last line of renderTrip'); + }, + failedRender(trip, response) { + console.log('failed render:::::'); + console.log(response); + } +}; + $(document).ready( () => { tripTemplate = _.template($('#trip-template').html()); infoTemplate = _.template($('#info-template').html()); diff --git a/src/app/models/trip.js b/src/app/models/trip.js index 5db4fae..8c304ad 100644 --- a/src/app/models/trip.js +++ b/src/app/models/trip.js @@ -1,8 +1,8 @@ import Backbone from 'backbone'; const Trip = Backbone.Model.extend({ - urlRoot: 'https://ada-backtrek-api.herokuapp.com/trips', - idAttribute: 'id' + // urlRoot: 'https://ada-backtrek-api.herokuapp.com/trips', + idAttribute: 'id', }); From 12f4ab60c736e281289b4ea1bb8d15293a17f579 Mon Sep 17 00:00:00 2001 From: Jocelyn Gonzalez Date: Fri, 1 Dec 2017 22:52:31 -0800 Subject: [PATCH 4/6] added new trip method and fixed css styling --- dist/index.html | 98 ++++++++++++++++++++++++++++++++++-------- src/app.js | 63 ++++++++++++++++++++++++++- src/app/models/trip.js | 2 +- src/css/style.css | 62 +++++++++++++++++++++++++- 4 files changed, 202 insertions(+), 23 deletions(-) diff --git a/dist/index.html b/dist/index.html index a46e346..bce56da 100644 --- a/dist/index.html +++ b/dist/index.html @@ -7,28 +7,69 @@
- +

BackTrek

+
-
Summary Here
- -
- - - - - - - - - - - - -
nameidcontinentcategoryweeks
-
+
+
+ + +
    +
    + + +
    +

    Summary goes here

    +
    +
    + +
    + + + + + + + + + + + + +
    nameidcontinentcategoryweeks
    + +
    + +
    +