diff --git a/src/app/stories/controller/story_detail_controller.js b/src/app/stories/controller/story_detail_controller.js index 4a0c44e7..16c4680d 100644 --- a/src/app/stories/controller/story_detail_controller.js +++ b/src/app/stories/controller/story_detail_controller.js @@ -20,7 +20,7 @@ angular.module('sb.story').controller('StoryDetailController', function ($log, $rootScope, $scope, $state, $stateParams, $modal, Session, Preference, TimelineEvent, Comment, TimelineEventTypes, story, - Story, creator, tasks, Task, DSCacheFactory, User, + Story, creator, tasks, Task, DSCacheFactory, User, $q, storyboardApiBase, SubscriptionList, CurrentUser, SessionModalService, moment, $document) { 'use strict'; @@ -325,6 +325,51 @@ angular.module('sb.story').controller('StoryDetailController', SessionModalService.showLoginRequiredModal(); }; + /** + * User typeahead search method. + */ + $scope.searchUsers = function (value, array) { + var deferred = $q.defer(); + + User.browse({full_name: value, limit: 10}, + function(searchResults) { + var results = []; + angular.forEach(searchResults, function(result) { + if (array.indexOf(result.id) === -1) { + results.push(result); + } + }); + deferred.resolve(results); + } + ); + return deferred.promise; + }; + + /** + * Formats the user name. + */ + $scope.formatUserName = function (model) { + if (!!model) { + return model.name; + } + return ''; + }; + + /** + * Add a new user to one of the permission levels. + */ + $scope.addUser = function (model) { + $scope.story.users.push(model); + }; + + /** + * Remove a user from one of the permission levels. + */ + $scope.removeUser = function (model) { + var idx = $scope.story.users.indexOf(model); + $scope.story.users.splice(idx, 1); + }; + // ################################################################### // Task Management // ################################################################### diff --git a/src/app/stories/controller/story_modal_controller.js b/src/app/stories/controller/story_modal_controller.js index 13793993..24849a41 100644 --- a/src/app/stories/controller/story_modal_controller.js +++ b/src/app/stories/controller/story_modal_controller.js @@ -18,11 +18,20 @@ * Controller for the "new story" modal popup. */ angular.module('sb.story').controller('StoryModalController', - function ($scope, $modalInstance, params, Project, Story, Task) { + function ($scope, $modalInstance, params, Project, Story, Task, User, + $q, CurrentUser) { 'use strict'; + var currentUser = CurrentUser.resolve(); + $scope.projects = Project.browse({}); - $scope.story = new Story({title: ''}); + + currentUser.then(function(user) { + $scope.story = new Story({ + title: '', + users: [user] + }); + }); $scope.tasks = [new Task({ title: '', @@ -153,5 +162,51 @@ angular.module('sb.story').controller('StoryModalController', $scope.selectNewProject = function (model, task) { task.project_id = model.id; }; + + /** + * User typeahead search method. + */ + $scope.searchUsers = function (value, array) { + var deferred = $q.defer(); + + User.browse({full_name: value, limit: 10}, + function(searchResults) { + var results = []; + angular.forEach(searchResults, function(result) { + if (array.indexOf(result.id) === -1) { + results.push(result); + } + }); + deferred.resolve(results); + } + ); + return deferred.promise; + }; + + /** + * Formats the user name. + */ + $scope.formatUserName = function (model) { + if (!!model) { + return model.name; + } + return ''; + }; + + /** + * Add a new user to one of the permission levels. + */ + $scope.addUser = function (model) { + $scope.story.users.push(model); + }; + + /** + * Remove a user from one of the permission levels. + */ + $scope.removeUser = function (model) { + var idx = $scope.story.users.indexOf(model); + $scope.story.users.splice(idx, 1); + }; + }) ; diff --git a/src/app/stories/template/detail.html b/src/app/stories/template/detail.html index bd7177ed..bd901b4f 100644 --- a/src/app/stories/template/detail.html +++ b/src/app/stories/template/detail.html @@ -1,5 +1,6 @@ diff --git a/src/app/stories/template/new.html b/src/app/stories/template/new.html index 7b32eb12..48c8e5ee 100644 --- a/src/app/stories/template/new.html +++ b/src/app/stories/template/new.html @@ -49,6 +49,69 @@ +
+ + +
+ +
+
+
+ + + + + + + + + + + + + + + +
Users that can see this story + + + + + Add User + + +
+ {{user.full_name}} + + × + +
+ +
+