Skip to content

Commit 8d9cb81

Browse files
committed
Merge branch 'develop'
2 parents 54ce583 + 6756a5a commit 8d9cb81

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

Dashboard.module

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,11 @@ class Dashboard extends Process implements Module
8787
*/
8888
const fallbackPanelSize = 'normal';
8989

90+
/**
91+
* Cached output of InputfieldIcon to check for supported icon names.
92+
*/
93+
static protected $iconField = null;
94+
9095
/**
9196
* Module initialization.
9297
*
@@ -499,10 +504,11 @@ class Dashboard extends Process implements Module
499504
$class = '';
500505

501506
if (empty($icons)) {
502-
$icons = [];
507+
return '';
503508
} elseif (is_string($icons)) {
504509
$icons = [$icons];
505510
}
511+
506512
if (is_array($icons)) {
507513
$classes = array_map(function ($icon) {
508514
if (strpos($icon, 'icon-') === 0) {
@@ -513,12 +519,23 @@ class Dashboard extends Process implements Module
513519
}
514520
return $icon;
515521
}, $icons);
516-
$class = implode(' ', $classes);
522+
$class = array_reduce($classes, function ($selectedClass, $classToCheck) {
523+
return $this->hasIcon($classToCheck) ? $classToCheck : $selectedClass;
524+
}, reset($classes));
517525
}
518526

519527
return "<i class='fa fa-fw {$class}'></i>";
520528
}
521529

530+
protected function hasIcon($icon)
531+
{
532+
if (!static::$iconField) {
533+
$module = $this->wire()->modules('InputfieldIcon');
534+
static::$iconField = $module ? $module->render() : '';
535+
}
536+
return preg_match("/\b{$icon}\b/", static::$iconField);
537+
}
538+
522539
/**
523540
* Render view with supplied data.
524541
*/

DashboardPanelCollection.module

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ class DashboardPanelCollection extends DashboardPanel
455455
$links['edit'] = [
456456
'href' => $page->editUrl,
457457
'label' => $this->_('Edit'),
458-
'icon' => ['pen', 'pen-to-square'],
458+
'icon' => ['pencil', 'pen-to-square'],
459459
'mode' => $this->editMode,
460460
'reload' => true,
461461
'disabled' => !$page->editable,

0 commit comments

Comments
 (0)