Skip to content

Commit

Permalink
Merge branch '5.21' into 5.x
Browse files Browse the repository at this point in the history
  • Loading branch information
Davidmattei committed Sep 19, 2024
2 parents cf82165 + 3a8a094 commit a99ccff
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ public function moveFile(Request $request, string $fileId): JsonResponse
throw new \RuntimeException('Missing target folder id');
}

$folder = $targetFolderId ? $this->mediaLibraryService->getFolder($targetFolderId) : null;
$folder = 'home' !== $targetFolderId ? $this->mediaLibraryService->getFolder($targetFolderId) : null;
$this->mediaLibraryService->moveFile($file, $folder);

$form = $this->formFactory->create(MediaLibraryDocumentFormType::class, $file, ['csrf_protection' => false]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,13 @@ public function getFolder(string $ouuid): MediaLibraryFolder
public function getFolders(): MediaLibraryFolders
{
$query = $this->elasticaService->getBoolQuery();
$query->addMustNot((new NestedQuery())->setPath($this->getConfig()->fieldFile)->setQuery(new Exists($this->getConfig()->fieldFile)));
$query->addMustNot(
(new NestedQuery())
->setPath($this->getConfig()->fieldFile)
->setQuery(new Exists($this->getConfig()->fieldFile))
);
$query->addMust(new Exists($this->getConfig()->fieldPath));
$query->addMust(new Exists($this->getConfig()->fieldFolder));

$folders = new MediaLibraryFolders($this->getConfig());
$scroll = $this->elasticaService->scroll($this->buildSearch($query));
Expand Down
11 changes: 8 additions & 3 deletions EMS/core-bundle/src/Form/DataField/AssetFieldType.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ public static function loadFromDb(array &$data): void
EmsFields::CONTENT_FILE_SIZE_FIELD_ => EmsFields::CONTENT_FILE_SIZE_FIELD,
EmsFields::CONTENT_MIME_TYPE_FIELD_ => EmsFields::CONTENT_MIME_TYPE_FIELD,
] as $newField => $oldField) {
if (!isset($data[$newField]) && isset($data[$oldField])) {
$data[$newField] = $data[$oldField];
}
if (!isset($data[$newField])) {
continue;
}
Expand All @@ -59,11 +62,13 @@ public static function loadFromDb(array &$data): void
foreach ($data as $id => $content) {
if (!\in_array($id, [EmsFields::CONTENT_FILE_HASH_FIELD_, EmsFields::CONTENT_FILE_NAME_FIELD_, EmsFields::CONTENT_FILE_SIZE_FIELD_, EmsFields::CONTENT_MIME_TYPE_FIELD_, EmsFields::CONTENT_FILE_HASH_FIELD, EmsFields::CONTENT_FILE_NAME_FIELD, EmsFields::CONTENT_FILE_SIZE_FIELD, EmsFields::CONTENT_MIME_TYPE_FIELD, EmsFields::CONTENT_IMAGE_RESIZED_HASH_FIELD, EmsFields::CONTENT_FILE_DATE, EmsFields::CONTENT_FILE_AUTHOR, EmsFields::CONTENT_FILE_LANGUAGE, EmsFields::CONTENT_FILE_CONTENT, EmsFields::CONTENT_FILE_TITLE], true)) {
unset($data[$id]);
} elseif (EmsFields::CONTENT_FILE_HASH_FIELD_ !== $id && empty($data[$id])) {
unset($data[EmsFields::CONTENT_FILE_HASH_FIELD_]);
unset($data[EmsFields::CONTENT_FILE_HASH_FIELD]);
}
}

if (empty($data[EmsFields::CONTENT_FILE_HASH_FIELD_])) {
unset($data[EmsFields::CONTENT_FILE_HASH_FIELD_]);
unset($data[EmsFields::CONTENT_FILE_HASH_FIELD]);
}
}

/**
Expand Down
4 changes: 2 additions & 2 deletions demo/skeleton/template_ems/view/overview_media_library.twig
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

{% set columns = [
{ "label": "Path", "template": (block('columnMediaPath')), "orderField": "media_path"},
{ "label": "Folder", "template": "{{ data.source.media_folder }}", "orderField": "media_folder"},
{ "label": "Folder", "template": "{{ data.source.media_folder|default('???') }}", "orderField": "media_folder"},
{ "label": "Last Update", "template": (block('columnLastUpdate')), "orderField": "_finalization_datetime"},
] %}

Expand Down Expand Up @@ -104,7 +104,7 @@

{% block columnMediaPath %}
{% verbatim %}
<a href="{{ path('data.revisions', {ouuid: data.id, type: data.contentType} ) }}">{{ data.source.media_path }}</a>
<a href="{{ path('data.revisions', {ouuid: data.id, type: data.contentType} ) }}">{{ data.source.media_path|default('???') }}</a>
{% endverbatim %}
{% endblock %}

Expand Down

0 comments on commit a99ccff

Please sign in to comment.