forked from AdaGold/rolodex
-
Notifications
You must be signed in to change notification settings - Fork 35
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
Stacks - Jackie - Rolodex #32
Open
jackiewatanabe
wants to merge
9
commits into
Ada-C7:master
Choose a base branch
from
jackiewatanabe:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
da75685
able to display one static contact
jackiewatanabe 11e0690
added defaults and initialize to Contact.js and also added Contact_view
jackiewatanabe ea7374f
added initial code for rolodex_view.js
jackiewatanabe 4138557
added get form, render and initialize functions to Rolodex_view
jackiewatanabe 1783dac
added events and saveContact function to rolodex_view
jackiewatanabe f82b94d
removed the add class in initialize in contact_view
jackiewatanabe 6ac8bc8
got the save contact function to actually work by changing the el in …
jackiewatanabe c4391ea
clicking on one contact now shows details of contact
jackiewatanabe 6e096de
changed css so modal container is clickable
jackiewatanabe File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,133 @@ | ||
import $ from 'jquery'; | ||
import _ from 'underscore'; | ||
import Contact from 'app/models/contact.js'; | ||
import Application from 'app/models/application'; | ||
import ApplicationView from 'app/views/application_view'; | ||
import Rolodex from 'app/collections/rolodex.js'; | ||
import ContactView from 'app/views/contact_view.js'; | ||
import RolodexView from 'app/views/rolodex_view.js'; | ||
|
||
var application = new Application(); | ||
// var application = new Application(); | ||
// | ||
// var appView = new ApplicationView({ | ||
// el: '#application', | ||
// model: application | ||
// }); | ||
|
||
var contactsData = [{ | ||
name: "Jill", | ||
email: "blabla@blabla.com", | ||
phone: "2394039403" | ||
}, | ||
{ | ||
name: "Jackie", | ||
email: "weeea@blabla.com", | ||
phone: "2394039403" | ||
}, | ||
{ | ||
name: "Your Mom", | ||
email: "yourmom@blabla.com", | ||
phone: "1234639403" | ||
} | ||
]; | ||
|
||
var myContact = new Contact({ | ||
name: "Jill", | ||
email: "blabla@blabla.com", | ||
phone: "2394039403" | ||
}); | ||
|
||
// var render = function(contact) { | ||
// var templateText = $('#tmpl-contact-card').html(); | ||
// | ||
// // create an underscore template object | ||
// var templateObject = _.template(templateText); | ||
// | ||
// // Fill in the ERB wth data from our task | ||
// var compiledHTML = templateObject(contact.toJSON()); | ||
// | ||
// // append the result to the DOM | ||
// $('#contact-cards').append(compiledHTML); | ||
// // console.log(compiledHTML); | ||
// }; | ||
|
||
var renderDetails = function() { | ||
console.log(this); | ||
var contact = this.get(id); | ||
var templateText1 = $('#tmpl-contact-details').html(); | ||
// create an underscore template object | ||
var templateObject1 = _.template(templateText1); | ||
// Fill in the ERB wth data from our task | ||
var compiledHTML1 = templateObject1(contact.toJSON()); | ||
|
||
$('#contact-details').html(compiledHTML1); | ||
}; | ||
|
||
|
||
// var renderContacts = function(rolodex) { | ||
// $('#contact-cards').empty(); | ||
// $('#contact-details').hide(); | ||
// | ||
// rolodex.each(function(contactCard){ | ||
// render(contactCard); | ||
// $(".contact-card").click(function() { | ||
// // console.log(contactCard); | ||
// $('#contact-details').show(); | ||
// console.log(this); | ||
// renderDetails(this); | ||
// }); | ||
// }); | ||
// }; | ||
|
||
var getFormData = function() { | ||
var formName = $("#name").val(); | ||
$("#name").val(''); | ||
|
||
// get checkbox and find out if it's checked - true/false | ||
var formEmail = $("email").val(); | ||
$("email").val(''); | ||
|
||
// clear checkbox get the property 'checked' and force is to false | ||
var formPhone = $('#phone').val(); | ||
$('#phone').val(''); | ||
|
||
return { | ||
name: formName, | ||
email: formEmail, | ||
phone: formPhone | ||
}; | ||
}; | ||
|
||
var myContacts = new Rolodex(contactsData); | ||
|
||
// var myContact = new Contact(taskData); | ||
|
||
$(document).ready(function() { | ||
// renderContacts(myContacts); | ||
|
||
// var myContactView = new ContactView({ | ||
// model: myContact, | ||
// template: _.template($('#tmpl-contact-card').html()), | ||
// el: 'ul' | ||
// }); | ||
// | ||
// myContactView.render(); | ||
|
||
|
||
var myRolodexView = new RolodexView({ | ||
model: myContacts, | ||
template: _.template($('#tmpl-contact-card').html()), | ||
el: 'div#application' | ||
// el: 'div#application' | ||
}); | ||
|
||
myRolodexView.render(); | ||
|
||
// $(".btn-save").click(function() { | ||
// var contact = new Contact(getFormData()); | ||
// | ||
// myContacts.add(contact); | ||
// // console.log(myTaskList); | ||
// }); | ||
|
||
var appView = new ApplicationView({ | ||
el: '#application', | ||
model: application | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import Backbone from 'backbone'; | ||
import _ from 'underscore'; | ||
import $ from 'jquery'; | ||
import RolodexView from '../views/rolodex_view.js'; | ||
|
||
|
||
var ContactDetailsView = Backbone.View.extend({ | ||
initialize: function(params){ | ||
this.template = params.template; | ||
|
||
console.log("something happened in contact-details"); | ||
// this.listenTo(RolodexView, "selected", this.render); | ||
// this.$('#contact-details').show(); | ||
}, | ||
render: function(){ | ||
// this.$('#contact-cards').empty(); | ||
// this.$('#contact-details').show(); | ||
|
||
console.log("render in contact-details"); | ||
|
||
var compiledTemplate = this.template(this.model.toJSON()); | ||
|
||
this.$("#contact-details").html(compiledTemplate); | ||
this.$el.show(); | ||
|
||
return this; | ||
}, | ||
|
||
events: { | ||
"click": "hideDetails" | ||
}, | ||
|
||
hideDetails: function(){ | ||
console.log("hide-details clicked"); | ||
// console.log(this); | ||
this.$el.hide(); | ||
} | ||
|
||
|
||
}); | ||
|
||
export default ContactDetailsView; | ||
|
||
// import Contact from '../models/contact.js'; | ||
// import ContactView from '../views/contact_view.js'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,35 @@ | ||
import Backbone from 'backbone'; | ||
import Contact from '../models/contact.js'; | ||
|
||
const ContactView = Backbone.View.extend({ | ||
initialize: function(params) { | ||
this.template = params.template; | ||
|
||
// this.$el.addClass("contact-card small-11 medium-4 large-2 medium-offset-1 columns"); | ||
|
||
this.listenTo(this.model, "change", this.render); | ||
}, | ||
render: function() { | ||
var compiledTemplate = this.template(this.model.toJSON()); | ||
|
||
this.$el.html(compiledTemplate); | ||
|
||
return this; | ||
}, | ||
events: { | ||
"click li": "loadContact" | ||
}, | ||
|
||
loadContact: function() { | ||
console.log("blabala"); | ||
// this.$('#contact-details').show(); | ||
console.log(this); | ||
|
||
this.trigger("selected", this); | ||
|
||
|
||
} | ||
|
||
}); | ||
|
||
export default ContactView; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Clever to do it this way so your View picks up the click to hide it.