Semaphore/public/js/routes/playbooks.js

51 lines
1.2 KiB
JavaScript
Raw Normal View History

2014-08-24 23:00:05 +02:00
define([
2014-08-25 01:02:34 +02:00
'app',
'factories/playbook'
2014-08-24 23:00:05 +02:00
], function(app) {
2014-08-25 01:02:34 +02:00
app.config(function($stateProvider, $couchPotatoProvider) {
2014-08-24 23:00:05 +02:00
$stateProvider
.state('addPlaybook', {
url: '/add',
pageTitle: 'Add Playbook',
2014-08-25 01:02:34 +02:00
templateUrl: "/view/playbook/add",
controller: 'AddPlaybookCtrl',
resolve: {
dummy: $couchPotatoProvider.resolve(['controllers/playbook/add'])
}
})
.state('playbook', {
abstract: true,
url: '/playbook/:playbook_id',
templateUrl: '/view/abstract',
controller: function ($scope, playbook) {
$scope.playbook = playbook;
},
resolve: {
2014-08-25 01:24:40 +02:00
playbook: function (Playbook, $stateParams, $q, $state) {
2014-08-25 01:02:34 +02:00
var deferred = $q.defer();
var playbook = new Playbook($stateParams.playbook_id, function (err, errStatus) {
2014-08-25 01:24:40 +02:00
if (err && errStatus == 404) {
$state.transitionTo('homepage');
return deferred.reject();
}
2014-08-25 01:02:34 +02:00
deferred.resolve(playbook);
});
return deferred.promise;
}
}
})
.state('playbook.view', {
url: '/',
controller: 'PlaybookCtrl',
templateUrl: '/view/playbook/view',
resolve: {
dummy: $couchPotatoProvider.resolve(['controllers/playbook/playbook'])
}
2014-08-24 23:00:05 +02:00
})
})
})