Skip to content

Commit

Permalink
drop dependency on abandoned package laravelcollective/html
Browse files Browse the repository at this point in the history
- move columnSort() into helpers.php and return HtmlString object directly, and drop TotemFormServiceProvider
- replace Form::{method}() calls with manual form markup
- update TestCase accordingly
  • Loading branch information
jonnott committed Mar 22, 2024
1 parent e98011d commit 2ef3787
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 83 deletions.
8 changes: 5 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@
"illuminate/contracts": "^9.0|^10.0",
"illuminate/database": "^9.0|^10.0",
"illuminate/events": "^9.0|^10.0",
"illuminate/notifications": "^9.0|^10.0",
"laravelcollective/html": "^6.0"
"illuminate/notifications": "^9.0|^10.0"
},
"require-dev": {
"mockery/mockery": "^1.0",
Expand All @@ -40,7 +39,10 @@
"Studio\\Totem\\": "src/",
"Studio\\Totem\\Tests\\": "tests/",
"Database\\Factories\\": "database/factories/"
}
},
"files": [
"src/helpers.php"
]
},
"extra": {
"component": "package",
Expand Down
29 changes: 17 additions & 12 deletions resources/views/tasks/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,29 @@
@section('title')
<div class="uk-flex uk-flex-between uk-flex-middle">
<h4 class="uk-card-title uk-margin-remove">Tasks</h4>
{!! Form::open([
'id' => 'totem__search__form',
'url' => Request::fullUrl(),
'method' => 'GET',
'class' => 'uk-display-inline uk-search uk-search-default'
]) !!}
<span uk-search-icon></span>
{!! Form::text('q', request('q'), ['class' => 'uk-search-input', 'placeholder' => 'Search...']) !!}
{!! Form::close() !!}
<form
accept-charset="UTF-8"
method="GET"
action="{{ request()->fullUrl() }}"
id="totem__search__form"
class="uk-display-inline uk-search uk-search-default">
<span uk-search-icon></span>
<input
value="{{ request('q') }}"
placeholder="Search..."
name="q"
type="text"
class="uk-search-input">
</form>
</div>
@stop
@section('main-panel-content')
<table class="uk-table uk-table-responsive" cellpadding="0" cellspacing="0" class="mb1">
<thead>
<tr>
<th>{!! Html::columnSort('Description', 'description') !!}</th>
<th>{!! Html::columnSort('Average Runtime', 'average_runtime') !!}</th>
<th>{!! Html::columnSort('Last Run', 'last_ran_at') !!}</th>
<th>{!! \Studio\Totem\Helpers\columnSort('Description', 'description') !!}</th>
<th>{!! \Studio\Totem\Helpers\columnSort('Average Runtime', 'average_runtime') !!}</th>
<th>{!! \Studio\Totem\Helpers\columnSort('Last Run', 'last_ran_at') !!}</th>
<th>Next Run</th>
<th class="uk-text-center">Execute</th>
</tr>
Expand Down
55 changes: 0 additions & 55 deletions src/Providers/TotemFormServiceProvider.php

This file was deleted.

1 change: 0 additions & 1 deletion src/Providers/TotemServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ public function register()
$this->app->alias('totem.tasks', TaskInterface::class);
$this->app->register(TotemRouteServiceProvider::class);
$this->app->register(TotemEventServiceProvider::class);
$this->app->register(TotemFormServiceProvider::class);
$this->app->register(ConsoleServiceProvider::class);
}

Expand Down
43 changes: 43 additions & 0 deletions src/helpers.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php
namespace Studio\Totem\Helpers;

use Illuminate\Support\HtmlString;

function columnSort (string $label, string $columnKey, bool $isDefault = false) {
$icon = '';

if (request()->has('sort_by')) {
if (request()->input('sort_by') == $columnKey) {
$icon = ' <span class="fa fa-caret-'
. (request()->input('sort_direction', 'asc') == 'asc' ? 'up' : 'down')
. '"></span>';
}
} elseif ($isDefault) {
$icon = ' <span class="fa fa-caret-'
. (request()->input('sort_direction', 'asc') == 'asc' ? 'up' : 'down')
. '"></span>';
}

$order = 'asc';
if (request()->has('sort_direction')) {
$order = (request()->input('sort_direction') == 'desc' ? 'asc' : 'desc');
} elseif ($isDefault) {
$order = 'desc';
}

$url = request()->fullUrlWithQuery([
'sort_by' => $columnKey,
'sort_direction' => $order,
'filter' => request('filter'),
'limit' => request('limit'),
]);

return new HtmlString(
'<a href="'
. $url
. '">'
. $label
. $icon
. '</a>'
);
}
12 changes: 0 additions & 12 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@

namespace Studio\Totem\Tests;

use Collective\Html\FormFacade;
use Collective\Html\HtmlFacade;
use Collective\Html\HtmlServiceProvider;
use Illuminate\Contracts\Debug\ExceptionHandler;
use Illuminate\Support\Facades\Auth;
use Orchestra\Testbench\Exceptions\Handler;
Expand Down Expand Up @@ -53,19 +50,10 @@ protected function getEnvironmentSetUp($app)
]);
}

protected function getPackageAliases($app)
{
return [
'Form' => FormFacade::class,
'Html' => HtmlFacade::class,
];
}

protected function getPackageProviders($app)
{
return [
TotemServiceProvider::class,
HtmlServiceProvider::class,
];
}

Expand Down

0 comments on commit 2ef3787

Please sign in to comment.