Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c0d9ed5

Browse files
committed
Tweaks and docs for the new actions dropdown
1 parent 3a27a4a commit c0d9ed5

8 files changed

Lines changed: 83 additions & 12 deletions

File tree

assets/css/easyadmin-theme/datagrids.scss

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,20 +60,47 @@ table.datagrid {
6060
.datagrid td.actions .fa {
6161
font-size: var(--font-size-base);
6262
}
63-
.datagrid td.actions .dropdown-actions {
63+
64+
.datagrid .actions-dropdown {
65+
position: relative;
66+
}
67+
.datagrid .actions-dropdown .dropdown-toggle {
68+
background: transparent !important;
69+
border: var(--border-width) solid transparent;
70+
box-shadow: none !important;
6471
padding: 1px 8px 0 8px;
65-
box-shadow: none;
66-
background: transparent;
6772
}
68-
.datagrid td.actions .dropdown-actions:after {
73+
.datagrid .actions-dropdown .dropdown-toggle:after {
6974
display: none;
7075
}
71-
.datagrid td.actions a.dropdown-item {
76+
.datagrid .actions-dropdown a.dropdown-item {
7277
margin: 0;
7378
}
74-
.datagrid td.actions a.dropdown-item i {
79+
.datagrid .actions-dropdown a.dropdown-item i {
7580
margin-right: 5px;
7681
}
82+
.datagrid .actions-dropdown .dropdown-menu-right {
83+
border-top-right-radius: 0;
84+
right: 0;
85+
top: 22px;
86+
}
87+
.datagrid .actions-dropdown:hover {
88+
cursor: pointer;
89+
90+
.dropdown-toggle {
91+
background: var(--white) !important;
92+
border: var(--border-width) solid var(--border-color);
93+
border-bottom-color: var(--white);
94+
z-index: $zindex-dropdown + 1;
95+
position: relative;
96+
border-bottom-left-radius: 0;
97+
border-bottom-right-radius: 0;
98+
}
99+
100+
.dropdown-menu {
101+
display: block;
102+
}
103+
}
77104

78105
.datagrid .easyadmin-thumbnail img {
79106
box-shadow: 0 0 0 2px var(--white), 0px 0px 4px 1px var(--gray-600);

assets/css/easyadmin-theme/variables.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,10 @@ $badge-border-radius: var(--border-radius);
112112
$dropdown-link-hover-color: var(--gray-900);
113113
$navbar-inverse-color: var(--gray-400);
114114
$navbar-inverse-link-color: var(--gray-400);
115+
$dropdown-border-color: var(--border-color);
116+
$dropdown-border-width: var(--border-width);
117+
$dropdown-box-shadow: var(--box-shadow-lg);
118+
$zindex-dropdown: 1000;
115119

116120
$nav-tabs-border-color: var(--border-color);
117121
$nav-tabs-border-width: var(--border-width);

doc/book/actions-configuration.rst

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,32 @@ This is configurable thanks to the ``icon``, ``label`` and ``title`` options:
277277
# the 'title' content is displayed when the cursor is over the icon
278278
- { name: 'edit', icon: 'pencil', label: false, title: 'Search' }
279279
280+
Displaying Item Actions in a Dropdown Menu
281+
------------------------------------------
282+
283+
In complex backends it's common to display lots of fields on each list row. In
284+
those cases it's recommended to display the actions in a dropdown menu instead
285+
of the expanded design used by default.
286+
287+
To do so, set the ``collapse_actions`` to ``true`` in the global ``list`` option
288+
or the local ``list`` option of each entity (the local option overrides the
289+
global option):
290+
291+
.. code-block:: yaml
292+
293+
# config/packages/easy_admin.yaml
294+
easy_admin:
295+
list:
296+
# hide actions by default in a dropdown menu...
297+
collapse_actions: true
298+
# ...
299+
entities:
300+
Category:
301+
list:
302+
# ...except for this entity, where actions are displayed expanded
303+
collapse_actions: false
304+
# ...
305+
280306
Batch Actions
281307
-------------
282308

doc/book/configuration-reference.rst

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ config key:
3232

3333
* :ref:`title <reference-list-title>`
3434
* :ref:`actions <reference-list-actions>`
35-
* :ref:`batch_actions <reference-list-batch_actions>`
35+
* :ref:`batch_actions <reference-list-batch-actions>`
36+
* :ref:`collapse_actions <reference-list-collapse-actions>`
3637
* :ref:`max_results <reference-list-max-results>`
3738
* `edit`_
3839
* `new`_
@@ -475,6 +476,18 @@ with a dash (``-``):
475476
list:
476477
batch_actions: ['-delete', 'myOtherAction']
477478
479+
.. _reference-list-collapse-actions:
480+
481+
collapse_actions
482+
~~~~~~~~~~~~~~~~
483+
484+
(**default value**: ``false``, **type**: boolean)
485+
486+
If set to ``true``, the actions of each listing item are displayed inside a
487+
dropdown menu that is revealed when moving the mouse over it. It's useful for
488+
complex backends that display lots of information on each list row and don't
489+
have enough space to display the actions expanded.
490+
478491
.. _reference-list-max-results:
479492

480493
max_results

src/Resources/public/app.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Resources/public/app.css.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Resources/views/default/includes/_actions_dropdown.html.twig

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
<div class="dropdown">
2-
<button type="button" class="btn btn-secondary btn-sm dropdown-toggle dropdown-actions" data-toggle="dropdown">
1+
<div class="actions-dropdown">
2+
<button type="button" class="btn btn-secondary btn-sm dropdown-toggle">
33
<i class="fa fa-ellipsis-h"></i>
44
</button>
5+
56
<div class="dropdown-menu dropdown-menu-right">
67
{{ include('@EasyAdmin/default/includes/_actions.html.twig', { is_dropdown: true }) }}
78
</div>

tests/Controller/CustomizedBackendTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public function testListViewDropdownItemActions()
9696
{
9797
$crawler = $this->requestListView('Product');
9898

99-
$this->assertCount(15, $crawler->filter('#main .table td.actions div.dropdown a.dropdown-item:contains("Edit")'));
99+
$this->assertCount(15, $crawler->filter('#main .table td.actions div.actions-dropdown a.dropdown-item:contains("Edit")'));
100100
}
101101

102102
public function testListViewTableIdColumn()

0 commit comments

Comments
 (0)