~lutostag/ubuntu/trusty/maas/1.5.4+keystone

« back to all changes in this revision

Viewing changes to src/maasserver/static/js/node_add.js

  • Committer: Package Import Robot
  • Author(s): Andres Rodriguez
  • Date: 2012-03-27 14:49:56 UTC
  • mto: (20.1.1 quantal) (1.2.1)
  • mto: This revision was merged to the branch mainline in revision 9.
  • Revision ID: package-import@ubuntu.com-20120327144956-z5stunhc83bnnwsi
Tags: upstream-0.1+bzr363+dfsg
ImportĀ upstreamĀ versionĀ 0.1+bzr363+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
87
87
        this.get('srcNode').all('div.field-error').remove();
88
88
    },
89
89
 
 
90
    /* Display validation errors on their respective fields.
 
91
     *
 
92
     * The "errors" argument is an object.  If a field has validation errors,
 
93
     * this object will map the field's name to a list of error strings.  Each
 
94
     * field's errors will be shown with the label for that field.
 
95
     *
 
96
     * @method displayFieldErrors
 
97
     */
90
98
    displayFieldErrors: function(errors) {
91
99
        this.cleanFormErrors();
92
100
        var key;
114
122
            .set('name', 'op')
115
123
            .set('value', 'new');
116
124
        var global_error = Y.Node.create('<p />')
117
 
            .addClass('form-global-errors');
 
125
            .addClass('form-errors');
118
126
        var addnodeform = Y.Node.create('<form />')
119
127
            .set('method', 'post')
120
128
            .append(global_error)
145
153
            error_node = error;
146
154
        }
147
155
 
148
 
        this.get(
149
 
            'srcNode').one('.form-global-errors').empty().append(error_node);
 
156
        this.get('srcNode').one('.form-errors').empty().append(error_node);
150
157
     },
151
158
 
152
159
   /**
227
234
                    self.hidePanel();
228
235
                },
229
236
                failure: function(id, out) {
 
237
                    Y.log("Adding a node failed.  Response object follows.")
230
238
                    Y.log(out);
231
239
                    if (out.status === 400) {
232
240
                        try {
233
 
                            // Validation error: display the errors in the
234
 
                            // form.
235
 
                            self.displayFieldErrors(JSON.parse(out.response));
 
241
                            /* Validation error: display the errors in the
 
242
                             * form next to their respective fields.
 
243
                             */
 
244
                            self.displayFieldErrors(
 
245
                                JSON.parse(out.responseText));
236
246
                        }
237
247
                        catch (e) {
238
 
                            self.displayFormError("Unable to create Node.");
 
248
                            Y.log(
 
249
                                "Exception while decoding error JSON: " +
 
250
                                e.message);
 
251
                            self.displayFormError(
 
252
                                "Unable to create Node: " + out.responseText);
239
253
                        }
240
254
                    }
241
255
                    else if (out.status === 401) {
244
258
                    }
245
259
                    else {
246
260
                        // Unexpected error.
247
 
                        self.displayFormError("Unable to create Node.");
 
261
                        self.displayFormError(
 
262
                            "Unable to create Node: " + out.responseText);
248
263
                    }
249
264
                },
250
265
                end: Y.bind(self.hideSpinner, self)