Skip to content

Commit

Permalink
feat(admin/release): unpublish revision table use es query (ems-proje…
Browse files Browse the repository at this point in the history
  • Loading branch information
Davidmattei authored Oct 24, 2024
1 parent 7fe7184 commit 14ae11a
Show file tree
Hide file tree
Showing 22 changed files with 229 additions and 288 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -26,26 +26,11 @@
</tr>
</thead>
<tbody>
{% for line in datatable %}
<tr>
{% if datatable.supportsTableActions %}
<td class="{{ datatable.attributeName|e('html_attr') }}-to-select">
{{ block('emsco_form_table_column_action_checkbox') }}
</td>
{% endif %}
{% for column in datatable.columns %}
{{ block(column.tableDataBlock()) }}
{% endfor %}
{% if datatable.itemActions|length > 0 %}
<td data-search="">
{{ block('emsco_form_table_column_row_actions') }}
</td>
{% endif %}
</tr>
{% endfor %}
{# ajax loaded always #}
</tbody>
</table>
</div>

{% if datatable.supportsTableActions and datatable.tableMassActions|length > 0%}
<div class="btn-group">
{% for action in datatable.tableMassActions %}
Expand All @@ -61,4 +46,4 @@
} %}
{% endfor %}
</div>
{% endif %}
{% endif %}
Original file line number Diff line number Diff line change
Expand Up @@ -117,3 +117,31 @@
</div>
</div>
{% endblock i18nTranslations %}

{%- block document_label -%}{{ data|emsco_display }}{%- endblock document_label -%}

{%- block document_content_type -%}
{{- data.contentType|emsco_get_content_type.singularName|default(data.contentType) -}}
{%- endblock document_content_type -%}

{% block release_unpublish_source %}
{%- set info = data.getValue('info', false) -%}
{%- if info -%}
{%- set revision = info.revision(table.context.release.environmentSource.name) -%}
{{- '%date% Finalized by %user%'|trans({
'%date%': (revision.finalizedDate ? revision.finalizedDate|date(date_time_format) : ''),
'%user%': (revision.finalizedBy ? revision.finalizedBy|displayname : '')
}) -}}
{%- endif -%}
{% endblock release_unpublish_source %}

{% block release_unpublish_target %}
{%- set info = data.getValue('info', false) -%}
{%- if info -%}
{%- set revision = info.revision(table.context.release.environmentTarget.name) -%}
{{- '%date% Finalized by %user%'|trans({
'%date%': (revision.finalizedDate ? revision.finalizedDate|date(date_time_format) : ''),
'%user%': (revision.finalizedBy ? revision.finalizedBy|displayname : '')
}) -}}
{%- endif -%}
{% endblock release_unpublish_target %}
Original file line number Diff line number Diff line change
Expand Up @@ -17,27 +17,22 @@
{% endif %}
{% endblock minrevid %}


{% block environmentSource %}
{{ data.environmentSource.label }}
{% endblock environmentSource %}


{% block status %}
{{ ('release.status.'~data.status)|trans }}
{% endblock status %}


{% block environmentTarget %}
{{ data.environmentTarget.label }}
{% endblock environmentTarget %}


{% block docs_count %}
{{ data.revisions|length }}
{% endblock docs_count %}


{% block maxrevid %}
{% set release = app.request.get('release') %}
{% set minrev = data.minrevid|split('/') %}
Expand Down Expand Up @@ -65,7 +60,6 @@
{% endif %}
{% endblock minrevidstatus %}


{% block maxrevidstatus %}
{% set release = app.request.get('release') %}
{% set maxrev = data.maxrevid|split('/') %}
Expand All @@ -84,22 +78,3 @@
{{ 'replace by revision %date%'|trans({ '%date%' : maxrev[2]|date(date_time_format) }) }}
{% endif %}
{% endblock maxrevidstatus %}

{% block unpublish_source %}
<div style="width: 250px">
{{ '%date% Finalized by %user%'|trans({
'%date%': data.default_finalized_date|date(date_time_format),
'%user%': data.default_finalized_by
}) }}
</div>
{% endblock unpublish_source %}

{% block unpublish_target %}
<div style="width: 250px">
{{ '%date% Finalized by %user%'|trans({
'%date%': data.published_finalized_date|date(date_time_format),
'%user%': data.published_finalized_by
}) }}
</div>
{% endblock unpublish_target %}

5 changes: 5 additions & 0 deletions EMS/common-bundle/src/Elasticsearch/Document/Document.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,11 @@ public function getEmsLink(): EMSLink
return EMSLink::fromContentTypeOuuid($this->contentType, $id);
}

public function getDocumentEmsId(): string
{
return EMSLink::fromContentTypeOuuid($this->contentType, $this->id)->getEmsId();
}

/**
* @return array<mixed>
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ interface DocumentInterface
{
public function getId(): string;

public function getDocumentEmsId(): string;

public function getOuuid(): string;

public function getContentType(): string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ public function __construct(
private readonly DataTableFactory $dataTableFactory,
private readonly TableRenderer $tableRenderer,
private readonly TableExporter $tableExporter,
private readonly TokenStorageInterface $tokenStorage,
private readonly string $templateNamespace
private readonly TokenStorageInterface $tokenStorage
) {
}

Expand All @@ -36,10 +35,12 @@ public function ajaxData(Request $request, string $hash, ?string $optionsCacheKe
$dataTableRequest = DataTableRequest::fromRequest($request);
$table->resetIterator($dataTableRequest);

return $this->render("@$this->templateNamespace/datatable/ajax.html.twig", [
'dataTableRequest' => $dataTableRequest,
'table' => $table,
], new JsonResponse());
return new JsonResponse([
'data' => $this->tableRenderer->buildRows($table),
'draw' => $dataTableRequest->getDraw(),
'recordsFiltered' => $table->count(),
'recordsTotal' => $table->totalCount(),
]);
}

public function ajaxExport(Request $request, string $format, string $hash, ?string $optionsCacheKey = null): Response
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class MediaLibraryConfig implements ConfigInterface
'bool' => [
'minimum_should_match' => 1,
'should' => [
['query_string' => ['default_field' => 'media_file.filename', 'query' => '%query%']],
['query_string' => ['default_field' => 'media_file.filename', 'query' => '%query_escaped%']],
['wildcard' => ['media_file.filename' => ['value' => '*%query_escaped%*']]],
['match' => ['media_file.filename' => '%query%']],
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -361,8 +361,9 @@ private function buildFileSearch(?MediaLibraryFolder $folder = null, ?string $se
private function buildSearchValueQuery(string $searchValue): AbstractQuery
{
$jsonSearchFileQuery = Json::encode($this->getConfig()->searchFileQuery);

$searchFileQuery = Json::decode(u($jsonSearchFileQuery)
->replace('%query%', $searchValue)
->replace('%query%', Json::escape($searchValue))
->replace('%query_escaped%', Json::escape(QueryStringEscaper::escape($searchValue)))
->toString());

Expand Down

This file was deleted.

Loading

0 comments on commit 14ae11a

Please sign in to comment.