Story project is defaulted to the current project if available
If we are creating a story in the scope of a project, pre-select the project on the initial task we are creating. If we are creating a series of tasks, pre-select the project of the second task according to the project of the first task. Change-Id: I8423c4dabeec415c214927b810673eaa4da8d78f
This commit is contained in:
@@ -22,12 +22,22 @@ angular.module('sb.story').controller('StoryModalController',
|
||||
'use strict';
|
||||
|
||||
$scope.projects = Project.browse({});
|
||||
$scope.story = new Story({title: ''});
|
||||
$scope.story = new Story({title: '',
|
||||
project_id: params.projectId || null});
|
||||
|
||||
$scope.tasks = [new Task({
|
||||
title: '',
|
||||
project_id: params.projectId || null
|
||||
})];
|
||||
|
||||
// Preload the project
|
||||
if (params.projectId) {
|
||||
Project.get({
|
||||
id: params.projectId
|
||||
}, function (project) {
|
||||
$scope.asyncProject = project;
|
||||
});
|
||||
}
|
||||
|
||||
var lastTitle = '', trackingStoryTitle = true;
|
||||
$scope.$on('$destroy', $scope.$watch(
|
||||
function () {
|
||||
@@ -88,9 +98,24 @@ angular.module('sb.story').controller('StoryModalController',
|
||||
// item in the list.
|
||||
|
||||
var lastTask = $scope.tasks[$scope.tasks.length - 1];
|
||||
$scope.tasks.push(new Task({
|
||||
project_id: lastTask.project_id
|
||||
}));
|
||||
var project_id = lastTask.project_id;
|
||||
|
||||
if (! project_id ) {
|
||||
// if we are in the scope of a project, grab the project ID
|
||||
// from that scope.
|
||||
project_id = params.projectId || null;
|
||||
}
|
||||
|
||||
var current_task = new Task({project_id: project_id});
|
||||
if ( project_id ) {
|
||||
// Preload the project
|
||||
Project.get({
|
||||
id: project_id
|
||||
}, function (project) {
|
||||
$scope.asyncProject = project;
|
||||
});
|
||||
}
|
||||
$scope.tasks.push(current_task);
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user