Add recent events templates for worklist notifications

This commit adds a set of templates for displaying worklist notifications
in the list of recent events on the dashboard. It also adds the ability
to choose to receive these notifications on the preferences page (off
by default).

Story: 2000644
Task: 3127
Change-Id: I8465287c2e10ef1820730378ffe6d5f8dbd91ecd
This commit is contained in:
Adam Coldrick 2016-07-12 13:36:07 +00:00
parent 6780da52f6
commit 699d19646f
11 changed files with 293 additions and 0 deletions

View File

@ -0,0 +1,28 @@
/*
* Copyright (c) 2016 Codethink Limited
*
* 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.
*/
/**
* A controller for Worklist event notifications.
*/
angular.module('sb.dashboard').controller('WorklistEventController',
function ($scope, Worklist) {
'use strict';
$scope.worklist = Worklist.get({
id: $scope.evt.event_info.worklist_id
});
}
);

View File

@ -0,0 +1,32 @@
<div class="discussion-comment"
ng-controller="WorklistEventController">
<p class="discussion-comment-author">
<p>
<span time-moment eventdate="evt.created_at" class="pull-right"></span>
<span>
{{author.full_name}}
<span ng-show="!!evt.event_info.added">
added the card "{{ evt.event_info.added.item_title }}" to
</span>
<span ng-show="!!evt.event_info.removed">
removed the card "{{ evt.event_info.removed.item_title }}" from
</span>
<span ng-show="!!evt.event_info.updated">
updated the card "{{ evt.event_info.updated.old.item_title }}" in
</span>
<a href="#!/worklist/{{evt.event_info.worklist_id}}">
{{ worklist.title }}
</a>
<span ng-show="!!evt.event_info.added">
in position {{ evt.event_info.added.position + 1 }}
</span>.
</span>
</p>
<div ng-show="!!evt.event_info.updated">
<p>
Moved from position {{ evt.event_info.updated.old.position + 1 }}
to {{ evt.event_info.updated.new.position + 1 }}.
</p>
</div>
</p>
</div>

View File

@ -0,0 +1,28 @@
<div class="discussion-comment"
ng-controller="WorklistEventController">
<p class="discussion-comment-author">
<p>
<span time-moment eventdate="evt.created_at" class="pull-right"></span>
<span>
{{author.full_name}} created the worklist
<a href="#!/worklist/{{evt.event_info.worklist_id}}">
{{ worklist.title }}
</a>.
</span>
</p>
<table class="table table-supercondensed table-striped">
<tr>
<td>Title</td>
<td>{{ worklist.title }}</td>
</tr>
<tr>
<td>Automatic</td>
<td>{{ 'Yes' ? worklist.automatic : 'No' }}</td>
</tr>
<tr>
<td>Private</td>
<td>{{ 'Yes' ? worklist.private : 'No' }}</td>
</tr>
</table>
</p>
</div>

View File

@ -0,0 +1,19 @@
<div class="discussion-comment"
ng-controller="WorklistEventController">
<p class="discussion-comment-author">
<p>
<span time-moment eventdate="evt.created_at" class="pull-right"></span>
<span>
{{author.full_name}} updated the worklist
<a href="#!/worklist/{{evt.event_info.worklist_id}}">
{{ worklist.title }}
</a>.
</span>
</p>
<p>
{{ evt.event_info.field | capitalize }} was updated
from <span class="label label-default">{{ evt.event_info.old_value }}</span>
to <span class="label label-default">{{ evt.event_info.new_value }}</span>.
</p>
</p>
</div>

View File

@ -0,0 +1,69 @@
<div class="discussion-comment"
ng-controller="WorklistEventController">
<p class="discussion-comment-author">
<p>
<span time-moment eventdate="evt.created_at" class="pull-right"></span>
<span>
{{author.full_name}} updated the filters of
<a href="#!/worklist/{{evt.event_info.worklist_id}}">
{{ worklist.title }}
</a>.
</span>
</p>
<p ng-show="!!evt.event_info.added">
<strong>Added:</strong>
{{ evt.event_info.added.type == 'Story' ? 'Stories' : 'Tasks' }}
where
<span ng-repeat="criterion in evt.event_info.added.criteria">
{{ criterion.field | capitalize }}
{{ criterion.negative ? 'is not' : 'is' }}
{{ criterion.title }}
<span ng-hide="evt.event_info.added.criteria.indexOf(criterion)
== evt.event_info.added.criteria.length - 1">
and
</span>
</span>
</p>
<p ng-show="!!evt.event_info.removed">
<strong>Removed:</strong>
{{ evt.event_info.removed.type == 'Story' ? 'Stories' : 'Tasks' }}
where
<span ng-repeat="criterion in evt.event_info.removed.criteria">
{{ criterion.field | capitalize }}
{{ criterion.negative ? 'is not' : 'is' }}
{{ criterion.title }}
<span ng-hide="evt.event_info.removed.criteria.indexOf(criterion)
== evt.event_info.removed.criteria.length - 1">
and
</span>
</span>
</p>
<p ng-show="!!evt.event_info.updated">
<strong>Updated:</strong>
<br>
From: {{ evt.event_info.updated.old.type == 'Story' ? 'Stories' : 'Tasks' }}
where
<span ng-repeat="criterion in evt.event_info.updated.old.criteria">
{{ criterion.field | capitalize }}
{{ criterion.negative ? 'is not' : 'is' }}
{{ criterion.title }}
<span ng-hide="evt.event_info.updated.old.criteria.indexOf(criterion)
== evt.event_info.updated.old.criteria.length - 1">
and
</span>
</span>
<br>
To: {{ evt.event_info.updated.new.type == 'Story' ? 'Stories' : 'Tasks' }}
where
<span ng-repeat="criterion in evt.event_info.updated.new.criteria">
{{ criterion.field | capitalize }}
{{ criterion.negative ? 'is not' : 'is' }}
{{ criterion.title }}
<span ng-hide="evt.event_info.updated.new.criteria.indexOf(criterion)
== evt.event_info.updated.new.criteria.length - 1">
and
</span>
</span>
</p>
</p>
</div>

View File

@ -0,0 +1,34 @@
<div class="discussion-comment"
ng-controller="WorklistEventController">
<p class="discussion-comment-author">
<p>
<span time-moment eventdate="evt.created_at" class="pull-right"></span>
<span>
{{author.full_name}} created a permission for
<a href="#!/worklist/{{evt.event_info.worklist_id}}">
{{ worklist.title }}
</a>.
</span>
</p>
<p>
<strong ng-show="evt.event_info.codename == 'move_items' ||
evt.event_info.codename == 'edit_worklist'">
{{ evt.event_info.codename == 'move_items' ? 'Users' : 'Owners' }}
</strong>
<strong ng-hide="evt.event_info.codename == 'move_items' ||
evt.event_info.codename == 'edit_worklist'">
{{ evt.event_info.codename }}
</strong>
<div ng-if="evt.event_info.users.length > 0">
<ul>
<li ng-repeat="user in evt.event_info.users">
<span ng-repeat="key in user">
{{ key }}
</span>
</li>
</ul>
</div>
</p>
</p>
</p>
</div>

View File

@ -0,0 +1,44 @@
<div class="discussion-comment"
ng-controller="WorklistEventController">
<p class="discussion-comment-author">
<p>
<span time-moment eventdate="evt.created_at" class="pull-right"></span>
<span>
{{author.full_name}} updated the permissions of
<a href="#!/worklist/{{evt.event_info.worklist_id}}">
{{ worklist.title }}
</a>.
</span>
</p>
<p>
<strong ng-show="evt.event_info.codename == 'move_items' ||
evt.event_info.codename == 'edit_worklist'">
{{ evt.event_info.codename == 'move_items' ? 'Users' : 'Owners' }}
</strong>
<strong ng-hide="evt.event_info.codename == 'move_items' ||
evt.event_info.codename == 'edit_worklist'">
{{ evt.event_info.codename }}
</strong>
<div ng-if="evt.event_info.added.length > 0">
Added:
<ul>
<li ng-repeat="user in evt.event_info.added">
<span ng-repeat="key in user">
{{ key }}
</span>
</li>
</ul>
</div>
<div ng-if="evt.event_info.removed.length > 0">
Removed:
<ul>
<li ng-repeat="user in evt.event_info.removed">
<span ng-repeat="key in user">
{{ key }}
</span>
</li>
</ul>
</div>
</p>
</p>
</div>

View File

@ -32,4 +32,22 @@
<div ng-switch-when="user_comment">
<div ng-include src="'app/dashboard/template/event/user_comment.html'"></div>
</div>
<div ng-switch-when="worklist_created">
<div ng-include src="'app/dashboard/template/event/worklist_created.html'"></div>
</div>
<div ng-switch-when="worklist_details_changed">
<div ng-include src="'app/dashboard/template/event/worklist_details_changed.html'"></div>
</div>
<div ng-switch-when="worklist_contents_changed">
<div ng-include src="'app/dashboard/template/event/worklist_contents_changed.html'"></div>
</div>
<div ng-switch-when="worklist_filters_changed">
<div ng-include src="'app/dashboard/template/event/worklist_filters_changed.html'"></div>
</div>
<div ng-switch-when="worklist_permission_created">
<div ng-include src="'app/dashboard/template/event/worklist_permission_created.html'"></div>
</div>
<div ng-switch-when="worklist_permissions_changed">
<div ng-include src="'app/dashboard/template/event/worklist_permissions_changed.html'"></div>
</div>
</div>

View File

@ -173,6 +173,20 @@
ng-model="preferences.plugin_email_enable">
<label for="enableEmails">Enable notification emails</label>
</div>
<p class="help-block">
Would you like to receive notifications from
worklists you are subscribed to?
</p>
<div>
<input type="checkbox" name="worklistNotificationSettings"
id="worklistNotifications"
ng-true-value="'true'"
ng-false-value="'false'"
ng-model="preferences.receive_notifications_worklists">
<label for="worklistNotifications">Enable worklist notifications</label>
</div>
</div>
</div>
</div>

View File

@ -238,4 +238,7 @@ angular.module('sb.services').provider('Preference',
// Let our preference provider know about email preferences.
PreferenceProvider.addPreference('plugin_email_enable', 'false');
// Let our preference provider know about notifications preferences.
PreferenceProvider.addPreference(
'receive_notifications_worklists', false);
});

View File

@ -192,3 +192,7 @@
.panel .discussion::before {
height: calc(100% - 35px);
}
.discussion-comment .kanban-card {
max-width: 300px;
}