summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimo Sorce <simo@redhat.com>2015-04-06 15:19:22 -0400
committerSimo Sorce <simo@redhat.com>2015-04-10 10:37:42 -0400
commit12139c6090941f67c098bf4387ce00a8503e825e (patch)
treeff57544494767a8c0faa3d6c00ed1902b4a013bd
parentfa333f2d94885df6beb3d7ea29380e28fde651a4 (diff)
downloadipsilon-12139c6090941f67c098bf4387ce00a8503e825e.zip
ipsilon-12139c6090941f67c098bf4387ce00a8503e825e.tar.gz
ipsilon-12139c6090941f67c098bf4387ce00a8503e825e.tar.xz
Use disabled template for mappings and lists
This way lists and mappings can be empty and still allow cloning of the last row which is always disabled and hidden. The javascript now clones the last row then fixes the indexes in the new cloned row, and re-enables and un-hides the previous last which becomes a new empty row. https://fedorahosted.org/ipsilon/ticket/25 Signed-off-by: Simo Sorce <simo@redhat.com> Reviewed-by: Rob Crittenden <rcritten@redhat.com>
-rw-r--r--templates/admin/plugin_config.html42
1 files changed, 40 insertions, 2 deletions
diff --git a/templates/admin/plugin_config.html b/templates/admin/plugin_config.html
index 79f6319..c6ae044 100644
--- a/templates/admin/plugin_config.html
+++ b/templates/admin/plugin_config.html
@@ -7,6 +7,11 @@
var ourTable = $(this).parents(".extensible-table")
var lastRow = $(ourTable).find(".list-field:last")
var newRow = $(lastRow).clone()
+ lastRow.show()
+ var inputFields = lastRow.find("input")
+ for (i = 0; i < inputFields.length; i++) {
+ $(inputFields[i]).prop("disabled", false)
+ }
var lastIndex = parseInt(newRow.find("td:first").text())
newRow.find("td:first").text(lastIndex + 1)
var inputFields = newRow.find("input")
@@ -112,10 +117,24 @@
</td>
<td>
<input type="checkbox" name="{{basename}}delete">
- <!-- Never cheked by default -->
+ <!-- Never checked by default -->
</td>
</tr>
{% endfor -%}
+ <!-- Template for new row -->
+ {%- set basename = "%s %d-"|format(v.name, value|length) -%}
+ <tr class="list-field" style="display:none">
+ <td>{{value|length + 1}}</td>
+ <td>
+ <input type="text" name="{{basename}}name" value=""
+ disabled="disabled">
+ </td>
+ <td>
+ <input type="checkbox" name="{{basename}}delete"
+ disabled="disabled">
+ </td>
+ </tr>
+ <!-- End of Template -->
<tr class="add-row">
<td><button class="btn add-field" type="button"> + </button></td>
<td colspan=3 />
@@ -148,10 +167,29 @@
</td>
<td>
<input type="checkbox" name="{{basename}}delete">
- <!-- Never cheked by default -->
+ <!-- Never checked by default -->
</td>
</tr>
{% endfor -%}
+ <!-- Template for new row -->
+ {%- set basename = "%s %d-"|format(v.name, value|length) -%}
+ <tr class="list-field" style="display:none">
+ <td>{{value|length + 1}}</td>
+ <td>
+ <input type="text" name="{{basename}}from" value=""
+ disabled="disabled">
+ </td>
+ <td>
+ <input type="text" name="{{basename}}to"
+ disabled="disabled">
+ </td>
+ <td>
+ <input type="checkbox" name="{{basename}}delete"
+ disabled="disabled">
+ <!-- Never checked by default -->
+ </td>
+ </tr>
+ <!-- End of Template -->
<tr class="add-row">
<td><button class="btn add-field" type="button"> + </button></td>
<td colspan=3 />