base_list_field.html.twig 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. {#
  2. This file is part of the Sonata package.
  3. (c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
  4. For the full copyright and license information, please view the LICENSE
  5. file that was distributed with this source code.
  6. #}
  7. <td class="sonata-ba-list-field sonata-ba-list-field-{{ field_description.type }}" objectId="{{ admin.id(object) }}">
  8. {% set route = field_description.options.route.name|default(null) %}
  9. {% set action = route == 'show' ? 'VIEW' : route|upper %}
  10. {% if
  11. field_description.options.identifier is defined
  12. and route
  13. and action
  14. and admin.hasRoute(route)
  15. and admin.isGranted(action, action in ['VIEW', 'EDIT'] ? object : null)
  16. %}
  17. <a class="sonata-link-identifier" href="{{ admin.generateObjectUrl(route, object, field_description.options.route.parameters) }}">
  18. {%- block field %}{{ value }}{% endblock -%}
  19. </a>
  20. {% else %}
  21. {% set isEditable = field_description.options.editable is defined and field_description.options.editable and admin.isGranted('EDIT', object) %}
  22. {% set xEditableType = field_description.type|sonata_xeditable_type %}
  23. {% if isEditable and xEditableType %}
  24. {% set url = path('sonata_admin_set_object_field_value', { 'context': 'list', 'field': field_description.name, 'objectId': admin.id(object), 'code': admin.code(object) }|merge(admin.getPersistentParameters|default([])) ) %}
  25. <span {% block field_span_attributes %}class="x-editable" data-type="{{ xEditableType }}" data-value="{{ value }}" data-title="{{ field_description.label|trans({}, field_description.translationDomain) }}" data-pk="{{ admin.id(object) }}" data-url="{{ url }}" {% endblock %}>
  26. {{ block('field') }}
  27. </span>
  28. {% else %}
  29. {{ block('field') }}
  30. {% endif %}
  31. {% endif %}
  32. </td>