Revision 283bb7de ui/static/snf/js/ui/web/ui_create_view.js
b/ui/static/snf/js/ui/web/ui_create_view.js | ||
---|---|---|
329 | 329 |
this.update_layout(); |
330 | 330 |
}, |
331 | 331 |
|
332 |
validate_selected_flavor: function() { |
|
333 |
if (!this.flavor_is_valid(this.current_flavor)) { |
|
334 |
this.select_valid_flavor(); |
|
335 |
} |
|
336 |
}, |
|
337 |
|
|
332 | 338 |
reset_flavors: function() { |
333 | 339 |
this.$(".flavor-opts-list .option").remove(); |
334 | 340 |
this.create_flavors(); |
... | ... | |
355 | 361 |
this.set_current(el.data("flavor")) |
356 | 362 |
}, |
357 | 363 |
|
364 |
select_valid_flavor: function() { |
|
365 |
var found = false; |
|
366 |
var self = this; |
|
367 |
_.each(this.flavors, function(flv) { |
|
368 |
if (self.flavor_is_valid(flv)) { |
|
369 |
found = flv; |
|
370 |
return false; |
|
371 |
} |
|
372 |
}); |
|
373 |
|
|
374 |
if (found) { |
|
375 |
this.set_current(found); |
|
376 |
} else { |
|
377 |
this.current_flavor = undefined; |
|
378 |
this.validate(); |
|
379 |
this.$("li.predefined-selection").addClass("disabled"); |
|
380 |
this.$(".flavor-opts-list li").removeClass("selected"); |
|
381 |
} |
|
382 |
}, |
|
383 |
|
|
358 | 384 |
update_valid_predefined: function() { |
359 | 385 |
this.update_unavailable_values(); |
360 | 386 |
var self = this; |
... | ... | |
423 | 449 |
|
424 | 450 |
flavor_is_valid: function(flv) { |
425 | 451 |
if (!flv) { return false }; |
452 |
|
|
426 | 453 |
var existing = storage.flavors.get_flavor(flv.get("cpu"), flv.get("ram"), flv.get("disk"), this.flavors); |
427 | 454 |
if (!existing) { return false }; |
428 |
if (this.unavailable_values && this.unavailable_values.disk.indexOf(flv.get("disk") > -1)) { |
|
429 |
return false |
|
455 |
|
|
456 |
if (this.unavailable_values && (this.unavailable_values.disk.indexOf(parseInt(flv.get("disk")) * 1000) > -1)) { |
|
457 |
return false; |
|
430 | 458 |
} |
431 | 459 |
return true; |
432 | 460 |
}, |
... | ... | |
440 | 468 |
}); |
441 | 469 |
|
442 | 470 |
this.set_current(found); |
471 |
this.validate_selected_flavor(); |
|
443 | 472 |
}, |
444 | 473 |
|
445 | 474 |
set_current: function(flv) { |
... | ... | |
573 | 602 |
this.update_selected_flavor(); |
574 | 603 |
this.update_disabled_flavors(); |
575 | 604 |
this.validate(); |
605 |
this.validate_selected_flavor(); |
|
576 | 606 |
}, |
577 | 607 |
|
578 | 608 |
reset: function() { |
Also available in: Unified diff