Bugfixes and Bootstrap 5 finalized

This commit is contained in:
Joey Kimsey
2024-12-17 22:57:55 -05:00
parent 2220c6cda3
commit a859fb7ace
79 changed files with 2011 additions and 1597 deletions

View File

@ -12,6 +12,7 @@
namespace TheTempusProject\Classes;
use TheTempusProject\Houdini\Classes\Forms;
use TheTempusProject\Houdini\Classes\Template;
use TheTempusProject\Canary\Bin\Canary as Debug;
use TheTempusProject\Bedrock\Functions\Check;
use TheTempusProject\Bedrock\Functions\Input;
@ -19,7 +20,6 @@ use TheTempusProject\Bedrock\Classes\Config as BedrockConfig;
class Config extends BedrockConfig {
public static function getFieldEditHtml( $name, $includeProtected = false ) {
// @todo: includeProtected is unused here
$node = self::get( $name );
if ( empty( $node ) ) {
return;
@ -28,13 +28,57 @@ class Config extends BedrockConfig {
return;
}
$fieldname = str_ireplace( '/', '-', $name );
$html = Forms::getFormFieldHtml(
$fieldname,
$node['pretty'],
$node['type'],
$node['value'],
);
return $html;
$html = '';
$fieldHtml = '';
switch ( $node['type'] ) {
case 'radio':
case 'bool':
case 'boolean':
$fieldHtml = Forms::getSwitchHtml( $fieldname, [ 'true', 'false' ], $node['value'] );
break;
case 'select':
$fieldHtml = Forms::getSelectHtml( $fieldname, $options, $node['value'] );
break;
case 'block':
$fieldHtml = Forms::getTextBlockHtml( $fieldname, $node['value'] );
break;
case 'text':
case 'url':
$fieldHtml = Forms::getTextHtml( $fieldname, $node['value'] );
break;
case 'checkbox':
$fieldHtml = Forms::getCheckboxHtml( $fieldname, $node['value'] );
break;
case 'timezone':
$fieldHtml = Forms::getTimezoneHtml( $node['value'] );
break;
case 'file':
$fieldHtml = Forms::getFileHtml( $fieldname );
break;
case 'customSelect':
if ( empty( $options ) ) {
$options = '{' . $fieldname . '-options}';
}
$fieldHtml = Forms::getSelectHtml( $fieldname, $options, $node['value'] );
break;
}
$html .= '<div class="mb-3 row">';
$html .= '<label for="' . $fieldname . '" class="col-lg-3 col-form-label text-end">' . $node['pretty'] . '</label>';
$html .= '<div class="col-lg-6">';
$html .= $fieldHtml;
$html .= '</div>';
if ( 'file' === $node['type'] ) {
$html .= '<div class="mb-3 row">';
$html .= '<h4 class="col-lg-3 col-form-label text-end">Current Image</h4>';
$html .= '<div class="col-lg-6">';
$html .= '<img alt="User Avatar" src="{ROOT_URL}' . $node['value'] . '" class="img-circle img-fluid p-2 avatar-125">';
$html .= '</div>';
}
$html .= '</div>';
return Template::parse( $html );
}
public static function getCategoryEditHtml( $category ) {
@ -47,12 +91,12 @@ class Config extends BedrockConfig {
Debug::warn( "Config category not found: $category" );
return;
}
$categoryHeader = '<div class="form-group"><label>' . ucfirst( $category ) . ':</label><hr></div>';
$categoryHeader = '<div class=""><h3 class="text-center">' . ucfirst( $category ) . ':</h3><hr>';
foreach ( self::$config[$category] as $field => $node ) {
$html .= self::getFieldEditHtml( $category . '/' . $field );
}
if ( !empty( $html ) ) {
$html = $categoryHeader . $html;
$html = $categoryHeader . $html . '</div>';
}
return $html;
}
@ -68,4 +112,4 @@ class Config extends BedrockConfig {
}
return $html;
}
}
}

View File

@ -15,6 +15,7 @@ use TheTempusProject\Canary\Bin\Canary as Debug;
use TheTempusProject\Bedrock\Functions\Check;
use TheTempusProject\Houdini\Classes\Forms;
use TheTempusProject\Bedrock\Functions\Input;
use TheTempusProject\Houdini\Classes\Template;
class Permissions {
public static $permissions = false;
@ -237,8 +238,21 @@ class Permissions {
} else {
$checked = false;
}
$form .= Forms::getFormFieldHtml( $name, $details['pretty'], 'checkbox', $checked );
$form .= self::getFieldEditHtml( $name, $checked, $details['pretty'] );
}
return $form;
}
public static function getFieldEditHtml( $name, $default, $pretty ) {
$fieldname = str_ireplace( '/', '-', $name );
$fieldHtml = Forms::getSwitchHtml( $fieldname, [ 'true', 'false' ], $default );
$html = '';
$html .= '<div class="mb-3 row">';
$html .= '<label for="' . $fieldname . '" class="col-lg-6 col-form-label text-end">' . $pretty . '</label>';
$html .= '<div class="col-lg-6">';
$html .= $fieldHtml;
$html .= '</div>';
$html .= '</div>';
return Template::parse( $html );
}
}