Skip to content

Commit

Permalink
Merge branch '4.6' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
barw4 committed Nov 27, 2024
2 parents fa04ad4 + 1671a3d commit f56003e
Show file tree
Hide file tree
Showing 5 changed files with 102 additions and 35 deletions.
24 changes: 22 additions & 2 deletions src/bundle/Resources/translations/ibexa_trash.en.xliff
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,14 @@
<note>The source node in most cases contains the sample message as written by the developer. If it looks like a dot-delimitted string such as "form.label.firstname", then the developer has not provided a default message.</note>
</header>
<body>
<trans-unit id="b789ae7144d8f3797cb4947abe0f9c9b133f9127" resname="search.creator_input.label">
<source>Creator</source>
<target state="new">Creator</target>
<note>key: search.creator_input.label</note>
</trans-unit>
<trans-unit id="3d9f547776de4846ff54fcd1cd173ac5937e5a46" resname="search.creator_input.placeholder">
<source>Search by creator</source>
<target state="new">Search by creator</target>
<source>Type creator's name</source>
<target state="new">Type creator's name</target>
<note>key: search.creator_input.placeholder</note>
</trans-unit>
<trans-unit id="6aa460340bed42d0d1baf9d1ea542c83a3f00821" resname="trash">
Expand All @@ -26,6 +31,16 @@
<target state="new">Restore in a new location</target>
<note>key: trash.button.restore_new_location</note>
</trans-unit>
<trans-unit id="e6c422268f3d22d619c37604653c3761711e9cab" resname="trash.content_not_found">
<source>Sorry, there are no contents for your search.</source>
<target state="new">Sorry, there are no contents for your search.</target>
<note>key: trash.content_not_found</note>
</trans-unit>
<trans-unit id="261490a73abcf9287393e8f8b08ed6e2a95dc9dc" resname="trash.content_not_found.action_text">
<source>Try again with new search criteria.</source>
<target state="new">Try again with new search criteria.</target>
<note>key: trash.content_not_found.action_text</note>
</trans-unit>
<trans-unit id="a644965219fc4d129dd4a5ef1cdb6eb073003702" resname="trash.content_type">
<source>Content type</source>
<target state="new">Content type</target>
Expand Down Expand Up @@ -101,6 +116,11 @@
<target state="new">Any time</target>
<note>key: trash.search.any_time</note>
</trans-unit>
<trans-unit id="c7905f2b692c3d584517c5e6b921771afcc73cf1" resname="trash.search.search_by_content_name">
<source>Search by content name</source>
<target state="new">Search by content name</target>
<note>key: trash.search.search_by_content_name</note>
</trans-unit>
<trans-unit id="c2b2679781ad4a22bb232e2ab34669ffe49c760b" resname="trash.search.section.any">
<source>All</source>
<target state="new">All</target>
Expand Down
83 changes: 53 additions & 30 deletions src/bundle/Resources/views/themes/admin/trash/list.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,39 @@
{% endblock %}

{% block content %}
{% set trash_search_params = app.request.get('trash_search') %}
{% set trash_search_params = app.request.get('trash_search') %}
{% set creator = form_search.vars.data ? form_search.vars.data.creator : '' %}
{% set creator_exists = creator is not empty %}

{% set creatorSearch %}
<div class="form-group">
<label class="ibexa-label form-label" for="trash_search_content_type">
{{ 'search.creator_input.label' | trans | desc('Creator') }}
</label>
<div class="ibexa-trash-search-form__item ibexa-trash-search-form__item--creator">
<div class="ibexa-trash-search-form__input-wrapper">
<input
type="text"
class="form-control ibexa-input ibexa-input--text ibexa-trash-search-form__input"
data-content-type-identifiers="{{ user_content_type_identifier | join(',') }}"
value="{{ creator_exists ? ibexa_content_name(creator) : '' }}"
placeholder="{{ 'search.creator_input.placeholder' | trans | desc('Type creator\'s name') }}"
{{ creator_exists ? 'disabled' : '' }}
>
<button class="btn ibexa-btn ibexa-btn--ghost ibexa-btn--no-text ibexa-btn--reset-creator">
<svg class="ibexa-icon ibexa-icon--tiny-small ibexa-icon--reset">
<use xlink:href="{{ ibexa_icon_path('discard') }}"></use>
</svg>
</button>
</div>
<ul class="ibexa-trash-search-form__user-list ibexa-trash-search-form__user-list--hidden"></ul>
</div>
</div>
{% endset %}

<div class="ibexa-container">
{% set collapsible_items = [
creatorSearch,
form_row(form_search.content_type, {
'attr': {'class': 'ibexa-trash-search-form__item ibexa-trash-search-form__item--auto-send'}
}),
Expand All @@ -45,6 +74,7 @@
{% endif %}

{% embed '@ibexadesign/ui/component/adaptive_filters/adaptive_filters.html.twig' with {
filters_id: 'ibexa_trash_list',
form: form_search,
is_inside_container: true,
collapsible_items: collapsible_items,
Expand All @@ -55,28 +85,11 @@
{% trans_default_domain 'ibexa_trash' %}

{% block static_left_input %}
<div class="ibexa-trash-search-form__item ibexa-trash-search-form__item--creator">
{% set creator = form_search.vars.data ? form_search.vars.data.creator : '' %}
{% set creator_exists = creator is not empty ? true : false %}

<div class="ibexa-trash-search-form__input-wrapper">
<input
type="text"
class="form-control ibexa-input ibexa-input--text ibexa-trash-search-form__input"
data-content-type-identifiers="{{ user_content_type_identifier|join(',') }}"
value="{{ creator_exists ? ibexa_content_name(creator) }}"
placeholder="{{ 'search.creator_input.placeholder'|trans|desc('Search by creator') }}"
{{ creator_exists ? 'disabled' }}
>
<button class="btn ibexa-btn ibexa-btn--ghost ibexa-btn--no-text ibexa-btn--reset-creator">
<svg class="ibexa-icon ibexa-icon--tiny-small ibexa-icon--reset">
<use xlink:href="{{ ibexa_icon_path('discard') }}"></use>
</svg>
</button>
</div>
<ul class="ibexa-trash-search-form__user-list ibexa-trash-search-form__user-list--hidden"></ul>
</div>

{{ form_widget(form_search.content_name, {
has_search: true,
should_clear_button_send_form: true
})
}}
{{ form_widget(form_search.creator, {'attr': {'hidden': 'hidden'}}) }}
{{ form_widget(form_search.sort, {'attr': {'hidden': 'hidden'}}) }}
{{ form_widget(form_search.trashed_interval, {'attr': {'hidden': 'hidden'}}) }}
Expand Down Expand Up @@ -239,18 +252,28 @@
]) %}

{% set has_search_params = trash_search_params|length > 0
? trash_search_params.creator is defined
or trash_search_params.content_type is defined
or trash_search_params.trashed is defined
or trash_search_params.section is defined
? (trash_search_params.creator is defined and trash_search_params.creator is not empty)
or (trash_search_params.content_type is defined and trash_search_params.content_type is not empty)
or (trash_search_params.trashed is defined and trash_search_params.trashed is not empty)
or (trash_search_params.section is defined and trash_search_params.section is not empty)
or (trash_search_params.content_name is defined and trash_search_params.content_name is not empty)
: false
%}

{% embed '@ibexadesign/ui/component/table/table.html.twig' with {
headline: custom_results_headline ?? results_headline(pager.getNbResults(), has_search_params),
headline: custom_results_headline ?? results_headline(
pager.getNbResults(),
has_search_params,
trash_search_params.content_name ?? null,
),
head_cols,
body_rows,
empty_table_info_text: 'trash.empty'|trans|desc('Trash is empty. Content you send to Trash will show up here.'),
empty_table_info_text: has_search_params
? 'trash.content_not_found'|trans|desc('Sorry, there are no contents for your search.')
: 'trash.empty'|trans|desc('Trash is empty. Content you send to Trash will show up here.'),
empty_table_action_text: has_search_params
? 'trash.content_not_found.action_text'|trans|desc('Try again with new search criteria.')
: "",
} %}
{% set modal_create_data_target = 'create-wildcards-modal' %}
{% set modal_delete_data_target = 'delete-wildcards-modal' %}
Expand Down Expand Up @@ -328,7 +351,7 @@
} %}
{% endif %}
{% include '@ibexadesign/trash/modal/empty_trash_confirmation.html.twig' with {'form': form_trash_empty, 'trash_items_count': pager.nbResults} %}
</div>
</div>
{% endblock %}

{% block react_modules %}
Expand Down
19 changes: 16 additions & 3 deletions src/lib/Form/Data/Search/TrashSearchData.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ class TrashSearchData
/** @var array|null */
private $sort;

private ?string $contentName;

public function __construct(
?int $limit = 10,
?int $page = 1,
Expand All @@ -46,6 +48,7 @@ public function __construct(
?string $trashed = null,
?array $trashedInterval = [],
?User $creator = null,
?string $contentName = null,
?array $sort = ['field' => 'trashed', 'direction' => 0]
) {
$this->limit = $limit;
Expand All @@ -55,6 +58,7 @@ public function __construct(
$this->trashed = $trashed;
$this->trashedInterval = $trashedInterval;
$this->creator = $creator;
$this->contentName = $contentName;
$this->sort = $sort;
}

Expand Down Expand Up @@ -128,6 +132,16 @@ public function setCreator(?User $creator): void
$this->creator = $creator;
}

public function getContentName(): ?string
{
return $this->contentName;
}

public function setContentName(?string $contentName): void
{
$this->contentName = $contentName;
}

public function getSort(): ?array
{
return $this->sort;
Expand All @@ -138,20 +152,19 @@ public function setSort(?array $sort): void
$this->sort = $sort;
}

/**
* @return bool
*/
public function isFiltered(): bool
{
$contentType = $this->getContentType();
$section = $this->getSection();
$trashed = $this->getTrashedInterval();
$creator = $this->getCreator();
$contentName = $this->getContentName();

return
null !== $contentType ||
null !== $section ||
null !== $creator ||
null !== $contentName ||
!empty($trashed);
}
}
7 changes: 7 additions & 0 deletions src/lib/Form/Type/Search/TrashSearchType.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\OptionsResolver\OptionsResolver;
Expand Down Expand Up @@ -58,6 +59,12 @@ public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('page', HiddenType::class)
->add('content_name', TextType::class, [
'required' => false,
'attr' => [
'placeholder' => /** @Desc("Search by content name") */ 'trash.search.search_by_content_name',
],
])
->add('content_type', ChoiceType::class, [
'choice_loader' => $this->searchContentTypeChoiceLoader,
'choice_label' => 'name',
Expand Down
4 changes: 4 additions & 0 deletions src/lib/QueryType/TrashSearchQueryType.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ protected function addCriteria(TrashSearchData $searchData, Query $query): void
);
}

if ($searchData->getContentName() !== null) {
$criteria[] = new Criterion\ContentName($searchData->getContentName());
}

if (!empty($criteria)) {
$query->filter = new Criterion\LogicalAnd($criteria);
}
Expand Down

0 comments on commit f56003e

Please sign in to comment.