~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/code/javascript/branchmergeproposal.updater.js

  • Committer: Rick Harding
  • Date: 2012-01-05 20:18:00 UTC
  • mto: This revision was merged to the branch mainline in revision 14648.
  • Revision ID: rick.harding@canonical.com-20120105201800-5w69pe37m68odybf
Add support for a context-less request in the buglisting 

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
        },
33
33
 
34
34
        /**
35
 
         * The summary node.
36
 
         *
37
 
         * @attribute summary_node
38
 
         */
39
 
        summary_node: {
40
 
            value: null,
41
 
            writeOnce: "initOnly"
42
 
        },
43
 
 
44
 
        /**
45
35
         * Whether or not this MP is still 'pending'.
46
36
         *
47
37
         * @attribute pending
56
46
        },
57
47
 
58
48
        /**
59
 
         * The HTML code for the stats diff.
60
 
         *
61
 
         * @attribute diff_stats
62
 
         */
63
 
        diff_stats: {
64
 
            getter: function() {
65
 
                var summary_node = this.get('summary_node');
66
 
                if (!Y.Lang.isValue(summary_node) ||
67
 
                    !Y.Lang.isValue(summary_node.one(
68
 
                         '#summary-row-b-diff'))) {
69
 
                    return null;
70
 
                }
71
 
                return summary_node.one(
72
 
                    '#summary-row-b-diff').one('td').get('innerHTML');
73
 
            },
74
 
            setter: function(value) {
75
 
               this._setup_diff_stats_container();
76
 
               var container = this.get(
77
 
                   'summary_node').one('#summary-row-b-diff').one('td');
78
 
               container.set('innerHTML', value);
79
 
            }
80
 
        },
81
 
 
82
 
        /**
83
49
         * The HTML code for the diff.
84
50
         *
85
51
         * @attribute diff
112
78
     * @method initializer
113
79
     * @protected
114
80
     */
115
 
    initializer: function(cfg){
 
81
    initializer: function(){
116
82
        // If we have not been provided with a Launchpad Client, then
117
83
        // create one now:
118
84
        if (null === this.get("lp_client")){
119
85
            // Create our own instance of the LP client.
120
86
            this.set("lp_client", new Y.lp.client.Launchpad());
121
87
        }
122
 
        this.set('summary_node', cfg.summary_node);
 
88
        var self = this;
123
89
    },
124
90
 
125
91
    /*
180
146
    },
181
147
 
182
148
    /*
183
 
     * Add a row in the page summary table to display the diff stats
184
 
     * if needed.
185
 
     *
186
 
     * @method _setup_diff_stats_container
187
 
     */
188
 
     _setup_diff_stats_container: function() {
189
 
        if (!Y.Lang.isValue(this.get('diff_stats'))) {
190
 
            var summary_node = this.get('summary_node');
191
 
            var diff_stats = Y.Node.create('<tr />')
192
 
                .set('id', 'summary-row-b-diff')
193
 
                .append(Y.Node.create('<th />')
194
 
                    .set("text", "Diff against target:"))
195
 
                .append(Y.Node.create('<td />'));
196
 
            summary_node.one(
197
 
                '#summary-row-9-target-branch').insert(diff_stats, 'after');
198
 
        }
199
 
     },
200
 
 
201
 
    /*
202
149
     * Populate the widget with the required nodes to display the diff
203
150
     * if needed.
204
151
     *
220
167
    },
221
168
 
222
169
    /*
223
 
     * Update the page with the last version of the diff and update the
224
 
     * stats.
 
170
     * Update the diff content with the last version.
225
171
     *
226
172
     * @method update
227
173
     */
228
174
    update: function() {
229
 
        this.update_stats();
230
 
        this.update_diff();
231
 
    },
232
 
 
233
 
    /*
234
 
     * Update the diff stats with the last version.
235
 
     *
236
 
     * @method update_stats
237
 
     */
238
 
    update_stats: function() {
239
 
        var self = this;
240
 
        var config = {
241
 
            on: {
242
 
                success: function(diff_stats) {
243
 
                    self.set('diff_stats', diff_stats);
244
 
                    // (re)connect the js scroller link.
245
 
                    Y.lp.code.branchmergeproposal.reviewcomment.link_scroller(
246
 
                        '#proposal-summary a.diff-link', '#review-diff');
247
 
                    var node = self.get('summary_node');
248
 
                    Y.lp.anim.green_flash({node: node}).run();
249
 
                },
250
 
                failure: function() {
251
 
                    var node = self.get('summary_node');
252
 
                    Y.lp.anim.red_flash({node: node}).run();
253
 
                }
254
 
            }
255
 
        };
256
 
        var mp_uri = LP.cache.context.web_link;
257
 
        this.get('lp_client').get(mp_uri + "/++diff-stats", config);
258
 
     },
259
 
 
260
 
 
261
 
    /*
262
 
     * Update the diff content with the last version.
263
 
     *
264
 
     * @method update_diff
265
 
     */
266
 
    update_diff: function() {
267
175
        var self = this;
268
176
        var config = {
269
177
            on: {
306
214
        event_data.edited_fields.indexOf("preview_diff") >= 0);
307
215
};
308
216
 
309
 
}, '0.1', {requires: ['node', 'lp.client', 'lp.anim',
310
 
                      'lp.code.branchmergeproposal.reviewcomment']});
 
217
}, '0.1', {requires: ['node', 'lp.client', 'lp.anim']});