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."))
class MetaDataForm(wtforms.Form):
identifier = wtforms.TextField('')
value = wtforms.TextField('')
identifier = wtforms.TextField(_(u'Identifier'))
value = wtforms.TextField(_(u'Value'))
class EditMetaDataForm(wtforms.Form):
media_metadata = wtforms.FieldList(

View File

@ -943,12 +943,16 @@ p.verifier {
table.metadata_editor {
margin: 10px auto;
width: 800px;
width: 1000px;
}
table.metadata_editor tr th {
width:100px;
}
table.metadata_editor tr td {
width:350px;
width:300px;
}
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. -->
<h3>{% trans %}Context{% endtrans %}</h3>
<table class="metadata_editor" id="context_list">
<tr>
<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 -%}
{{ wtforms_util.render_fieldlist_as_table_rows(form.context) }}
</table>
<table class="metadata_editor" id="buttons_top">
<tr>
<th></th>
<td><input type=button value="{% trans %}Add new Row{% endtrans %}"
class="button_action" id="add_new_context_row" /></td>
<th></th>
<td></td>
</tr>
</table>
@ -99,26 +94,22 @@
<!-- This table holds all the information about the media entry's metadata -->
<h3>{% trans %}Data{% endtrans %}</h3>
<table class="metadata_editor" id="metadata_list" >
<tr>
<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 -%}
{{ wtforms_util.render_fieldlist_as_table_rows(form.media_metadata) }}
</table>
<!-- These are the buttons you use to control the form -->
<table class="metadata_editor" id="buttons_bottom">
<tr>
<th></th>
<td><input type=button value="{% trans %}Add new Row{% endtrans %}"
class="button_action" id="add_new_metadata_row" />
</td>
<th></th>
<td><input type=submit value="{% trans %}Update Metadata{% endtrans %}"
class="button_action_highlight" /></td>
</tr>
<tr>
<th></th>
<td><input type=button value="{% trans %}Clear empty Rows{% endtrans %}"
class="button_action" id="clear_empty_rows" /></td>
</tr>

View File

@ -70,26 +70,14 @@
{# Auto-render a form as a table #}
{% macro render_table(form) -%}
{% for field in form %}
<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>
render_field_as_table_row(field)
{% endfor %}
{%- endmacro %}
{% macro render_table_row(form) %}
{% macro render_form_as_table_row(form) %}
<tr>
{%- for field in form %}
<th>{{ render_label_p(field) }}</th>
<td class="form_field_input">
{{field}}
{%- if field.errors -%}
@ -105,6 +93,33 @@
</tr>
{%- 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 #}
{% macro render_bool(field) %}
<div class="boolean">