Move Indexable to Viewable
This commit is contained in:
parent
291eec3849
commit
3a4908f505
|
@ -3,10 +3,10 @@
|
|||
namespace App\Fileshare;
|
||||
|
||||
use App\Fileshare\Actions\FileshareIndexAction;
|
||||
use App\Setting\Contracts\Indexable;
|
||||
use App\Setting\Contracts\Viewable;
|
||||
use App\Setting\LocalSettings;
|
||||
|
||||
class FileshareSettings extends LocalSettings implements Indexable
|
||||
class FileshareSettings extends LocalSettings implements Viewable
|
||||
{
|
||||
public static function group(): string
|
||||
{
|
||||
|
|
|
@ -4,11 +4,11 @@ namespace App\Form;
|
|||
|
||||
use App\Form\Actions\SettingIndexAction;
|
||||
use App\Form\Actions\SettingStoreAction;
|
||||
use App\Setting\Contracts\Indexable;
|
||||
use App\Setting\Contracts\Viewable;
|
||||
use App\Setting\Contracts\Storeable;
|
||||
use App\Setting\LocalSettings;
|
||||
|
||||
class FormSettings extends LocalSettings implements Indexable, Storeable
|
||||
class FormSettings extends LocalSettings implements Viewable, Storeable
|
||||
{
|
||||
public string $registerUrl;
|
||||
public string $clearCacheUrl;
|
||||
|
|
|
@ -2,11 +2,11 @@
|
|||
|
||||
namespace App\Invoice;
|
||||
|
||||
use App\Setting\Contracts\Indexable;
|
||||
use App\Setting\Contracts\Viewable;
|
||||
use App\Setting\Contracts\Storeable;
|
||||
use App\Setting\LocalSettings;
|
||||
|
||||
class InvoiceSettings extends LocalSettings implements Indexable, Storeable
|
||||
class InvoiceSettings extends LocalSettings implements Viewable, Storeable
|
||||
{
|
||||
public string $from_long;
|
||||
|
||||
|
|
|
@ -3,10 +3,10 @@
|
|||
namespace App\Mailgateway;
|
||||
|
||||
use App\Mailgateway\Actions\IndexAction;
|
||||
use App\Setting\Contracts\Indexable;
|
||||
use App\Setting\Contracts\Viewable;
|
||||
use App\Setting\LocalSettings;
|
||||
|
||||
class MailgatewaySettings extends LocalSettings implements Indexable
|
||||
class MailgatewaySettings extends LocalSettings implements Viewable
|
||||
{
|
||||
public static function group(): string
|
||||
{
|
||||
|
|
|
@ -2,11 +2,11 @@
|
|||
|
||||
namespace App\Module;
|
||||
|
||||
use App\Setting\Contracts\Indexable;
|
||||
use App\Setting\Contracts\Viewable;
|
||||
use App\Setting\Contracts\Storeable;
|
||||
use App\Setting\LocalSettings;
|
||||
|
||||
class ModuleSettings extends LocalSettings implements Indexable, Storeable
|
||||
class ModuleSettings extends LocalSettings implements Viewable, Storeable
|
||||
{
|
||||
/** @var array<int, string> */
|
||||
public array $modules;
|
||||
|
|
|
@ -4,10 +4,10 @@ namespace App\Prevention;
|
|||
|
||||
use App\Lib\Editor\EditorData;
|
||||
use App\Prevention\Actions\PreventionIndexAction;
|
||||
use App\Setting\Contracts\Indexable;
|
||||
use App\Setting\Contracts\Viewable;
|
||||
use App\Setting\LocalSettings;
|
||||
|
||||
class PreventionSettings extends LocalSettings implements Indexable
|
||||
class PreventionSettings extends LocalSettings implements Viewable
|
||||
{
|
||||
|
||||
public EditorData $formmail;
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace App\Setting\Contracts;
|
||||
|
||||
interface Indexable
|
||||
interface Viewable
|
||||
{
|
||||
/**
|
||||
* @return class-string
|
|
@ -5,12 +5,12 @@ namespace App\Setting;
|
|||
use App\Group;
|
||||
use App\Nami\Actions\SettingIndexAction;
|
||||
use App\Nami\Actions\SettingSaveAction;
|
||||
use App\Setting\Contracts\Indexable;
|
||||
use App\Setting\Contracts\Viewable;
|
||||
use App\Setting\Contracts\Storeable;
|
||||
use Zoomyboy\LaravelNami\Api;
|
||||
use Zoomyboy\LaravelNami\Nami;
|
||||
|
||||
class NamiSettings extends LocalSettings implements Indexable, Storeable
|
||||
class NamiSettings extends LocalSettings implements Viewable, Storeable
|
||||
{
|
||||
public int $mglnr;
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace App\Setting;
|
||||
|
||||
use App\Setting\Contracts\Indexable;
|
||||
use App\Setting\Contracts\Viewable;
|
||||
use App\Setting\Contracts\Storeable;
|
||||
use Illuminate\Routing\Router;
|
||||
|
||||
|
@ -20,16 +20,16 @@ class SettingFactory
|
|||
{
|
||||
$this->settings[] = $setting;
|
||||
|
||||
if (new $setting() instanceof Indexable) {
|
||||
if (new $setting() instanceof Viewable) {
|
||||
app(Router::class)->middleware(['web', 'auth:web', SettingMiddleware::class])->get($setting::url(), $setting::indexAction());
|
||||
}
|
||||
|
||||
if (new $setting() instanceof Storeable) {
|
||||
app(Router::class)->middleware(['web', 'auth:web', SettingMiddleware::class])->post($setting::url(), $setting::storeAction());
|
||||
app(Router::class)->middleware(['web', 'auth:web'])->post($setting::url(), $setting::storeAction());
|
||||
}
|
||||
|
||||
if (1 === count($this->settings)) {
|
||||
app(Router::class)->redirect('/setting', '/setting/'.$setting::slug());
|
||||
app(Router::class)->redirect('/setting', '/setting/' . $setting::slug());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -40,9 +40,9 @@ class SettingFactory
|
|||
{
|
||||
return collect($this->settings)->map(fn ($setting) => [
|
||||
'url' => $setting::url(),
|
||||
'is_active' => '/'.request()->path() === $setting::url(),
|
||||
'is_active' => '/' . request()->path() === $setting::url(),
|
||||
'title' => $setting::title(),
|
||||
])
|
||||
->toArray();
|
||||
->toArray();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,10 +10,10 @@ class SettingTest extends TestCase
|
|||
{
|
||||
use DatabaseTransactions;
|
||||
|
||||
public function testSettingIndex(): void
|
||||
public function testDisplaySettings(): void
|
||||
{
|
||||
$this->withoutExceptionHandling()->login()->loginNami();
|
||||
InvoiceSettings::fake([
|
||||
app(InvoiceSettings::class)->fill([
|
||||
'from_long' => 'DPSG Stamm Muster',
|
||||
'from' => 'Stamm Muster',
|
||||
'mobile' => '+49 176 55555',
|
||||
|
@ -25,43 +25,33 @@ class SettingTest extends TestCase
|
|||
'iban' => 'DE05',
|
||||
'bic' => 'SOLSDE',
|
||||
'rememberWeeks' => 6
|
||||
]);
|
||||
])->save();
|
||||
|
||||
$response = $this->get('/setting/bill');
|
||||
|
||||
$response->assertOk();
|
||||
$this->assertInertiaHas([
|
||||
'from_long' => 'DPSG Stamm Muster',
|
||||
'from' => 'Stamm Muster',
|
||||
'mobile' => '+49 176 55555',
|
||||
'email' => 'max@muster.de',
|
||||
'website' => 'https://example.com',
|
||||
'address' => 'Musterstr 4',
|
||||
'place' => 'Solingen',
|
||||
'zip' => '12345',
|
||||
'iban' => 'DE05',
|
||||
'bic' => 'SOLSDE',
|
||||
'remember_weeks' => 6
|
||||
], $response, 'data');
|
||||
$this->get('/setting/bill')
|
||||
->assertOk()
|
||||
->assertComponent('setting/Bill')
|
||||
->assertInertiaPath('data.from_long', 'DPSG Stamm Muster')
|
||||
->assertInertiaPath('data.from', 'Stamm Muster')
|
||||
->assertInertiaPath('data.mobile', '+49 176 55555')
|
||||
->assertInertiaPath('data.email', 'max@muster.de')
|
||||
->assertInertiaPath('data.website', 'https://example.com')
|
||||
->assertInertiaPath('data.address', 'Musterstr 4')
|
||||
->assertInertiaPath('data.place', 'Solingen')
|
||||
->assertInertiaPath('data.zip', '12345')
|
||||
->assertInertiaPath('data.iban', 'DE05')
|
||||
->assertInertiaPath('data.bic', 'SOLSDE')
|
||||
->assertInertiaPath('data.remember_weeks', 6);
|
||||
}
|
||||
|
||||
public function testItReturnsTabs(): void
|
||||
{
|
||||
$this->withoutExceptionHandling()->login()->loginNami();
|
||||
|
||||
$response = $this->get('/setting/bill');
|
||||
|
||||
/** @var array<int, array{url: string, title: string, is_active: bool}> */
|
||||
$menus = $this->inertia($response, 'setting_menu');
|
||||
$this->assertTrue(
|
||||
collect($menus)
|
||||
->pluck('url')
|
||||
->contains('/setting/bill')
|
||||
);
|
||||
|
||||
$settingMenu = collect($menus)->first(fn ($menu) => '/setting/bill' === $menu['url']);
|
||||
$this->assertTrue($settingMenu['is_active']);
|
||||
$this->assertEquals('Rechnung', $settingMenu['title']);
|
||||
$this->get('/setting/bill')
|
||||
->assertInertiaPath('setting_menu.1.title', 'Rechnung')
|
||||
->assertInertiaPath('setting_menu.1.url', '/setting/bill')
|
||||
->assertInertiaPath('setting_menu.1.is_active', true)
|
||||
->assertInertiaPath('setting_menu.0.is_active', false);
|
||||
}
|
||||
|
||||
public function testItCanChangeSettings(): void
|
||||
|
|
Loading…
Reference in New Issue