Skip to content

Commit

Permalink
minor #41 Minor tweaks for listings (javiereguiluz)
Browse files Browse the repository at this point in the history
This PR was merged into the master branch.

Discussion
----------

Minor tweaks for listings

  * Boolean values are now centered, which makes them look better
  * ID numbers are not formatted as a regular number (commas, decimals, etc.)

Commits
-------

cb0f974 Minor tweaks for listings
  • Loading branch information
javiereguiluz committed Jan 18, 2015
2 parents 47c3d64 + cb0f974 commit 65a6ded
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
5 changes: 5 additions & 0 deletions Resources/public/stylesheet/admin.css
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,11 @@ body.list table tbody td.sorted {
border-color: #FFF;
}

body.list table thead th.boolean,
body.list table tbody td.boolean {
text-align: center;
}

body.list .table thead tr th {
border-bottom: 2px solid #DBD6DB;
}
Expand Down
4 changes: 2 additions & 2 deletions Resources/views/list.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
{% for field, metadata in fields %}
{% set isSortingField = metadata.fieldName == app.request.get('sortField') %}

<th class="{{ isSortingField ? 'sorted' : '' }}">
<th class="{{ isSortingField ? 'sorted' : '' }} {{ metadata.type|lower }}">
{% if isSortingField %}
{% set sortDirection = ('DESC' == app.request.get('sortDirection')) ? 'ASC' : 'DESC' %}
{% set request_attributes = request_attributes|merge({ sortField: metadata.fieldName }) %}
Expand Down Expand Up @@ -85,7 +85,7 @@
{% for field, metadata in fields %}
{% set isSortingField = metadata.fieldName == app.request.get('sortField') %}

<td class="{{ isSortingField ? 'sorted' : '' }}">
<td class="{{ isSortingField ? 'sorted' : '' }} {{ metadata.type|lower }}">
{{ entity_field(item, field, metadata) }}
</td>
{% endfor %}
Expand Down
9 changes: 7 additions & 2 deletions Twig/EasyAdminTwigExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function getFunctions()

public function displayEntityField($entity, $fieldName, array $fieldMetadata)
{
if ('__inaccessible__' === $value = $this->getEntityProperty($entity, $fieldName)) {
if ('__inaccessible_doctrine_property__' === $value = $this->getEntityProperty($entity, $fieldName)) {
return '<span class="label label-danger" title="Method does not exist or property is not public">inaccessible</span>';
}

Expand All @@ -46,6 +46,11 @@ public function displayEntityField($entity, $fieldName, array $fieldMetadata)
return '<span class="label">NULL</span>';
}

if ('id' === $fieldName) {
// return the ID value as is to avoid number formatting
return $value;
}

if (in_array($fieldType, array('date', 'datetime', 'datetimetz'))) {
return $value->format(self::DATE_FORMAT);
}
Expand Down Expand Up @@ -119,7 +124,7 @@ private function getEntityProperty($entity, $property)
return $entity->{$property};
}

return '__inaccessible__';
return '__inaccessible_doctrine_property__';
}

public function getName()
Expand Down

0 comments on commit 65a6ded

Please sign in to comment.