Fix code quality errors in Lists widget

This commit is contained in:
Ben Thomson 2019-07-07 14:49:56 +08:00
parent c1dcc62559
commit be2a850787
No known key found for this signature in database
GPG Key ID: B2BAFACC5ED68F87
1 changed files with 3 additions and 6 deletions

View File

@ -410,7 +410,6 @@ class Lists extends WidgetBase
* Prepare related eager loads (withs) and custom selects (joins) * Prepare related eager loads (withs) and custom selects (joins)
*/ */
foreach ($this->getVisibleColumns() as $column) { foreach ($this->getVisibleColumns() as $column) {
// If useRelationCount is enabled, eager load the count of the relation into $relation_count // If useRelationCount is enabled, eager load the count of the relation into $relation_count
if ($column->relation && @$column->config['useRelationCount']) { if ($column->relation && @$column->config['useRelationCount']) {
$query->withCount($column->relation); $query->withCount($column->relation);
@ -464,7 +463,6 @@ class Lists extends WidgetBase
} }
} }
} }
}); });
/* /*
@ -481,7 +479,6 @@ class Lists extends WidgetBase
* Relation column * Relation column
*/ */
if (isset($column->relation)) { if (isset($column->relation)) {
// @todo Find a way... // @todo Find a way...
$relationType = $this->model->getRelationType($column->relation); $relationType = $this->model->getRelationType($column->relation);
if ($relationType == 'morphTo') { if ($relationType == 'morphTo') {
@ -731,7 +728,6 @@ class Lists extends WidgetBase
} }
if ($this->columnOverride && is_array($this->columnOverride)) { if ($this->columnOverride && is_array($this->columnOverride)) {
$invalidColumns = array_diff($this->columnOverride, array_keys($definitions)); $invalidColumns = array_diff($this->columnOverride, array_keys($definitions));
if (!count($definitions)) { if (!count($definitions)) {
throw new ApplicationException(Lang::get( throw new ApplicationException(Lang::get(
@ -1478,7 +1474,6 @@ class Lists extends WidgetBase
public function onSort() public function onSort()
{ {
if ($column = post('sortColumn')) { if ($column = post('sortColumn')) {
/* /*
* Toggle the sort direction and set the sorting column * Toggle the sort direction and set the sorting column
*/ */
@ -1544,7 +1539,9 @@ class Lists extends WidgetBase
*/ */
if ($this->sortColumn === null || !$this->isSortable($this->sortColumn)) { if ($this->sortColumn === null || !$this->isSortable($this->sortColumn)) {
$columns = $this->visibleColumns ?: $this->getVisibleColumns(); $columns = $this->visibleColumns ?: $this->getVisibleColumns();
$columns = array_filter($columns, function ($column) { return $column->sortable; }); $columns = array_filter($columns, function ($column) {
return $column->sortable;
});
$this->sortColumn = key($columns); $this->sortColumn = key($columns);
$this->sortDirection = 'desc'; $this->sortDirection = 'desc';
} }