~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/registry/javascript/distroseries.js

Fix submit params.

Show diffs side-by-side

added added

removed removed

Lines of Context:
177
177
 
178
178
    ATTRS: {
179
179
 
180
 
        parentSeries: {
 
180
        /**
 
181
         * The DistroSeries the choices in this field should
 
182
         * reflect. Takes the form of a list of ids,
 
183
         * e.g. ["4", "55"].
 
184
         *
 
185
         * @property parents
 
186
         */
 
187
        parents: {
181
188
            getter: function() {
182
189
                var series = [];
183
 
                this.fieldNode.all("tbody > tr > td.series").each(
 
190
                this.fieldNode.all("tbody > tr.parent").each(
184
191
                    function(node) {
185
 
                        series.push(node.get("text"));
 
192
                        series.push(node.get('id').replace('parent-',''));
186
193
                    }
187
194
                );
188
195
                return series;
189
196
            }
190
 
        },
191
 
        /**
192
 
         * The DistroSeries the choices in this field should
193
 
         * reflect. Takes the form of a string, e.g. "ubuntu/hoary".
194
 
         *
195
 
         * @property distroSeries
196
 
         */
197
 
        distroSeries: {
198
 
            setter: function(value, name) {
199
 
                var path = value + "/architectures";
200
 
                var on = {
201
 
                    start: Y.bind(this.showSpinner, this),
202
 
                    success: Y.bind(this.set, this, "distroArchSerieses"),
203
 
                    failure: this.error_handler.getFailureHandler(),
204
 
                    end: Y.bind(this.hideSpinner, this)
205
 
                };
206
 
                this.client.get(path, {on: on});
207
 
            }
208
197
        }
209
198
    }
210
199
 
322
311
    },
323
312
 
324
313
    /**
 
314
     * Remove a parent series.
 
315
     *
 
316
     * @method add_parent
 
317
     */
 
318
    remove_parent: function(parent_id) {
 
319
        if (this.get('parents').length == 1) {
 
320
            this.clean_display();
 
321
            this.renderUI();
 
322
        }
 
323
        else {
 
324
            this.fieldNode.one('tr#parent-' + parent_id).remove();
 
325
        }
 
326
        Y.fire("parent_removed", parent_id);
 
327
     },
 
328
 
 
329
    /**
325
330
     * Add a parent series.
326
331
     *
327
332
     * @method add_parent
328
333
     */
329
334
    add_parent: function(parent) {
330
 
        if (this.get('parentSeries').length == 0) {
 
335
        if (this.get('parents').length == 0) {
331
336
            this.init_display();
332
337
            this.renderUI();
333
338
        }
377
382
            return false;
378
383
        }, this);
379
384
        item.one('.remove').on('click', function(e) {
380
 
            if (this.get('parentSeries').length == 1) {
381
 
                this.clean_display();
382
 
            }
383
 
            else {
384
 
                item.remove();
385
 
            }
386
 
            if (this.get('parentSeries').length == 0) {
387
 
                this.clean_display();
388
 
                this.renderUI();
389
 
            }
390
 
            Y.fire("parent_removed", item.get('id').replace('parent-',''));
 
385
            var parent_id = item.get('id').replace('parent-','');
 
386
            this.remove_parent(parent_id);
391
387
            e.preventDefault();
392
388
            return false;
393
389
        }, this);
1102
1098
 
1103
1099
    initializer: function(config) {
1104
1100
        this.context = config.context;
1105
 
        this.deriveFromChoice = config.deriveFromChoice;
 
1101
        this.deriveFromChoices = config.deriveFromChoices;
1106
1102
        this.architectureChoice = config.architectureChoice;
1107
1103
        this.packagesetChoice = config.packagesetChoice;
1108
1104
        this.packageCopyOptions = config.packageCopyOptions;
1149
1145
            parameters: {
1150
1146
                name: this.context.name,
1151
1147
                distribution: this.context.distribution_link,
 
1148
                parents: this.deriveFromChoices.get("parents"),
1152
1149
                architectures: this.architectureChoice.get("choice"),
1153
1150
                packagesets: this.packagesetChoice.get("choice"),
1154
1151
                rebuild: this.packageCopyOptions.get("choice") == (
1155
1152
                    "Copy Source and Rebuild")
1156
1153
            }
1157
1154
        };
1158
 
        debugger;
1159
 
        var parent = this.deriveFromChoice.get("value");
1160
1155
        this.client.named_post(
1161
1156
            this.context.self_link, "deriveDistroSeries", config);
1162
1157
    }
1256
1251
        new DeriveDistroSeriesActionsWidget({
1257
1252
            context: LP.cache.context,
1258
1253
            srcNode: form_container.one("div.actions"),
1259
 
            deriveFromChoice: parents_selection,
 
1254
            deriveFromChoices: parents_selection,
1260
1255
            architectureChoice: architecture_choice,
1261
1256
            packagesetChoice: packageset_choice,
1262
1257
            packageCopyOptions: package_copy_options