Skip to content

Commit

Permalink
#1 MemberView extended. Boolean attributes rendered
Browse files Browse the repository at this point in the history
  • Loading branch information
digedag committed Oct 8, 2015
1 parent 288cc16 commit 5349b5d
Show file tree
Hide file tree
Showing 8 changed files with 180 additions and 3 deletions.
9 changes: 9 additions & 0 deletions src/DMKClub/Bundle/BasicsBundle/DMKClubBasicsBundle.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

namespace DMKClub\Bundle\BasicsBundle;

use Symfony\Component\HttpKernel\Bundle\Bundle;

class DMKClubBasicsBundle extends Bundle
{
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

namespace DMKClub\Bundle\BasicsBundle\DependencyInjection;

use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ConfigurationInterface;

/**
* This is the class that validates and merges configuration from your app/config files
*
* To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html#cookbook-bundles-extension-config-class}
*/
class Configuration implements ConfigurationInterface
{
/**
* {@inheritDoc}
*/
public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder();
$rootNode = $treeBuilder->root('dmk_club_basics');

// Here you should define the parameters that are allowed to
// configure your bundle. See the documentation linked above for
// more information on that topic.

return $treeBuilder;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

namespace DMKClub\Bundle\BasicsBundle\DependencyInjection;

use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
use Symfony\Component\DependencyInjection\Loader;

/**
* This is the class that loads and manages your bundle configuration
*
* To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html}
*/
class DMKClubBasicsExtension extends Extension
{
/**
* {@inheritDoc}
*/
public function load(array $configs, ContainerBuilder $container)
{
$configuration = new Configuration();
$config = $this->processConfiguration($configuration, $configs);

$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
// $loader->load('services.yml');
// $loader->load('form.yml');
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bundles:
- { name: DMKClub\Bundle\BasicsBundle\DMKClubBasicsBundle, priority: 160 }
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dmkclub.basics.label.yes: Ja
dmkclub.basics.label.no: Nein
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dmkclub.basics.label.yes: Yes
dmkclub.basics.label.no: No
103 changes: 103 additions & 0 deletions src/DMKClub/Bundle/BasicsBundle/Resources/views/macros.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@

{#
Alias für attibuteRow (fehlendes "r")
#}
{% macro attributeRow(title, value, additionalData) %}
{% import 'OroUIBundle::macros.html.twig' as UI %}
{{ UI.attibuteRow(title, value, additionalData) }}
{% endmacro %}

{#
Render row with boolean attribute
#}
{% macro attributeRowBoolean(title, value, additionalData) %}
{% macro value_bool(value) %}
{% if value %}
<i class="icon-ok">{{ 'dmkclub.basics.label.yes'|trans }}</i>
{% else %}
<i class="icon-ban-circle">{{ 'dmkclub.basics.label.no'|trans }}</i>
{% endif %}
{% endmacro %}

{% import 'OroUIBundle::macros.html.twig' as UI %}
{{ UI.attibuteRow(title, _self.value_bool(value), additionalData) }}
{% endmacro %}

{#
Render property with boolean attribute
#}
{% macro renderPropertyBoolean(title, value) %}
{% macro value_bool(value) %}
{% if value %}
<i class="icon-ok"> {{ 'dmkclub.basics.label.yes'|trans }}</i>
{% else %}
<i class="icon-ban-circle"> {{ 'dmkclub.basics.label.no'|trans }}</i>
{% endif %}
{% endmacro %}

{% import 'OroUIBundle::macros.html.twig' as UI %}
{{ UI.renderHtmlProperty(title, _self.value_bool(value)|raw) }}
{% endmacro %}


{% macro attributeInEuro(title, value, additionalData) %}
{% import 'OroUIBundle::macros.html.twig' as UI %}
{{ UI.attibuteRow(title, [value|number_format(2, ',', '.')]|merge([''])|join, additionalData) }}
{% endmacro %}

{% macro attributeInPercent(title, value, additionalData) %}
{% import 'OroUIBundle::macros.html.twig' as UI %}
{{ UI.attibuteRow(title, [value|number_format(4, ',', '.')]|merge([' %'])|join, additionalData) }}
{% endmacro %}

{% macro attributeInDays(title, value, additionalData) %}
{% import 'OroUIBundle::macros.html.twig' as UI %}
{{ UI.attibuteRow(title, [value|number_format(0, ',', '.')]|merge(['Days'|trans])|join(' '), additionalData) }}
{% endmacro %}

{% macro attributeWithText(title, value, text, additionalData) %}
{% import 'OroUIBundle::macros.html.twig' as UI %}
{{ UI.attibuteRow(title, [value]|merge([text])|join(' '), additionalData) }}
{% endmacro %}

{#
Zahlen werden absolut angezeigt
negative Werte werden rot positive grün dargestellt, Rest inherited
#}
{% macro coloredNumber(number) %}
{% set classNumber = number < 0
? 'text-error'
: number > 0
? 'text-success'
: ''
%}

<span class="{{ classNumber }}">
{{ number|abs }}
</span>
{% endmacro %}

{#
Renders a given file size value in Byte to a human readable format
#}
{% macro bytesToSize(bytes) %}
{% spaceless %}
{% set kilobyte = 1024 %}
{% set megabyte = kilobyte * 1024 %}
{% set gigabyte = megabyte * 1024 %}
{% set terabyte = gigabyte * 1024 %}

{% if bytes < kilobyte %}
{{ bytes ~ ' B' }}
{% elseif bytes < megabyte %}
{{ (bytes / kilobyte)|number_format(2, '.') ~ ' KB' }}
{% elseif bytes < gigabyte %}
{{ (bytes / megabyte)|number_format(2, '.') ~ ' MB' }}
{% elseif bytes < terabyte %}
{{ (bytes / gigabyte)|number_format(2, '.') ~ ' GB' }}
{% else %}
{{ (bytes / terabyte)|number_format(2, '.') ~ ' TB' }}
{% endif %}
{% endspaceless %}
{% endmacro %}

Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
{% import 'OroEntityConfigBundle::macros.html.twig' as entityConfig %}
{% import 'OroAddressBundle::macros.html.twig' as address %}
{% import 'OroCRMChannelBundle::macros.html.twig' as channel %}
{% import 'DMKClubBasicsBundle::macros.html.twig' as CLUBUI %}

{#
Wird in der Detailansicht des Mitglieds verwendet
Expand Down Expand Up @@ -48,9 +49,9 @@ Wird in der Detailansicht des Mitglieds verwendet

{{ UI.renderProperty('orocrm.contact.birthday.label'|trans, entity.contact.birthday ? birthdayData : null) }}
{{ UI.renderProperty('orocrm.contact.gender.label'|trans, oro_gender(entity.contact.gender)) }}
{{ UI.renderProperty('dmkclub.member.is_active.label'|trans, entity.isActive) }}
{{ UI.renderProperty('dmkclub.member.is_honorary.label'|trans, entity.isHonorary) }}
{{ UI.renderProperty('dmkclub.member.is_free_of_charge.label'|trans, entity.isFreeOfCharge) }}
{{ CLUBUI.renderPropertyBoolean('dmkclub.member.is_active.label'|trans, entity.isActive) }}
{{ CLUBUI.renderPropertyBoolean('dmkclub.member.is_honorary.label'|trans, entity.isHonorary) }}
{{ CLUBUI.renderPropertyBoolean('dmkclub.member.is_free_of_charge.label'|trans, entity.isFreeOfCharge) }}
{% endif %}
{{ entityConfig.renderDynamicFields(entity) }}
</div>
Expand Down

0 comments on commit 5349b5d

Please sign in to comment.