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-06 15:19:22 -0400
commitd9dd45cb8980acf7a5cfe2555e260cb1708ea1df (patch)
tree8f4d2ce142091163942e11aac8ac7eddba012763
parent326f6e2e40eda22b3efc9ee2541ca0a8c9e392aa (diff)
downloadipsilon-rowmagic.zip
ipsilon-rowmagic.tar.gz
ipsilon-rowmagic.tar.xz
Use disabled template for mappings and listsrowmagic
This way lists and mappings can be empty and still allow cloning of the last row whic his 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. Signed-off-by: Simo Sorce <simo@redhat.com>
-rw-r--r--templates/admin/plugin_config.html38
1 files changed, 38 insertions, 0 deletions
diff --git a/templates/admin/plugin_config.html b/templates/admin/plugin_config.html
index 79f6319..5072fca 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")
@@ -116,6 +121,20 @@
</td>
</tr>
{% endfor -%}
+ <!-- Template for new row -->
+ {%- set basename = "%s %d-"|format(v.name, value|length) -%}
+ <tr class="list-field">
+ <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 />
@@ -152,6 +171,25 @@
</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 cheked by default -->
+ </td>
+ </tr>
+ <!-- End of Template -->
<tr class="add-row">
<td><button class="btn add-field" type="button"> + </button></td>
<td colspan=3 />