This commit is contained in:
Xes
2025-08-14 22:41:49 +02:00
parent 2de81ccc46
commit 8ce45119b6
39774 changed files with 4309466 additions and 0 deletions

View File

@@ -0,0 +1,51 @@
{#
This file is part of the Sonata package.
(c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
#}
{% extends sonata_block.templates.block_base %}
{% block block %}
{% for group in groups %}
{% set display = (group.roles is empty or is_granted('ROLE_SUPER_ADMIN') ) %}
{% for role in group.roles if not display %}
{% set display = is_granted(role)%}
{% endfor %}
{% if display %}
<div class="box">
<div class="box-header">
<h3 class="box-title">{{ group.label|trans({}, group.label_catalogue) }}</h3>
</div>
<div class="box-body">
<table class="table table-hover">
<tbody>
{% for admin in group.items %}
{% if admin.dashboardActions|length > 0 %}
<tr>
<td class="sonata-ba-list-label" width="40%">
{{ admin.label|trans({}, admin.translationdomain) }}
</td>
<td>
<div class="btn-group">
{% for action in admin.dashboardActions %}
{% include action.template|default('SonataAdminBundle:CRUD:dashboard__action.html.twig') with {'action': action} %}
{% endfor %}
</div>
</td>
</tr>
{% endif %}
{% endfor %}
</tbody>
</table>
</div>
</div>
{% endif %}
{% endfor %}
{% endblock %}

View File

@@ -0,0 +1,31 @@
{#
This file is part of the Sonata package.
(c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
#}
{% extends "SonataBlockBundle:Block:block_core_rss.html.twig" %}
{% block block %}
<div class="box box-warning">
<div class="box-header with-border">
<h3 class="box-title sonata-feed-title"><i class="fa fa-rss" aria-hidden="true"></i> {{ settings.title }}</h3>
</div>
<div class="sonata-feeds-container list-group">
{% for feed in feeds %}
<a class="list-group-item" href="{{ feed.link}}" rel="nofollow" title="{{ feed.title }}">
<strong>{{ feed.title }}</strong>
<div>{{ feed.description|raw }}</div>
</a>
{% else %}
<div class="list-group-item">No feeds available.</div>
{% endfor %}
</div>
</div>
{% endblock %}

View File

@@ -0,0 +1,67 @@
{#
This file is part of the Sonata package.
(c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
#}
{% extends sonata_block.templates.block_base %}
{% block block %}
{% set show_empty_boxes = sonata_admin.adminPool.container.getParameter('sonata.admin.configuration.global_search.empty_boxes') %}
{% set visibility_class = 'sonata-search-result-' ~ show_empty_boxes %}
{% if pager and pager.getResults()|length %}
{% set visibility_class = 'sonata-search-result-show' %}
{% endif %}
<div class="col-lg-4 col-md-6 search-box-item {{ visibility_class }}">
<div class="box box-solid box-primary {{ visibility_class }}">
<div class="box-header with-border {{ visibility_class }}">
{% set icon = settings.icon|default('') %}
{{ icon|raw }}
<h3 class="box-title">
{{ admin.label|trans({}, admin.translationdomain) }}
</h3>
<div class="box-tools pull-right">
{% if pager and pager.getNbResults() > 0 %}
<span class="badge bg-light-blue">{{ pager.getNbResults() }}</span>
{% elseif admin.hasRoute('create') and admin.hasAccess('create') %}
<a href="{{ admin.generateUrl('create') }}" class="btn btn-box-tool">
<i class="fa fa-plus" aria-hidden="true"></i>
</a>
{% endif %}
{% if admin.hasRoute('list') and admin.hasAccess('list') %}
<a href="{{ admin.generateUrl('list') }}" class="btn btn-box-tool">
<i class="fa fa-list" aria-hidden="true"></i>
</a>
{% endif %}
</div>
</div>
{% if pager and pager.getResults()|length %}
<div class="box-body no-padding">
<ul class="nav nav-stacked sonata-search-result-list">
{% for result in pager.getResults() %}
{% set link = admin.getSearchResultLink(result) %}
{% if link %}
<li><a href="{{ link }}">{{ admin.toString(result) }}</a></li>
{% else %}
<li><a>{{ admin.toString(result) }}</a></li>
{% endif %}
{% endfor %}
</ul>
</div>
{% else %}
<div class="box-body">
<p>
<em>{{ 'no_results_found'|trans({}, 'SonataAdminBundle') }}</em>
</p>
</div>
{% endif %}
</div>
</div>
{% endblock %}

View File

@@ -0,0 +1,29 @@
{#
This file is part of the Sonata package.
(c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
#}
{% extends sonata_block.templates.block_base %}
{% block block %}
<!-- small box -->
<div class="small-box {{ settings.color }}">
<div class="inner">
<h3>{{ pager.count() }}</h3>
<p>{{ settings.text|trans({}, admin.translationDomain) }}</p>
</div>
<div class="icon">
<i class="fa {{ settings.icon }}"></i>
</div>
<a href="{{ admin.generateUrl('list', {filter: settings.filters}) }}" class="small-box-footer">
{{ 'stats_view_more'|trans({}, 'SonataAdminBundle') }} <i class="fa fa-arrow-circle-right" aria-hidden="true"></i>
</a>
</div>
{% endblock %}

View File

@@ -0,0 +1,18 @@
{#
This file is part of the Sonata package.
(c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
#}
{% if admin.isAclEnabled() and admin.canAccessObject('acl', object) and admin.hasRoute('acl') %}
<li>
<a class="sonata-action-element" href="{{ admin.generateObjectUrl('acl', object) }}">
<i class="fa fa-users" aria-hidden="true"></i>
{{ 'link_action_acl'|trans({}, 'SonataAdminBundle') }}
</a>
</li>
{% endif %}

View File

@@ -0,0 +1,30 @@
{#
This file is part of the Sonata package.
(c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
#}
{% if admin.hasAccess('create') and admin.hasRoute('create') %}
{% if admin.subClasses is empty %}
<li>
<a class="sonata-action-element" href="{{ admin.generateUrl('create') }}">
<i class="fa fa-plus-circle" aria-hidden="true"></i>
{{ 'link_action_create'|trans({}, 'SonataAdminBundle') }}
</a>
</li>
{% else %}
{% for subclass in admin.subclasses|keys %}
<li>
<a class="sonata-action-element" href="{{ admin.generateUrl('create', {'subclass': subclass}) }}">
<i class="fa fa-plus-circle" aria-hidden="true"></i>
{{ 'link_action_create'|trans({}, 'SonataAdminBundle') }} {{ subclass|trans({}, admin.translationdomain) }}
</a>
</li>
{% endfor %}
{% endif %}
{% endif %}

View File

@@ -0,0 +1,19 @@
{#
This file is part of the Sonata package.
(c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
#}
{% if admin.canAccessObject('edit', object) and admin.hasRoute('edit') %}
<li>
<a class="sonata-action-element" href="{{ admin.generateObjectUrl('edit', object) }}">
<i class="fa fa-edit" aria-hidden="true"></i>
{{ 'link_action_edit'|trans({}, 'SonataAdminBundle') }}
</a>
</li>
{% endif %}

View File

@@ -0,0 +1,19 @@
{#
This file is part of the Sonata package.
(c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
#}
{% if admin.canAccessObject('history', object) and admin.hasRoute('history') %}
<li>
<a class="sonata-action-element" href="{{ admin.generateObjectUrl('history', object) }}">
<i class="fa fa-archive" aria-hidden="true"></i>
{{ 'link_action_history'|trans({}, 'SonataAdminBundle') }}
</a>
</li>
{% endif %}

View File

@@ -0,0 +1,19 @@
{#
This file is part of the Sonata package.
(c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
#}
{% if admin.hasAccess('list') and admin.hasRoute('list') %}
<li>
<a class="sonata-action-element" href="{{ admin.generateUrl('list') }}">
<i class="fa fa-list" aria-hidden="true"></i>
{{ 'link_action_list'|trans({}, 'SonataAdminBundle') }}
</a>
</li>
{% endif %}

View File

@@ -0,0 +1,18 @@
{#
This file is part of the Sonata package.
(c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
#}
{% if admin.canAccessObject('show', object) and admin.show|length > 0 and admin.hasRoute('show') %}
<li>
<a class="sonata-action-element" href="{{ admin.generateObjectUrl('show', object) }}">
<i class="fa fa-eye" aria-hidden="true"></i>
{{ 'link_action_show'|trans({}, 'SonataAdminBundle') }}
</a>
</li>
{% endif %}

View File

@@ -0,0 +1,423 @@
{#
This file is part of the Sonata package.
(c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
#}
{#
This code manages the many-to-[one|many] association field popup
#}
{% autoescape false %}
{% set associationadmin = sonata_admin.field_description.associationadmin %}
<!-- edit many association -->
<script type="text/javascript">
{#
handle link click in a list :
- if the parent has an objectId defined then the related input get updated
- if the parent has NO object then an ajax request is made to refresh the popup
#}
var field_dialog_form_list_link_{{ id }} = function(event) {
initialize_popup_{{ id }}();
var target = jQuery(this);
if (target.attr('href').length === 0 || target.attr('href') === '#') {
return;
}
event.preventDefault();
event.stopPropagation();
Admin.log('[{{ id }}|field_dialog_form_list_link] handle link click in a list');
var element = jQuery(this).parents('#field_dialog_{{ id }} .sonata-ba-list-field');
// the user does not click on a row column
if (element.length == 0) {
Admin.log('[{{ id }}|field_dialog_form_list_link] the user does not click on a row column, make ajax call to retrieve inner html');
// make a recursive call (ie: reset the filter)
jQuery.ajax({
type: 'GET',
url: jQuery(this).attr('href'),
dataType: 'html',
success: function(html) {
Admin.log('[{{ id }}|field_dialog_form_list_link] callback success, attach valid js event');
field_dialog_content_{{ id }}.html(html);
field_dialog_form_list_handle_action_{{ id }}();
Admin.shared_setup(field_dialog_{{ id }});
}
});
return;
}
Admin.log('[{{ id }}|field_dialog_form_list_link] the user select one element, update input and hide the modal');
jQuery('#{{ id }}').val(element.attr('objectId'));
jQuery('#{{ id }}').trigger('change');
field_dialog_{{ id }}.modal('hide');
};
// this function handle action on the modal list when inside a selected list
var field_dialog_form_list_handle_action_{{ id }} = function() {
Admin.log('[{{ id }}|field_dialog_form_list_handle_action] attaching valid js event');
// capture the submit event to make an ajax call, ie : POST data to the
// related create admin
jQuery('a', field_dialog_{{ id }}).on('click', field_dialog_form_list_link_{{ id }});
jQuery('form', field_dialog_{{ id }}).on('submit', function(event) {
event.preventDefault();
var form = jQuery(this);
Admin.log('[{{ id }}|field_dialog_form_list_handle_action] catching submit event, sending ajax request');
jQuery(form).ajaxSubmit({
type: form.attr('method'),
url: form.attr('action'),
dataType: 'html',
data: {_xml_http_request: true},
success: function(html) {
Admin.log('[{{ id }}|field_dialog_form_list_handle_action] form submit success, restoring event');
field_dialog_content_{{ id }}.html(html);
field_dialog_form_list_handle_action_{{ id }}();
Admin.shared_setup(field_dialog_{{ id }});
}
});
});
};
// handle the list link
var field_dialog_form_list_{{ id }} = function(event) {
initialize_popup_{{ id }}();
event.preventDefault();
event.stopPropagation();
Admin.log('[{{ id }}|field_dialog_form_list] open the list modal');
var a = jQuery(this);
field_dialog_content_{{ id }}.html('');
// retrieve the form element from the related admin generator
jQuery.ajax({
url: a.attr('href'),
dataType: 'html',
success: function(html) {
Admin.log('[{{ id }}|field_dialog_form_list] retrieving the list content');
// populate the popup container
field_dialog_content_{{ id }}.html(html);
field_dialog_title_{{ id }}.html("{{ associationadmin.label|trans({}, associationadmin.translationdomain) }}");
Admin.shared_setup(field_dialog_{{ id }});
field_dialog_form_list_handle_action_{{ id }}();
// open the dialog in modal mode
field_dialog_{{ id }}.modal();
Admin.setup_list_modal(field_dialog_{{ id }});
}
});
};
// handle the add link
var field_dialog_form_add_{{ id }} = function(event) {
initialize_popup_{{ id }}();
event.preventDefault();
event.stopPropagation();
var a = jQuery(this);
field_dialog_content_{{ id }}.html('');
Admin.log('[{{ id }}|field_dialog_form_add] add link action');
// retrieve the form element from the related admin generator
jQuery.ajax({
url: a.attr('href'),
dataType: 'html',
success: function(html) {
Admin.log('[{{ id }}|field_dialog_form_add] ajax success', field_dialog_{{ id }});
// populate the popup container
field_dialog_content_{{ id }}.html(html);
field_dialog_title_{{ id }}.html("{{ associationadmin.label|trans({}, associationadmin.translationdomain) }}");
Admin.shared_setup(field_dialog_{{ id }});
// capture the submit event to make an ajax call, ie : POST data to the
// related create admin
jQuery('a', field_dialog_{{ id }}).on('click', field_dialog_form_action_{{ id }});
jQuery('form', field_dialog_{{ id }}).on('submit', field_dialog_form_action_{{ id }});
// open the dialog in modal mode
field_dialog_{{ id }}.modal();
Admin.setup_list_modal(field_dialog_{{ id }});
}
});
};
// handle the post data
var field_dialog_form_action_{{ id }} = function(event) {
var element = jQuery(this);
// return if the link is an anchor inside the same page
if (
this.nodeName === 'A'
&& (
element.attr('href').length === 0
|| element.attr('href')[0] === '#'
|| element.attr('href').substr(0, 11) === 'javascript:'
)
) {
Admin.log('[{{ id }}|field_dialog_form_action] element is an anchor or a script, skipping action', this);
return;
}
event.preventDefault();
event.stopPropagation();
Admin.log('[{{ id }}|field_dialog_form_action] action catch', this);
initialize_popup_{{ id }}();
if (this.nodeName == 'FORM') {
var url = element.attr('action');
var type = element.attr('method');
} else if (this.nodeName == 'A') {
var url = element.attr('href');
var type = 'GET';
} else {
alert('unexpected element : @' + this.nodeName + '@');
return;
}
if (element.hasClass('sonata-ba-action')) {
Admin.log('[{{ id }}|field_dialog_form_action] reserved action stop catch all events');
return;
}
var data = {
_xml_http_request: true
}
var form = jQuery(this);
Admin.log('[{{ id }}|field_dialog_form_action] execute ajax call');
// the ajax post
jQuery(form).ajaxSubmit({
url: url,
type: type,
data: data,
success: function(data) {
Admin.log('[{{ id }}|field_dialog_form_action] ajax success');
// if the crud action return ok, then the element has been added
// so the widget container must be refresh with the last option available
if (typeof data != 'string' && data.result == 'ok') {
field_dialog_{{ id }}.modal('hide');
{% if sonata_admin.edit == 'list' %}
{#
in this case we update the hidden input, and call the change event to
retrieve the post information
#}
jQuery('#{{ id }}').val(data.objectId);
jQuery('#{{ id }}').change();
{% else %}
// reload the form element
jQuery('#field_widget_{{ id }}').closest('form').ajaxSubmit({
url: '{{ path('sonata_admin_retrieve_form_element', {
'elementId': id,
'subclass': sonata_admin.admin.getActiveSubclassCode(),
'objectId': sonata_admin.admin.root.id(sonata_admin.admin.root.subject),
'uniqid': sonata_admin.admin.root.uniqid,
'code': sonata_admin.admin.root.code
}) }}',
data: {_xml_http_request: true },
dataType: 'html',
type: 'POST',
success: function(html) {
jQuery('#field_container_{{ id }}').replaceWith(html);
var newElement = jQuery('#{{ id }} [value="' + data.objectId + '"]');
if (newElement.is("input")) {
newElement.attr('checked', 'checked');
} else {
newElement.attr('selected', 'selected');
}
jQuery('#field_container_{{ id }}').trigger('sonata-admin-append-form-element');
}
});
{% endif %}
return;
}
// otherwise, display form error
field_dialog_content_{{ id }}.html(data);
Admin.shared_setup(field_dialog_{{ id }});
// reattach the event
jQuery('form', field_dialog_{{ id }}).submit(field_dialog_form_action_{{ id }});
}
});
return false;
};
var field_dialog_{{ id }} = false;
var field_dialog_content_{{ id }} = false;
var field_dialog_title_{{ id }} = false;
function initialize_popup_{{ id }}() {
// initialize component
if (!field_dialog_{{ id }}) {
field_dialog_{{ id }} = jQuery("#field_dialog_{{ id }}");
field_dialog_content_{{ id }} = jQuery(".modal-body", "#field_dialog_{{ id }}");
field_dialog_title_{{ id }} = jQuery(".modal-title", "#field_dialog_{{ id }}");
// move the dialog as a child of the root element, nested form breaks html ...
jQuery(document.body).append(field_dialog_{{ id }});
Admin.log('[{{ id }}|field_dialog] move dialog container as a document child');
}
}
{#
This code is used to defined the "add" popup
#}
// this function initializes the popup
// this can be only done this way as popup can be cascaded
function start_field_dialog_form_add_{{ id }}(link) {
// remove the html event
link.onclick = null;
initialize_popup_{{ id }}();
// add the jQuery event to the a element
jQuery(link)
.click(field_dialog_form_add_{{ id }})
.trigger('click')
;
return false;
}
if (field_dialog_{{ id }}) {
Admin.shared_setup(field_dialog_{{ id }});
}
{% if sonata_admin.edit == 'list' %}
{#
This code is used to defined the "list" popup
#}
// this function initializes the popup
// this can be only done this way as popup can be cascaded
function start_field_dialog_form_list_{{ id }}(link) {
link.onclick = null;
initialize_popup_{{ id }}();
// add the jQuery event to the a element
jQuery(link)
.click(field_dialog_form_list_{{ id }})
.trigger('click')
;
return false;
}
function remove_selected_element_{{ id }}(link) {
link.onclick = null;
jQuery(link)
.click(field_remove_element_{{ id}})
.trigger('click')
;
return false;
}
function field_remove_element_{{ id }}(event) {
event.preventDefault();
if (jQuery('#{{ id }} option').get(0)) {
jQuery('#{{ id }}').attr('selectedIndex', '-1').children("option:selected").attr("selected", false);
}
jQuery('#{{ id }}').val('');
jQuery('#{{ id }}').trigger('change');
return false;
}
{#
attach onchange event on the input
#}
// update the label
jQuery('#{{ id }}').on('change', function(event) {
Admin.log('[{{ id }}|on:change] update the label');
jQuery('#field_widget_{{ id }}').html("<span><img src=\"{{ asset('bundles/sonataadmin/ajax-loader.gif') }}\" style=\"vertical-align: middle; margin-right: 10px\"/>{{ 'loading_information'|trans([], 'SonataAdminBundle') }}</span>");
jQuery.ajax({
type: 'GET',
url: '{{ path('sonata_admin_short_object_information', {
'objectId': 'OBJECT_ID',
'uniqid': associationadmin.uniqid,
'code': associationadmin.code,
'linkParameters': sonata_admin.field_description.options.link_parameters
})}}'.replace('OBJECT_ID', jQuery(this).val()),
dataType: 'html',
success: function(html) {
jQuery('#field_widget_{{ id }}').html(html);
}
});
});
{% endif %}
</script>
<!-- / edit many association -->
{% endautoescape %}

View File

@@ -0,0 +1,127 @@
{#
This file is part of the Sonata package.
(c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
#}
{% if sonata_admin.field_description.hasassociationadmin %}
<div id="field_container_{{ id }}" class="field-container">
<span id="field_widget_{{ id }}" >
{% if sonata_admin.edit == 'inline' %}
{% if sonata_admin.inline == 'table' %}
{% if form.children|length > 0 %}
<table class="table table-bordered">
<thead>
<tr>
{% for field_name, nested_field in form.children[0].children %}
{% if field_name == '_delete' %}
<th>{{ 'action_delete'|trans({}, 'SonataAdminBundle') }}</th>
{% else %}
<th {{ nested_field.vars['required'] ? 'class="required"' : '' }}>
{{ nested_field.vars['sonata_admin'].admin.trans(nested_field.vars.label) }}
</th>
{% endif %}
{% endfor %}
</tr>
</thead>
<tbody class="sonata-ba-tbody">
{% for nested_group_field_name, nested_group_field in form.children %}
<tr>
{% for field_name, nested_field in nested_group_field.children %}
<td class="sonata-ba-td-{{ id }}-{{ field_name }} control-group{% if nested_field.vars.errors|length > 0 %} error sonata-ba-field-error{% endif %}">
{% if sonata_admin.field_description.associationadmin.hasformfielddescriptions(field_name) is defined %}
{{ form_widget(nested_field) }}
{% set dummy = nested_group_field.setrendered %}
{% else %}
{{ form_widget(nested_field) }}
{% endif %}
{% if nested_field.vars.errors|length > 0 %}
<div class="help-inline sonata-ba-field-error-messages">
{{ form_errors(nested_field) }}
</div>
{% endif %}
</td>
{% endfor %}
</tr>
{% endfor %}
</tbody>
</table>
{% endif %}
{% elseif form.children|length > 0 %}
<div>
{% for nested_group_field_name, nested_group_field in form.children %}
{% for field_name, nested_field in nested_group_field.children %}
{% if sonata_admin.field_description.associationadmin.hasformfielddescriptions(field_name) is defined %}
{{ form_row(nested_field, {
'inline': 'natural',
'edit' : 'inline'
}) }}
{% set dummy = nested_group_field.setrendered %}
{% else %}
{% if nested_field.vars.name == '_delete' %}
{{ form_row(nested_field, { 'label': ('action_delete'|trans({}, 'SonataAdminBundle')) }) }}
{% else %}
{{ form_row(nested_field) }}
{% endif %}
{% endif %}
{% endfor %}
{% endfor %}
</div>
{% endif %}
{% else %}
{{ form_widget(form) }}
{% endif %}
</span>
{% if sonata_admin.edit == 'inline' %}
{% if sonata_admin.field_description.associationadmin.hasroute('create') and sonata_admin.field_description.associationadmin.isGranted('CREATE') and btn_add %}
<span id="field_actions_{{ id }}" >
<a
href="{{ sonata_admin.field_description.associationadmin.generateUrl('create', sonata_admin.field_description.getOption('link_parameters', {})) }}"
onclick="return start_field_retrieve_{{ id }}(this);"
class="btn btn-success btn-sm sonata-ba-action"
title="{{ btn_add|trans({}, btn_catalogue) }}"
>
<i class="fa fa-plus-circle"></i>
{{ btn_add|trans({}, btn_catalogue) }}
</a>
</span>
{% endif %}
{# include association code #}
{% include 'SonataAdminBundle:CRUD/Association:edit_one_script.html.twig' %}
{% else %}
<div id="field_container_{{ id }}" class="field-container">
<span id="field_widget_{{ id }}" >
{{ form_widget(form) }}
</span>
<span id="field_actions_{{ id }}" class="field-actions">
{% if sonata_admin.field_description.associationadmin.hasRoute('create') and sonata_admin.field_description.associationadmin.isGranted('CREATE') and btn_add %}
<a
href="{{ sonata_admin.field_description.associationadmin.generateUrl('create', sonata_admin.field_description.getOption('link_parameters', {})) }}"
onclick="return start_field_dialog_form_add_{{ id }}(this);"
class="btn btn-success btn-sm sonata-ba-action"
title="{{ btn_add|trans({}, btn_catalogue) }}"
>
<i class="fa fa-plus-circle"></i>
{{ btn_add|trans({}, btn_catalogue) }}
</a>
{% endif %}
</span>
{% include 'SonataAdminBundle:CRUD/Association:edit_modal.html.twig' %}
</div>
{% include 'SonataAdminBundle:CRUD/Association:edit_many_script.html.twig' %}
{% endif %}
</div>
{% endif %}

View File

@@ -0,0 +1,89 @@
{#
This file is part of the Sonata package.
(c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
#}
{% if not sonata_admin.field_description.hasassociationadmin%}
{{ value|render_relation_element(sonata_admin.field_description) }}
{% elseif sonata_admin.edit == 'inline' %}
{% for field_description in sonata_admin.field_description.associationadmin.formfielddescriptions %}
{{ form_row(form[field_description.name])}}
{% endfor %}
{% else %}
<div id="field_container_{{ id }}" class="field-container">
{% if sonata_admin.edit == 'list' %}
<span id="field_widget_{{ id }}" class="field-short-description">
{% if sonata_admin.admin.id(sonata_admin.value) %}
{{ render(path('sonata_admin_short_object_information', {
'code': sonata_admin.field_description.associationadmin.code,
'objectId': sonata_admin.field_description.associationadmin.id(sonata_admin.value),
'uniqid': sonata_admin.field_description.associationadmin.uniqid,
'linkParameters': sonata_admin.field_description.options.link_parameters
})) }}
{% elseif sonata_admin.field_description.options.placeholder is defined and sonata_admin.field_description.options.placeholder %}
<span class="inner-field-short-description">
{{ sonata_admin.field_description.options.placeholder|trans({}, 'SonataAdminBundle') }}
</span>
{% endif %}
</span>
<span style="display: none" >
{{ form_widget(form) }}
</span>
{% else %}
<span id="field_widget_{{ id }}" >
{{ form_widget(form) }}
</span>
{% endif %}
<div id="field_actions_{{ id }}" class="field-actions">
{% set display_btn_list = sonata_admin.edit == 'list' and sonata_admin.field_description.associationadmin.hasRoute('list') and sonata_admin.field_description.associationadmin.isGranted('LIST') and btn_list %}
{% set display_btn_add = sonata_admin.edit != 'admin' and sonata_admin.field_description.associationadmin.hasRoute('create') and sonata_admin.field_description.associationadmin.isGranted('CREATE') and btn_add %}
{% if display_btn_list or display_btn_add %}
<div class="btn-group">
{% if display_btn_list %}
<a href="{{ sonata_admin.field_description.associationadmin.generateUrl('list', sonata_admin.field_description.getOption('link_parameters', {})) }}"
onclick="return start_field_dialog_form_list_{{ id }}(this);"
class="btn btn-info btn-sm sonata-ba-action"
title="{{ btn_list|trans({}, btn_catalogue) }}"
>
<i class="fa fa-list"></i>
{{ btn_list|trans({}, btn_catalogue) }}
</a>
{% endif %}
{% if display_btn_add %}
<a href="{{ sonata_admin.field_description.associationadmin.generateUrl('create', sonata_admin.field_description.getOption('link_parameters', {})) }}"
onclick="return start_field_dialog_form_add_{{ id }}(this);"
class="btn btn-success btn-sm sonata-ba-action"
title="{{ btn_add|trans({}, btn_catalogue) }}"
>
<i class="fa fa-plus-circle"></i>
{{ btn_add|trans({}, btn_catalogue) }}
</a>
{% endif %}
</div>
{% endif %}
{% if sonata_admin.edit == 'list' and sonata_admin.field_description.associationadmin.hasRoute('delete') and sonata_admin.field_description.associationadmin.isGranted('DELETE') and btn_delete %}
<a href=""
onclick="return remove_selected_element_{{ id }}(this);"
class="btn btn-danger btn-sm sonata-ba-action"
title="{{ btn_delete|trans({}, btn_catalogue) }}"
>
<i class="fa fa-minus-circle"></i>
{{ btn_delete|trans({}, btn_catalogue) }}
</a>
{% endif %}
</div>
{% include 'SonataAdminBundle:CRUD/Association:edit_modal.html.twig' %}
</div>
{% include 'SonataAdminBundle:CRUD/Association:edit_many_script.html.twig' %}
{% endif %}

View File

@@ -0,0 +1,23 @@
{#
This file is part of the Sonata package.
(c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
#}
<div class="modal fade" id="field_dialog_{{ id }}" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<h4 class="modal-title"></h4>
</div>
<div class="modal-body">
</div>
</div>
</div>
</div>

View File

@@ -0,0 +1,89 @@
{#
This file is part of the Sonata package.
(c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
#}
{#
This code manages the one-to-many association field popup
#}
{% autoescape false %}
<!-- edit one association -->
<script type="text/javascript">
// handle the add link
var field_add_{{ id }} = function(event) {
event.preventDefault();
event.stopPropagation();
var form = jQuery(this).closest('form');
// the ajax post
jQuery(form).ajaxSubmit({
url: '{{ path('sonata_admin_append_form_element', {
'code': sonata_admin.admin.root.code,
'elementId': id,
'objectId': sonata_admin.admin.root.id(sonata_admin.admin.root.subject),
'uniqid': sonata_admin.admin.root.uniqid,
'subclass': app.request.query.get('subclass'),
} + sonata_admin.field_description.getOption('link_parameters', {})) }}',
type: "POST",
dataType: 'html',
data: { _xml_http_request: true },
success: function(html) {
if (!html.length) {
return;
}
jQuery('#field_container_{{ id }}').replaceWith(html); // replace the html
Admin.shared_setup(jQuery('#field_container_{{ id }}'));
if(jQuery('input[type="file"]', form).length > 0) {
jQuery(form).attr('enctype', 'multipart/form-data');
jQuery(form).attr('encoding', 'multipart/form-data');
}
jQuery('#sonata-ba-field-container-{{ id }}').trigger('sonata.add_element');
jQuery('#field_container_{{ id }}').trigger('sonata.add_element');
}
});
return false;
};
var field_widget_{{ id }} = false;
// this function initializes the popup
// this can be only done this way as popup can be cascaded
function start_field_retrieve_{{ id }}(link) {
link.onclick = null;
// initialize component
field_widget_{{ id }} = jQuery("#field_widget_{{ id }}");
// add the jQuery event to the a element
jQuery(link)
.click(field_add_{{ id }})
.trigger('click')
;
return false;
}
</script>
<!-- / edit one association -->
{% endautoescape %}

View File

@@ -0,0 +1,97 @@
{#
This file is part of the Sonata package.
(c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
#}
{% if not sonata_admin.field_description.hasassociationadmin %}
{% for element in value %}
{{ element|render_relation_element(sonata_admin.field_description) }}
{% endfor %}
{% else %}
<div id="field_container_{{ id }}" class="field-container">
<span id="field_widget_{{ id }}" >
{% if sonata_admin.edit == 'inline' %}
{% if sonata_admin.inline == 'table' %}
{% if form.children|length > 0 %}
{% include 'SonataAdminBundle:CRUD/Association:edit_one_to_many_inline_table.html.twig' %}
{% endif %}
{% elseif form.children|length > 0 %}
{% set associationAdmin = sonata_admin.field_description.associationadmin %}
{% include 'SonataAdminBundle:CRUD/Association:edit_one_to_many_inline_tabs.html.twig' %}
{% endif %}
{% else %}
{{ form_widget(form) }}
{% endif %}
</span>
{% set display_create_button = sonata_admin.field_description.associationadmin.hasroute('create')
and sonata_admin.field_description.associationadmin.isGranted('CREATE')
and btn_add
and (
sonata_admin.field_description.options.limit is not defined or
form.children|length < sonata_admin.field_description.options.limit
) %}
{% if sonata_admin.edit == 'inline' %}
{% if display_create_button %}
<span id="field_actions_{{ id }}" >
<a
href="{{ sonata_admin.field_description.associationadmin.generateUrl(
'create',
sonata_admin.field_description.getOption('link_parameters', {})
) }}"
onclick="return start_field_retrieve_{{ id }}(this);"
class="btn btn-success btn-sm sonata-ba-action"
title="{{ btn_add|trans({}, btn_catalogue) }}"
>
<i class="fa fa-plus-circle"></i>
{{ btn_add|trans({}, btn_catalogue) }}
</a>
</span>
{% endif %}
{# add code for the sortable options #}
{% if sonata_admin.field_description.options.sortable is defined %}
{% if sonata_admin.inline == 'table' %}
{% include 'SonataAdminBundle:CRUD/Association:edit_one_to_many_sortable_script_table.html.twig' %}
{% else %}
{% include 'SonataAdminBundle:CRUD/Association:edit_one_to_many_sortable_script_tabs.html.twig' %}
{% endif %}
{% endif %}
{# include association code #}
{% include 'SonataAdminBundle:CRUD/Association:edit_one_script.html.twig' %}
{% else %}
<span id="field_actions_{{ id }}" >
{% if display_create_button %}
<a
href="{{ sonata_admin.field_description.associationadmin.generateUrl(
'create',
sonata_admin.field_description.getOption('link_parameters', {})
) }}"
onclick="return start_field_dialog_form_add_{{ id }}(this);"
class="btn btn-success btn-sm sonata-ba-action"
title="{{ btn_add|trans({}, btn_catalogue) }}"
>
<i class="fa fa-plus-circle"></i>
{{ btn_add|trans({}, btn_catalogue) }}
</a>
{% endif %}
</span>
{% include 'SonataAdminBundle:CRUD/Association:edit_modal.html.twig' %}
{% include 'SonataAdminBundle:CRUD/Association:edit_one_script.html.twig' %}
{% endif %}
</div>
{% endif %}

View File

@@ -0,0 +1,68 @@
{#
This file is part of the Sonata package.
(c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
#}
<table class="table table-bordered">
<thead>
<tr>
{% for field_name, nested_field in form.children|first.children %}
{% if field_name == '_delete' %}
<th>{{ 'action_delete'|trans({}, 'SonataAdminBundle') }}</th>
{% else %}
<th
{% if nested_field.vars['required'] %}
class="required"
{% endif %}
{% if (nested_field.vars['attr']['hidden'] is defined) and (nested_field.vars['attr']['hidden']) %}
style="display:none;"
{% endif %}
>
{{ nested_field.vars.label|trans({}, nested_field.vars['sonata_admin'].admin.translationDomain
|default(nested_field.vars.translation_domain)
) }}
</th>
{% endif %}
{% endfor %}
</tr>
</thead>
<tbody class="sonata-ba-tbody">
{% for nested_group_field_name, nested_group_field in form.children %}
<tr>
{% for field_name, nested_field in nested_group_field.children %}
<td class="
sonata-ba-td-{{ id }}-{{ field_name }}
control-group
{% if nested_field.vars.errors|length > 0 %} error sonata-ba-field-error{% endif %}
"
{% if (nested_field.vars['attr']['hidden'] is defined) and (nested_field.vars['attr']['hidden']) %}
style="display:none;"
{% endif %}
>
{% if sonata_admin.field_description.associationadmin.formfielddescriptions[field_name] is defined %}
{{ form_widget(nested_field) }}
{% set dummy = nested_group_field.setrendered %}
{% else %}
{% if field_name == '_delete' %}
{{ form_widget(nested_field, { label: false }) }}
{% else %}
{{ form_widget(nested_field) }}
{% endif %}
{% endif %}
{% if nested_field.vars.errors|length > 0 %}
<div class="help-inline sonata-ba-field-error-messages">
{{ form_errors(nested_field) }}
</div>
{% endif %}
</td>
{% endfor %}
</tr>
{% endfor %}
</tbody>
</table>

View File

@@ -0,0 +1,63 @@
{#
This file is part of the Sonata package.
(c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
#}
<div class="sonata-ba-tabs">
{% for nested_group_field in form.children %}
<div>
<div class="nav-tabs-custom">
<ul class="nav nav-tabs">
{% for name, form_group in associationAdmin.formgroups %}
<li class="{% if loop.first %}active{% endif %}">
<a
href="#{{ associationAdmin.uniqid }}_{{ loop.parent.loop.index }}_{{ loop.index }}"
data-toggle="tab"
>
<i class="icon-exclamation-sign has-errors hide"></i>
{{ associationAdmin.trans(name, {}, form_group.translation_domain) }}
</a>
</li>
{% endfor %}
</ul>
<div class="tab-content">
{% for name, form_group in associationAdmin.formgroups %}
<div
class="tab-pane {% if loop.first %}active{% endif %}"
id="{{ associationAdmin.uniqid }}_{{ loop.parent.loop.index }}_{{ loop.index }}"
>
<fieldset>
<div class="sonata-ba-collapsed-fields">
{% for field_name in form_group.fields %}
{% set nested_field = nested_group_field.children[field_name] %}
<div class="sonata-ba-field-{{ id }}-{{ field_name }}">
{% if associationAdmin.formfielddescriptions[field_name] is defined %}
{{ form_row(nested_field, {
'inline': 'natural',
'edit' : 'inline'
}) }}
{% set dummy = nested_group_field.setrendered %}
{% else %}
{{ form_row(nested_field) }}
{% endif %}
</div>
{% endfor %}
</div>
</fieldset>
</div>
{% endfor %}
</div>
</div>
{% if nested_group_field['_delete'] is defined %}
{{ form_row(nested_group_field['_delete'], {'label': 'action_delete', 'translation_domain': 'SonataAdminBundle'}) }}
{% endif %}
</div>
{% endfor %}
</div>

View File

@@ -0,0 +1,40 @@
{#
This file is part of the Sonata package.
(c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
#}
<script type="text/javascript">
jQuery('div#field_container_{{ id }} tbody.sonata-ba-tbody').first().sortable({
axis: 'y',
opacity: 0.6,
items: '> tr',
stop: apply_position_value_{{ id }}
});
function apply_position_value_{{ id }}() {
// update the input value position
jQuery('div#field_container_{{ id }} tbody.sonata-ba-tbody td.sonata-ba-td-{{ id }}-{{ sonata_admin.field_description.options.sortable }}').each(function(index, element) {
// remove the sortable handler and put it back
jQuery('span.sonata-ba-sortable-handler', element).remove();
jQuery(element).append('<span class="sonata-ba-sortable-handler ui-icon ui-icon-grip-solid-horizontal"></span>');
jQuery('input', element).hide();
});
jQuery('div#field_container_{{ id }} tbody.sonata-ba-tbody td.sonata-ba-td-{{ id }}-{{ sonata_admin.field_description.options.sortable }} input').each(function(index, value) {
jQuery(value).val(index + 1);
});
}
// refresh the sortable option when a new element is added
jQuery('#sonata-ba-field-container-{{ id }}').bind('sonata.add_element', function() {
apply_position_value_{{ id }}();
jQuery('div#field_container_{{ id }} tbody.sonata-ba-tbody').sortable('refresh');
});
apply_position_value_{{ id }}();
</script>

View File

@@ -0,0 +1,44 @@
{#
This file is part of the Sonata package.
(c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
#}
<script type="text/javascript">
jQuery('div#field_container_{{ id }} .sonata-ba-tabs').sortable({
axis: 'y',
opacity: 0.6,
items: '> div',
stop: apply_position_value_{{ id }}
});
function apply_position_value_{{ id }}() {
// update the input value position
jQuery('div#field_container_{{ id }} .sonata-ba-tabs .sonata-ba-field-{{ id }}-{{ sonata_admin.field_description.options.sortable }}').each(function(index, element) {
// remove the sortable handler and put it back
var parent = jQuery(element).closest('.nav-tabs-custom');
var tabs = parent.find('> .nav-tabs');
jQuery('.sonata-ba-sortable-handler', tabs).remove();
$('<li class="sonata-ba-sortable-handler pull-right"></li>')
.prepend('<span class="ui-icon ui-icon-grip-solid-horizontal"></span>')
.appendTo(tabs);
jQuery('input', element).hide();
});
jQuery('div#field_container_{{ id }} .sonata-ba-tabs .sonata-ba-field-{{ id }}-{{ sonata_admin.field_description.options.sortable }} input').each(function(index, value) {
jQuery(value).val(index + 1);
});
}
// refresh the sortable option when a new element is added
jQuery('#sonata-ba-field-container-{{ id }}').bind('sonata.add_element', function() {
apply_position_value_{{ id }}();
jQuery('div#field_container_{{ id }} .sonata-ba-tabs').sortable('refresh');
});
apply_position_value_{{ id }}();
</script>

View File

@@ -0,0 +1,89 @@
{#
This file is part of the Sonata package.
(c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
#}
{% if not sonata_admin.field_description.hasassociationadmin%}
{{ value|render_relation_element(sonata_admin.field_description) }}
{% elseif sonata_admin.edit == 'inline' %}
{% for field_description in sonata_admin.field_description.associationadmin.formfielddescriptions %}
{{ form_row(form.children[field_description.name]) }}
{% endfor %}
{% else %}
<div id="field_container_{{ id }}" class="field-container">
{% if sonata_admin.edit == 'list' %}
<span id="field_widget_{{ id }}" class="field-short-description">
{% if sonata_admin.field_description.associationadmin.id(sonata_admin.value) %}
{{ render(path('sonata_admin_short_object_information', {
'code': sonata_admin.field_description.associationadmin.code,
'objectId': sonata_admin.field_description.associationadmin.id(sonata_admin.value),
'uniqid': sonata_admin.field_description.associationadmin.uniqid,
'linkParameters': sonata_admin.field_description.options.link_parameters
})) }}
{% elseif sonata_admin.field_description.options.placeholder is defined and sonata_admin.field_description.options.placeholder %}
<span class="inner-field-short-description">
{{ sonata_admin.field_description.options.placeholder|trans({}, 'SonataAdminBundle') }}
</span>
{% endif %}
</span>
<span style="display: none" >
{{ form_widget(form) }}
</span>
{% else %}
<span id="field_widget_{{ id }}" >
{{ form_widget(form) }}
</span>
{% endif %}
<div id="field_actions_{{ id }}" class="field-actions">
{% set display_btn_list = sonata_admin.edit == 'list' and sonata_admin.field_description.associationadmin.hasroute('list') and sonata_admin.field_description.associationadmin.isGranted('LIST') and btn_list %}
{% set display_btn_add = sonata_admin.edit != 'admin' and sonata_admin.field_description.associationadmin.hasroute('create') and sonata_admin.field_description.associationadmin.isGranted('CREATE') and btn_add %}
{% if display_btn_list or display_btn_add %}
<div class="btn-group">
{% if display_btn_list %}
<a href="{{ sonata_admin.field_description.associationadmin.generateUrl('list', sonata_admin.field_description.getOption('link_parameters', {})) }}"
onclick="return start_field_dialog_form_list_{{ id }}(this);"
class="btn btn-info btn-sm sonata-ba-action"
title="{{ btn_list|trans({}, btn_catalogue) }}"
>
<i class="fa fa-list"></i>
{{ btn_list|trans({}, btn_catalogue) }}
</a>
{% endif %}
{% if display_btn_add %}
<a href="{{ sonata_admin.field_description.associationadmin.generateUrl('create', sonata_admin.field_description.getOption('link_parameters', {})) }}"
onclick="return start_field_dialog_form_add_{{ id }}(this);"
class="btn btn-success btn-sm sonata-ba-action"
title="{{ btn_add|trans({}, btn_catalogue) }}"
>
<i class="fa fa-plus-circle"></i>
{{ btn_add|trans({}, btn_catalogue) }}
</a>
{% endif %}
</div>
{% endif %}
{% if sonata_admin.edit == 'list' and sonata_admin.field_description.associationadmin.hasRoute('delete') and sonata_admin.field_description.associationadmin.isGranted('DELETE') and btn_delete %}
<a href=""
onclick="return remove_selected_element_{{ id }}(this);"
class="btn btn-danger btn-sm sonata-ba-action"
title="{{ btn_delete|trans({}, btn_catalogue) }}"
>
<i class="fa fa-minus-circle"></i>
{{ btn_delete|trans({}, btn_catalogue) }}
</a>
{% endif %}
</div>
{% include 'SonataAdminBundle:CRUD/Association:edit_modal.html.twig' %}
</div>
{% include 'SonataAdminBundle:CRUD/Association:edit_many_script.html.twig' %}
{% endif %}

View File

@@ -0,0 +1,41 @@
{#
This file is part of the Sonata package.
(c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
#}
{% extends admin.getTemplate('base_list_field') %}
{% block field %}
{% set route_name = field_description.options.route.name %}
{% if field_description.hasassociationadmin and field_description.associationadmin.hasRoute(route_name) %}
{% for element in value %}
{%- if field_description.associationadmin.hasAccess(route_name, element) -%}
{{ block('relation_link') }}
{%- else -%}
{{ block('relation_value') }}
{%- endif -%}
{% if not loop.last %}, {% endif %}
{% endfor %}
{% else %}
{% for element in value%}
{{ block('relation_value') }}
{% if not loop.last %}, {% endif %}
{% endfor %}
{% endif %}
{% endblock %}
{%- block relation_link -%}
<a href="{{ field_description.associationadmin.generateObjectUrl(route_name, element, field_description.options.route.parameters) }}">
{{- element|render_relation_element(field_description) -}}
</a>
{%- endblock -%}
{%- block relation_value -%}
{{- element|render_relation_element(field_description) -}}
{%- endblock -%}

View File

@@ -0,0 +1,29 @@
{#
This file is part of the Sonata package.
(c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
#}
{% extends admin.getTemplate('base_list_field') %}
{% block field %}
{% if value %}
{% set route_name = field_description.options.route.name %}
{% if not field_description.options.identifier|default(false) and
field_description.hasAssociationAdmin and
field_description.associationadmin.hasRoute(route_name) and
field_description.associationadmin.hasAccess(route_name, value)
%}
<a href="{{ field_description.associationadmin.generateObjectUrl(route_name, value, field_description.options.route.parameters) }}">
{{ value|render_relation_element(field_description) }}
</a>
{% else %}
{{ value|render_relation_element(field_description) }}
{% endif %}
{% endif %}
{% endblock %}

View File

@@ -0,0 +1,40 @@
{#
This file is part of the Sonata package.
(c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
#}
{% extends admin.getTemplate('base_list_field') %}
{% block field %}
{% set route_name = field_description.options.route.name %}
{% if field_description.hasassociationadmin and field_description.associationadmin.hasRoute(route_name) %}
{% for element in value %}
{%- if field_description.associationadmin.hasAccess(route_name, element) -%}
{{ block('relation_link') }}
{%- else -%}
{{ block('relation_value') }}
{%- endif -%}
{% if not loop.last %}, {% endif %}
{% endfor %}
{% else %}
{% for element in value %}
{{ block('relation_value') }}{% if not loop.last %}, {% endif %}
{% endfor %}
{% endif %}
{% endblock %}
{%- block relation_link -%}
<a href="{{ field_description.associationadmin.generateObjectUrl(route_name, element, field_description.options.route.parameters) }}">
{{- element|render_relation_element(field_description) -}}
</a>
{%- endblock -%}
{%- block relation_value -%}
{{- element|render_relation_element(field_description) -}}
{%- endblock -%}

View File

@@ -0,0 +1,24 @@
{#
This file is part of the Sonata package.
(c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
#}
{% extends admin.getTemplate('base_list_field') %}
{% block field %}
{% set route_name = field_description.options.route.name %}
{% if field_description.hasAssociationAdmin
and field_description.associationadmin.id(value)
and field_description.associationadmin.hasRoute(route_name)
and field_description.associationadmin.hasAccess(route_name, value) %}
<a href="{{ field_description.associationadmin.generateObjectUrl(route_name, value, field_description.options.route.parameters) }}">{{ value|render_relation_element(field_description) }}</a>
{% else %}
{{ value|render_relation_element(field_description) }}
{% endif %}
{% endblock %}

View File

@@ -0,0 +1,31 @@
{#
This file is part of the Sonata package.
(c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
#}
{% extends 'SonataAdminBundle:CRUD:base_show_field.html.twig' %}
{% block field %}
<ul class="sonata-ba-show-many-to-many">
{% set route_name = field_description.options.route.name %}
{% for element in value %}
<li>
{% if field_description.hasassociationadmin
and field_description.associationadmin.hasRoute(route_name)
and field_description.associationadmin.hasAccess(route_name, element) %}
<a href="{{ field_description.associationadmin.generateObjectUrl(route_name, element, field_description.options.route.parameters) }}">
{{ element|render_relation_element(field_description) }}
</a>
{% else %}
{{ element|render_relation_element(field_description) }}
{% endif %}
</li>
{% endfor %}
</ul>
{% endblock %}

View File

@@ -0,0 +1,27 @@
{#
This file is part of the Sonata package.
(c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
#}
{% extends 'SonataAdminBundle:CRUD:base_show_field.html.twig' %}
{% block field %}
{% if value %}
{% set route_name = field_description.options.route.name %}
{% if field_description.hasAssociationAdmin
and field_description.associationadmin.hasRoute(route_name)
and field_description.associationadmin.hasAccess(route_name, value) %}
<a href="{{ field_description.associationadmin.generateObjectUrl(route_name, value, field_description.options.route.parameters) }}">
{{ value|render_relation_element(field_description) }}
</a>
{% else %}
{{ value|render_relation_element(field_description) }}
{% endif %}
{% endif %}
{% endblock %}

View File

@@ -0,0 +1,31 @@
{#
This file is part of the Sonata package.
(c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
#}
{% extends 'SonataAdminBundle:CRUD:base_show_field.html.twig' %}
{% block field %}
<ul class="sonata-ba-show-one-to-many">
{% set route_name = field_description.options.route.name %}
{% for element in value%}
{% if field_description.hasassociationadmin
and field_description.associationadmin.hasRoute(route_name)
and field_description.associationadmin.hasAccess(route_name, element) %}
<li>
<a href="{{ field_description.associationadmin.generateObjectUrl(route_name, element, field_description.options.route.parameters) }}">
{{ element|render_relation_element(field_description) }}
</a>
</li>
{% else %}
<li>{{ element|render_relation_element(field_description) }}</li>
{% endif %}
{% endfor %}
</ul>
{% endblock %}

View File

@@ -0,0 +1,26 @@
{#
This file is part of the Sonata package.
(c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
#}
{% extends 'SonataAdminBundle:CRUD:base_show_field.html.twig' %}
{% block field %}
{% set route_name = field_description.options.route.name %}
{% if field_description.hasAssociationAdmin
and field_description.associationadmin.id(value)
and field_description.associationadmin.hasRoute(route_name)
and field_description.associationadmin.hasAccess(route_name, value) %}
<a href="{{ field_description.associationadmin.generateObjectUrl(route_name, value, field_description.options.route.parameters) }}">
{{ value|render_relation_element(field_description) }}
</a>
{% else %}
{{ value|render_relation_element(field_description) }}
{% endif %}
{% endblock %}

View File

@@ -0,0 +1,21 @@
{%- if value is empty -%}
&nbsp;
{%- elseif field_description.options.as_string is defined and field_description.options.as_string -%}
{{ value }}
{%- else -%}
{% set parameters = {} %}
{% set subject = field_description.options.subject|default('') %}
{% set body = field_description.options.body|default('') %}
{% if subject is not empty %}
{% set parameters = parameters|merge({'subject': subject}) %}
{% endif %}
{% if body is not empty %}
{% set parameters = parameters|merge({'body': body}) %}
{% endif %}
<a href="mailto:{{ value }}{% if parameters|length > 0 %}?{{- parameters|url_encode -}}{% endif %}">
{{- value -}}
</a>
{%- endif -%}

View File

@@ -0,0 +1,12 @@
{#
This file is part of the Sonata package.
(c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
#}
{% extends 'SonataAdminBundle:CRUD:base_acl.html.twig' %}

View File

@@ -0,0 +1,28 @@
{#
This file is part of the Sonata package.
(c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
#}
{% extends base_template %}
{%- block actions -%}
{% include 'SonataAdminBundle:CRUD:action_buttons.html.twig' %}
{%- endblock -%}
{% block tab_menu %}
{% if action is defined %}
{{ knp_menu_render(admin.sidemenu(action), {'currentClass' : 'active', 'template': sonata_admin.adminPool.getTemplate('tab_menu_template')}, 'twig') }}
{% endif %}
{% endblock %}
{% block content %}
Redefine the content block in your action template
{% endblock %}

View File

@@ -0,0 +1,17 @@
{#
This file is part of the Sonata package.
(c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
#}
{% spaceless %}
{% for item in admin.getActionButtons(action, object|default(null)) %}
{% if item.template is defined %}
{% include item.template %}
{% endif %}
{% endfor %}
{% endspaceless %}

View File

@@ -0,0 +1,27 @@
{#
This file is part of the Sonata package.
(c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
#}
{% extends base_template %}
{%- block actions -%}
{% include 'SonataAdminBundle:CRUD:action_buttons.html.twig' %}
{%- endblock -%}
{% import 'SonataAdminBundle:CRUD:base_acl_macro.html.twig' as acl %}
{% block form %}
{% block form_acl_roles %}
{{ acl.render_form(aclRolesForm, permissions, 'td_role', admin, sonata_admin.adminPool, object) }}
{% endblock %}
{% block form_acl_users %}
{{ acl.render_form(aclUsersForm, permissions, 'td_username', admin, sonata_admin.adminPool, object) }}
{% endblock %}
{% endblock %}

View File

@@ -0,0 +1,63 @@
{#
This file is part of the Sonata package.
(c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
#}
{% macro render_form(form, permissions, td_type, admin, admin_pool, object) %}
<form class="form-horizontal"
action="{{ admin.generateUrl('acl', {'id': admin.id(object), 'uniqid': admin.uniqid, 'subclass': app.request.get('subclass')}) }}"
{% if form.vars.multipart %} enctype="multipart/form-data"{% endif %}
method="POST"
{% if not admin_pool.getOption('html5_validate') %}novalidate="novalidate"{% endif %}
>
{{ include('SonataAdminBundle:Helper:render_form_dismissable_errors.html.twig') }}
<div class="box box-success">
<div class="body table-responsive no-padding">
<table class="table">
<colgroup>
<col style="width: 100%;"/>
{% for permission in permissions %}
<col/>
{% endfor %}
</colgroup>
{% for child in form.children if child.vars.name != '_token' %}
{% if loop.index0 == 0 or loop.index0 % 10 == 0 %}
<tr>
<th>{{ td_type|trans({}, 'SonataAdminBundle') }}</th>
{% for permission in permissions %}
<th class="text-right">{{ permission }}</th>
{% endfor %}
</tr>
{% endif %}
<tr>
<td>
{% set typeChild = child['role'] is defined ? child['role'] : child['user'] %}
{{ typeChild.vars.value }}
{{ form_widget(typeChild) }}
</td>
{% for permission in permissions %}
<td class="text-right">{{ form_widget(child[permission], { label: false }) }}</td>
{% endfor %}
</tr>
{% endfor %}
</table>
</div>
</div>
{{ form_row(form._token) }}
<div class="well well-small form-actions">
<input class="btn btn-primary" type="submit" name="btn_create_and_edit" value="{{ 'btn_update_acl'|trans({}, 'SonataAdminBundle') }}">
</div>
</form>
{% endmacro %}

View File

@@ -0,0 +1,23 @@
{#
This file is part of the Sonata package.
(c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
#}
{% macro render_array(value, inline) %}
{% for key, val in value %}
{% if val is iterable %}
[{{ key }} => {{ _self.render_array(val, inline) }}]
{% else %}
[{{ key }} => {{ val }}]
{% endif %}
{% if not loop.last and not inline %}
<br>
{% endif %}
{% endfor %}
{% endmacro %}

View File

@@ -0,0 +1,37 @@
{#
This file is part of the Sonata package.
(c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
#}
{% extends base_template %}
{% block title %}
{# NEXT_MAJOR: remove default filter #}
{% if objectId|default(admin.id(object)) is not null %}
{{ "title_edit"|trans({'%name%': admin.toString(object)|truncate(15) }, 'SonataAdminBundle') }}
{% else %}
{{ "title_create"|trans({}, 'SonataAdminBundle') }}
{% endif %}
{% endblock %}
{% block navbar_title %}
{{ block('title') }}
{% endblock %}
{%- block actions -%}
{% include 'SonataAdminBundle:CRUD:action_buttons.html.twig' %}
{%- endblock -%}
{% block tab_menu %}{{ knp_menu_render(admin.sidemenu(action), {'currentClass' : 'active', 'template': sonata_admin.adminPool.getTemplate('tab_menu_template')}, 'twig') }}{% endblock %}
{% use 'SonataAdminBundle:CRUD:base_edit_form.html.twig' with form as parentForm %}
{% block form %}
{{ block('parentForm') }}
{% endblock %}

View File

@@ -0,0 +1,120 @@
{% block form %}
{% import "SonataAdminBundle:CRUD:base_edit_form_macro.html.twig" as form_helper %}
{{ sonata_block_render_event('sonata.admin.edit.form.top', { 'admin': admin, 'object': object }) }}
{# NEXT_MAJOR: remove default filter #}
{% set url = objectId|default(admin.id(object)) is not null ? 'edit' : 'create' %}
{% if not admin.hasRoute(url)%}
<div>
{{ "form_not_available"|trans({}, "SonataAdminBundle") }}
</div>
{% else %}
<form
{% if sonata_admin.adminPool.getOption('form_type') == 'horizontal' %}class="form-horizontal"{% endif %}
role="form"
{# NEXT_MAJOR: remove default filter #}
action="{% block sonata_form_action_url %}{{ admin.generateUrl(url, {'id': objectId|default(admin.id(object)), 'uniqid': admin.uniqid, 'subclass': app.request.get('subclass')}) }}{% endblock %}"
{% if form.vars.multipart %} enctype="multipart/form-data"{% endif %}
method="POST"
{% if not sonata_admin.adminPool.getOption('html5_validate') %}novalidate="novalidate"{% endif %}
{% block sonata_form_attributes %}{% endblock %}
>
{{ include('SonataAdminBundle:Helper:render_form_dismissable_errors.html.twig') }}
{% block sonata_pre_fieldsets %}
<div class="row">
{% endblock %}
{% block sonata_tab_content %}
{% set has_tab = ((admin.formtabs|length == 1 and admin.formtabs|keys[0] != 'default') or admin.formtabs|length > 1 ) %}
<div class="col-md-12">
{% if has_tab %}
<div class="nav-tabs-custom">
<ul class="nav nav-tabs" role="tablist">
{% for name, form_tab in admin.formtabs %}
<li{% if loop.index == 1 %} class="active"{% endif %}><a href="#tab_{{ admin.uniqid }}_{{ loop.index }}" data-toggle="tab"><i class="fa fa-exclamation-circle has-errors hide" aria-hidden="true"></i> {{ form_tab.label|trans({}, form_tab.translation_domain ?: admin.translationDomain) }}</a></li>
{% endfor %}
</ul>
<div class="tab-content">
{% for code, form_tab in admin.formtabs %}
<div class="tab-pane fade{% if loop.first %} in active{% endif %}" id="tab_{{ admin.uniqid }}_{{ loop.index }}">
<div class="box-body container-fluid">
<div class="sonata-ba-collapsed-fields">
{% if form_tab.description != false %}
<p>{{ form_tab.description|raw }}</p>
{% endif %}
{{ form_helper.render_groups(admin, form, form_tab['groups'], has_tab) }}
</div>
</div>
</div>
{% endfor %}
</div>
</div>
{% else %}
{{ form_helper.render_groups(admin, form, admin.formtabs['default'].groups, has_tab) }}
{% endif %}
</div>
{% endblock %}
{% block sonata_post_fieldsets %}
</div>
{% endblock %}
{{ form_rest(form) }}
{% block formactions %}
<div class="sonata-ba-form-actions well well-small form-actions">
{% block sonata_form_actions %}
{% if app.request.isxmlhttprequest %}
{# NEXT_MAJOR: remove default filter #}
{% if objectId|default(admin.id(object)) is not null %}
<button type="submit" class="btn btn-success" name="btn_update"><i class="fa fa-save" aria-hidden="true"></i> {{ 'btn_update'|trans({}, 'SonataAdminBundle') }}</button>
{% else %}
<button type="submit" class="btn btn-success" name="btn_create"><i class="fa fa-plus-circle" aria-hidden="true"></i> {{ 'btn_create'|trans({}, 'SonataAdminBundle') }}</button>
{% endif %}
{% else %}
{% if admin.supportsPreviewMode %}
<button class="btn btn-info persist-preview" name="btn_preview" type="submit">
<i class="fa fa-eye" aria-hidden="true"></i>
{{ 'btn_preview'|trans({}, 'SonataAdminBundle') }}
</button>
{% endif %}
{# NEXT_MAJOR: remove default filter #}
{% if objectId|default(admin.id(object)) is not null %}
<button type="submit" class="btn btn-success" name="btn_update_and_edit"><i class="fa fa-save" aria-hidden="true"></i> {{ 'btn_update_and_edit_again'|trans({}, 'SonataAdminBundle') }}</button>
{% if admin.hasRoute('list') and admin.hasAccess('list') %}
<button type="submit" class="btn btn-success" name="btn_update_and_list"><i class="fa fa-save"></i> <i class="fa fa-list" aria-hidden="true"></i> {{ 'btn_update_and_return_to_list'|trans({}, 'SonataAdminBundle') }}</button>
{% endif %}
{% if admin.hasRoute('delete') and admin.hasAccess('delete', object) %}
{{ 'delete_or'|trans({}, 'SonataAdminBundle') }}
<a class="btn btn-danger" href="{{ admin.generateObjectUrl('delete', object) }}"><i class="fa fa-minus-circle" aria-hidden="true"></i> {{ 'link_delete'|trans({}, 'SonataAdminBundle') }}</a>
{% endif %}
{% if admin.isAclEnabled() and admin.hasRoute('acl') and admin.hasAccess('acl', object) %}
<a class="btn btn-info" href="{{ admin.generateObjectUrl('acl', object) }}"><i class="fa fa-users" aria-hidden="true"></i> {{ 'link_edit_acl'|trans({}, 'SonataAdminBundle') }}</a>
{% endif %}
{% else %}
{% if admin.hasroute('edit') and admin.hasAccess('edit') %}
<button class="btn btn-success" type="submit" name="btn_create_and_edit"><i class="fa fa-save" aria-hidden="true"></i> {{ 'btn_create_and_edit_again'|trans({}, 'SonataAdminBundle') }}</button>
{% endif %}
{% if admin.hasroute('list') and admin.hasAccess('list') %}
<button type="submit" class="btn btn-success" name="btn_create_and_list"><i class="fa fa-save"></i> <i class="fa fa-list" aria-hidden="true"></i> {{ 'btn_create_and_return_to_list'|trans({}, 'SonataAdminBundle') }}</button>
{% endif %}
<button class="btn btn-success" type="submit" name="btn_create_and_create"><i class="fa fa-plus-circle" aria-hidden="true"></i> {{ 'btn_create_and_create_a_new_one'|trans({}, 'SonataAdminBundle') }}</button>
{% endif %}
{% endif %}
{% endblock %}
</div>
{% endblock formactions %}
</form>
{% endif%}
{{ sonata_block_render_event('sonata.admin.edit.form.bottom', { 'admin': admin, 'object': object }) }}
{% endblock %}

View File

@@ -0,0 +1,31 @@
{% macro render_groups(admin, form, groups, has_tab) %}
<div class="row">
{% for code in groups if admin.formgroups[code] is defined %}
{% set form_group = admin.formgroups[code] %}
<div class="{{ form_group.class|default('col-md-12') }}">
<div class="{{ form_group.box_class }}">
<div class="box-header">
<h4 class="box-title">
{{ form_group.label|trans({}, form_group.translation_domain ?: admin.translationDomain) }}
</h4>
</div>
<div class="box-body">
<div class="sonata-ba-collapsed-fields">
{% if form_group.description %}
<p>{{ form_group.description|raw }}</p>
{% endif %}
{% for field_name in form_group.fields if form[field_name] is defined %}
{{ form_row(form[field_name])}}
{% else %}
<em>{{ 'message_form_group_empty'|trans({}, 'SonataAdminBundle') }}</em>
{% endfor %}
</div>
</div>
</div>
</div>
{% endfor %}
</div>
{% endmacro %}

View File

@@ -0,0 +1,26 @@
{#
This file is part of the Sonata package.
(c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
#}
<div>
{% block label %}
{% if filter.fielddescription.options.name is defined %}
{{ form_label(filter_form, filter.fielddescription.options.name) }}
{% else %}
{{ form_label(filter_form) }}
{% endif %}
<br>
{% endblock %}
<div class="sonata-ba-field{% if filter_form.vars.errors %} sonata-ba-field-error{% endif %}">
{% block field %}{{ form_widget(filter_form) }}{% endblock %}
</div>
</div>

View File

@@ -0,0 +1,91 @@
{#
This file is part of the Sonata package.
(c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
#}
{% extends base_template %}
{%- block actions -%}
{% include 'SonataAdminBundle:CRUD:action_buttons.html.twig' %}
{%- endblock -%}
{% block content %}
<div class="row">
<div class="col-md-5">
<div class="box box-primary">
<div class="box-body table-responsive no-padding">
<table class="table" id="revisions">
<thead>
<tr>
<th>{{ 'td_revision'|trans({}, 'SonataAdminBundle') }}</th>
<th>{{ 'td_timestamp'|trans({}, 'SonataAdminBundle') }}</th>
<th>{{ 'td_username'|trans({}, 'SonataAdminBundle') }}</th>
<th>{{ 'td_action'|trans({}, 'SonataAdminBundle') }}</th>
<th>{{ 'td_compare'|trans({}, 'SonataAdminBundle') }}</th>
</tr>
</thead>
<tbody>
{% for revision in revisions %}
<tr class="{% if (currentRevision != false and revision.rev == currentRevision.rev) %}current-revision{% endif %}">
<td>{{ revision.rev }}</td>
<td>{% include admin.getTemplate('history_revision_timestamp') %}</td>
<td>{{ revision.username|default('label_unknown_user'|trans({}, 'SonataAdminBundle')) }}</td>
<td><a href="{{ admin.generateObjectUrl('history_view_revision', object, {'revision': revision.rev }) }}" class="revision-link" rel="{{ revision.rev }}">{{ "label_view_revision"|trans({}, 'SonataAdminBundle') }}</a></td>
<td>
{% if (currentRevision == false or revision.rev == currentRevision.rev) %}
/
{% else %}
<a href="{{ admin.generateObjectUrl('history_compare_revisions', object, {'base_revision': currentRevision.rev, 'compare_revision': revision.rev }) }}" class="revision-compare-link" rel="{{ revision.rev }}">{{ 'label_compare_revision'|trans({}, 'SonataAdminBundle') }}</a>
{% endif %}
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
</div>
<div id="revision-detail" class="col-md-7 revision-detail">
</div>
</div>
<script>
jQuery(document).ready(function() {
jQuery('a.revision-link, a.revision-compare-link').bind('click', function(event) {
event.stopPropagation();
event.preventDefault();
action = jQuery(this).hasClass('revision-link')
? 'show'
: 'compare';
jQuery('#revision-detail').html('');
if(action == 'show'){
jQuery('table#revisions tbody tr').removeClass('current');
jQuery(this).parent('').removeClass('current');
}
jQuery.ajax({
url: jQuery(this).attr('href'),
dataType: 'html',
success: function(data) {
jQuery('#revision-detail').html(data);
}
});
return false;
});
});
</script>
{% endblock %}

View File

@@ -0,0 +1,30 @@
{#
This file is part of the Sonata package.
(c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
#}
<div id="sonata-ba-field-container-{{ field_element.vars.id }}" class="sonata-ba-field sonata-ba-field-{{ edit }}-{{ inline }} {% if field_element.vars.errors|length %}sonata-ba-field-error{% endif %}">
{% block label %}
{% if inline == 'natural' %}
{% if field_description.options.name is defined %}
{{ form_label(field_element, field_description.options.name) }}
{% else %}
{{ form_label(field_element) }}
{% endif %}
<br>
{% endif %}
{% endblock %}
{% block field %}{{ form_widget(field_element) }}{% endblock %}
<div class="sonata-ba-field-error-messages">
{% block errors %}{{ form_errors(field_element) }}{% endblock %}
</div>
</div>

View File

@@ -0,0 +1,335 @@
{#
This file is part of the Sonata package.
(c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
#}
{% extends base_template %}
{%- block actions -%}
{% include 'SonataAdminBundle:CRUD:action_buttons.html.twig' %}
{%- endblock -%}
{% block tab_menu %}{{ knp_menu_render(admin.sidemenu(action), {'currentClass' : 'active', 'template': sonata_admin.adminPool.getTemplate('tab_menu_template')}, 'twig') }}{% endblock %}
{% block title %}
{#
The list template can be used in nested mode,
so we define the title corresponding to the parent's admin.
#}
{% if admin.isChild and admin.parent.subject %}
{{ "title_edit"|trans({'%name%': admin.parent.toString(admin.parent.subject)|truncate(15) }, 'SonataAdminBundle') }}
{% endif %}
{% endblock %}
{% block navbar_title %}
{{ block('title') }}
{% endblock %}
{% block list_table %}
<div class="col-xs-12 col-md-12">
{% set batchactions = admin.batchactions %}
{% if admin.hasRoute('batch') and batchactions|length %}
<form action="{{ admin.generateUrl('batch', {'filter': admin.filterParameters}) }}" method="POST" >
<input type="hidden" name="_sonata_csrf_token" value="{{ csrf_token }}">
{% endif %}
{# Add a margin if no pager to prevent dropdown cropping on window #}
<div class="box box-primary" {% if admin.datagrid.pager.lastPage == 1 %}style="margin-bottom: 100px;"{% endif %}>
<div class="box-body {% if admin.datagrid.results|length > 0 %}table-responsive no-padding{% endif %}">
{{ sonata_block_render_event('sonata.admin.list.table.top', { 'admin': admin }) }}
{% block list_header %}{% endblock %}
{% if admin.datagrid.results|length > 0 %}
<table class="table table-bordered table-striped sonata-ba-list">
{% block table_header %}
<thead>
<tr class="sonata-ba-list-field-header">
{% for field_description in admin.list.elements %}
{% if admin.hasRoute('batch') and field_description.getOption('code') == '_batch' and batchactions|length > 0 %}
<th class="sonata-ba-list-field-header sonata-ba-list-field-header-batch">
<input type="checkbox" id="list_batch_checkbox">
</th>
{% elseif field_description.getOption('code') == '_select' %}
<th class="sonata-ba-list-field-header sonata-ba-list-field-header-select"></th>
{% elseif field_description.name == '_action' and app.request.isXmlHttpRequest %}
{# Action buttons disabled in ajax view! #}
{% elseif field_description.getOption('ajax_hidden') == true and app.request.isXmlHttpRequest %}
{# Disable fields with 'ajax_hidden' option set to true #}
{% else %}
{% set sortable = false %}
{% if field_description.options.sortable is defined and field_description.options.sortable %}
{% set sortable = true %}
{% set sort_parameters = admin.modelmanager.sortparameters(field_description, admin.datagrid) %}
{% set current = admin.datagrid.values._sort_by == field_description or admin.datagrid.values._sort_by.fieldName == sort_parameters.filter._sort_by %}
{% set sort_active_class = current ? 'sonata-ba-list-field-order-active' : '' %}
{% set sort_by = current ? admin.datagrid.values._sort_order : field_description.options._sort_order %}
{% endif %}
{% spaceless %}
<th class="sonata-ba-list-field-header-{{ field_description.type}} {% if sortable %} sonata-ba-list-field-header-order-{{ sort_by|lower }} {{ sort_active_class }}{% endif %}{% if field_description.options.header_class is defined %} {{ field_description.options.header_class }}{% endif %}"{% if field_description.options.header_style is defined %} style="{{ field_description.options.header_style }}"{% endif %}>
{% if sortable %}<a href="{{ admin.generateUrl('list', sort_parameters) }}">{% endif %}
{% if field_description.getOption('label_icon') %}
<i class="sonata-ba-list-field-header-label-icon {{ field_description.getOption('label_icon') }}" aria-hidden="true"></i>
{% endif %}
{{ field_description.label|trans({}, field_description.translationDomain) }}
{% if sortable %}</a>{% endif %}
</th>
{% endspaceless %}
{% endif %}
{% endfor %}
</tr>
</thead>
{% endblock %}
{% block table_body %}
<tbody>
{% include admin.getTemplate('outer_list_rows_' ~ admin.getListMode()) %}
</tbody>
{% endblock %}
{% block table_footer %}
{% endblock %}
</table>
{% else %}
{% block no_result_content %}
<div class="info-box">
<span class="info-box-icon bg-aqua"><i class="fa fa-arrow-circle-right" aria-hidden="true"></i></span>
<div class="info-box-content">
<span class="info-box-text">{{ 'no_result'|trans({}, 'SonataAdminBundle') }}</span>
<div class="progress">
<div class="progress-bar" style="width: 0%"></div>
</div>
<span class="progress-description">
{% if not app.request.xmlHttpRequest %}
<ul class="list-unstyled">
{% include 'SonataAdminBundle:Button:create_button.html.twig' %}
</ul>
{% endif %}
</span>
</div><!-- /.info-box-content -->
</div>
{% endblock %}
{% endif %}
{{ sonata_block_render_event('sonata.admin.list.table.bottom', { 'admin': admin }) }}
</div>
{% block list_footer %}
{% if admin.datagrid.results|length > 0 %}
<div class="box-footer">
<div class="form-inline clearfix">
{% if not app.request.isXmlHttpRequest %}
<div class="pull-left">
{% if admin.hasRoute('batch') and batchactions|length > 0 %}
{% block batch %}
<script>
{% block batch_javascript %}
jQuery(document).ready(function ($) {
// Toggle individual checkboxes when the batch checkbox is changed
$('#list_batch_checkbox').on('ifChanged change', function () {
var checkboxes = $(this)
.closest('table')
.find('td.sonata-ba-list-field-batch input[type="checkbox"], div.sonata-ba-list-field-batch input[type="checkbox"]')
;
if (window.SONATA_CONFIG.USE_ICHECK) {
checkboxes.iCheck($(this).is(':checked') ? 'check' : 'uncheck');
} else {
checkboxes.prop('checked', this.checked);
}
});
// Add a CSS class to rows when they are selected
$('td.sonata-ba-list-field-batch input[type="checkbox"], div.sonata-ba-list-field-batch input[type="checkbox"]')
.on('ifChanged change', function () {
$(this)
.closest('tr, div.sonata-ba-list-field-batch')
.toggleClass('sonata-ba-list-row-selected', $(this).is(':checked'))
;
})
.trigger('ifChanged')
;
});
{% endblock %}
</script>
{% block batch_actions %}
<label class="checkbox" for="{{ admin.uniqid }}_all_elements">
<input type="checkbox" name="all_elements" id="{{ admin.uniqid }}_all_elements">
{{ 'all_elements'|trans({}, 'SonataAdminBundle') }}
({{ admin.datagrid.pager.nbresults }})
</label>
<select name="action" style="width: auto; height: auto" class="form-control">
{% for action, options in batchactions %}
<option value="{{ action }}">{{ options.label|trans({}, options.translation_domain|default(admin.translationDomain)) }}</option>
{% endfor %}
</select>
{% endblock %}
<input type="submit" class="btn btn-small btn-primary" value="{{ 'btn_batch'|trans({}, 'SonataAdminBundle') }}">
{% endblock %}
{% endif %}
</div>
{# NEXT_MAJOR : remove this assignment #}
{% set export_formats = export_formats|default(admin.exportFormats) %}
<div class="pull-right">
{% if admin.hasRoute('export') and admin.hasAccess('export') and export_formats|length %}
<div class="btn-group">
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
<i class="fa fa-share-square-o" aria-hidden="true"></i>
{{ "label_export_download"|trans({}, "SonataAdminBundle") }}
<span class="caret"></span>
</button>
<ul class="dropdown-menu">
{% for format in export_formats %}
<li>
<a href="{{ admin.generateUrl('export', admin.modelmanager.paginationparameters(admin.datagrid, 0) + {'format' : format}) }}">
<i class="fa fa-arrow-circle-o-down" aria-hidden="true"></i>
{{ ("export_format_" ~ format)|trans({}, 'SonataAdminBundle') }}
</a>
<li>
{% endfor %}
</ul>
</div>
&nbsp;-&nbsp;
{% endif %}
{% block pager_results %}
{% include admin.getTemplate('pager_results') %}
{% endblock %}
</div>
{% endif %}
</div>
{% block pager_links %}
{% if admin.datagrid.pager.haveToPaginate() %}
<hr/>
{% include admin.getTemplate('pager_links') %}
{% endif %}
{% endblock %}
</div>
{% endif %}
{% endblock %}
</div>
{% if admin.hasRoute('batch') and batchactions|length %}
</form>
{% endif %}
</div>
{% endblock %}
{% block list_filters_actions %}
{%- if admin.datagrid.filters|length %}
<ul class="nav navbar-nav navbar-right">
<li class="dropdown sonata-actions">
<a href="#" class="dropdown-toggle sonata-ba-action" data-toggle="dropdown">
<i class="fa fa-filter" aria-hidden="true"></i>
{{ 'link_filters'|trans({}, 'SonataAdminBundle') }} <b class="caret"></b>
</a>
<ul class="dropdown-menu" role="menu">
{% for filter in admin.datagrid.filters if (filter.options['show_filter'] is same as(true) or filter.options['show_filter'] is null) %}
{% set filterActive = ((filter.isActive() or filter.options['show_filter']) and not admin.isDefaultFilter(filter.formName)) %}
<li>
<a href="#" class="sonata-toggle-filter sonata-ba-action" filter-target="filter-{{ admin.uniqid }}-{{ filter.name }}" filter-container="filter-container-{{ admin.uniqid() }}">
<i class="fa {{ (filter.isActive() or filter.options['show_filter']) ? 'fa-check-square-o' : 'fa-square-o' }}"></i>{{ filter.label|trans({}, filter.translationDomain ?: admin.translationDomain) }}
</a>
</li>
{% endfor %}
</ul>
</li>
</ul>
{% endif -%}
{% endblock %}
{% block list_filters %}
{% if admin.datagrid.filters %}
{% form_theme form admin.getTemplate('filter') %}
<div class="col-xs-12 col-md-12 sonata-filters-box" style="display: {{ admin.datagrid.hasDisplayableFilters ? 'block' : 'none' }}" id="filter-container-{{ admin.uniqid() }}">
<div class="box box-primary" >
<div class="box-body">
<form class="sonata-filter-form form-horizontal {{ admin.isChild and 1 == admin.datagrid.filters|length ? 'hide' : '' }}" action="{{ admin.generateUrl('list') }}" method="GET" role="form">
{{ form_errors(form) }}
<div class="row">
<div class="col-sm-9">
{% set withAdvancedFilter = false %}
{% for filter in admin.datagrid.filters %}
{% set filterActive = ((filter.isActive() and filter.options['show_filter'] is null) or (filter.options['show_filter'] is same as(true))) and not admin.isDefaultFilter(filter.formName) %}
{% set filterVisible = filter.options['show_filter'] is same as(true) or filter.options['show_filter'] is null %}
<div class="form-group {% block sonata_list_filter_group_class %}{% endblock %}" id="filter-{{ admin.uniqid }}-{{ filter.name }}" sonata-filter="{{ filterVisible ? 'true' : 'false' }}" style="display: {% if filterActive %}block{% else %}none{% endif %}">
{% if filter.label is not same as(false) %}
<label for="{{ form.children[filter.formName].children['value'].vars.id }}" class="col-sm-3 control-label">{{ filter.label|trans({}, filter.translationDomain ?: admin.translationDomain) }}</label>
{% endif %}
{% set attr = form.children[filter.formName].children['type'].vars.attr|default({}) %}
<div class="col-sm-4 advanced-filter">
{{ form_widget(form.children[filter.formName].children['type'], {'attr': attr}) }}
</div>
<div class="col-sm-4">
{{ form_widget(form.children[filter.formName].children['value']) }}
</div>
<div class="col-sm-1">
<label class="control-label">
<a href="#" class="sonata-toggle-filter sonata-ba-action" filter-target="filter-{{ admin.uniqid }}-{{ filter.name }}" filter-container="filter-container-{{ admin.uniqid() }}">
<i class="fa fa-minus-circle" aria-hidden="true"></i>
</a>
</label>
</div>
</div>
{% if filter.options['advanced_filter'] %}
{% set withAdvancedFilter = true %}
{% endif %}
{% endfor %}
</div>
<div class="col-sm-3 text-center">
<input type="hidden" name="filter[_page]" id="filter__page" value="1">
{% set foo = form.children['_page'].setRendered() %}
{{ form_rest(form) }}
<div class="form-group">
<button type="submit" class="btn btn-primary">
<i class="fa fa-filter" aria-hidden="true"></i> {{ 'btn_filter'|trans({}, 'SonataAdminBundle') }}
</button>
<a class="btn btn-default" href="{{ admin.generateUrl('list', {filters: 'reset'}) }}">
{{ 'link_reset_filter'|trans({}, 'SonataAdminBundle') }}
</a>
</div>
{% if withAdvancedFilter %}
<div class="form-group">
<a href="#" data-toggle="advanced-filter">
<i class="fa fa-cogs" aria-hidden="true"></i>
{{ 'btn_advanced_filters'|trans({}, 'SonataAdminBundle') }}
</a>
</div>
{% endif %}
</div>
</div>
{% for paramKey, paramValue in admin.persistentParameters %}
<input type="hidden" name="{{ paramKey }}" value="{{ paramValue }}">
{% endfor %}
</form>
</div>
</div>
</div>
{% endif %}
{% endblock %}

View File

@@ -0,0 +1,71 @@
{#
This file is part of the Sonata package.
(c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
#}
<td class="sonata-ba-list-field sonata-ba-list-field-{{ field_description.type }}" objectId="{{ admin.id(object) }}"{% if field_description.options.row_align is defined %} style="text-align:{{ field_description.options.row_align }}"{% endif %}>
{% set route = field_description.options.route.name|default(null) %}
{% if
field_description.options.identifier is defined
and route
and admin.hasRoute(route)
and admin.hasAccess(route, route in ['show', 'edit'] ? object : null)
%}
<a class="sonata-link-identifier" href="{{ admin.generateObjectUrl(route, object, field_description.options.route.parameters) }}">
{%- block field %}
{% spaceless %}
{% if field_description.options.collapse is defined %}
{% set collapse = field_description.options.collapse %}
<div class="sonata-readmore"
data-readmore-height="{{ collapse.height|default(40) }}"
data-readmore-more="{{ collapse.more|default('read_more')|trans({}, 'SonataAdminBundle') }}"
data-readmore-less="{{ collapse.less|default('read_less')|trans({}, 'SonataAdminBundle') }}">{{ value }}</div>
{% else %}
{{ value }}
{% endif %}
{% endspaceless %}
{% endblock -%}
</a>
{% else %}
{% set isEditable = field_description.options.editable is defined and field_description.options.editable and admin.hasAccess('edit', object) %}
{% set xEditableType = field_description.type|sonata_xeditable_type %}
{% if isEditable and xEditableType %}
{% set url = path(
'sonata_admin_set_object_field_value',
admin.getPersistentParameters|default([])|merge({
'context': 'list',
'field': field_description.name,
'objectId': admin.id(object),
'code': admin.code(object)
})
) %}
{% if field_description.type == 'date' and value is not empty %}
{% set data_value = value.format('Y-m-d') %}
{% elseif field_description.type == 'boolean' and value is empty %}
{% set data_value = 0 %}
{% else %}
{% set data_value = value %}
{% endif %}
<span {% block field_span_attributes %}class="x-editable"
data-type="{{ xEditableType }}"
data-value="{{ data_value }}"
data-title="{{ field_description.label|trans({}, field_description.translationDomain) }}"
data-pk="{{ admin.id(object) }}"
data-url="{{ url }}" {% endblock %}>
{{ block('field') }}
</span>
{% else %}
{{ block('field') }}
{% endif %}
{% endif %}
</td>

View File

@@ -0,0 +1,25 @@
{#
This file is part of the Sonata package.
(c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
#}
<span class="sonata-ba-list-field sonata-ba-list-field-{{ field_description.type }}" objectId="{{ admin.id(object) }}">
{% if
field_description.options.identifier is defined
and field_description.options.route is defined
and admin.hasAccess(field_description.options.route.name, object)
and admin.hasRoute(field_description.options.route.name)
%}
<a href="{{ admin.generateObjectUrl(field_description.options.route.name, object, field_description.options.route.parameters) }}">
{%- block field %}{{ value }}{% endblock -%}
</a>
{% else %}
{{ block('field') }}
{% endif %}
</span>

View File

@@ -0,0 +1,26 @@
{#
This file is part of the Sonata package.
(c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
#}
{% if admin.list.has('batch') and not app.request.isXmlHttpRequest %}
<td class="sonata-ba-list-field sonata-ba-list-field-batch">
{{ object|render_list_element(admin.list['batch']) }}
</td>
{% endif %}
<td class="sonata-ba-list-field sonata-ba-list-field-inline-fields" colspan="{{ admin.list.elements|length - (admin.list.has('_action') + admin.list.has('batch')) }}" objectId="{{ admin.id(object) }}">
{% block row %}{% endblock %}
</td>
{% if admin.list.has('_action') and not app.request.isXmlHttpRequest %}
<td class="sonata-ba-list-field sonata-ba-list-field-_action" objectId="{{ admin.id(object) }}">
{{ object|render_list_element(admin.list['_action']) }}
</td>
{% endif %}

View File

@@ -0,0 +1,20 @@
{#
This file is part of the Sonata package.
(c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
#}
{% for field_description in admin.list.elements %}
{% if field_description.name == '_action' and app.request.isXmlHttpRequest %}
{# Action buttons disabled in ajax view! #}
{% elseif field_description.getOption('ajax_hidden') == true and app.request.isXmlHttpRequest %}
{# Disable fields with 'ajax_hidden' option set to true #}
{% else %}
{{ object|render_list_element(field_description) }}
{% endif %}
{% endfor %}

View File

@@ -0,0 +1,119 @@
{#
This file is part of the Sonata package.
(c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
#}
{% extends base_template %}
{% block title %}
{{ "title_show"|trans({'%name%': admin.toString(object)|truncate(15) }, 'SonataAdminBundle') }}
{% endblock %}
{% block navbar_title %}
{{ block('title') }}
{% endblock %}
{%- block actions -%}
{% include 'SonataAdminBundle:CRUD:action_buttons.html.twig' %}
{%- endblock -%}
{% block tab_menu %}
{{ knp_menu_render(admin.sidemenu(action), {
'currentClass' : 'active',
'template': sonata_admin.adminPool.getTemplate('tab_menu_template')
}, 'twig') }}
{% endblock %}
{% block show %}
<div class="sonata-ba-view">
{{ sonata_block_render_event('sonata.admin.show.top', { 'admin': admin, 'object': object }) }}
{% set has_tab = (admin.showtabs|length == 1 and admin.showtabs|keys[0] != 'default') or admin.showtabs|length > 1 %}
{% if has_tab %}
<div class="nav-tabs-custom">
<ul class="nav nav-tabs" role="tablist">
{% for name, show_tab in admin.showtabs %}
<li{% if loop.first %} class="active"{% endif %}>
<a href="#tab_{{ admin.uniqid }}_{{ loop.index }}" data-toggle="tab">
<i class="fa fa-exclamation-circle has-errors hide" aria-hidden="true"></i>
{{ show_tab.label|trans({}, show_tab.translation_domain ?: admin.translationDomain) }}
</a>
</li>
{% endfor %}
</ul>
<div class="tab-content">
{% for code, show_tab in admin.showtabs %}
<div
class="tab-pane fade{% if loop.first %} in active{% endif %}"
id="tab_{{ admin.uniqid }}_{{ loop.index }}"
>
<div class="box-body container-fluid">
<div class="sonata-ba-collapsed-fields">
{% if show_tab.description != false %}
<p>{{ show_tab.description|raw }}</p>
{% endif %}
{% set groups = show_tab.groups %}
{{ block('show_groups') }}
</div>
</div>
</div>
{% endfor %}
</div>
</div>
{% elseif admin.showtabs is iterable %}
{% set groups = admin.showtabs.default.groups %}
{{ block('show_groups') }}
{% endif %}
</div>
{{ sonata_block_render_event('sonata.admin.show.bottom', { 'admin': admin, 'object': object }) }}
{% endblock %}
{% block show_groups %}
<div class="row">
{% block field_row %}
{% for code in groups %}
{% set show_group = admin.showgroups[code] %}
<div class="{{ show_group.class|default('col-md-12') }} {{ no_padding|default(false) ? 'nopadding' }}">
<div class="{{ show_group.box_class }}">
<div class="box-header">
<h4 class="box-title">
{% block show_title %}
{{ show_group.label|trans({}, show_group.translation_domain|default(admin.translationDomain)) }}
{% endblock %}
</h4>
</div>
<div class="box-body table-responsive no-padding">
<table class="table">
<tbody>
{% for field_name in show_group.fields %}
{% block show_field %}
<tr class="sonata-ba-view-container">
{% if elements[field_name] is defined %}
{{ elements[field_name]|render_view_element(object)}}
{% endif %}
</tr>
{% endblock %}
{% endfor %}
</tbody>
</table>
</div>
</div>
</div>
{% endfor %}
{% endblock %}
</div>
{% endblock %}

View File

@@ -0,0 +1,20 @@
{#
This file is part of the Sonata package.
(c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
#}
{% extends 'SonataAdminBundle:CRUD:base_show.html.twig' %}
{% block show_field %}
<tr class="sonata-ba-view-container history-audit-compare">
{% if elements[field_name] is defined %}
{{ elements[field_name]|render_view_element_compare(object, object_compare) }}
{% endif %}
</tr>
{% endblock %}

View File

@@ -0,0 +1,40 @@
{#
This file is part of the Sonata package.
(c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
#}
<th{% if(is_diff|default(false)) %} class="diff"{% endif %}>{% block name %}{{ field_description.label|trans({}, field_description.translationDomain ?: admin.translationDomain) }}{% endblock %}</th>
<td>
{%- block field -%}
{% spaceless %}
{% set collapse = field_description.options.collapse|default(false) %}
{% if collapse %}
<div class="sonata-readmore"
data-readmore-height="{{ collapse.height|default(40) }}"
data-readmore-more="{{ collapse.more|default('read_more')|trans({}, 'SonataAdminBundle') }}"
data-readmore-less="{{ collapse.less|default('read_less')|trans({}, 'SonataAdminBundle') }}">
{% block field_value %}
{% if field_description.options.safe %}{{ value|raw }}{% else %}{{ value|nl2br }}{% endif %}
{% endblock %}
</div>
{% else %}
{{ block('field_value') }}
{% endif %}
{% endspaceless %}
{%- endblock -%}
</td>
{% block field_compare %}
{% if(value_compare is defined) %}
<td>
{% set value = value_compare %}
{{ block('field') }}
</td>
{% endif %}
{% endblock %}

View File

@@ -0,0 +1,40 @@
{# NEXT_MAJOR: remove this template #}
{% macro render_groups(admin, object, elements, groups, has_tab, no_padding = false) %}
<div class="row">
{{ block('field_row') }}
</div>
{% endmacro %}
{% block field_row %}
{% for code in groups %}
{% set show_group = admin.showgroups[code] %}
<div class="{{ show_group.class|default('col-md-12') }} {{ no_padding ? 'nopadding' }}">
<div class="{{ show_group.box_class }}">
<div class="box-header">
<h4 class="box-title">
{% block show_title %}
{{ show_group.label|trans({}, show_group.translation_domain ?: admin.translationDomain) }}
{% endblock %}
</h4>
</div>
<div class="box-body table-responsive no-padding">
<table class="table">
<tbody>
{% for field_name in show_group.fields %}
{% block show_field %}
<tr class="sonata-ba-view-container">
{% if elements[field_name] is defined %}
{{ elements[field_name]|render_view_element(object)}}
{% endif %}
</tr>
{% endblock %}
{% endfor %}
</tbody>
</table>
</div>
</div>
</div>
{% endfor %}
{% endblock %}

View File

@@ -0,0 +1,34 @@
{#
This file is part of the Sonata package.
(c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
#}
<div class="form-group{% if field_element.var.errors|length > 0%} has-error{%endif%}" id="sonata-ba-field-container-{{ field_element.vars.id }}">
{% block label %}
{% if field_description.options.name is defined %}
{{ form_label(field_element, field_description.options.name) }}
{% else %}
{{ form_label(field_element) }}
{% endif %}
{% endblock %}
<div class="col-sm-10 col-md-5 sonata-ba-field sonata-ba-field-{{ edit }}-{{ inline }} {% if field_element.vars.errors|length > 0 %}sonata-ba-field-error{% endif %}">
{% block field %}{{ form_widget(field_element) }}{% endblock %}
{% if field_description.help %}
<span class="help-block">{% block help %}{{ field_description.help|raw }}{% endblock %}</span>
{% endif %}
<div class="sonata-ba-field-error-messages">
{% block errors %}{{ form_errors(field_element) }}{% endblock %}
</div>
</div>
</div>

View File

@@ -0,0 +1,59 @@
{#
This file is part of the Sonata package.
(c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
#}
{% extends base_template %}
{%- block actions -%}
{% include 'SonataAdminBundle:CRUD:action_buttons.html.twig' %}
{%- endblock -%}
{% block tab_menu %}{{ knp_menu_render(admin.sidemenu(action), {'currentClass' : 'active', 'template': sonata_admin.adminPool.getTemplate('tab_menu_template')}, 'twig') }}{% endblock %}
{% block content %}
<div class="sonata-ba-delete">
<div class="box box-danger">
<div class="box-header">
{% if batch_translation_domain is not same as(false) %}
{% set action_label = action_label|trans({}, batch_translation_domain) %}
{% endif %}
<h4 class="box-title">{% trans with {'%action%': action_label} from 'SonataAdminBundle' %}title_batch_confirmation{% endtrans %}</h4>
</div>
<div class="box-body">
{% if data.all_elements %}
{{ 'message_batch_all_confirmation'|trans({}, 'SonataAdminBundle') }}
{% else %}
{% transchoice data.idx|length with {'%count%': data.idx|length} from 'SonataAdminBundle' %}message_batch_confirmation{% endtranschoice %}
{% endif %}
</div>
<div class="box-footer clearfix">
<form action="{{ admin.generateUrl('batch', {'filter': admin.filterParameters}) }}" method="POST">
<input type="hidden" name="confirmation" value="ok">
<input type="hidden" name="data" value="{{ data|json_encode }}">
<input type="hidden" name="_sonata_csrf_token" value="{{ csrf_token }}">
<div style="display: none">
{{ form_rest(form) }}
</div>
<button type="submit" class="btn btn-danger">{{ 'btn_execute_batch_action'|trans({}, 'SonataAdminBundle') }}</button>
{% if admin.hasRoute('list') and admin.hasAccess('list') %}
{{ 'delete_or'|trans({}, 'SonataAdminBundle') }}
<a class="btn btn-success" href="{{ admin.generateUrl('list') }}">
<i class="fa fa-th-list" aria-hidden="true"></i> {{ 'link_action_list'|trans({}, 'SonataAdminBundle') }}
</a>
{% endif %}
</form>
</div>
</div>
</div>
{% endblock %}

View File

@@ -0,0 +1,4 @@
<a class="btn btn-link btn-flat" href="{{ action.url }}">
<i class="fa fa-{{ action.icon }}" aria-hidden="true"></i>
{{ action.label|trans({}, action.translation_domain|default('SonataAdminBundle')) }}
</a>

View File

@@ -0,0 +1,19 @@
{% if admin.subClasses is empty %}
<a class="btn btn-link btn-flat" href="{{ action.url }}">
<i class="fa fa-{{ action.icon }}" aria-hidden="true"></i>
{{ action.label|trans({}, action.translation_domain|default('SonataAdminBundle')) }}
</a>
{% else %}
<a class="btn btn-link btn-flat dropdown-toggle" data-toggle="dropdown" href="#">
<i class="fa fa-{{ action.icon }}" aria-hidden="true"></i>
{{ action.label|trans({}, action.translation_domain|default('SonataAdminBundle')) }}
<span class="caret"></span>
</a>
<ul class="dropdown-menu">
{% for subclass in admin.subclasses|keys %}
<li>
<a href="{{ admin.generateUrl('create', {'subclass': subclass}) }}">{{ subclass|trans({}, action.translation_domain|default('SonataAdminBundle')) }}</a>
</li>
{% endfor %}
</ul>
{% endif %}

View File

@@ -0,0 +1,47 @@
{#
This file is part of the Sonata package.
(c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
#}
{% extends base_template %}
{%- block actions -%}
{% include 'SonataAdminBundle:CRUD:action_buttons.html.twig' %}
{%- endblock -%}
{% block tab_menu %}{{ knp_menu_render(admin.sidemenu(action), {'currentClass' : 'active', 'template': sonata_admin.adminPool.getTemplate('tab_menu_template')}, 'twig') }}{% endblock %}
{% block content %}
<div class="sonata-ba-delete">
<div class="box box-danger">
<div class="box-header">
<h3 class="box-title">{{ 'title_delete'|trans({}, 'SonataAdminBundle') }}</h3>
</div>
<div class="box-body">
{{ 'message_delete_confirmation'|trans({'%object%': admin.toString(object)}, 'SonataAdminBundle') }}
</div>
<div class="box-footer clearfix">
<form method="POST" action="{{ admin.generateObjectUrl('delete', object) }}">
<input type="hidden" name="_method" value="DELETE">
<input type="hidden" name="_sonata_csrf_token" value="{{ csrf_token }}">
<button type="submit" class="btn btn-danger"><i class="fa fa-trash" aria-hidden="true"></i> {{ 'btn_delete'|trans({}, 'SonataAdminBundle') }}</button>
{% if admin.hasRoute('edit') and admin.hasAccess('edit', object) %}
{{ 'delete_or'|trans({}, 'SonataAdminBundle') }}
<a class="btn btn-success" href="{{ admin.generateObjectUrl('edit', object) }}">
<i class="fa fa-pencil" aria-hidden="true"></i>
{{ 'link_action_edit'|trans({}, 'SonataAdminBundle') }}</a>
{% endif %}
</form>
</div>
</div>
</div>
{% endblock %}

View File

@@ -0,0 +1,26 @@
{#
This file is part of the Sonata package.
(c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
#}
{%- spaceless %}
{% if value %}
{% set text = 'label_type_yes'|trans({}, 'SonataAdminBundle') %}
{% else %}
{% set text = 'label_type_no'|trans({}, 'SonataAdminBundle') %}
{% endif %}
{% if field_description.options.inverse|default(false) ? not value : value %}
{% set class = 'label-success' %}
{% else %}
{% set class = 'label-danger' %}
{% endif %}
<span class="label {{ class }}">{{ text }}</span>
{% endspaceless -%}

View File

@@ -0,0 +1,12 @@
{#
This file is part of the Sonata package.
(c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
#}
{% extends 'SonataAdminBundle:CRUD:base_edit.html.twig' %}

View File

@@ -0,0 +1,18 @@
{#
This file is part of the Sonata package.
(c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
#}
{% extends base_template %}
{% block field %}
<span class="edit">
{{ form_widget(field_element, {'attr': {'class' : 'title'}}) }}
</span>
{% endblock %}

View File

@@ -0,0 +1,29 @@
{#
This file is part of the Sonata package.
(c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
#}
<div>
<div class="sonata-ba-field {% if field_element.vars.errors|length > 0 %}sonata-ba-field-error{% endif %}">
{% block field %}{{ form_widget(field_element) }}{% endblock %}
{% block label %}
{% if field_description.options.name is defined %}
{{ form_label(field_element, field_description.options.name) }}
{% else %}
{{ form_label(field_element) }}
{% endif %}
<br>
{% endblock %}
<div class="sonata-ba-field-error-messages">
{% block errors %}{{ form_errors(field_element) }}{% endblock %}
</div>
</div>
</div>

View File

@@ -0,0 +1,14 @@
{#
This file is part of the Sonata package.
(c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
#}
{% extends base_template %}
{% block field %}{{ form_widget(field_element, {'attr': {'class' : 'title'}}) }}{% endblock %}

View File

@@ -0,0 +1,14 @@
{#
This file is part of the Sonata package.
(c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
#}
{% extends base_template %}
{% block field %}{{ form_widget(field_element, {'attr': {'class' : 'title'}}) }}{% endblock %}

View File

@@ -0,0 +1,12 @@
{#
This file is part of the Sonata package.
(c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
#}
{% extends base_template %}

View File

@@ -0,0 +1,14 @@
{#
This file is part of the Sonata package.
(c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
#}
{% extends base_template %}
{% block field %}{{ form_widget(field_element, {'attr': {'class' : 'title'}}) }}{% endblock %}

View File

@@ -0,0 +1,14 @@
{#
This file is part of the Sonata package.
(c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
#}
{% extends base_template %}
{% block field %}{{ form_widget(field_element, {'attr': {'class' : 'title'}}) }}{% endblock %}

View File

@@ -0,0 +1,12 @@
{#
This file is part of the Sonata package.
(c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
#}
{% extends 'SonataAdminBundle:CRUD:base_history.html.twig' %}

View File

@@ -0,0 +1,12 @@
{#
This file is part of the Sonata package.
(c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
#}
{{ revision.timestamp|date }}

View File

@@ -0,0 +1,12 @@
{#
This file is part of the Sonata package.
(c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
#}
{% extends 'SonataAdminBundle:CRUD:base_list.html.twig' %}

View File

@@ -0,0 +1,20 @@
{#
This file is part of the Sonata package.
(c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
#}
{% extends admin.getTemplate('base_list_field') %}
{% block field %}
<div class="btn-group">
{% for actions in field_description.options.actions %}
{% include actions.template %}
{% endfor %}
</div>
{% endblock %}

View File

@@ -0,0 +1,17 @@
{#
This file is part of the Sonata package.
(c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
#}
{% if admin.hasAccess('delete', object) and admin.hasRoute('delete') %}
<a href="{{ admin.generateObjectUrl('delete', object) }}" class="btn btn-sm btn-default delete_link" title="{{ 'action_delete'|trans({}, 'SonataAdminBundle') }}">
<i class="fa fa-times" aria-hidden="true"></i>
{{ 'action_delete'|trans({}, 'SonataAdminBundle') }}
</a>
{% endif %}

View File

@@ -0,0 +1,17 @@
{#
This file is part of the Sonata package.
(c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
#}
{% if admin.hasAccess('edit', object) and admin.hasRoute('edit') %}
<a href="{{ admin.generateObjectUrl('edit', object) }}" class="btn btn-sm btn-default edit_link" title="{{ 'action_edit'|trans({}, 'SonataAdminBundle') }}">
<i class="fa fa-pencil" aria-hidden="true"></i>
{{ 'action_edit'|trans({}, 'SonataAdminBundle') }}
</a>
{% endif %}

View File

@@ -0,0 +1,17 @@
{#
This file is part of the Sonata package.
(c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
#}
{% if admin.hasAccess('show', object) and admin.hasRoute('show') %}
<a href="{{ admin.generateObjectUrl('show', object) }}" class="btn btn-sm btn-default view_link" title="{{ 'action_show'|trans({}, 'SonataAdminBundle') }}">
<i class="fa fa-eye" aria-hidden="true"></i>
{{ 'action_show'|trans({}, 'SonataAdminBundle') }}
</a>
{% endif %}

View File

@@ -0,0 +1,16 @@
{#
This file is part of the Sonata package.
(c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
#}
{% extends admin.getTemplate('base_list_field') %}
{% block field %}
<input type="checkbox" name="idx[]" value="{{ admin.id(object) }}">
{% endblock %}

View File

@@ -0,0 +1,19 @@
{#
This file is part of the Sonata package.
(c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
#}
{% extends admin.getTemplate('base_list_field') %}
{% block field %}
<a class="btn btn-primary" href="{{ admin.generateUrl('list') }}">
<i class="fa fa-check" aria-hidden="true"></i>
{{ 'list_select'|trans({}, 'SonataAdminBundle') }}
</a>
{% endblock %}

View File

@@ -0,0 +1,17 @@
{#
This file is part of the Sonata package.
(c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
#}
{% import 'SonataAdminBundle:CRUD:base_array_macro.html.twig' as list %}
{% extends admin.getTemplate('base_list_field') %}
{% block field %}
{{ list.render_array(value, field_description.options.inline is not defined or field_description.options.inline) }}
{% endblock %}

View File

@@ -0,0 +1,28 @@
{#
This file is part of the Sonata package.
(c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
#}
{% extends admin.getTemplate('base_list_field') %}
{% set isEditable = field_description.options.editable is defined and field_description.options.editable and admin.hasAccess('edit', object) %}
{% set xEditableType = field_description.type|sonata_xeditable_type %}
{% if isEditable and xEditableType %}
{% block field_span_attributes %}
{% spaceless %}
{{ parent() }}
data-source="[{value: 0, text: '{%- trans from 'SonataAdminBundle' %}label_type_no{% endtrans -%}'},{value: 1, text: '{%- trans from 'SonataAdminBundle' %}label_type_yes{% endtrans -%}'}]"
{% endspaceless %}
{% endblock %}
{% endif %}
{% block field %}
{%- include 'SonataAdminBundle:CRUD:display_boolean.html.twig' -%}
{% endblock %}

View File

@@ -0,0 +1,67 @@
{#
This file is part of the Sonata package.
(c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
#}
{% extends admin.getTemplate('base_list_field') %}
{% set is_editable =
field_description.options.editable is defined and
field_description.options.editable and
admin.hasAccess('edit', object)
%}
{% set x_editable_type = field_description.type|sonata_xeditable_type %}
{% if is_editable and x_editable_type %}
{% block field_span_attributes %}
{% spaceless %}
{{ parent() }}
data-source="{{ field_description|sonata_xeditable_choices|json_encode }}"
{% endspaceless %}
{% endblock %}
{% endif %}
{% block field %}
{% spaceless %}
{% if field_description.options.choices is defined %}
{% if field_description.options.multiple is defined and field_description.options.multiple==true and value is iterable %}
{% set result = '' %}
{% set delimiter = field_description.options.delimiter|default(', ') %}
{% for val in value %}
{% if result is not empty %}
{% set result = result ~ delimiter %}
{% endif %}
{% if field_description.options.choices[val] is defined %}
{% if field_description.options.catalogue is not defined %}
{% set result = result ~ field_description.options.choices[val] %}
{% else %}
{% set result = result ~ field_description.options.choices[val]|trans({}, field_description.options.catalogue) %}
{% endif %}
{% else %}
{% set result = result ~ val %}
{% endif %}
{% endfor %}
{% set value = result %}
{% elseif value in field_description.options.choices|keys %}
{% if field_description.options.catalogue is not defined %}
{% set value = field_description.options.choices[value] %}
{% else %}
{% set value = field_description.options.choices[value]|trans({}, field_description.options.catalogue) %}
{% endif %}
{% endif %}
{% endif %}
{{ value }}
{% endspaceless %}
{% endblock %}

View File

@@ -0,0 +1,18 @@
{#
This file is part of the Sonata package.
(c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
#}
{% extends admin.getTemplate('base_list_field') %}
{% block field %}
{% if value is not null %}
{{ field_description.options.currency }} {{ value }}
{% endif %}
{% endblock %}

View File

@@ -0,0 +1,22 @@
{#
This file is part of the Sonata package.
(c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
#}
{% extends admin.getTemplate('base_list_field') %}
{% block field%}
{%- if value is empty -%}
&nbsp;
{%- elseif field_description.options.format is defined -%}
{{ value|date(field_description.options.format) }}
{%- else -%}
{{ value|date('F j, Y') }}
{%- endif -%}
{% endblock %}

View File

@@ -0,0 +1,25 @@
{#
This file is part of the Sonata package.
(c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
#}
{% extends admin.getTemplate('base_list_field') %}
{% block field %}
{%- if value is empty -%}
&nbsp;
{%- elseif field_description.options.format is defined -%}
{% set timezone = field_description.options.timezone is defined ? field_description.options.timezone : null %}
{{ value|date(field_description.options.format, timezone) }}
{%- elseif field_description.options.timezone is defined -%}
{{ value|date(null, field_description.options.timezone) }}
{%- else -%}
{{ value|date }}
{%- endif -%}
{% endblock %}

View File

@@ -0,0 +1,16 @@
{#
This file is part of the Sonata package.
(c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
#}
{% extends admin.getTemplate('base_list_field') %}
{% block field %}
{% include 'SonataAdminBundle:CRUD:_email_link.html.twig' %}
{% endblock %}

View File

@@ -0,0 +1,20 @@
{% extends admin.getTemplate('base_list_field') %}
{% block field %}
{%- if value is empty -%}
&nbsp;
{% else %}
{%- if field_description.options.truncate is defined -%}
{% set truncate = field_description.options.truncate %}
{% set length = truncate.length|default(30) %}
{% set preserve = truncate.preserve|default(false) %}
{% set separator = truncate.separator|default('...') %}
{{ value|striptags|truncate(length, preserve, separator)|raw }}
{%- else -%}
{%- if field_description.options.strip is defined -%}
{% set value = value|striptags %}
{%- endif -%}
{{ value|raw }}
{% endif %}
{% endif %}
{% endblock %}

View File

@@ -0,0 +1,12 @@
{#
This file is part of the Sonata package.
(c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
#}
{% extends 'SonataAdminBundle:CRUD:base_list_inner_row.html.twig' %}

View File

@@ -0,0 +1,16 @@
{#
This file is part of the Sonata package.
(c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
#}
{% for object in admin.datagrid.results %}
<tr>
{% include admin.getTemplate('inner_list_row') %}
</tr>
{% endfor %}

View File

@@ -0,0 +1,86 @@
{#
This file is part of the Sonata package.
(c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
#}
<!--
This template can be customized to match your needs. You should only extends the template and used the differents block to customize the view:
- sonata_mosaic_default_view
- sonata_mosaic_hover_view
- sonata_mosaic_description
-->
<tr>
<td colspan="{{ admin.list.elements|length - (app.request.isXmlHttpRequest ? (admin.list.has('_action') + admin.list.has('batch')) : 0) }}">
<div class="row">
{% for object in admin.datagrid.results %}
{% set meta = admin.getObjectMetadata(object) %}
<div class="col-xs-6 col-sm-3 mosaic-box sonata-ba-list-field-batch sonata-ba-list-field" objectId="{{ admin.id(object) }}">
<div class="mosaic-box-outter">
<div class="mosaic-inner-box">
{#
This box will be display when the mouse is not on the box
#}
<div class="mosaic-inner-box-default">
{% block sonata_mosaic_background %}
<img src="{{ meta.image }}" alt="" />
{% endblock %}
{% block sonata_mosaic_default_view %}
<span class="mosaic-box-label label label-primary pull-right">#{{ admin.id(object) }}</span>
{% endblock %}
</div>
{#
This box will be display when the mouse is on the box
You can add more description
#}
<div class="mosaic-inner-box-hover">
{% block sonata_mosaic_hover_view %}
<span class="mosaic-box-label label label-primary pull-right">#{{ admin.id(object) }}</span>
{{ meta.description }}
{% endblock %}
</div>
</div>
{# NEXT_MAJOR : remove this assignment #}
{% set export_formats = export_formats|default(admin.getExportFormats) %}
<div class="mosaic-inner-text">
{% if (admin.hasRoute('batch') and batchactions|length > 0) or (admin.hasRoute('export') and admin.hasAccess('export') and export_formats|length) %}
<input type="checkbox" name="idx[]" value="{{ admin.id(object) }}">
{% else %}
&nbsp;
{% endif %}
{% block sonata_mosaic_description %}
{% if admin.hasAccess('edit', object) and admin.hasRoute('edit') %}
<a class="mosaic-inner-link" href="{{ admin.generateUrl('edit', {'id' : object|sonata_urlsafeid(admin) }) }}">{{ meta.title|truncate(40) }}</a>
{% elseif admin.hasAccess('show', object) and admin.hasRoute('show') %}
<a class="mosaic-inner-link" href="{{ admin.generateUrl('show', {'id' : object|sonata_urlsafeid(admin) }) }}">{{ meta.title|truncate(40) }}</a>
{% else %}
{{ meta.title|truncate(40) }}
{% endif %}
{% endblock %}
</div>
</div>
</div>
{% if loop.index % 4 == 0 %}
<div class="clearfix hidden-xs"></div>
{% endif %}
{% if loop.index % 2 == 0 %}
<div class="clearfix visible-xs"></div>
{% endif %}
{% endfor %}
</div>
</td>
</tr>

View File

@@ -0,0 +1,17 @@
{#
This file is part of the Sonata package.
(c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
#}
{% extends admin.getTemplate('base_list_field') %}
{% block field %}
{% set value = value * 100 %}
{{ value }} %
{% endblock %}

View File

@@ -0,0 +1,12 @@
{#
This file is part of the Sonata package.
(c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
#}
{% extends admin.getTemplate('base_list_field') %}

View File

@@ -0,0 +1,20 @@
{#
This file is part of the Sonata package.
(c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
#}
{% extends admin.getTemplate('base_list_field') %}
{% block field %}
{%- if value is empty -%}
&nbsp;
{%- else -%}
{{ value|date('H:i:s') }}
{%- endif -%}
{% endblock %}

View File

@@ -0,0 +1,19 @@
{#
This file is part of the Sonata package.
(c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
#}
{% extends admin.getTemplate('base_list_field') %}
{% block field%}
{% set translationDomain = field_description.options.catalogue|default(admin.translationDomain) %}
{% set valueFormat = field_description.options.format|default('%s') %}
{{valueFormat|format(value)|trans({}, translationDomain)}}
{% endblock %}

View File

@@ -0,0 +1,55 @@
{#
This file is part of the Sonata package.
(c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
#}
{% extends admin.getTemplate('base_list_field') %}
{% block field %}
{% spaceless %}
{% if value is empty %}
&nbsp;
{% else %}
{% if field_description.options.url is defined %}
{# target url is string #}
{% set url_address = field_description.options.url %}
{% elseif field_description.options.route is defined and field_description.options.route.name not in ['edit', 'show'] %}
{# target url is Symfony route #}
{% set parameters = field_description.options.route.parameters|default([]) %}
{# route with paramter related to object ID #}
{% if field_description.options.route.identifier_parameter_name is defined %}
{% set parameters = parameters|merge({(field_description.options.route.identifier_parameter_name):(admin.normalizedidentifier(object))}) %}
{% endif %}
{% if field_description.options.route.absolute|default(false) %}
{% set url_address = url(field_description.options.route.name, parameters) %}
{% else %}
{% set url_address = path(field_description.options.route.name, parameters) %}
{% endif %}
{% else %}
{# value is url #}
{% set url_address = value %}
{% endif %}
{% if field_description.options.hide_protocol|default(false) %}
{% set value = value|replace({'http://': '', 'https://': ''}) %}
{% endif %}
<a
href="{{ url_address }}"
{%- for attribute, value in field_description.options.attributes|default([]) %}
{{ attribute }}="{{ value|escape('html_attr') }}"
{%- endfor -%}
>
{{- value -}}
</a>
{% endif %}
{% endspaceless %}
{% endblock %}

View File

@@ -0,0 +1,59 @@
{#
This file is part of the Sonata package.
(c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
#}
{% extends 'SonataAdminBundle:CRUD:edit.html.twig' %}
{% block actions %}
{% endblock %}
{% block side_menu %}
{% endblock %}
{% block formactions %}
<button class="btn btn-success" type="submit" name="btn_preview_approve">
<i class="fa fa-check" aria-hidden="true"></i>
{{ 'btn_preview_approve'|trans({}, 'SonataAdminBundle') }}
</button>
<button class="btn btn-danger" type="submit" name="btn_preview_decline">
<i class="fa fa-times" aria-hidden="true"></i>
{{ 'btn_preview_decline'|trans({}, 'SonataAdminBundle') }}
</button>
{% endblock %}
{% block preview %}
<div class="sonata-ba-view">
{% for name, view_group in admin.showgroups %}
<table class="table table-bordered">
{% if name %}
<tr class="sonata-ba-view-title">
<td colspan="2">
{{ name|trans({}, admin.translationdomain) }}
</td>
</tr>
{% endif %}
{% for field_name in view_group.fields %}
<tr class="sonata-ba-view-container">
{% if admin.show[field_name] is defined %}
{{ admin.show[field_name]|render_view_element(object) }}
{% endif %}
</tr>
{% endfor %}
</table>
{% endfor %}
</div>
{% endblock %}
{% block form %}
<div class="sonata-preview-form-container">
{{ parent() }}
</div>
{% endblock %}

View File

@@ -0,0 +1,38 @@
{#
This file is part of the Sonata package.
(c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
#}
{% extends base_template %}
{% block title %}{{ 'title_select_subclass'|trans({}, 'SonataAdminBundle') }}{% endblock %}
{% block content %}
<div class="box box-success">
<div class="box-header">
<h3 class="box-title">
{{ block('title') }}
</h3>
</div>
<div class="box-body">
{% for subclass in admin.subclasses|keys %}
<div class="col-lg-2 col-md-3 col-sm-4 col-xs-6">
<a href="{{ admin.generateUrl(action, {'subclass': subclass }) }}"
class="btn btn-app btn-block"
>
<i class="fa fa-plus-square" aria-hidden="true"></i>
{{ subclass|trans({}, admin.translationdomain|default('SonataAdminBundle')) }}
</a>
</div>
{% else %}
<span class="alert alert-info">{{ 'no_subclass_available'|trans({}, 'SonataAdminBundle') }}</span>
{% endfor %}
<div class="clearfix"></div>
</div>
</div>
{% endblock %}

View File

@@ -0,0 +1,12 @@
{#
This file is part of the Sonata package.
(c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
#}
{% extends 'SonataAdminBundle:CRUD:base_show.html.twig' %}

View File

@@ -0,0 +1,17 @@
{#
This file is part of the Sonata package.
(c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
#}
{% import 'SonataAdminBundle:CRUD:base_array_macro.html.twig' as show %}
{% extends 'SonataAdminBundle:CRUD:base_show_field.html.twig' %}
{% block field%}
{{ show.render_array(value, field_description.options.inline|default(false)) }}
{% endblock %}

View File

@@ -0,0 +1,16 @@
{#
This file is part of the Sonata package.
(c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
#}
{% extends 'SonataAdminBundle:CRUD:base_show_field.html.twig' %}
{% block field %}
{%- include 'SonataAdminBundle:CRUD:display_boolean.html.twig' -%}
{% endblock %}

View File

@@ -0,0 +1,55 @@
{#
This file is part of the Sonata package.
(c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
#}
{% extends 'SonataAdminBundle:CRUD:base_show_field.html.twig' %}
{% block field%}
{% spaceless %}
{% if field_description.options.choices is defined %}
{% if field_description.options.multiple is defined and field_description.options.multiple==true and value is iterable %}
{% set result = '' %}
{% set delimiter = field_description.options.delimiter|default(', ') %}
{% for val in value %}
{% if result is not empty %}
{% set result = result ~ delimiter %}
{% endif %}
{% if field_description.options.choices[val] is defined %}
{% if field_description.options.catalogue is not defined %}
{% set result = result ~ field_description.options.choices[val] %}
{% else %}
{% set result = result ~ field_description.options.choices[val]|trans({}, field_description.options.catalogue) %}
{% endif %}
{% else %}
{% set result = result ~ val %}
{% endif %}
{% endfor %}
{% set value = result %}
{% elseif value in field_description.options.choices|keys %}
{% if field_description.options.catalogue is not defined %}
{% set value = field_description.options.choices[value] %}
{% else %}
{% set value = field_description.options.choices[value]|trans({}, field_description.options.catalogue) %}
{% endif %}
{% endif %}
{% endif %}
{% if field_description.options.safe %}
{{ value|raw }}
{% else %}
{{ value }}
{% endif %}
{% endspaceless %}
{% endblock %}

View File

@@ -0,0 +1,12 @@
{#
This file is part of the Sonata package.
(c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
#}
{% extends 'SonataAdminBundle:CRUD:base_show_compare.html.twig' %}

View File

@@ -0,0 +1,18 @@
{#
This file is part of the Sonata package.
(c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
#}
{% extends 'SonataAdminBundle:CRUD:base_show_field.html.twig' %}
{% block field %}
{% if value is not null %}
{{ field_description.options.currency }} {{ value }}
{% endif %}
{% endblock %}

View File

@@ -0,0 +1,22 @@
{#
This file is part of the Sonata package.
(c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
#}
{% extends 'SonataAdminBundle:CRUD:base_show_field.html.twig' %}
{% block field%}
{%- if value is empty -%}
&nbsp;
{%- elseif field_description.options.format is defined -%}
{{ value|date(field_description.options.format) }}
{%- else -%}
{{ value|date('F j, Y') }}
{%- endif -%}
{% endblock %}

View File

@@ -0,0 +1,22 @@
{#
This file is part of the Sonata package.
(c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
#}
{% extends 'SonataAdminBundle:CRUD:base_show_field.html.twig' %}
{% block field %}
{%- if value is empty -%}
&nbsp;
{%- elseif field_description.options.format is defined -%}
{{ value|date(field_description.options.format) }}
{%- else -%}
{{ value|date }}
{%- endif -%}
{% endblock %}

Some files were not shown because too many files have changed in this diff Show More