Merge "Correctly handle non-array team_id and user_id parameters"
This commit is contained in:
commit
e9a5c9ca43
|
@ -48,21 +48,29 @@ angular.module('sb.story').controller('StoryNewController',
|
|||
});
|
||||
|
||||
// Convert the user_id and team_id parameters to arrays if needed
|
||||
if (!!$stateParams.team_id
|
||||
&& $stateParams.team_id.constructor !== Array) {
|
||||
$stateParams.team_id = [$stateParams.team_id];
|
||||
var stateTeamIds = [];
|
||||
if (!!$stateParams.team_id) {
|
||||
if ($stateParams.team_id.constructor !== Array) {
|
||||
stateTeamIds.push($stateParams.team_id);
|
||||
} else {
|
||||
stateTeamIds.push.apply(stateTeamIds, $stateParams.team_id);
|
||||
}
|
||||
}
|
||||
if (!!$stateParams.user_id
|
||||
&& $stateParams.user_id.constructor !== Array) {
|
||||
$stateParams.user_id = [$stateParams.user_id];
|
||||
var stateUserIds = [];
|
||||
if (!!$stateParams.user_id) {
|
||||
if ($stateParams.user_id.constructor !== Array) {
|
||||
stateUserIds.push($stateParams.user_id);
|
||||
} else {
|
||||
stateUserIds.push.apply(stateUserIds, $stateParams.user_id);
|
||||
}
|
||||
}
|
||||
// Populate the story's permission lists as requested
|
||||
angular.forEach($stateParams.team_id, function(team_id) {
|
||||
angular.forEach(stateTeamIds, function(team_id) {
|
||||
Team.get({team_id: team_id}).$promise.then(function(team) {
|
||||
story.teams.push(team);
|
||||
});
|
||||
});
|
||||
angular.forEach($stateParams.user_id, function(user_id) {
|
||||
angular.forEach(stateUserIds, function(user_id) {
|
||||
User.get({id: user_id}).$promise.then(function(user) {
|
||||
story.users.push(user);
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue