Skip to content

Commit d7f2133

Browse files
authored
[6.0] ListView improvements (joomla#46165)
1 parent ad048fb commit d7f2133

File tree

8 files changed

+20
-38
lines changed

8 files changed

+20
-38
lines changed

administrator/components/com_actionlogs/src/View/Actionlogs/HtmlView.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,6 @@ protected function initializeView()
7979

8080
// Load all actionlog plugins language files
8181
ActionlogsHelper::loadActionLogPluginsLanguage();
82-
83-
// Add form control fields
84-
$this->filterForm
85-
->addControlField('task', '')
86-
->addControlField('boxchecked', '0');
8782
}
8883

8984
/**

administrator/components/com_banners/src/View/Banners/HtmlView.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,5 @@ protected function initializeView()
8383
unset($this->activeFilters['language']);
8484
$this->filterForm->removeField('language', 'filter');
8585
}
86-
87-
// Add form control fields
88-
$this->filterForm
89-
->addControlField('task', '')
90-
->addControlField('boxchecked', '0');
9186
}
9287
}

administrator/components/com_banners/tmpl/banners/default.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -177,11 +177,7 @@
177177

178178
<?php // Load the batch processing form. ?>
179179
<?php
180-
if (
181-
$user->authorise('core.create', 'com_banners')
182-
&& $user->authorise('core.edit', 'com_banners')
183-
&& $user->authorise('core.edit.state', 'com_banners')
184-
) : ?>
180+
if ($this->batchAllowed) : ?>
185181
<template id="joomla-dialog-batch"><?php echo $this->loadTemplate('batch_body'); ?></template>
186182
<?php endif; ?>
187183
<?php endif; ?>

administrator/components/com_contact/src/View/Contacts/HtmlView.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,5 @@ protected function initializeView()
9595
$this->filterForm
9696
->addControlField('forcedLanguage', $forcedLanguage);
9797
}
98-
99-
// Add form control fields
100-
$this->filterForm
101-
->addControlField('task', '')
102-
->addControlField('boxchecked', '0');
10398
}
10499
}

administrator/components/com_contact/tmpl/contacts/default.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -187,11 +187,7 @@
187187

188188
<?php // Load the batch processing form. ?>
189189
<?php
190-
if (
191-
$user->authorise('core.create', 'com_contact')
192-
&& $user->authorise('core.edit', 'com_contact')
193-
&& $user->authorise('core.edit.state', 'com_contact')
194-
) : ?>
190+
if ($this->batchAllowed) : ?>
195191
<template id="joomla-dialog-batch"><?php echo $this->loadTemplate('batch_body'); ?></template>
196192
<?php endif; ?>
197193
<?php endif; ?>

administrator/components/com_modules/src/View/Modules/HtmlView.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -130,11 +130,6 @@ protected function initializeView()
130130
unset($this->activeFilters['state'], $this->activeFilters['language']);
131131
}
132132
}
133-
134-
// Add form control fields
135-
$this->filterForm
136-
->addControlField('task', '')
137-
->addControlField('boxchecked', '0');
138133
}
139134

140135
/**
@@ -147,7 +142,6 @@ protected function initializeView()
147142
protected function addToolbar()
148143
{
149144
$canDo = $this->canDo;
150-
$user = $this->getCurrentUser();
151145

152146
$canCreate = $canDo->get('core.create');
153147

administrator/components/com_modules/tmpl/modules/default.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -200,11 +200,7 @@
200200

201201
<?php // Load the batch processing form. ?>
202202
<?php
203-
if (
204-
$user->authorise('core.create', 'com_modules')
205-
&& $user->authorise('core.edit', 'com_modules')
206-
&& $user->authorise('core.edit.state', 'com_modules')
207-
) : ?>
203+
if ($this->batchAllowed) : ?>
208204
<template id="joomla-dialog-batch"><?php echo $this->loadTemplate('batch_body'); ?></template>
209205
<?php endif; ?>
210206

libraries/src/MVC/View/ListView.php

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,14 @@ class ListView extends HtmlView
105105
*/
106106
protected $supportsBatch = true;
107107

108+
/**
109+
* The flag which determine if the current user is allowed to perform batch actions. It is
110+
* used in layout to determine if we need to render batch layout
111+
*
112+
* @var boolean
113+
*/
114+
protected $batchAllowed = false;
115+
108116
/**
109117
* Holds the extension for categories, if available
110118
*
@@ -227,6 +235,11 @@ protected function initializeView()
227235
$this->state = $model->getState();
228236
$this->filterForm = $model->getFilterForm();
229237
$this->activeFilters = $model->getActiveFilters();
238+
239+
// Add form control fields
240+
$this->filterForm
241+
->addControlField('task', '')
242+
->addControlField('boxchecked', '0');
230243
}
231244

232245
/**
@@ -242,7 +255,7 @@ protected function addToolbar()
242255
$user = $this->getCurrentUser();
243256

244257
/**
245-
* @var Toolbar $toolbar
258+
* @var \Joomla\CMS\Toolbar\Toolbar $toolbar
246259
*/
247260
$toolbar = $this->getDocument()->getToolbar();
248261

@@ -257,7 +270,7 @@ protected function addToolbar()
257270
}
258271

259272
if (!$this->isEmptyState && $canDo->get('core.edit.state')) {
260-
/** @var DropdownButton $dropdown */
273+
/** @var \Joomla\CMS\Toolbar\Button\DropdownButton $dropdown */
261274
$dropdown = $toolbar->dropdownButton('status-group', 'JTOOLBAR_CHANGE_STATUS')
262275
->toggleSplit(false)
263276
->icon('icon-ellipsis-h')
@@ -299,6 +312,8 @@ protected function addToolbar()
299312
->modalWidth('800px')
300313
->modalHeight('fit-content')
301314
->listCheck(true);
315+
316+
$this->batchAllowed = true;
302317
}
303318
}
304319

0 commit comments

Comments
 (0)