Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@ language: php

matrix:
include:
- php: 7.1
- php: 7.2
- php: 7.3
- php: 7.4

cache:
directories:
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ The behavior of the relation list is completely controlled by the field definiti

Refer to [the general information](doc/GENERAL.md) and [usage documentation](doc/USAGE.md) for more information.

:heavy_exclamation_mark: Upgrade in progress! :heavy_exclamation_mark:

## Installation

The installation uses composer and the general concept for adding bundles to a symfony installation.
Expand Down
11 changes: 5 additions & 6 deletions bundle/Core/FieldType/Mapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
namespace IntProg\EnhancedRelationListBundle\Core\FieldType;

use eZ\Publish\API\Repository\ContentTypeService;
use EzSystems\RepositoryForms\Data\Content\FieldData;
use EzSystems\RepositoryForms\Data\FieldDefinitionData;
use EzSystems\RepositoryForms\FieldType\FieldDefinitionFormMapperInterface;
use EzSystems\RepositoryForms\FieldType\FieldValueFormMapperInterface;
use EzSystems\EzPlatformAdminUi\FieldType\FieldDefinitionFormMapperInterface;
use EzSystems\EzPlatformAdminUi\Form\Data\FieldDefinitionData;
use EzSystems\EzPlatformContentForms\Data\Content\FieldData;
use EzSystems\EzPlatformContentForms\FieldType\FieldValueFormMapperInterface;
use IntProg\EnhancedRelationListBundle\Form\Type\EnhancedRelationListFieldDefinitionAttributesType;
use IntProg\EnhancedRelationListBundle\Form\Type\EnhancedRelationListFieldDefinitionGroupsType;
use IntProg\EnhancedRelationListBundle\Form\Type\EnhancedRelationListType;
Expand Down Expand Up @@ -54,7 +54,7 @@ public function __construct(ContentTypeService $contentTypeService)
*
* @return void
*/
public function mapFieldDefinitionForm(FormInterface $fieldDefinitionForm, FieldDefinitionData $data)
public function mapFieldDefinitionForm(FormInterface $fieldDefinitionForm, FieldDefinitionData $data): void
{
$fieldDefinitionForm
->add(
Expand All @@ -71,7 +71,6 @@ public function mapFieldDefinitionForm(FormInterface $fieldDefinitionForm, Field
ChoiceType::class,
[
'choices' => $this->getContentTypesHash(),
'choices_as_values' => true,
'expanded' => false,
'multiple' => true,
'required' => false,
Expand Down
11 changes: 8 additions & 3 deletions bundle/Core/FieldType/Storage.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
namespace IntProg\EnhancedRelationListBundle\Core\FieldType;

use eZ\Publish\API\Repository\Exceptions\NotFoundException;
use eZ\Publish\Core\MVC\ConfigResolverInterface;
use eZ\Publish\SPI\FieldType\GatewayBasedStorage;
use eZ\Publish\SPI\Persistence\Content\Field;
use eZ\Publish\SPI\Persistence\Content\Type as FieldType;
Expand Down Expand Up @@ -41,13 +42,17 @@ class Storage extends GatewayBasedStorage
*
* @param Handler $contentTypeHandler
* @param RelationAttributeRepository $repository
* @param array $languages
* @param ConfigResolverInterface $configResolver
*/
public function __construct(Handler $contentTypeHandler, RelationAttributeRepository $repository, array $languages)
public function __construct(
Handler $contentTypeHandler,
RelationAttributeRepository $repository,
ConfigResolverInterface $configResolver
)
{
$this->contentTypeHandler = $contentTypeHandler;
$this->repository = $repository;
$this->languages = $languages;
$this->languages = $configResolver->getParameter('languages');
}

/**
Expand Down
9 changes: 5 additions & 4 deletions bundle/Core/FieldType/Type.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
use eZ\Publish\Core\FieldType\FieldType;
use eZ\Publish\Core\FieldType\ValidationError;
use eZ\Publish\Core\FieldType\Value as CoreValue;
use eZ\Publish\SPI\FieldType\Nameable;
use eZ\Publish\SPI\FieldType\Value as SpiValue;
use IntProg\EnhancedRelationListBundle\Core\FieldType\Value\Group;
use IntProg\EnhancedRelationListBundle\Core\FieldType\Value\Relation;
Expand All @@ -28,7 +27,7 @@
* @author Konrad, Steve <s.konrad@wingmail.net>
* @copyright 2018 Intense Programming
*/
class Type extends FieldType implements Nameable
class Type extends FieldType
{
/** @var RelationAttributeRepository $relationAttributeTransformer */
protected $relationAttributeTransformer;
Expand Down Expand Up @@ -130,11 +129,13 @@ public function getFieldTypeIdentifier()
/**
* Returns a human readable string representation from the given $value.
*
* @param SpiValue $value
* @param SpiValue $value
* @param FieldDefinition $fieldDefinition
* @param string $languageCode
*
* @return string
*/
public function getName(SpiValue $value)
public function getName(SpiValue $value, FieldDefinition $fieldDefinition, string $languageCode): string
{
return (string) $value;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

use eZ\Publish\API\Repository\Exceptions\NotFoundException;
use eZ\Publish\API\Repository\LanguageService;
use eZ\Publish\Core\MVC\ConfigResolverInterface;
use IntProg\EnhancedRelationListBundle\Core\DataTransformer\FieldDefinitionAttributesTransformer;
use IntProg\EnhancedRelationListBundle\Service\RelationAttributeRepository;
use Symfony\Component\Form\AbstractType;
Expand All @@ -35,24 +36,25 @@ class EnhancedRelationListFieldDefinitionAttributesType extends AbstractType
/** @var LanguageService $languageService */
protected $languageService;

/** @var array|string[] $languages */
protected $languages;

/**
* EnhancedRelationListFieldDefinitionAttributesType constructor.
*
* @param RelationAttributeRepository $attributeRepository
* @param LanguageService $languageService
* @param array $languages
* @param ConfigResolverInterface $configResolver
*/
public function __construct(
RelationAttributeRepository $attributeRepository,
LanguageService $languageService,
array $languages
ConfigResolverInterface $configResolver
)
{
$this->attributeRepository = $attributeRepository;
$this->languageService = $languageService;
$this->languages = $languages;
$this->languages = $configResolver->getParameter('languages');
}

/**
Expand Down
13 changes: 11 additions & 2 deletions bundle/Form/Type/EnhancedRelationListFieldDefinitionGroupsType.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

use eZ\Publish\API\Repository\Exceptions\NotFoundException;
use eZ\Publish\API\Repository\LanguageService;
use eZ\Publish\Core\MVC\ConfigResolverInterface;
use IntProg\EnhancedRelationListBundle\Core\DataTransformer\FieldDefinitionGroupsTransformer;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
Expand All @@ -28,14 +29,22 @@
*/
class EnhancedRelationListFieldDefinitionGroupsType extends AbstractType
{
/** @var LanguageService $languageService */
protected $languageService;

/** @var array|string[] $languages */
protected $languages;

public function __construct(LanguageService $languageService, array $languages)
/**
* EnhancedRelationListFieldDefinitionGroupsType constructor.
*
* @param LanguageService $languageService
* @param ConfigResolverInterface $configResolver
*/
public function __construct(LanguageService $languageService, ConfigResolverInterface $configResolver)
{
$this->languageService = $languageService;
$this->languages = $languages;
$this->languages = $configResolver->getParameter('languages');
}

/**
Expand Down
1 change: 1 addition & 0 deletions bundle/Resources/assets/js/intprogenhancedrelationlist.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ document.addEventListener('DOMContentLoaded', function _onLoad() {
input: jsonValueInput,
value: JSON.parse(jsonValueInput.value),
cloneContainer: cloneContainer,
udwConfig: JSON.parse(fieldContainer.querySelector('script[data-udw-config]').innerText),
udwContainer: udwContainer,
udwModule: global.eZ.modules.UniversalDiscovery,
settings: JSON.parse(fieldContainer.querySelector('script[data-settings]').innerText),
Expand Down
9 changes: 7 additions & 2 deletions bundle/Resources/config/ez_field_templates.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,13 @@ system:
content_view:
element_simple_link:
default:
controller: 'EzPlatformAdminUiBundle:ContentView:locationView'
template: '@ezdesign/enhanced_relation_list/simple_link.html.twig'
controller: 'ez_content:viewAction'
template: '@ezdesign/enhanced_relation_list/view/default/content/simple_link.html.twig'
match: true
element_simple_text:
default:
controller: 'ez_content:viewAction'
template: '@ezdesign/enhanced_relation_list/view/default/content/simple_text.html.twig'
match: true
fielddefinition_settings_templates:
- {template: '@ezdesign/enhanced_relation_list/fielddefinition_settings.html.twig', priority: 0}
7 changes: 4 additions & 3 deletions bundle/Resources/config/fieldtypes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ services:

IntProg\EnhancedRelationListBundle\Core\FieldType\Storage:
arguments:
- '@ezpublish.spi.persistence.content_type_handler'
- '@IntProg\EnhancedRelationListBundle\Service\RelationAttributeRepository'
- '$languages$'
$contentTypeHandler: '@ezpublish.spi.persistence.content_type_handler'
$repository: '@IntProg\EnhancedRelationListBundle\Service\RelationAttributeRepository'
lazy: true
autowire: true
tags:
- { name: ezpublish.fieldType.externalStorageHandler, alias: intprogenhancedrelationlist }
11 changes: 5 additions & 6 deletions bundle/Resources/config/form.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,15 @@ services:
- { name: form.type }

IntProg\EnhancedRelationListBundle\Form\Type\EnhancedRelationListFieldDefinitionGroupsType:
arguments:
- '@ezpublish.api.service.language'
- '$languages$'
lazy: true
autowire: true
tags:
- { name: form.type }

IntProg\EnhancedRelationListBundle\Form\Type\EnhancedRelationListFieldDefinitionAttributesType:
arguments:
- '@IntProg\EnhancedRelationListBundle\Service\RelationAttributeRepository'
- '@ezpublish.api.service.language'
- '$languages$'
$attributeRepository: '@IntProg\EnhancedRelationListBundle\Service\RelationAttributeRepository'
lazy: true
autowire: true
tags:
- { name: form.type }
4 changes: 1 addition & 3 deletions bundle/Resources/config/templating.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@ services:
class: IntProg\EnhancedRelationListBundle\Templating\Twig\AttributeBlockRenderer
calls:
- [setTwig, ['@twig']]
- [setBaseTemplate, ["$enhanced_relation_list.base_template$"]]
- [setAttributeViewResources, ["$enhanced_relation_list.attribute_templates$"]]
- [setAttributeDefinitionViewResources, ["$enhanced_relation_list.attribute_definition_templates$"]]
lazy: true
autowire: true

intprog.enhanced-relation-list.templating.attribute_block_renderer:
alias: intprog.enhanced-relation-list.templating.attribute_block_renderer.twig
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,16 @@
<script data-settings type="application/json">{{ fieldSettings|json_encode|raw }}</script>
<script data-validation type="application/json">{{ validatorConfiguration|json_encode|raw }}</script>
<script data-errors type="application/json">{{ attribute_errors|json_encode|raw }}</script>
<script data-languages type="application/json">{{ ezpublish.configResolver.parameter('languages')|json_encode|raw }}</script>
<script data-languages type="application/json">{{ ezplatform.configResolver.parameter('languages')|json_encode|raw }}</script>
<script data-udw-config type="application/json">{%- if limit == 1 %}{{ ez_udw_config('single', {
'type': 'object_relation',
'starting_location_id' : fieldSettings.defaultBrowseLocation,
'allowed_content_types': validatorConfiguration.relationValidator.allowedContentTypes
})|raw }}{% else %}{{ ez_udw_config('multiple', {
'type': 'object_relation',
'starting_location_id' : fieldSettings.defaultBrowseLocation,
'allowed_content_types': validatorConfiguration.relationValidator.allowedContentTypes
})|raw }}{% endif %}</script>
</div>

<div><table class="relation-root-table erl-table table drag-clone-container my-0"><tbody> </tbody></table></div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
{% macro render_intprogenhancedrelationlist(content, field, fieldSettings) %}
{% import _self as erl_table_macros %}

{% include '@ezdesign/parts/table_header.html.twig' with {headerText: 'field.attribute.table.head.relations'|trans} %}
{% include '@ezdesign/ui/table_header.html.twig' with {header_text: 'field.attribute.table.head.relations'|trans} %}
<table class="table mb-0">
{{ erl_table_macros.table_head_macro(fieldSettings, field) }}
<tbody>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

{% use 'EzPublishCoreBundle::fielddefinition_settings.html.twig' %}
{% use '@ezdesign/fielddefinition_settings.html.twig' %}

{% trans_default_domain 'enhancedrelationlist_attribute' %}

Expand All @@ -11,18 +11,18 @@
{{- form_widget(form.defaultBrowseLocation) -}}

<div class="mt-1">
<button data-universaldiscovery-title="{{"field_definition.ezobjectrelationlist.selection_root_udw_title"|trans({}, "ezrepoforms_content_type")}}"
<button data-universaldiscovery-title="{{"field_definition.ezobjectrelationlist.selection_root_udw_title"|trans({}, "content_type")}}"
class="ez-button-tree pure-button ez-font-icon ez-button ez-relation-pick-root-button btn btn-secondary btn--udw-relation-default-location"
data-relation-root-input-selector="#{{form.defaultBrowseLocation.vars.id}}"
data-relation-selected-root-name-selector="#{{form.defaultBrowseLocation.vars.id}}-selected-root-name"
data-starting-location-id="1"
data-udw-config="{{ ez_udw_config('single') }}"
data-udw-config="{{ ez_udw_config('single') }}"
>{{"field_definition.ezobjectrelationlist.selection_root_udw_button"|trans({}, "ezrepoforms_content_type")}}</button>
>{{"field_definition.ezobjectrelationlist.selection_root_udw_button"|trans({}, "content_type")}}</button>
</div>
<div id="{{form.defaultBrowseLocation.vars.id}}-selected-root-name">
{% if form.defaultBrowseLocation.vars.value is not empty %}
{{ render( controller( "ez_content:viewLocation", {'locationId': form.defaultBrowseLocation.vars.value, 'viewType': '_platformui_content_name'} ) ) }}
{{ render( controller( "ez_content:viewAction", {'locationId': form.defaultBrowseLocation.vars.value, 'viewType': 'element_simple_text', 'layout': false} ) ) }}
{% endif %}
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<a {% if not content.contentInfo.trashed %}
href="{{ path('_ezpublishLocation', { 'locationId': locationId } ) }}"
href="{{ path('_ez_content_view', { 'contentId': contentId } ) }}"
{% endif %}>
{{ content.getName() }}
{% if content.contentInfo.trashed %}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{{ content.getName() }}
Loading