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