Changed the format of the wtforms table slightly

This commit is contained in:
tilly-Q 2014-05-12 12:20:03 -04:00
parent d015e4a84d
commit 494bce47f9
4 changed files with 46 additions and 36 deletions

View File

@ -124,8 +124,8 @@ class ChangeEmailForm(wtforms.Form):
"Enter your password to prove you own this account.")) "Enter your password to prove you own this account."))
class MetaDataForm(wtforms.Form): class MetaDataForm(wtforms.Form):
identifier = wtforms.TextField('') identifier = wtforms.TextField(_(u'Identifier'))
value = wtforms.TextField('') value = wtforms.TextField(_(u'Value'))
class EditMetaDataForm(wtforms.Form): class EditMetaDataForm(wtforms.Form):
media_metadata = wtforms.FieldList( media_metadata = wtforms.FieldList(

View File

@ -943,12 +943,16 @@ p.verifier {
table.metadata_editor { table.metadata_editor {
margin: 10px auto; margin: 10px auto;
width: 800px; width: 1000px;
}
table.metadata_editor tr th {
width:100px;
} }
table.metadata_editor tr td { table.metadata_editor tr td {
width:350px; width:300px;
} }
table.metadata_editor tr td.form_field_input input { table.metadata_editor tr td.form_field_input input {
width: 300px width:300px;
} }

View File

@ -78,20 +78,15 @@
visit http:/wwww.json-ld.org for more information. --> visit http:/wwww.json-ld.org for more information. -->
<h3>{% trans %}Context{% endtrans %}</h3> <h3>{% trans %}Context{% endtrans %}</h3>
<table class="metadata_editor" id="context_list"> <table class="metadata_editor" id="context_list">
<tr> {{ wtforms_util.render_fieldlist_as_table_rows(form.context) }}
<td><a class="strong highlight">
{% trans %}Identifier{% endtrans %}</a></td>
<td><a class="strong highlight">{% trans %}Value{% endtrans %}</a></td>
</tr>
{% for miniform in form.context -%}
{{ wtforms_util.render_table_row(miniform) }}
{% endfor -%}
</table> </table>
<table class="metadata_editor" id="buttons_top"> <table class="metadata_editor" id="buttons_top">
<tr> <tr>
<th></th>
<td><input type=button value="{% trans %}Add new Row{% endtrans %}" <td><input type=button value="{% trans %}Add new Row{% endtrans %}"
class="button_action" id="add_new_context_row" /></td> class="button_action" id="add_new_context_row" /></td>
<th></th>
<td></td> <td></td>
</tr> </tr>
</table> </table>
@ -99,26 +94,22 @@
<!-- This table holds all the information about the media entry's metadata --> <!-- This table holds all the information about the media entry's metadata -->
<h3>{% trans %}Data{% endtrans %}</h3> <h3>{% trans %}Data{% endtrans %}</h3>
<table class="metadata_editor" id="metadata_list" > <table class="metadata_editor" id="metadata_list" >
<tr> {{ wtforms_util.render_fieldlist_as_table_rows(form.media_metadata) }}
<td><a class="strong highlight">
{% trans %}Identifier{% endtrans %}</a></td>
<td><a class="strong highlight">{% trans %}Value{% endtrans %}</a></td>
</tr>
{% for miniform in form.media_metadata -%}
{{ wtforms_util.render_table_row(miniform) }}
{% endfor -%}
</table> </table>
<!-- These are the buttons you use to control the form --> <!-- These are the buttons you use to control the form -->
<table class="metadata_editor" id="buttons_bottom"> <table class="metadata_editor" id="buttons_bottom">
<tr> <tr>
<th></th>
<td><input type=button value="{% trans %}Add new Row{% endtrans %}" <td><input type=button value="{% trans %}Add new Row{% endtrans %}"
class="button_action" id="add_new_metadata_row" /> class="button_action" id="add_new_metadata_row" />
</td> </td>
<th></th>
<td><input type=submit value="{% trans %}Update Metadata{% endtrans %}" <td><input type=submit value="{% trans %}Update Metadata{% endtrans %}"
class="button_action_highlight" /></td> class="button_action_highlight" /></td>
</tr> </tr>
<tr> <tr>
<th></th>
<td><input type=button value="{% trans %}Clear empty Rows{% endtrans %}" <td><input type=button value="{% trans %}Clear empty Rows{% endtrans %}"
class="button_action" id="clear_empty_rows" /></td> class="button_action" id="clear_empty_rows" /></td>
</tr> </tr>

View File

@ -70,26 +70,14 @@
{# Auto-render a form as a table #} {# Auto-render a form as a table #}
{% macro render_table(form) -%} {% macro render_table(form) -%}
{% for field in form %} {% for field in form %}
<tr> render_field_as_table_row(field)
<th>{{ field.label.text }}</th>
<td>
{{field}}
{% if field.errors %}
<br />
<ul class="errors">
{% for error in field.errors %}
<li>{{error}}</li>
{% endfor %}
</ul>
{% endif %}
</td>
</tr>
{% endfor %} {% endfor %}
{%- endmacro %} {%- endmacro %}
{% macro render_table_row(form) %} {% macro render_form_as_table_row(form) %}
<tr> <tr>
{%- for field in form %} {%- for field in form %}
<th>{{ render_label_p(field) }}</th>
<td class="form_field_input"> <td class="form_field_input">
{{field}} {{field}}
{%- if field.errors -%} {%- if field.errors -%}
@ -105,6 +93,33 @@
</tr> </tr>
{%- endmacro %} {%- endmacro %}
{% macro render_field_as_table_row(field) %}
<tr>
<th>{{ field.label.text }}</th>
<td>
{{field}}
{% if field.errors %}
<br />
<ul class="errors">
{% for error in field.errors %}
<li>{{error}}</li>
{% endfor %}
</ul>
{% endif %}
</td>
</tr>
{% endmacro %}
{% macro render_fieldlist_as_table_rows(fieldlist) %}
{% for field in fieldlist -%}
{%- if field.type == 'FormField' %}
{{ render_form_as_table_row(field) }}
{%- else %}
{{ render_field_as_table_row(field) }}
{%- endif %}
{% endfor -%}
{% endmacro %}
{# Render a boolean field #} {# Render a boolean field #}
{% macro render_bool(field) %} {% macro render_bool(field) %}
<div class="boolean"> <div class="boolean">