Skip to content

Commit

Permalink
update route on pedigree/person switch
Browse files Browse the repository at this point in the history
  • Loading branch information
justincy committed Dec 19, 2016
1 parent 13fc648 commit 4624a05
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
15 changes: 10 additions & 5 deletions components/sample-app.html
Original file line number Diff line number Diff line change
Expand Up @@ -257,9 +257,9 @@ <h1>FamilySearch Web Components Sample App</h1>
*/
_togglePage: function(){
if(this.page === 'person'){
this.page = 'pedigree';
page('/pedigree/' + this.personId);
} else {
this.page = 'person';
page('/person/' + this.personId);
}
},

Expand All @@ -279,12 +279,17 @@ <h1>FamilySearch Web Components Sample App</h1>
var app = this,
loadUser = this._routeMiddleware.loadUser.bind(this),
ensureAuth = this._routeMiddleware.ensureAuth.bind(this);


page('/person', ensureAuth, loadUser, function(){
page.redirect('/person/' + app.user.personId);
});
page('/person/:personId', ensureAuth, function(context){
app.personId = context.params.personId;
app.page = 'person';
});
page('/person', ensureAuth, loadUser, function(){
page.redirect('/person/' + app.user.personId);
page('/pedigree/:personId', function(context){
app.personId = context.params.personId;
app.page = 'pedigree';
});

// When signed in, forward to /person by default to load the current user
Expand Down
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/

var serverFactory = require('spa-server');
var matcher = /\/person/;
var matcher = /^\/(person|pedigree)/;
var server = serverFactory.create({
port: process.env.PORT || 8080,

Expand Down

0 comments on commit 4624a05

Please sign in to comment.