From 76f93f4ed448ebdd0766c627eb63d5c11afb1205 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Sun, 22 Feb 2015 17:12:13 -0500 Subject: Add dynamic list to plugin_config forms This little javascript allows us to dyamically add form fields in the ComplexList and MappingList tables. Makes it much easier to add elements to these lists. Signed-off-by: Simo Sorce Reviewed-by: Patrick Uiterwijk --- templates/admin/plugin_config.html | 42 ++++++++++++++++++++++++++++++++++---- templates/master-admin.html | 2 ++ 2 files changed, 40 insertions(+), 4 deletions(-) diff --git a/templates/admin/plugin_config.html b/templates/admin/plugin_config.html index 18792a2..79f6319 100644 --- a/templates/admin/plugin_config.html +++ b/templates/admin/plugin_config.html @@ -1,4 +1,30 @@ {% extends "master-admin.html" %} +{% block scripts %} + +{% endblock %} {% block main %} {% if user.is_admin %} @@ -69,11 +95,11 @@ {% endif -%} > {% elif v.__class__.__name__ == 'ComplexList' -%} - +
{% for line in value -%} {%- set basename = "%s %d-"|format(v.name, loop.index0) -%} - + {% endfor -%} + + +
#NameDelete
{{loop.index}}
+
{% elif v.__class__.__name__ == 'MappingList' -%} - +
{% for line in value -%} {%- set basename = "%s %d-"|format(v.name, loop.index0) -%} - + {% endfor -%} + + +
#FromToDelete
{{loop.index}}
+
{% else -%} {{ v.__class__.__name__ }} diff --git a/templates/master-admin.html b/templates/master-admin.html index c058360..e838111 100644 --- a/templates/master-admin.html +++ b/templates/master-admin.html @@ -19,6 +19,8 @@ $( document ).tooltip(); {% endif %} + {% block scripts %} + {% endblock %}