feat: Added auto list item generation -> based on files in tabs directory

This commit is contained in:
IceToast 2022-01-03 01:52:25 +01:00
parent ef732d5426
commit 267f28e6e9
5 changed files with 59 additions and 66 deletions

View file

@ -26,18 +26,19 @@ class SettingsController extends Controller
$tabs[] = 'admin.settings.tabs.' . basename($filename, '.blade.php'); $tabs[] = 'admin.settings.tabs.' . basename($filename, '.blade.php');
} }
// <li class="nav-item"> //Generate a html list item for each tab based on tabs file basename, set first tab as active
// <a class="nav-link" data-toggle="pill" href="#invoice">{{ __('Invoice Settings2') }}</a> $tabListItems = [];
// </li>
//Generate a html list item for each tab based on tabs file basename
$tabsListItem = [];
foreach ($tabs as $tab) { foreach ($tabs as $tab) {
$tabsListItem[] = '<li class="nav-item"><a class="nav-link" href="' . route('admin.settings.index', ['tab' => $tab]) . '">' . str_replace('_', ' ', ucfirst(basename($tab, '.blade.php'))) . '</a></li>'; $tabName = str_replace('admin.settings.tabs.', '', $tab);
$tabListItems[] = '<li class="nav-item">
<a class="nav-link ' . (empty($tabListItems) ? 'active' : '') . '" data-toggle="pill" href="#' . $tabName . '">
' . __(ucfirst($tabName)) . '
</a></li>';
} }
return view('admin.settings.index', [ return view('admin.settings.index', [
'tabs' => $tabs, 'tabs' => $tabs,
'tabListItems' => $tabListItems,
]);; ]);;
} }

2
package-lock.json generated
View file

@ -1,5 +1,5 @@
{ {
"name": "bitsec-dashboard", "name": "controllpanelgg",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {

View file

@ -36,67 +36,14 @@
<!-- Nav pills --> <!-- Nav pills -->
<ul class="nav nav-tabs"> <ul class="nav nav-tabs">
<li class="nav-item">
<a class="nav-link active" data-toggle="pill" @foreach ($tabListItems as $tabListItem)
href="#dashboard-icons">{{ __('Dashboard icons') }}</a> {!! $tabListItem !!}
</li> @endforeach
<li class="nav-item">
<a class="nav-link" data-toggle="pill"
href="#invoice-settings">{{ __('Invoice Settings') }}</a>
</li>
<li class="nav-item">
<a class="nav-link" data-toggle="pill" href="#invoice">{{ __('Invoice Settings2') }}</a>
</li>
</ul> </ul>
<!-- Tab panes --> <!-- Tab panes -->
<div class="tab-content"> <div class="tab-content">
<div class="tab-pane mt-3 active" id="dashboard-icons">
<form method="POST" enctype="multipart/form-data" class="mb-3"
action="{{ route('admin.settings.update.icons') }}">
@csrf
@method('PATCH')
<div class="row">
<div class="col-md-6 col-lg-4 col-12">
<div class="form-group">
<div class="custom-file mb-3 mt-3">
<input type="file" accept="image/png,image/jpeg,image/jpg"
class="custom-file-input" name="icon" id="icon">
<label class="custom-file-label selected"
for="icon">{{ __('Select panel icon') }}</label>
</div>
@error('icon')
<span class="text-danger">
{{ $message }}
</span>
@enderror
</div>
<div class="form-group">
<div class="custom-file mb-3">
<input type="file" accept="image/x-icon" class="custom-file-input"
name="favicon" id="favicon">
<label class="custom-file-label selected"
for="favicon">{{ __('Select panel favicon') }}</label>
</div>
@error('favicon')
<span class="text-danger">
{{ $message }}
</span>
@enderror
</div>
</div>
</div>
<button class="btn btn-primary">{{ __('Submit') }}</button>
</form>
<p class="text-muted">Images and Icons may be cached, use <code>CNTRL +
F5</code><sup>(google
chrome hotkey)</sup> to reload without cache to see your changes appear :)</p>
</div>
@foreach ($tabs as $tab) @foreach ($tabs as $tab)
@include($tab) @include($tab)

View file

@ -0,0 +1,43 @@
<div class="tab-pane mt-3 active" id="dashboard">
<form method="POST" enctype="multipart/form-data" class="mb-3"
action="{{ route('admin.settings.update.icons') }}">
@csrf
@method('PATCH')
<div class="row">
<div class="col-md-6 col-lg-4 col-12">
<div class="form-group">
<div class="custom-file mb-3 mt-3">
<input type="file" accept="image/png,image/jpeg,image/jpg" class="custom-file-input" name="icon"
id="icon">
<label class="custom-file-label selected" for="icon">{{ __('Select panel icon') }}</label>
</div>
@error('icon')
<span class="text-danger">
{{ $message }}
</span>
@enderror
</div>
<div class="form-group">
<div class="custom-file mb-3">
<input type="file" accept="image/x-icon" class="custom-file-input" name="favicon" id="favicon">
<label class="custom-file-label selected"
for="favicon">{{ __('Select panel favicon') }}</label>
</div>
@error('favicon')
<span class="text-danger">
{{ $message }}
</span>
@enderror
</div>
</div>
</div>
<button class="btn btn-primary">{{ __('Submit') }}</button>
</form>
<p class="text-muted">Images and Icons may be cached, use <code>CNTRL +
F5</code><sup>(google
chrome hotkey)</sup> to reload without cache to see your changes appear :)</p>
</div>

View file

@ -1,3 +1,5 @@
@inject('Invoices', 'App\Http\Controllers\Admin\SettingsControllers\InvoiceSettingsController')
<div class="tab-pane mt-3" id="invoice"> <div class="tab-pane mt-3" id="invoice">
<div class="float-right"> <div class="float-right">
<a href="{{ route('admin.settings.downloadAllInvoices') }}"><button <a href="{{ route('admin.settings.downloadAllInvoices') }}"><button
@ -15,7 +17,7 @@
<div class="custom-control mb-3"> <div class="custom-control mb-3">
<label for="company-name">{{ __('Enter your companys name') }}</label> <label for="company-name">{{ __('Enter your companys name') }}</label>
<input x-model="company-name" id="company-name" name="company-name" type="text" <input x-model="company-name" id="company-name" name="company-name" type="text"
value="{{ $invoiceSettings->company_name }}" value="{{ $Invoices->invoiceSettings->company_name }}"
class="form-control @error('company-name') is-invalid @enderror"> class="form-control @error('company-name') is-invalid @enderror">
</div> </div>
</div> </div>