Use FormsetStep for selecting flavors in the resource class workflow.
Instead of using data tables, use a django formset for displaying the list of available flavor templates. There is a new step, FormsetStep added for the purpose. Additional code for handling validation is added to the step's action, and code for rendering the formset in a way similar to the data table is added to the step's template. Currently the code only allows selecting the templates and setting their max_vms, but it is possible to modify this solution to allow editing the class templates in place and even adding new ones directly from the resource class form. Change-Id: If57d01822a85abb1c496bb705fc28644aecbe94a Closes-Bug: #1220240
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
<noscript><h3>{{ step }}</h3></noscript>
|
||||
<noscript><h3>{{ step }}</h3>xx</noscript>
|
||||
<table class="table-fixed">
|
||||
<tbody>
|
||||
<tr>
|
||||
@@ -13,10 +13,50 @@
|
||||
</table>
|
||||
|
||||
<div id="id_resource_class_flavors_table">
|
||||
{{ flavors_table.render }}
|
||||
{{ flavors_formset.management_form }}
|
||||
{% if flavors_formset.non_field_errors %}
|
||||
<div class="alert alert-error">
|
||||
{{ flavors_formset.non_field_errors }}
|
||||
</div>
|
||||
{% endif %}
|
||||
<table class="table table-bordered">
|
||||
<thead>
|
||||
<tr class="table_caption"></tr>
|
||||
<tr>
|
||||
{% for field in flavors_formset.0.visible_fields %}
|
||||
<th class="normal_column">{{ field.field.label }}</th>
|
||||
{% endfor %}
|
||||
</tr></thead>
|
||||
<tbody>
|
||||
{% for form in flavors_formset %}
|
||||
<tr>
|
||||
{% for field in form.visible_fields %}
|
||||
<td class="control-group{% if field.errors %} error{% endif %}">
|
||||
{{ field }}
|
||||
{% for error in field.errors %}
|
||||
<span class="help-inline">{{ error }}</span>
|
||||
{% endfor %}
|
||||
{% if forloop.first %}
|
||||
{% for field in form.hidden_fields %}
|
||||
{{ field }}
|
||||
{% endfor %}
|
||||
{% if form.non_field_errors %}
|
||||
<div class="alert alert-error">
|
||||
{{ form.non_field_errors }}
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</td>
|
||||
{% endfor %}
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr><td colspan="{{ flavors_formset.0.visible_fields|length }}"></tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
// show the flavors table only when service_type is compute
|
||||
var toggle_table = function(value){
|
||||
@@ -51,6 +91,4 @@
|
||||
$(".modal #flavors input[type=checkbox]").bind('click', function() {
|
||||
toggle_max_vms($(this));
|
||||
});
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user