url generation seems to work fine, but for some weird reason it seems to pushState urls with all segments undefined
This commit is contained in:
parent
240b1da238
commit
e3a4d0194c
|
@ -51,69 +51,67 @@ App.Router = Em.Router.extend({
|
||||||
enableLogging: true,
|
enableLogging: true,
|
||||||
location: 'hash',
|
location: 'hash',
|
||||||
|
|
||||||
|
serialize: function() {
|
||||||
|
var ownerName = this.getPath('repositoryController.content.ownerName');
|
||||||
|
var name = this.getPath('repositoryController.content.name');
|
||||||
|
return { ownerName: ownerName, name: name };
|
||||||
|
},
|
||||||
|
|
||||||
|
connectLeft: function() {
|
||||||
|
this.get('applicationController').connectOutlet({ outletName: 'left', name: 'repositories', context: App.Repository.find() })
|
||||||
|
},
|
||||||
|
|
||||||
|
connectLoading: function() {
|
||||||
|
this.get('applicationController').connectOutlet({ outletName: 'main', name: 'loading' });
|
||||||
|
},
|
||||||
|
|
||||||
|
connectMain: function(repository, build) {
|
||||||
|
this.setPath('tabsController.repository', repository);
|
||||||
|
this.setPath('tabsController.build', build);
|
||||||
|
|
||||||
|
this.get('applicationController').connectOutlet({ outletName: 'main', name: 'repository', context: repository });
|
||||||
|
this.get('repositoryController').connectOutlet({ outletName: 'tabs', name: 'tabs' });
|
||||||
|
},
|
||||||
|
|
||||||
root: Em.Route.extend({
|
root: Em.Route.extend({
|
||||||
routePath: function(router, path) {
|
viewRepository: Ember.Route.transitionTo('repository.current'),
|
||||||
router.transitionTo('loading', path);
|
|
||||||
},
|
|
||||||
|
|
||||||
viewRepository: Ember.Route.transitionTo('repository'),
|
// why is applicationController undefined here? would like to share connecting the left outlet to repositories
|
||||||
|
// connectOutlets: function(router) {
|
||||||
loading: Ember.Route.extend({
|
// router.connectLeft();
|
||||||
connectOutlets: function(router, path) {
|
// },
|
||||||
var repositories = App.Repository.find();
|
|
||||||
|
|
||||||
router.get('applicationController').connectOutlet({ outletName: 'left', name: 'repositories', context: repositories })
|
|
||||||
router.get('applicationController').connectOutlet({ outletName: 'main', name: 'loading' });
|
|
||||||
|
|
||||||
if (path === '') {
|
|
||||||
// should observe RecordArray.isLoaded instead, but that doesn't seem to exist?
|
|
||||||
onReady(repositories, 'length', function() {
|
|
||||||
router.transitionTo('index', repositories.get('firstObject'));
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
// this would be a query for the repo based on `path`
|
|
||||||
var repository = App.Repository.find(1);
|
|
||||||
onReady(repository, 'isLoaded', function() {
|
|
||||||
router.transitionTo('repository', repository);
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
|
|
||||||
index: Em.Route.extend({
|
index: Em.Route.extend({
|
||||||
route: '/',
|
route: '/',
|
||||||
|
|
||||||
connectOutlets: function(router, repository) {
|
connectOutlets: function(router) {
|
||||||
var build = App.Build.find(1);
|
router.connectLeft();
|
||||||
|
router.connectLoading();
|
||||||
|
|
||||||
router.setPath('tabsController.repository', repository);
|
var repositories = router.getPath('repositoriesController.content');
|
||||||
router.setPath('tabsController.build', build);
|
// should observe RecordArray.isLoaded instead, but that doesn't seem to exist?
|
||||||
|
onReady(repositories, 'firstObject.isLoaded', function() {
|
||||||
router.get('applicationController').connectOutlet({ outletName: 'main', name: 'repository', context: repository });
|
router.connectMain(repositories.get('firstObject'), App.Build.find(1))
|
||||||
router.get('repositoryController').connectOutlet({ outletName: 'tabs', name: 'tabs' });
|
});
|
||||||
router.get('repositoryController').connectOutlet({ outletName: 'tab', name: 'current', context: build});
|
|
||||||
},
|
},
|
||||||
|
|
||||||
viewCurrent: Ember.Route.transitionTo('root.repository.current'),
|
viewCurrent: Ember.Route.transitionTo('repository.current'),
|
||||||
viewHistory: Ember.Route.transitionTo('root.repository.history'),
|
viewHistory: Ember.Route.transitionTo('repository.history'),
|
||||||
viewBuild: Ember.Route.transitionTo('root.repository.build'),
|
viewBuild: Ember.Route.transitionTo('repository.build'),
|
||||||
}),
|
}),
|
||||||
|
|
||||||
repository: Em.Route.extend({
|
repository: Em.Route.extend({
|
||||||
route: '/:ownerName/:name',
|
route: '/:ownerName/:name',
|
||||||
|
|
||||||
serialize: function(router, repository) {
|
connectOutlets: function(router) {
|
||||||
return repository.getProperties('ownerName', 'name');
|
router.connectLeft();
|
||||||
},
|
router.connectLoading();
|
||||||
|
|
||||||
connectOutlets: function(router, repository) {
|
// this would be a query for the repo based on path (how to retrieve the path here?)
|
||||||
var build = App.Build.find(1);
|
var repository = App.Repository.find(1);
|
||||||
|
onReady(repository, 'isLoaded', function() {
|
||||||
router.setPath('tabsController.repository', repository);
|
router.connectMain(repository, App.Build.find(1))
|
||||||
router.setPath('tabsController.build', build);
|
})
|
||||||
|
|
||||||
router.get('applicationController').connectOutlet({ outletName: 'main', name: 'repository', context: repository });
|
|
||||||
router.get('repositoryController').connectOutlet({ outletName: 'tabs', name: 'tabs' });
|
|
||||||
},
|
},
|
||||||
|
|
||||||
viewCurrent: Ember.Route.transitionTo('current'),
|
viewCurrent: Ember.Route.transitionTo('current'),
|
||||||
|
@ -122,6 +120,11 @@ App.Router = Em.Router.extend({
|
||||||
|
|
||||||
current: Em.Route.extend({
|
current: Em.Route.extend({
|
||||||
route: '/',
|
route: '/',
|
||||||
|
|
||||||
|
serialize: function(router, context) {
|
||||||
|
return router.serialize();
|
||||||
|
},
|
||||||
|
|
||||||
connectOutlets: function(router, context) {
|
connectOutlets: function(router, context) {
|
||||||
router.get('repositoryController').connectOutlet({ outletName: 'tab', name: 'current', context: App.Build.find(1)});
|
router.get('repositoryController').connectOutlet({ outletName: 'tab', name: 'current', context: App.Build.find(1)});
|
||||||
}
|
}
|
||||||
|
@ -129,6 +132,11 @@ App.Router = Em.Router.extend({
|
||||||
|
|
||||||
history: Em.Route.extend({
|
history: Em.Route.extend({
|
||||||
route: '/builds',
|
route: '/builds',
|
||||||
|
|
||||||
|
serialize: function(router, context) {
|
||||||
|
return router.serialize();
|
||||||
|
},
|
||||||
|
|
||||||
connectOutlets: function(router, context) {
|
connectOutlets: function(router, context) {
|
||||||
router.get('repositoryController').connectOutlet({ outletName: 'tab', name: 'history', context: App.Build.find()});
|
router.get('repositoryController').connectOutlet({ outletName: 'tab', name: 'history', context: App.Build.find()});
|
||||||
}
|
}
|
||||||
|
@ -136,6 +144,11 @@ App.Router = Em.Router.extend({
|
||||||
|
|
||||||
build: Em.Route.extend({
|
build: Em.Route.extend({
|
||||||
route: '/builds/:build_id',
|
route: '/builds/:build_id',
|
||||||
|
|
||||||
|
serialize: function(router, context) {
|
||||||
|
return $.extend(router.serialize(), this._super(router, context));
|
||||||
|
},
|
||||||
|
|
||||||
connectOutlets: function(router, context) {
|
connectOutlets: function(router, context) {
|
||||||
params = { id: 1 }
|
params = { id: 1 }
|
||||||
router.get('repositoryController').connectOutlet({ outletName: 'tab', name: 'build', context: App.Build.find(params.id)});
|
router.get('repositoryController').connectOutlet({ outletName: 'tab', name: 'build', context: App.Build.find(params.id)});
|
||||||
|
|
|
@ -1,3 +1,8 @@
|
||||||
|
<div id="head">
|
||||||
|
<a href="/">Travis CI</a>
|
||||||
|
<a href="#">#</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div id="left">
|
<div id="left">
|
||||||
{{outlet left}}
|
{{outlet left}}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<ul>
|
<ul>
|
||||||
{{#each build in content}}
|
{{#each build in content}}
|
||||||
<li><a {{action viewBuild href=true}}>Build #{{build.number}}</a></li>
|
<li><a {{action viewBuild href=true context="build"}}>Build #{{build.number}}</a></li>
|
||||||
{{/each}}
|
{{/each}}
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,13 @@ body {
|
||||||
font-family: Helvetica;
|
font-family: Helvetica;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#head {
|
||||||
|
width: 100%;
|
||||||
|
height: 40px;
|
||||||
|
font-size: 20px;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
#left, #main {
|
#left, #main {
|
||||||
float: left;
|
float: left;
|
||||||
height: 500px;
|
height: 500px;
|
||||||
|
@ -23,14 +30,32 @@ body {
|
||||||
|
|
||||||
#left {
|
#left {
|
||||||
width: 200px;
|
width: 200px;
|
||||||
background-color: #f9f9f9;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#main {
|
#main {
|
||||||
width: 400px;
|
width: 400px;
|
||||||
padding: 1em;
|
padding-left: 1em;
|
||||||
}
|
}
|
||||||
|
|
||||||
h2 {
|
h2 {
|
||||||
margin-top: 0;
|
margin-top: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ul {
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
li {
|
||||||
|
list-style-type: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tabs li {
|
||||||
|
float: left;
|
||||||
|
margin-right: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tab {
|
||||||
|
clear: both;
|
||||||
|
padding-top: 20px;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user