chg: [settings] Possibility to add icons and description in setting panels
parent
9662e15afe
commit
feeda3b32b
|
@ -51,6 +51,8 @@ class SettingsProviderTable extends AppTable
|
||||||
'Application' => [
|
'Application' => [
|
||||||
'General' => [
|
'General' => [
|
||||||
'Essentials' => [
|
'Essentials' => [
|
||||||
|
'_description' => __('Ensentials settings required for the application to run normally.'),
|
||||||
|
'_icon' => 'user-cog',
|
||||||
'app.baseurl' => [
|
'app.baseurl' => [
|
||||||
'name' => __('Base URL'),
|
'name' => __('Base URL'),
|
||||||
'type' => 'string',
|
'type' => 'string',
|
||||||
|
@ -200,6 +202,9 @@ class SettingsProviderTable extends AppTable
|
||||||
private function mergeSettingsIntoSettingConfiguration(array $settingConf, array $settings, string $path=''): array
|
private function mergeSettingsIntoSettingConfiguration(array $settingConf, array $settings, string $path=''): array
|
||||||
{
|
{
|
||||||
foreach ($settingConf as $key => $value) {
|
foreach ($settingConf as $key => $value) {
|
||||||
|
if ($this->isSettingMetaKey($key)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if ($this->isLeaf($value)) {
|
if ($this->isLeaf($value)) {
|
||||||
if (isset($settings[$key])) {
|
if (isset($settings[$key])) {
|
||||||
$settingConf[$key]['value'] = $settings[$key];
|
$settingConf[$key]['value'] = $settings[$key];
|
||||||
|
@ -218,6 +223,9 @@ class SettingsProviderTable extends AppTable
|
||||||
public function flattenSettingsConfiguration(array $settingsProvider, $flattenedSettings=[]): array
|
public function flattenSettingsConfiguration(array $settingsProvider, $flattenedSettings=[]): array
|
||||||
{
|
{
|
||||||
foreach ($settingsProvider as $key => $value) {
|
foreach ($settingsProvider as $key => $value) {
|
||||||
|
if ($this->isSettingMetaKey($key)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if ($this->isLeaf($value)) {
|
if ($this->isLeaf($value)) {
|
||||||
$flattenedSettings[$key] = $value;
|
$flattenedSettings[$key] = $value;
|
||||||
} else {
|
} else {
|
||||||
|
@ -237,6 +245,9 @@ class SettingsProviderTable extends AppTable
|
||||||
{
|
{
|
||||||
$notices = [];
|
$notices = [];
|
||||||
foreach ($settingsProvider as $key => $value) {
|
foreach ($settingsProvider as $key => $value) {
|
||||||
|
if ($this->isSettingMetaKey($key)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if ($this->isLeaf($value)) {
|
if ($this->isLeaf($value)) {
|
||||||
if (!empty($value['error'])) {
|
if (!empty($value['error'])) {
|
||||||
if (empty($notices[$value['severity']])) {
|
if (empty($notices[$value['severity']])) {
|
||||||
|
@ -320,6 +331,11 @@ class SettingsProviderTable extends AppTable
|
||||||
}
|
}
|
||||||
return $functionResult;
|
return $functionResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isSettingMetaKey($key)
|
||||||
|
{
|
||||||
|
return substr($key, 0, 1) == '_';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function testValidator($value, $validator)
|
function testValidator($value, $validator)
|
||||||
|
|
|
@ -75,6 +75,12 @@ class BootstrapHelper extends Helper
|
||||||
return $bsButton->button();
|
return $bsButton->button();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function icon($icon, $options=[])
|
||||||
|
{
|
||||||
|
$bsIcon = new BoostrapIcon($icon, $options);
|
||||||
|
return $bsIcon->icon();
|
||||||
|
}
|
||||||
|
|
||||||
public function badge($options)
|
public function badge($options)
|
||||||
{
|
{
|
||||||
$bsBadge = new BoostrapBadge($options);
|
$bsBadge = new BoostrapBadge($options);
|
||||||
|
@ -733,9 +739,10 @@ class BoostrapButton extends BootstrapGeneric {
|
||||||
|
|
||||||
private function genIcon()
|
private function genIcon()
|
||||||
{
|
{
|
||||||
return $this->genNode('span', [
|
$bsIcon = new BoostrapIcon($this->options['icon'], [
|
||||||
'class' => ['mr-1', "fa fa-{$this->options['icon']}"],
|
'class' => ['mr-1']
|
||||||
]);
|
]);
|
||||||
|
return $bsIcon->icon();
|
||||||
}
|
}
|
||||||
|
|
||||||
private function genContent()
|
private function genContent()
|
||||||
|
@ -784,6 +791,40 @@ class BoostrapBadge extends BootstrapGeneric {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class BoostrapIcon extends BootstrapGeneric {
|
||||||
|
private $icon = '';
|
||||||
|
private $defaultOptions = [
|
||||||
|
'class' => [],
|
||||||
|
];
|
||||||
|
|
||||||
|
function __construct($icon, $options=[]) {
|
||||||
|
$this->icon = $icon;
|
||||||
|
$this->processOptions($options);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function processOptions($options)
|
||||||
|
{
|
||||||
|
$this->options = array_merge($this->defaultOptions, $options);
|
||||||
|
$this->checkOptionValidity();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function icon()
|
||||||
|
{
|
||||||
|
return $this->genIcon();
|
||||||
|
}
|
||||||
|
|
||||||
|
private function genIcon()
|
||||||
|
{
|
||||||
|
$html = $this->genNode('span', [
|
||||||
|
'class' => array_merge(
|
||||||
|
is_array($this->options['class']) ? $this->options['class'] : [$this->options['class']],
|
||||||
|
["fa fa-{$this->icon}"]
|
||||||
|
),
|
||||||
|
]);
|
||||||
|
return $html;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class BoostrapModal extends BootstrapGeneric {
|
class BoostrapModal extends BootstrapGeneric {
|
||||||
private $defaultOptions = [
|
private $defaultOptions = [
|
||||||
'size' => '',
|
'size' => '',
|
||||||
|
|
|
@ -10,9 +10,22 @@ if (isLeaf($panelSettings)) {
|
||||||
$panelHTML = "<div>{$singleSetting}</div>";
|
$panelHTML = "<div>{$singleSetting}</div>";
|
||||||
} else {
|
} else {
|
||||||
$panelID = getResolvableID($sectionName, $panelName);
|
$panelID = getResolvableID($sectionName, $panelName);
|
||||||
$panelHTML .= sprintf('<h4 id="%s"><a class="text-reset text-decoration-none" href="#%s">%s</a></h4>', $panelID, $panelID, h($panelName));
|
$panelHTML .= sprintf('<h4 id="%s"><a class="text-reset text-decoration-none" href="#%s">%s%s</a></h4>',
|
||||||
|
$panelID,
|
||||||
|
$panelID,
|
||||||
|
!empty($panelSettings['_icon']) ? $this->Bootstrap->icon($panelSettings['_icon'], ['class' => 'mr-1']) : '',
|
||||||
|
h($panelName)
|
||||||
|
);
|
||||||
|
if (!empty($panelSettings['_description'])) {
|
||||||
|
$panelHTML .= $this->Bootstrap->genNode('div', [
|
||||||
|
'class' => ['mb-1',],
|
||||||
|
], h($panelSettings['_description']));
|
||||||
|
}
|
||||||
$groupIssueSeverity = false;
|
$groupIssueSeverity = false;
|
||||||
foreach ($panelSettings as $singleSettingName => $singleSetting) {
|
foreach ($panelSettings as $singleSettingName => $singleSetting) {
|
||||||
|
if (substr($singleSettingName, 0, 1) == '_') {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
$singleSettingHTML = $this->element('Settings/fieldGroup', [
|
$singleSettingHTML = $this->element('Settings/fieldGroup', [
|
||||||
'panelName' => $panelName,
|
'panelName' => $panelName,
|
||||||
'panelSettings' => $panelSettings,
|
'panelSettings' => $panelSettings,
|
||||||
|
|
Loading…
Reference in New Issue