From 12139c6090941f67c098bf4387ce00a8503e825e Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Mon, 6 Apr 2015 15:19:22 -0400 Subject: [PATCH] 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 Reviewed-by: Rob Crittenden --- templates/admin/plugin_config.html | 42 ++++++++++++++++++++++++++++-- 1 file 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 @@ - + {% endfor -%} + + {%- set basename = "%s %d-"|format(v.name, value|length) -%} + + {{value|length + 1}} + + + + + + + + @@ -148,10 +167,29 @@ - + {% endfor -%} + + {%- set basename = "%s %d-"|format(v.name, value|length) -%} + + {{value|length + 1}} + + + + + + + + + + + + -- 2.20.1