~launchpad-pqm/launchpad/devel

13487.1.3 by Ian Booth
Port bug subscription_lists to app and make generic
1
/* Copyright 2011 Canonical Ltd.  This software is licensed under the
2
 * GNU Affero General Public License version 3 (see the file LICENSE).
3
 *
4
 * Setup for managing subscribers list for bugs.
5
 *
6
 * @module bugs
7
 * @submodule subscribers
8
 */
9
10
YUI.add('lp.bugs.subscribers', function(Y) {
11
12
var namespace = Y.namespace('lp.bugs.subscribers');
13
14
/**
15
 * Possible subscriber levels with descriptive headers for
16
 * sections that will hold them.
17
 *
18
 * These match BugNotificationLevel enum options (as defined in
19
 * lib/lp/bugs/enum.py).
20
 */
21
var subscriber_levels = {
22
    'Discussion': 'Notified of all changes',
23
    'Details': 'Notified of all changes except comments',
24
    'Lifecycle': 'Notified when the bug is closed or reopened',
25
    'Maybe': 'May be notified'
26
};
27
28
/**
29
 * Order of subscribers sections.
30
 */
31
var subscriber_level_order = ['Discussion', 'Details', 'Lifecycle', 'Maybe'];
32
33
34
/**
35
 * Create the SubscribersLoader instance which will load subscribers for
36
 * a bug and put them in the web page.
37
 *
38
 * @param config {Object} Defines `container_box' CSS selector for the
39
 *     SubscribersList container box, `context' holding context metadata (at
40
 *     least with `web_link') and `subscribers_details_view' holding
41
 *     a relative URI to load subscribers' details from.
42
 */
43
function createBugSubscribersLoader(config) {
14186.3.10 by Ian Booth
Lint
44
    var url_data = LP.cache.subscribers_portlet_url_data;
14186.3.8 by Ian Booth
Add ajax bug task delete functionality
45
    if (!Y.Lang.isValue(url_data)) {
46
        url_data = { self_link: LP.cache.context.bug_link,
47
                    web_link: LP.cache.context.web_link };
48
    }
13487.1.3 by Ian Booth
Port bug subscription_lists to app and make generic
49
    config.subscriber_levels = subscriber_levels;
50
    config.subscriber_level_order = subscriber_level_order;
14186.3.8 by Ian Booth
Add ajax bug task delete functionality
51
    config.context = url_data;
13487.1.3 by Ian Booth
Port bug subscription_lists to app and make generic
52
    config.subscribe_someone_else_level = 'Discussion';
53
    config.default_subscriber_level = 'Maybe';
54
    var module = Y.lp.app.subscribers.subscribers_list;
55
    return new module.SubscribersLoader(config);
56
}
57
namespace.createBugSubscribersLoader = createBugSubscribersLoader;
58
59
}, "0.1", {"requires": ["lp.app.subscribers.subscribers_list"]});