Procedural node add and edit forms

This commit is contained in:
2015-02-02 20:42:48 +01:00
parent cc534ae4ef
commit be5c33c581
9 changed files with 242 additions and 33 deletions

View File

@@ -47,10 +47,12 @@
<li><a role="menuitem" tabindex="-1" href="">Tasks</a></li>
<li><a role="menuitem" tabindex="-1" href="">Profile</a></li>
<li class="divider"></li>
<li><a role="menuitem" tabindex="-1" href="{{url_for('node_types.index')}}">Task Types</a></li>
<li class="divider"></li>
<li><a role="menuitem" tabindex="-1" href="">Log out</a></li>
</ul>
</li>
</ul>
</li>
</ul>
</div><!--/.navbar-collapse -->
</div>

View File

@@ -0,0 +1,31 @@
{% extends 'layout.html' %}
{% block body %}
<div class="col-md-9">
<h2>Add Node type</h2>
<div class="row">
<div class="col-md-6">
<form method="POST" action="{{url_for('node_types.add')}}">
{{ form.hidden_tag() }}
<div class="form-group">
{{ form.name.label }}
{{ form.name(size=20, class='form-control') }}
</div>
<div class="form-group">
{{ form.description.label }}
{{ form.description(size=20, class='form-control') }}
</div>
<div class="form-group">
{{ form.url.label }}
{{ form.url(size=20, class='form-control') }}
</div>
<div class="form-group">
{{ form.is_extended.label }}
{{ form.is_extended(class='form-control') }}
</div>
<input class="btn btn-default" type="submit" value="Add Node Type">
</form>
</div>
</div>
</div>
{% endblock %}

View File

@@ -44,7 +44,7 @@
</div>
<div class="row">
<div class="col-md-12">
<a href="{{url_for('nodes.add')}}" class="btn btn-default">Add</a>
<a href="{{url_for('node_types.add')}}" class="btn btn-default">Add</a>
</div>
</div>
</div>

View File

@@ -2,28 +2,25 @@
{% block body %}
<div class="col-md-9">
<h2>Add Node type</h2>
<h2>Add {{ node_type }}</h2>
<div class="row">
<div class="col-md-6">
<form method="POST" action="{{url_for('nodes.add')}}">
{{ form.hidden_tag() }}
<div class="form-group">
{{ form.name.label }}
{{ form.name(size=20, class='form-control') }}
</div>
<div class="form-group">
{{ form.description.label }}
{{ form.description(size=20, class='form-control') }}
</div>
<div class="form-group">
{{ form.url.label }}
{{ form.url(size=20, class='form-control') }}
</div>
<div class="form-group">
{{ form.is_extended.label }}
{{ form.is_extended(class='form-control') }}
</div>
<input class="btn btn-default" type="submit" value="Add Node Type">
<form method="POST" action="{{url_for('nodes.add', node_type=node_type)}}">
{% for field in form %}
{% if field.name == 'csrf_token' %}
{{ field }}
{% else %}
{% if field.type == "HiddenField" %}
{{ field }}
{% else %}
<div class="form-group">
{{ field.label }}
{{ field(class='form-control') }}
</div>
{% endif %}
{% endif %}
{% endfor %}
<input class="btn btn-default" type="submit" value="Create {{ node_type.name }}">
</form>
</div>
</div>

View File

@@ -0,0 +1,28 @@
{% extends 'layout.html' %}
{% block body %}
<div class="col-md-9">
<h2>Edit {{ node.node_type.name }}</h2>
<div class="row">
<div class="col-md-6">
<form method="POST" action="{{url_for('nodes.edit', node_id=node.id)}}">
{% for field in form %}
{% if field.name == 'csrf_token' %}
{{ field }}
{% else %}
{% if field.type == "HiddenField" %}
{{ field }}
{% else %}
<div class="form-group">
{{ field.label }}
{{ field(class='form-control') }}
</div>
{% endif %}
{% endif %}
{% endfor %}
<input class="btn btn-default" type="submit" value="Edit {{ node.node_type.name }}">
</form>
</div>
</div>
</div>
{% endblock %}

View File

@@ -34,7 +34,7 @@
{% endif %}
</td>
<td>
<a class="btn btn-default btn-xs" href="{{url_for('shots.edit', shot_id=shot['id'])}}"><i class="glyphicon glyphicon-edit"></i> Edit</a>
<a class="btn btn-default btn-xs" href="{{url_for('nodes.edit', node_id=shot['id'])}}"><i class="glyphicon glyphicon-edit"></i> Edit</a>
</td>
</tr>
{% endfor %}
@@ -56,7 +56,7 @@
</div>
<div class="row">
<div class="col-md-12">
<a href="{{url_for('shots.add')}}" class="btn btn-default">Add</a>
<a href="{{url_for('nodes.add', node_type='shot')}}" class="btn btn-default">Add</a>
</div>
</div>
</div>