Skip to content

Commit

Permalink
feat(contentType/field): asset field type add label field (#1055)
Browse files Browse the repository at this point in the history
  • Loading branch information
theus77 authored Oct 25, 2024
1 parent 915cc60 commit 84662f9
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 1 deletion.
3 changes: 3 additions & 0 deletions EMS/core-bundle/src/Form/DataField/AssetFieldType.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ public function buildView(FormView $view, FormInterface $form, array $options):
*/
public function generateMapping(FieldType $current): array
{
$mapping = parent::generateMapping($current);

return [
$current->getName() => \array_merge([
'type' => 'nested',
Expand All @@ -160,6 +162,7 @@ public function generateMapping(FieldType $current): array
EmsFields::CONTENT_FILE_SIZE_FIELD => $this->elasticsearchService->getLongMapping(),
EmsFields::CONTENT_FILE_SIZE_FIELD_ => $this->elasticsearchService->getLongMapping(),
EmsFields::CONTENT_IMAGE_RESIZED_HASH_FIELD => $this->elasticsearchService->getKeywordMapping(),
EmsFields::CONTENT_FILE_TITLE => $mapping[$current->getName()],
],
], \array_filter($current->getMappingOptions())),
];
Expand Down
3 changes: 3 additions & 0 deletions EMS/core-bundle/src/Form/Field/AssetType.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
'class' => 'name',
],
'required' => $options['required'],
])
->add(EmsFields::CONTENT_FILE_TITLE, TextType::class, [
'required' => $options['required'],
]);
}
}
Expand Down
1 change: 1 addition & 0 deletions EMS/core-bundle/src/Resources/views/form/fields.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -983,6 +983,7 @@
{{- form_row(fileItem.sha1) -}}
{{- form_row(fileItem._image_resized_hash) -}}
{{- form_row(fileItem.mimetype) -}}
{{- form_row(fileItem._title) -}}
</div>
</div>
<div class="modal-footer">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@
{% elseif dataField.rawData.files is defined and dataField.rawData.files is iterable %}
<ul class="nav nav-stacked">
{% for item in dataField.rawData.files %}
<li><a href="{{ ems_asset_path(item) }}" target="_blank">{{ item.filename }}</a></li>
<li><a href="{{ ems_asset_path(item) }}" target="_blank"{% if item._title|default %} title="{{ item._title }}"{% endif %}>{{ item.filename }}</a></li>
{% endfor %}
</ul>
{% endif %}
Expand Down

0 comments on commit 84662f9

Please sign in to comment.