Make Timeline configurable

The Timeline events can now be filtered in preferences view.
By default all event types are enabled.

Change-Id: I6099e8491e2f8615273df198df95596d31584870
This commit is contained in:
Nikita Konovalov 2014-05-13 17:17:30 +04:00
parent 295ac5582a
commit 490d38ea13
13 changed files with 109 additions and 10 deletions

View File

@ -23,9 +23,13 @@ angular.module('sb.profile').controller('ProfilePreferencesController',
'use strict'; 'use strict';
$scope.pageSize = Preference.get('page_size'); $scope.pageSize = Preference.get('page_size');
$scope.enabled_event_types = Preference.get('display_events_filter');
$scope.save = function () { $scope.save = function () {
Preference.set('page_size', $scope.pageSize); Preference.set('page_size', $scope.pageSize);
Preference.set('display_events_filter',
$scope.enabled_event_types);
$scope.message = 'Preferences Saved!'; $scope.message = 'Preferences Saved!';
}; };
}); });

View File

@ -19,7 +19,7 @@
*/ */
angular.module('sb.story').controller('StoryDetailController', angular.module('sb.story').controller('StoryDetailController',
function ($log, $scope, $state, $stateParams, $modal, Story, function ($log, $scope, $state, $stateParams, $modal, Story,
Session, User) { Session, User, Preference) {
'use strict'; 'use strict';
// Parse the ID // Parse the ID
@ -27,6 +27,8 @@ angular.module('sb.story').controller('StoryDetailController',
parseInt($stateParams.storyId, 10) : parseInt($stateParams.storyId, 10) :
null; null;
$scope.enabled_event_types = Preference.get('display_events_filter');
/** /**
* Generic service error handler. Assigns errors to the view's scope, * Generic service error handler. Assigns errors to the view's scope,
* and unsets our flags. * and unsets our flags.

View File

@ -20,7 +20,8 @@
*/ */
angular.module('sb.story', ['ui.router', 'sb.services', 'sb.util', angular.module('sb.story', ['ui.router', 'sb.services', 'sb.util',
'ui.bootstrap']) 'ui.bootstrap'])
.config(function ($stateProvider, $urlRouterProvider) { .config(function ($stateProvider, $urlRouterProvider, PreferenceProvider,
TimelineEventTypes) {
'use strict'; 'use strict';
// URL Defaults. // URL Defaults.
@ -42,4 +43,15 @@ angular.module('sb.story', ['ui.router', 'sb.services', 'sb.util',
url: '/{storyId:[0-9]+}', url: '/{storyId:[0-9]+}',
templateUrl: 'app/templates/story/detail.html' templateUrl: 'app/templates/story/detail.html'
}); });
// Register a preference for filtering timeline events.
// By default all types of events should be displayed.
var events_filter_defaults = {};
TimelineEventTypes.forEach(function(type) {
events_filter_defaults[type] = true;
});
PreferenceProvider.addPreference('display_events_filter',
events_filter_defaults);
}); });

View File

@ -56,6 +56,59 @@
<hr/> <hr/>
<div class="form-group">
<label>Timeline events</label>
<p class="help-block">
Which types of Timeline events would you like to be
displayed?
</p>
<div>
<input type="checkbox" name="enabledTypes"
id="storyCreated"
ng-model="enabled_event_types.story_created">
<label for="storyCreated">Story created</label>
<br/>
<input type="checkbox" name="enabledTypes"
id="storyDetailsChanged"
ng-model="enabled_event_types.story_details_changed">
<label for="storyDetailsChanged">Story details changed</label>
<br/>
<input type="checkbox" name="enabledTypes"
id="taskCreated"
ng-model="enabled_event_types.task_created">
<label for="taskCreated">Task created</label>
<br/>
<input type="checkbox" name="enabledTypes"
id="taskAssigneeChanged"
ng-model="enabled_event_types.task_assignee_changed">
<label for="taskAssigneeChanged">Task assignee changed</label>
<br/>
<input type="checkbox" name="enabledTypes"
id="taskStatusChanged"
ng-model="enabled_event_types.task_status_changed">
<label for="taskStatusChanged">Task status changed</label>
<br/>
<input type="checkbox" name="enabledTypes"
id="taskDetailsChanged"
ng-model="enabled_event_types.task_details_changed">
<label for="taskDetailsChanged">Task details Changed</label>
<br/>
<input type="checkbox" name="enabledTypes"
id="taskDeleted"
ng-model="enabled_event_types.task_deleted">
<label for="taskDeleted">Task deleted</label>
<br/>
<input type="checkbox" name="enabledTypes"
id="userComment"
ng-model="enabled_event_types.user_comment">
<label for="userComment">User comment</label>
</div>
</div>
<hr/>
<div class="form-group"> <div class="form-group">
<button type="button" class="btn btn-default" <button type="button" class="btn btn-default"
ng-click="save()"> ng-click="save()">

View File

@ -1,4 +1,4 @@
<div class="discussion-comment"> <div class="discussion-comment" ng-show="enabled_event_types.story_created">
<p class="discussion-comment-author"> <p class="discussion-comment-author">
{{ author.full_name }} has created this story. {{ author.full_name }} has created this story.
<span class="pull-right">{{event.created_at | date: 'medium'}}</span> <span class="pull-right">{{event.created_at | date: 'medium'}}</span>

View File

@ -1,4 +1,4 @@
<div class="discussion-comment"> <div class="discussion-comment" ng-show="enabled_event_types.story_details_Changed">
<p class="discussion-comment-author"> <p class="discussion-comment-author">
{{ author.full_name }} has updated this story. {{ author.full_name }} has updated this story.
<span class="pull-right">{{event.created_at | date: 'medium'}}</span> <span class="pull-right">{{event.created_at | date: 'medium'}}</span>

View File

@ -1,4 +1,4 @@
<div class="discussion-comment"> <div class="discussion-comment" ng-show="enabled_event_types.task_assignee_changed">
<p class="discussion-comment-author"> <p class="discussion-comment-author">
{{author.full_name}} has updated assignee for task {{ event_info.task_title }}: {{author.full_name}} has updated assignee for task {{ event_info.task_title }}:
{{ event_info.old_assignee_fullname }} ==> {{ event_info.new_assignee_fullname }} {{ event_info.old_assignee_fullname }} ==> {{ event_info.new_assignee_fullname }}

View File

@ -1,4 +1,4 @@
<div class="discussion-comment"> <div class="discussion-comment" ng-show="enabled_event_types.task_created">
<p class="discussion-comment-author"> <p class="discussion-comment-author">
{{ author.full_name }} has created a task {{ event_info.task_title }} {{ author.full_name }} has created a task {{ event_info.task_title }}
<span class="pull-right">{{event.created_at | date: 'medium'}}</span> <span class="pull-right">{{event.created_at | date: 'medium'}}</span>

View File

@ -1,4 +1,4 @@
<div class="discussion-comment"> <div class="discussion-comment" ng-show="enabled_event_types.task_deleted">
<p class="discussion-comment-author"> <p class="discussion-comment-author">
{{ author.full_name }} has deleted a task {{ event_info.task_title }} {{ author.full_name }} has deleted a task {{ event_info.task_title }}
<span class="pull-right">{{event.created_at | date: 'medium'}}</span> <span class="pull-right">{{event.created_at | date: 'medium'}}</span>

View File

@ -1,4 +1,4 @@
<div class="discussion-comment"> <div class="discussion-comment" ng-show="enabled_event_types.task_details_changed">
<p class="discussion-comment-author"> <p class="discussion-comment-author">
{{ author.full_name }} has updated {{ event_info.task_title }} {{ author.full_name }} has updated {{ event_info.task_title }}
<span class="pull-right">{{event.created_at | date: 'medium'}}</span> <span class="pull-right">{{event.created_at | date: 'medium'}}</span>

View File

@ -1,4 +1,4 @@
<div class="discussion-comment"> <div class="discussion-comment" ng-show="enabled_event_types.task_status_changed">
<p class="discussion-comment-author"> <p class="discussion-comment-author">
{{author.full_name}} has updated a task {{ event_info.task_title }} status: {{author.full_name}} has updated a task {{ event_info.task_title }} status:
{{ event_info.old_status }} ==> {{ event_info.new_status }} {{ event_info.old_status }} ==> {{ event_info.new_status }}

View File

@ -1,4 +1,4 @@
<div class="discussion-comment"> <div class="discussion-comment" ng-show="enabled_event_types.user_comment">
<p class="discussion-comment-author"> <p class="discussion-comment-author">
{{ author.full_name }} {{ author.full_name }}
<span class="pull-right">{{event.created_at | date: 'medium'}}</span> <span class="pull-right">{{event.created_at | date: 'medium'}}</span>

View File

@ -0,0 +1,28 @@
/*
* Copyright (c) 2014 Mirantis Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License. You may obtain
* a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*/
angular.module('sb.util').constant('TimelineEventTypes',
[
'story_created',
'story_details_changed',
'task_created',
'task_assignee_changed',
'task_status_changed',
'task_details_changed',
'task_deleted',
'user_comment'
]
);