diff options
-rw-r--r-- | mediagoblin/edit/forms.py | 4 | ||||
-rw-r--r-- | mediagoblin/static/css/base.css | 10 | ||||
-rw-r--r-- | mediagoblin/templates/mediagoblin/edit/metadata.html | 23 | ||||
-rw-r--r-- | mediagoblin/templates/mediagoblin/utils/wtforms.html | 45 |
4 files changed, 46 insertions, 36 deletions
diff --git a/mediagoblin/edit/forms.py b/mediagoblin/edit/forms.py index ce66526f..7ddf603e 100644 --- a/mediagoblin/edit/forms.py +++ b/mediagoblin/edit/forms.py @@ -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( diff --git a/mediagoblin/static/css/base.css b/mediagoblin/static/css/base.css index d0396ceb..bb2a2cbd 100644 --- a/mediagoblin/static/css/base.css +++ b/mediagoblin/static/css/base.css @@ -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; } diff --git a/mediagoblin/templates/mediagoblin/edit/metadata.html b/mediagoblin/templates/mediagoblin/edit/metadata.html index 364cad0d..d5d1fec5 100644 --- a/mediagoblin/templates/mediagoblin/edit/metadata.html +++ b/mediagoblin/templates/mediagoblin/edit/metadata.html @@ -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> diff --git a/mediagoblin/templates/mediagoblin/utils/wtforms.html b/mediagoblin/templates/mediagoblin/utils/wtforms.html index e861b674..c83d53f1 100644 --- a/mediagoblin/templates/mediagoblin/utils/wtforms.html +++ b/mediagoblin/templates/mediagoblin/utils/wtforms.html @@ -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"> |