Skip to content

Commit

Permalink
Swap comment widget into blade component, remove comment JS from comm…
Browse files Browse the repository at this point in the history
…on clients/detail layout.

Swap calls to conf() with config() where possible.
Remove unused head js in 426 error page.
Update CHANGELOG
  • Loading branch information
mosen committed Jan 16, 2024
1 parent 4e53887 commit 4309630
Show file tree
Hide file tree
Showing 7 changed files with 75 additions and 11 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
- Composer 2.2.x now required
- Blade Component Dashboards now default layout type, old style dashboard.php view has a warning applied.
- Jetstream views are used instead of custom ones for user profile editing and password update.
- Client Summary Widgets are partially converted to use blade components.

### [6.0.0-beta.3](https://github.com/munkireport/munkireport-php/compare/v6.0.0-beta.3...wip) (Unreleased)

Expand Down
36 changes: 36 additions & 0 deletions app/View/Components/Widget/Detail/Comments.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

namespace App\View\Components\Widget\Detail;

use Closure;
use Illuminate\Contracts\View\View;
use Illuminate\View\Component;

class Comments extends Component
{
/**
* @var string Widget name/template name
*/
public $name;

public $data;

/**
* Create a new component instance.
*
* @return void
*/
public function __construct(string $name, ?array $data)
{
$this->name = $name;
$this->data = $data;
}

/**
* Get the view / contents that represent the component.
*/
public function render(): View|Closure|string
{
return view('components.widget.detail.comments', $this->data);
}
}
16 changes: 12 additions & 4 deletions app/lib/munkireport/Modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class Modules
public function __construct()
{
// Populate allowedModules if hide_inactive_modules is true
if(conf('hide_inactive_modules')){
if(config('_munkireport.hide_inactive_modules', false)){
$this->skipInactiveModules = True;
}

Expand All @@ -60,9 +60,9 @@ public function __construct()
$moduleSearchPaths = conf('module_search_paths');
}
// And then local modules
$moduleSearchPaths[] = conf('local') . 'modules/';
$moduleSearchPaths[] = config('_munkireport.local') . 'modules/';
// And then built-in modules
$moduleSearchPaths[] = conf('module_path');
$moduleSearchPaths[] = config('_munkireport.module_path');

foreach ($moduleSearchPaths as $path) {
if(is_dir($path)){
Expand Down Expand Up @@ -148,7 +148,14 @@ protected function addCoreModules(): void

$this->moduleList['comment'] = [
'detail_widgets' => [
'comment_detail' => [ 'view' => 'comment_detail_widget'],
'comment_detail' => [
'version' => 6,
'component' => 'widget.detail.comments',
// 'view' => 'comment_detail_widget',
'id' => 'comment-widget',
'icon' => 'comment-o',
'i18n_title' => 'client.comment'
]
],
'path' => realpath(__DIR__ . '../'),
'core' => true,
Expand Down Expand Up @@ -275,6 +282,7 @@ public function getModuleList(bool $all_modules = false): array
* Load Module info
*
* Load info from provides.php
* - v6.0.0: Added loading from module cache to speed up page loads.
*
* @param boolean $allModules If true, don't mind $skipInactiveModules
*/
Expand Down
7 changes: 6 additions & 1 deletion app/lib/munkireport/Widgets.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ public function get($widgetName, $data = [])
* The output array is mapped into the same format as a dashboard widget so that all widget data
* appears the same, even though client detail widgets are declared using a totally different structure in v5.
*
* In v6, the `view` key is not required (supply one of `view` or `component`+`version`+`module`)
*
* @param array $data Widget data, including the widget name.
* @param string|null $name Optional name to override the widget to render.
* @return array Widget info which will be used to render the widget.
Expand All @@ -107,7 +109,10 @@ public function getDetail(array $data, ?string $name = null): array
'widget' => $data['widget'] ?? $name,
'vars' => $data['view_vars'] ?? [],
'path' => $data['view_path'],
'file' => $data['view'],
'file' => $data['view'] ?? null,
'version' => $data['version'] ?? 5,
'module' => $data['module'] ?? null,
'component' => $data['component'] ?? null,
];

// $view = $data['view'];
Expand Down
2 changes: 0 additions & 2 deletions resources/views/clients/detail.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
<script src="{{ asset('assets/js/bootstrap-tagsinput.min.js') }}"></script>
{{-- <script src="{{ asset('assets/js/bootstrap4-tagsinput.js') }}">--}}
<script src="{{ asset('assets/js/typeahead.bundle.min.js') }}"></script>
<script src="{{ asset('assets/js/marked.min.js') }}"></script>
<script src="{{ asset('assets/js/munkireport.comment.js') }}"></script>
@endpush

@section('content')
Expand Down
20 changes: 20 additions & 0 deletions resources/views/components/widget/detail/comments.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<div class="col-lg-4"
@isset($id)id="{{ $id }}"@endisset
>
<h4>
@isset($icon)
<i class="fa fa-{{ $icon }}"></i>
@endisset
<span
@isset($i18n_title)data-i18n="{{ $i18n_title }}"@endisset
@isset($class)class="{{ $class }}"@endisset
></span>
</h4>
<div class="comment" data-section="client"></div>
</div>


@push('scripts')
<script src="{{ asset('assets/js/marked.min.js') }}"></script>
<script src="{{ asset('assets/js/munkireport.comment.js') }}"></script>
@endpush
4 changes: 0 additions & 4 deletions resources/views/errors/426.blade.php
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
@extends('layouts.blank')

@push('stylesheets')
<link rel="stylesheet" href="{{ asset('assets/css/bootstrap-markdown.min.css') }}" />
<link rel="stylesheet" href="{{ asset('assets/css/bootstrap-tagsinput.css') }}" />
@endpush

@push('scripts')
<script src="{{ asset('assets/js/bootstrap-markdown.js') }}"></script>
<script src="{{ asset('assets/js/bootstrap-tagsinput.min.js') }}"></script>
<script src="{{ asset('assets/js/typeahead.bundle.min.js') }}"></script>
<script src="{{ asset('assets/js/marked.min.js') }}"></script>
<script src="{{ asset('assets/js/munkireport.comment.js') }}"></script>
@endpush

@section('content')
Expand Down

0 comments on commit 4309630

Please sign in to comment.