Merge "Make $scope.project into a promise in the detail view"
This commit is contained in:
commit
8b8bc6c151
@ -37,13 +37,6 @@ angular.module('sb.projects').controller('ProjectDetailController',
|
||||
parseInt($stateParams.id, 10) :
|
||||
null;
|
||||
|
||||
/**
|
||||
* The project we're manipulating right now.
|
||||
*
|
||||
* @type Project
|
||||
*/
|
||||
$scope.project = {};
|
||||
|
||||
/**
|
||||
* UI flag for when we're initially loading the view.
|
||||
*
|
||||
@ -101,19 +94,23 @@ angular.module('sb.projects').controller('ProjectDetailController',
|
||||
* Load the project
|
||||
*/
|
||||
function loadProject() {
|
||||
Project.get(
|
||||
return Project.get(
|
||||
{'id': id},
|
||||
function (result) {
|
||||
// We've got a result, assign it to the view and unset our
|
||||
// loading flag.
|
||||
$scope.project = result;
|
||||
|
||||
handleServiceSuccess();
|
||||
return result;
|
||||
},
|
||||
handleServiceError
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* The project we're manipulating right now.
|
||||
*
|
||||
* @type Project
|
||||
*/
|
||||
$scope.project = loadProject();
|
||||
|
||||
/**
|
||||
* Toggles the form back.
|
||||
*/
|
||||
@ -159,6 +156,4 @@ angular.module('sb.projects').controller('ProjectDetailController',
|
||||
handleServiceError
|
||||
);
|
||||
};
|
||||
|
||||
loadProject();
|
||||
});
|
||||
|
@ -22,18 +22,6 @@ angular.module('sb.projects').controller('ProjectStoryListController',
|
||||
Preference, SubscriptionList, CurrentUser) {
|
||||
'use strict';
|
||||
|
||||
// Parse the ID. Since we're in a nested state, we don't really need
|
||||
// to sanity check here, but in case of a future refactor we'll
|
||||
// go ahead and do so anyway.
|
||||
var id = $stateParams.hasOwnProperty('id') ?
|
||||
parseInt($stateParams.id, 10) :
|
||||
null;
|
||||
|
||||
if (id === null) {
|
||||
$state.go('sb.index');
|
||||
return;
|
||||
}
|
||||
|
||||
var pageSize = Preference.get('project_detail_page_size');
|
||||
|
||||
// Variables and methods available to the template...
|
||||
@ -65,7 +53,7 @@ angular.module('sb.projects').controller('ProjectStoryListController',
|
||||
|
||||
// Execute the story query.
|
||||
Story.browse({
|
||||
project_id: id,
|
||||
project_id: $scope.project.id,
|
||||
status: $scope.filter || null,
|
||||
offset: $scope.searchOffset,
|
||||
limit: pageSize,
|
||||
@ -123,7 +111,7 @@ angular.module('sb.projects').controller('ProjectStoryListController',
|
||||
};
|
||||
|
||||
$scope.newStory = function () {
|
||||
NewStoryService.showNewStoryModal(id)
|
||||
NewStoryService.showNewStoryModal($scope.project.id)
|
||||
.then(function (story) {
|
||||
// On success, go to the story detail
|
||||
$state.go('sb.story.detail', {storyId: story.id});
|
||||
@ -133,7 +121,9 @@ angular.module('sb.projects').controller('ProjectStoryListController',
|
||||
|
||||
// Initialize the view with a default search.
|
||||
resetScope();
|
||||
$scope.search();
|
||||
$scope.project.$promise.then(function() {
|
||||
$scope.search();
|
||||
});
|
||||
|
||||
// GET list of story subscriptions
|
||||
var cuPromise = CurrentUser.resolve();
|
||||
|
Loading…
x
Reference in New Issue
Block a user