Skip to content

Commit

Permalink
improve avro and knockout templates
Browse files Browse the repository at this point in the history
  • Loading branch information
jdewit committed May 19, 2012
1 parent 575a346 commit caa7fb5
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 21 deletions.
2 changes: 1 addition & 1 deletion Templates/Avro/Controller/actions/list.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/
public function listAction($filter)
{
$form = $this->container->get('{{ bundle_alias }}.{{ entity_cc }}Search.form');
$form = $this->container->get('{{ bundleAlias }}.{{ entityCC }}Search.form');
$request = $this->container->get('request');
$form->bindRequest($request);

Expand Down
2 changes: 1 addition & 1 deletion Templates/Avro/Resources/views/import.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<h1>Import {{ entityTitle }}s</h1>
</div>
<form class="form-horizontal" action="{{ "{{ path('"~ bundleAlias ~"_"~ entityCC ~"_import') }}" }}" method="post" {{ "{{ form_enctype(form) }}" }}>
{{ form_errors(form) }}
{{ "{{ form_errors(form) }}" }}
<div class="form-content">
{{ "{{ form_widget(form) }}" }}
</div>
Expand Down
2 changes: 1 addition & 1 deletion Templates/Avro/Resources/views/list.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<a href="{{ "{{ path('"~ bundleAlias ~"_"~ entityCC ~"_new') }}" }}" class="btn btn-primary throw-right">+ New {{ entityTitle }}</a>
</div>
<div>
{{ "{% include '"~ bundleName~":"~ entity ~":table.html.twig' %}" }}
{{ "{% include '"~ bundleName ~":"~ entity ~":table.html.twig' %}" }}
</div>
{{ "{% endblock %}" }}

4 changes: 2 additions & 2 deletions Templates/Knockout/Entity/Entity.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ class {{ entity }}
protected $id;

{% for field in fields %}
{%- if field.type == "manyToOne" %}
{% if field.type == "manyToOne" %}
/**
* @var \{{ field.targetEntity }}
*
* @ORM\ManyToOne(targetEntity="{{ field.targetEntity }}")
*/
protected ${{ field.fieldName }};

{%- elseif field.type == "oneToMany" %}
{% elseif field.type == "oneToMany" %}
/**
* @var ArrayCollection
*
Expand Down
10 changes: 5 additions & 5 deletions Templates/Knockout/Resources/views/form.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@
</div>
</div>
<div class="modal-footer">
<a href="#" class="btn" data-bind="click: closeFormModal"><i class="ui-icon ui-icon-closethick"></i>Cancel</a>
<a href="#" class="btn" data-bind="click: closeFormModal">Cancel</a>
<span data-bind="visible: !{{ entityCC }}Id()">
<button type="submit" class="btn btn-primary"><i class="sprite-tick"></i>Create {{ entity | camelCaseToTitle }}</button>
<button type="submit" class="btn btn-primary">Create {{ entity | camelCaseToTitle }}</button>
</span>
<span data-bind="visible: {{ entityCC }}Id()">
<button type="submit" class="btn btn-primary"><i class="sprite-tick"></i>Update {{ entity | camelCaseToTitle }}</button>
<button type="submit" class="btn btn-primary">Update {{ entity | camelCaseToTitle }}</button>
{{ "{% if is_granted('ROLE_ADMIN') %}" }}
<a class="btn pull-left" title="Delete {{ entityTitleLC }}" data-bind="click: avro.{{ entityCC }}ListModel.delete{{ entity }}, attr: { 'href': '{{ "{{ path('"~ bundleAlias ~"_"~ entityCC ~"_delete') }}" }}/'+ {{ entityCC }}Id() }, visible: !isDeleted()"><i class="sprite-delete"></i>Delete</a>
<a class="btn pull-left" title="Restore {{ entityTitleLC }}" data-bind="click: avro.{{ entityCC }}ListModel.restore{{ entity }}, attr: { 'href': '{{ "{{ path('"~ bundleAlias ~"_"~ entityCC ~"_restore') }}" }}/'+ {{ entityCC }}Id() }, visible: isDeleted()"><i class="sprite-arrow_refresh"></i>Restore</a>
<a class="btn btn-danger pull-left" title="Delete {{ entityTitleLC }}" data-bind="click: avro.{{ entityCC }}ListModel.delete{{ entity }}, attr: { 'href': '{{ "{{ path('"~ bundleAlias ~"_"~ entityCC ~"_delete') }}" }}/'+ {{ entityCC }}Id() }, visible: !isDeleted()">Delete</a>
<a class="btn btn-success pull-left" title="Restore {{ entityTitleLC }}" data-bind="click: avro.{{ entityCC }}ListModel.restore{{ entity }}, attr: { 'href': '{{ "{{ path('"~ bundleAlias ~"_"~ entityCC ~"_restore') }}" }}/'+ {{ entityCC }}Id() }, visible: isDeleted()">Restore</a>
{{ "{% endif %}" }}
</span>
</div>
Expand Down
23 changes: 14 additions & 9 deletions Templates/Knockout/Resources/views/list.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,17 @@
{{ "{% block content %}" }}
<div id="{{ entityCC }}ListContainer">
<div class="page-header">
<h1>
{{ entityTitle }}s
<select data-bind="filter: filter, value: filter">
<option value="All">All</option>
<option value="Deleted">Deleted</option>
<option value="Search">Search</option>
</select>
</h1>
<a href="#" class="btn btn-primary throw-right" data-bind="click: new{{ entity }}"><i class="sprite-add"></i>New {{ entity | camelCaseToTitle }}</a>
<h1 class="pull-left">{{ entityTitle }}s</h1>
<span id="filter" class="dropdown" style="margin-left: 2em;">
<a href="#filter" class="btn dropdown-toggle" data-toggle="dropdown"><span data-bind="text: filter"></span> <b class="caret"></b></a>
<ul class="dropdown-menu" style="margin-top: 7px;">
<li><a href="#" data-bind="filter: 'All'">All</a></li>
<li><a href="#" data-bind="filter: 'Deleted'">Deleted</a></li>
<li class="divider"></li>
<li><a href="#" data-bind="filter: 'Search'">Search</a></li>
</ul>
</span>
<a href="#" class="btn btn-primary throw-right" data-bind="click: new{{ entity }}"><i class="icon-plus icon-white"></i>New {{ entity | camelCaseToTitle }}</a>
</div>
{{ "{% include '"~ bundleName~":"~ entity ~":table.html.twig' %}" }}
{{ "{% include '"~ bundleName~":"~ entity ~":searchForm.html.twig' %}" }}
Expand All @@ -25,6 +27,9 @@
{% for field in uniqueManyToOneRelations %}
avro.available{{ field.targetEntityName | ucFirst }}s = {{ "{{ available"~ field.targetEntityName | ucFirst ~"s | serialize | raw }}" }};
{% endfor %}

avro.owner = {{ "{{ app.user.owner | serialize | raw }}" }};

avro.{{ entityCC }}ListModel = new {{ entityCC }}ListModel({
{{ entityCC }}s: {{ "{{ "~ entityCC ~"s | serialize | raw }}" }}
});
Expand Down
4 changes: 2 additions & 2 deletions Templates/Knockout/Resources/views/table.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@
</table>
</form>
<div class="paginator">
<a class="btn" href="#" data-bind="paginate: 'prev', target: {{ entityCC }}s"><i class="ui-icon ui-icon-triangle-1-w"></i>Prev</a>
<a class="btn" href="#" data-bind="paginate: 'prev', target: {{ entityCC }}s"><i class="icon-arrow-left"></i>Prev</a>
<a href="#" data-bind="text: avro.add(avro.divide(offset(), limit(), 0), 1, 0)"></a>
<a class="btn" href="#" data-bind="paginate: 'next', target: {{ entityCC }}s">Next<i class="ui-icon ui-icon-triangle-1-e"></i></a>
<a class="btn" href="#" data-bind="paginate: 'next', target: {{ entityCC }}s">Next<i class="icon-arrow-right"></i></a>
</div>

0 comments on commit caa7fb5

Please sign in to comment.