-
Notifications
You must be signed in to change notification settings - Fork 3
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
Friendly url #7
base: master
Are you sure you want to change the base?
Friendly url #7
Conversation
This will allow us to use the pad title in the url of the pad instead of the id, but still be able to identify it with the id.
Rename the paramether in the route fron `id` to `name` to have friendly urls. Use the name in the route to call `getObjectNames` which allow us to get the id. The result need an ugly parsing to get the id, due to the format of the response. See: SwellRT#1 (comment) Closes SwellRT#1.
} | ||
init(name) { | ||
// get the id from the name | ||
this.swellService.getObjectNames(name) |
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.
Would be good to encapsulate the "get object id from name" logic in a method of swellService?
@@ -47,7 +47,7 @@ export class HomeComponent implements OnInit, OnDestroy { | |||
this.swellService.getObject(name) |
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.
missing trailing ;
@@ -47,7 +47,7 @@ export class HomeComponent implements OnInit, OnDestroy { | |||
this.swellService.getObject(name) | |||
.then( object => { |
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.
swellService.getObject(objectId) requires a id as parameter, not a name. This code creates an object with id == name
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 changes break the current logic to open/create objects (sorry, surely it was not clear enough).
HomeComponent:
- Gets a pad (object) name from user input.
- Checks whether this name correspond with an existing pad (for example a method swellService.getObjectIdByName()).
If not, creates a new object (with autogenerated id) and assing it the name - Redirect to pad/:name
- To be considered: are we going to pass the object name as is as URL part?
PadComponent:
- gets the name from URL and invoque padService.init(name)
Align pad URL with pad title. For that it was needed to:
id
toname
getObjectNames
which allow us to get the id