forked from AdaGold/BackTREK
-
Notifications
You must be signed in to change notification settings - Fork 44
Lauren Cardella -- Carets #42
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
Open
enigmagnetic
wants to merge
11
commits into
Ada-C8:master
Choose a base branch
from
enigmagnetic: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
11 commits
Select commit
Hold shift + click to select a range
4b0cfca
Add templates for status messages, trips table rows, and trip details…
enigmagnetic c60c9dc
Add loadTrip() function to show individual trip details. Cannot get t…
enigmagnetic 5ff2bd6
Add sorting by table headers to trip list. Add styles to sort classes…
enigmagnetic d28528f
Forgot to commit yesterday. Add forms for new trips and reservations.…
enigmagnetic 009be5f
Adjust border styling for trip details element.
enigmagnetic 7bfa39d
I made a filter and it WORKS. PRAISE BE TO ISAAC.
enigmagnetic 1885bb8
Move sorting function out of document.ready and implement reverse sor…
enigmagnetic 7bb7abd
Error messages for new trip validation now show next to the labels in…
enigmagnetic d3410dd
Add clearFilter function to remove last selected values on page refresh.
enigmagnetic 3351dd5
Adjust styling to fix trips table appearing at the top of the page.
enigmagnetic 06998fd
Add inline error messages to reservation form. Replace url funciton w…
enigmagnetic 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 hidden or 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or 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 hidden or 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,22 @@ | ||
| 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: function(response) { | ||
| return response; | ||
| }, | ||
| filterBy: function(filterCategory, query) { | ||
| if (query === '') { | ||
| return this; | ||
| } | ||
| if (filterCategory === 'weeks' || filterCategory === 'cost') { | ||
| return this.where(trip => trip.get(filterCategory) <= Number(query)); | ||
| } else { | ||
| return this.where((trip) => trip.get(filterCategory).toLowerCase().includes(query)); | ||
| } | ||
| }, | ||
| }); | ||
|
|
||
| export default TripList; |
This file contains hidden or 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,46 @@ | ||
| import Backbone from 'backbone'; | ||
|
|
||
| const Trip = Backbone.Model.extend({ | ||
| urlRoot: 'https://ada-backtrek-api.herokuapp.com/trips/', | ||
| validate: function(attributes) { | ||
| const errors = {}; | ||
| const CONTINENTS = ['Africa', 'Antartica', 'Asia', 'Australasia', 'Europe', 'North America', 'South America']; | ||
| if (!attributes.name) { | ||
| errors['name'] = ['Cannot be blank']; | ||
| } | ||
|
|
||
| if (!attributes.continent) { | ||
| errors['continent'] = ['Cannot be blank']; | ||
| } else if (!CONTINENTS.includes(attributes.continent)) { | ||
| errors['continent'] = ['Must be a valid continent']; | ||
| } | ||
|
|
||
| if (!attributes.category) { | ||
| errors['category'] = ['Cannot be blank']; | ||
| } | ||
|
|
||
| if (!attributes.weeks) { | ||
| errors['weeks'] = ['Cannot be blank']; | ||
| } else if (isNaN(attributes.weeks)) { | ||
| errors['weeks'] = ['Must be a number']; | ||
| } else if (attributes.weeks < 1) { | ||
| errors['weeks'] = ['Must be greater than 0']; | ||
| } | ||
|
|
||
| if (!attributes.cost) { | ||
| errors['cost'] = ['Cannot be blank']; | ||
| } else if (isNaN(attributes.cost)) { | ||
| errors['cost'] = ['Must be a number']; | ||
| } else if (attributes.cost <= 0) { | ||
| errors['cost'] = ['Must be greater than 0']; | ||
| } | ||
|
|
||
| if (Object.keys(errors).length > 0) { | ||
| return errors; | ||
| } else { | ||
| return false; | ||
| } | ||
| } | ||
| }); | ||
|
|
||
| export default Trip; |
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.
This is where you should have the
tripListrefresh, or fetch the trip's name and manually add it to the list.