Skip to content
This repository has been archived by the owner on Mar 31, 2023. It is now read-only.

Commit

Permalink
Disable booking button if user is viewing own listing; display bookin…
Browse files Browse the repository at this point in the history
…g failure inline
  • Loading branch information
shibbi committed May 6, 2015
1 parent cc27cbc commit e593852
Show file tree
Hide file tree
Showing 11 changed files with 24 additions and 177 deletions.
15 changes: 4 additions & 11 deletions README.md
Expand Up @@ -21,16 +21,12 @@ PetBnB is AirBnB for pets, built on Rails and Backbone. Users can:
- [x] Brief owner's info
- [x] Description
- [x] Dates to book
- [ ] Reviews
- [x] Make reservations on listing details page
- [ ] Leave reviews on listings and user profiles
- [x] See user's own profile with:
- [x] Brief info
- [x] Reservations
- [ ] See other users' profiles with:
- [x] See other users' profiles with:
- [x] Listings
- [ ] Reviews
- [ ] Create new listings

## Design Docs
* [View Wireframes][views]
Expand Down Expand Up @@ -84,19 +80,16 @@ a listing's detail page.

[Details][phase-four]

### Phase 5: Reviews and Wrapping Up (~1-2 days)
I will add the ability for users to leave reviews on both listings and
other users. These will be shown on the bottom of a listing detail page
or a user's profile page. This will be implemented with a polymorphic
association that connects reviews to either users or listings. Users
will also be able to edit their profiles.
### Phase 5: Wrapping Up (~1-2 days)
I will do any styling needed for the pages from previous days that still
need styling, and standardize the format across the whole site.


[Details][phase-five]

### Bonus Features (TBD)
- [ ] Create new listings
- [ ] Leave / view reviews on listings and user profiles
- [ ] Email activation / password reset
- [x] Animation of data population on guest login
- [ ] Messaging between users
Expand Down
8 changes: 0 additions & 8 deletions app/assets/javascripts/models/listing.js
Expand Up @@ -17,14 +17,6 @@ PetBnB.Models.Listing = Backbone.Model.extend({
return this._images;
},

reservations: function () {

},

reviews: function () {

},

parse: function (payload) {
if (payload.images) {
this.images().set(payload.images);
Expand Down
4 changes: 0 additions & 4 deletions app/assets/javascripts/models/user.js
Expand Up @@ -19,10 +19,6 @@ PetBnB.Models.User = Backbone.Model.extend({
return this._listings;
},

reviews: function () {

},

parse: function (payload) {
if (payload.reservations) {
this.reservations().set(payload.reservations);
Expand Down
1 change: 0 additions & 1 deletion app/assets/javascripts/views/listings/map.js
Expand Up @@ -93,7 +93,6 @@ PetBnB.Views.MapShowView = Backbone.View.extend({

toggleMarkerInfo: function (event, marker) {
this._currentInfoWindow && this._currentInfoWindow.close();
// make template for this (marker has title, first image, and price)
this._currentInfoWindow = new google.maps.InfoWindow({
content: marker.title
});
Expand Down
26 changes: 0 additions & 26 deletions app/assets/javascripts/views/listings/navbar_search.js

This file was deleted.

16 changes: 1 addition & 15 deletions app/assets/javascripts/views/listings/results.js
Expand Up @@ -6,8 +6,6 @@ PetBnB.Views.ResultsView = Backbone.View.extend({
events: {
'change #checkin': 'checkDates',
'change #checkout': 'checkDates'
// 'click a.remove-listing': 'destroyListing',
// 'click a.listing-name': 'panToListing',
// 'mouseenter .listing': 'startBounce',
// 'mouseleave .listing': 'stopBounce'
},
Expand Down Expand Up @@ -84,19 +82,7 @@ PetBnB.Views.ResultsView = Backbone.View.extend({
// var listingId = $(event.currentTarget).children('a').data('listing-id');
// PetBnB.mapView.stopBounce(listingId);
// },
//
// destroyListing: function (event) {
// var listingId = $(event.currentTarget).data('listing-id');
// var listing = this.collection.get(listingId);
// listing.destroy();
// },
//
// panToListing: function (event) {
// var listingId = $(event.currentTarget).data('listing-id');
// var marker = PetBnB.mapView._markers[listingId];
// PetBnB.mapView._map.panTo(marker.getPosition());
// },


remove: function () {
Backbone.View.prototype.remove.call(this);
PetBnB.mapView.remove();
Expand Down
15 changes: 9 additions & 6 deletions app/assets/javascripts/views/listings/show.js
Expand Up @@ -24,6 +24,9 @@ PetBnB.Views.ListingShowView = Backbone.View.extend({
this.$el.html(content);
document.title = this.model.get('name') + ' | PetBnB';
$('#navbar-search-container').addClass('active');
if (this.model.user().id === PetBnB.currentUser.id) {
$('#booking-button').prop('disabled', true);
}

PetBnB.setDatepickers();
this.getTotalNights();
Expand All @@ -39,7 +42,6 @@ PetBnB.Views.ListingShowView = Backbone.View.extend({
var checkout = $('#checkout').val();
if (checkin !== "" && checkout !== "") {
if (checkout > checkin) {
// $('.booking-errors').removeClass('enabled');
$('.panel-padding-fit').addClass('enabled');
$('.booking-button').addClass('enabled');

Expand All @@ -53,12 +55,12 @@ PetBnB.Views.ListingShowView = Backbone.View.extend({
}
} else {
$('.panel-padding-fit').removeClass('enabled');
// $('.booking-errors').removeClass('enabled');
$('.booking-button').addClass('enabled');
}
},

instantBook: function (event) {
$('.booking-errors').removeClass('enabled');
if ($('#checkin').val() === "") {
$('#checkin').focus();
} else if ($('#checkout').val() === "") {
Expand All @@ -74,18 +76,19 @@ PetBnB.Views.ListingShowView = Backbone.View.extend({
var reservation = new PetBnB.Models.Reservation();
reservation.save({ reservation: reservationData }, {
success: function () {
$('#checkin').val('');
$('#checkout').val('');
PetBnB.currentUser.reservations().add(reservation);
var successMsg = 'You have successfully booked this listing ';
successMsg += 'from ' + checkin + ' to ' + checkout + ' :)';
successMsg += 'from ' + checkin + ' to ' + checkout;
successMsg += '<br/>';
successMsg += 'Please go to your account to view it!';
$('#bookingSuccessModal .modal-body').html(successMsg);
$('#bookingSuccessModal').modal();
},
error: function (models, resp) {
var failureMsg = resp.responseJSON;
$('#bookingFailureModal .modal-body').html(failureMsg);
$('#bookingFailureModal').modal();
$('.booking-errors .message').html('Those dates are not available');
$('.booking-errors').addClass('enabled');
}
});
$('.panel-padding-fit').removeClass('enabled');
Expand Down
91 changes: 9 additions & 82 deletions app/assets/templates/listings/show.jst.ejs
Expand Up @@ -26,7 +26,6 @@
<input type="hidden" id="lat" value=<%= listing.escape('latitude') %>>
<input type="hidden" id="lng" value=<%= listing.escape('longitude') %>>
<span class="address"><%= listing.escape('address') %></span>
<span class="reviews">[Reviews TBA]</span>
</div>
</div>
</div>
Expand All @@ -41,6 +40,10 @@
<div class="panel">
<div class="panel-body panel-light">
<div class="form-fields">
<div class="booking-errors">
<div class="message">
</div>
</div>
<div class="row row-condensed">
<div class="col-sm-6">
Check In
Expand Down Expand Up @@ -82,15 +85,6 @@
<i class="fa fa-bolt"></i> Instant Book
</button>
</div>
<div class="booking-errors">
<div class="message">
Those dates are not available
</div>
<a class="btn btn-large btn-block"
id="view_other_listings">
View Other Listings
</a>
</div>
</div>
<div id="book-urgency-commitment">
<div class="panel-body">
Expand Down Expand Up @@ -120,11 +114,6 @@
With PetBnB, you can find unique accommodations for your pets—from houses and apartments, to tree houses and igloos. The listing details below explain what you'll find in this space. If you have any questions, you can contact the host directly.
</div>
</div>
<!-- <p>
<a href="#" id="contact-host-link">
<strong>Contact Host</strong>
</a>
</p> -->
<% if (detailImgTop !== "") { %>
<div class="row-space-4 row-space-top-4 inline-photo">
<a href="#" class="photo-trigger" data-index="1">
Expand Down Expand Up @@ -170,11 +159,6 @@
<div class="col-md-6">
<strong>2 nights</strong> minimum stay
</div>
<!-- <div class="col-md-6">
<a href="#" id="calendar">
<strong>View Calendar</strong>
</a>
</div> -->
</div>
</div>
</div>
Expand All @@ -189,51 +173,6 @@
</div>
</div>
</div>
<!-- <div id="reviews">
<div class="panel">
<div class="row container-responsive">
<div class="col-md-8 col-sm-12">
<div class="row-space-8 row-space-top-8">
[reviewers]
</div>
<div class="review-content">
[review details]
</div>
</div>
</div>
</div>
</div>
<div id="host-profile">
<div class="row container-responsive">
<div class="col-md-8 col-sm-12">
<div class="row-space-8 row-space-top-8">
<h4>About the Host, <%= userName %></h4>
<div class="row">
<div class="col-md-3 text-center">
<a href="/users/<%= listing.escape('user_id') %>"
class="user-icon">
<img src="<%= iconUrl %>" alt="user_icon" />
</a>
</div>
<div class="col-md-9">
<div class="row-space-2" id="user-description">
[user description]
</div>
<div class="row-space-2" id="u">
[more user description]
</div>
<div class="contact-wrapper">
<button class="btn btn-small btn-primary"
id="host-profile-contact-btn">
Contact Host
</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div> -->

<div class="modal fade" id="bookingSuccessModal" tabindex="-1"
role="dialog" aria-labelledby="reservationSuccessModal"
Expand All @@ -253,20 +192,8 @@
</div>
</div>

<div class="modal fade" id="bookingFailureModal" tabindex="-1"
role="dialog" aria-labelledby="reservationSuccessModal"
aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"
aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
<h4 class="modal-title">Booking failure</h4>
</div>
<div class="modal-body">
</div>
</div>
</div>
</div>
<script type="text/javascript">
(function () {
})();
</script>
2 changes: 1 addition & 1 deletion app/views/api/listings/show.json.jbuilder
Expand Up @@ -5,4 +5,4 @@ json.images @listing.images do |image|
json.extract! image, :listing_id, :url
end

json.user(@listing.user, :email, :avatar_url)
json.user(@listing.user, :id, :email, :avatar_url)
16 changes: 0 additions & 16 deletions app/views/shared/_navbar.html.erb
Expand Up @@ -22,22 +22,6 @@
<input type="text" class="form-control" id="navbar-searchbox"
placeholder="Where is your pet going?">
</form>
<!-- <ul class="nav navbar-nav">
<li class="dropdown">
<a href="#" class="dropdown-toggle"
data-toggle="dropdown"
role="button"
aria-expanded="false">
Browse<span class="caret"></span>
</a>
<ul class="dropdown-menu" role="menu">
<li><a href="#">Popular</a></li>
<li><a href="#">Friends</a></li>
<li><a href="#">Neighborhoods</a></li>
<li><a href="#">Groups</a></li>
</ul>
</li>
</ul> -->
</div>
<ul class="nav navbar-nav navbar-right">
<% if logged_in? %>
Expand Down
7 changes: 0 additions & 7 deletions docs/schema.md
Expand Up @@ -43,10 +43,3 @@ booker_id | integer | not null, fk (ref users)
listing_id | integer | not null, fk (ref listings)
start_date | string | not null
end_date | string | not null

## reviews
column name | data type | details
----------------|-----------|-----------------------
id | integer | not null, pk
user_id | integer | not null, fk (ref users)
body | string | not null

0 comments on commit e593852

Please sign in to comment.