Compare commits

..

5 Commits

Author SHA1 Message Date
philipp lang f21c636803 Move Dashboard registrations
continuous-integration/drone/push Build is failing Details
2024-10-14 21:29:33 +02:00
philipp lang 72cb7dd818 Add Settings for Bill 2024-10-14 21:21:19 +02:00
philipp lang a53637c14f Add Toast and tooltip 2024-10-14 20:25:11 +02:00
philipp lang 3c324fa211 Remove Base tests from Composer 2024-10-14 00:09:17 +02:00
philipp lang 03b839d5ae Add Component Resolver for Modules 2024-10-14 00:07:39 +02:00
54 changed files with 3674 additions and 508 deletions

View File

@ -4,10 +4,10 @@ namespace App\Contribution\Documents;
use App\Contribution\Data\MemberData; use App\Contribution\Data\MemberData;
use App\Country; use App\Country;
use App\Invoice\InvoiceSettings;
use Carbon\Carbon; use Carbon\Carbon;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
use Illuminate\Support\Str; use Illuminate\Support\Str;
use Modules\Invoice\InvoiceSettings;
use Zoomyboy\Tex\Engine; use Zoomyboy\Tex\Engine;
use Zoomyboy\Tex\Template; use Zoomyboy\Tex\Template;

View File

@ -3,10 +3,10 @@
namespace App\Contribution\Documents; namespace App\Contribution\Documents;
use App\Contribution\Data\MemberData; use App\Contribution\Data\MemberData;
use App\Invoice\InvoiceSettings;
use Carbon\Carbon; use Carbon\Carbon;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
use Illuminate\Support\Str; use Illuminate\Support\Str;
use Modules\Invoice\InvoiceSettings;
use Zoomyboy\Tex\Engine; use Zoomyboy\Tex\Engine;
use Zoomyboy\Tex\Template; use Zoomyboy\Tex\Template;

View File

@ -3,7 +3,7 @@
namespace App\Http\Middleware; namespace App\Http\Middleware;
use App\Http\Resources\UserResource; use App\Http\Resources\UserResource;
use App\Module\ModuleSettings; use Modules\Module\ModuleSettings;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Support\Facades\Session; use Illuminate\Support\Facades\Session;
use Inertia\Middleware; use Inertia\Middleware;

View File

@ -6,6 +6,7 @@ use App\Invoice\Models\Invoice;
use App\Payment\Payment; use App\Payment\Payment;
use Illuminate\Database\Eloquent\Relations\HasMany; use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Support\Str; use Illuminate\Support\Str;
use Modules\Invoice\InvoiceSettings;
use Zoomyboy\Tex\Document; use Zoomyboy\Tex\Document;
use Zoomyboy\Tex\Engine; use Zoomyboy\Tex\Engine;
use Zoomyboy\Tex\Template; use Zoomyboy\Tex\Template;

View File

@ -6,7 +6,6 @@ use App\Invoice\BillDocument;
use App\Invoice\BillKind; use App\Invoice\BillKind;
use App\Invoice\Enums\InvoiceStatus; use App\Invoice\Enums\InvoiceStatus;
use App\Invoice\InvoiceDocument; use App\Invoice\InvoiceDocument;
use App\Invoice\InvoiceSettings;
use App\Invoice\RememberDocument; use App\Invoice\RememberDocument;
use App\Invoice\Scopes\InvoiceFilterScope; use App\Invoice\Scopes\InvoiceFilterScope;
use App\Member\Member; use App\Member\Member;
@ -17,6 +16,7 @@ use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany; use Illuminate\Database\Eloquent\Relations\HasMany;
use Modules\Invoice\InvoiceSettings;
use stdClass; use stdClass;
class Invoice extends Model class Invoice extends Model

View File

@ -2,7 +2,6 @@
namespace App\Prevention\Mails; namespace App\Prevention\Mails;
use App\Invoice\InvoiceSettings;
use App\Lib\Editor\EditorData; use App\Lib\Editor\EditorData;
use App\Prevention\Contracts\Preventable; use App\Prevention\Contracts\Preventable;
use Illuminate\Bus\Queueable; use Illuminate\Bus\Queueable;
@ -11,6 +10,7 @@ use Illuminate\Mail\Mailable;
use Illuminate\Mail\Mailables\Content; use Illuminate\Mail\Mailables\Content;
use Illuminate\Mail\Mailables\Envelope; use Illuminate\Mail\Mailables\Envelope;
use Illuminate\Queue\SerializesModels; use Illuminate\Queue\SerializesModels;
use Modules\Invoice\InvoiceSettings;
class PreventionRememberMail extends Mailable class PreventionRememberMail extends Mailable
{ {

View File

@ -6,13 +6,6 @@ use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\Blade; use Illuminate\Support\Facades\Blade;
use Illuminate\View\ComponentAttributeBag; use Illuminate\View\ComponentAttributeBag;
use Livewire\Livewire; use Livewire\Livewire;
use Modules\Base\Components\Page\Sidebar;
use Modules\Dashboard\DashboardFactory;
use Modules\Invoice\MemberPaymentBlock;
use Modules\Member\AgeGroupCountBlock;
use Modules\Member\TestersBlock;
use Modules\Prevention\EfzPendingBlock;
use Modules\Prevention\PsPendingBlock;
class BaseServiceProvider extends ServiceProvider class BaseServiceProvider extends ServiceProvider
{ {
@ -23,18 +16,22 @@ class BaseServiceProvider extends ServiceProvider
{ {
Blade::componentNamespace('App\\View\\Ui', 'ui'); Blade::componentNamespace('App\\View\\Ui', 'ui');
Blade::componentNamespace('App\\View\\Page', 'page'); Blade::componentNamespace('App\\View\\Page', 'page');
Blade::componentNamespace('App\\View\\Form', 'form');
app(DashboardFactory::class)->register(AgeGroupCountBlock::class);
app(DashboardFactory::class)->register(MemberPaymentBlock::class);
app(DashboardFactory::class)->register(TestersBlock::class);
app(DashboardFactory::class)->register(EfzPendingBlock::class);
app(DashboardFactory::class)->register(PsPendingBlock::class);
ComponentAttributeBag::macro('mergeWhen', function ($condition, $key, $attributes) { ComponentAttributeBag::macro('mergeWhen', function ($condition, $key, $attributes) {
/** @var ComponentAttributeBag */ /** @var ComponentAttributeBag */
$self = $this; $self = $this;
return $condition ? $self->merge([$key => $attributes]) : $self; return $condition ? $self->merge([$key => $attributes]) : $self;
}); });
Livewire::resolveMissingComponent(function ($name) {
'modules.dashboard.components.dashboard-component';
if (str($name)->startsWith('modules.')) {
return str($name)->explode('.')->map(fn ($name) => str($name)->studly()->toString())->implode('\\');
}
return null;
});
} }
/** /**

View File

@ -7,6 +7,7 @@ use Illuminate\Http\RedirectResponse;
use Lorisleiva\Actions\ActionRequest; use Lorisleiva\Actions\ActionRequest;
use Lorisleiva\Actions\Concerns\AsAction; use Lorisleiva\Actions\Concerns\AsAction;
/** @deprecated */
class StoreAction class StoreAction
{ {
use AsAction; use AsAction;

View File

@ -8,6 +8,7 @@ use Inertia\Inertia;
use Inertia\Response; use Inertia\Response;
use Lorisleiva\Actions\Concerns\AsAction; use Lorisleiva\Actions\Concerns\AsAction;
/** @deprecated */
class ViewAction class ViewAction
{ {
use AsAction; use AsAction;

View File

@ -0,0 +1,36 @@
<?php
namespace App\Setting\Data;
use Livewire\Mechanisms\HandleComponents\Synthesizers\Synth;
use Spatie\LaravelSettings\Settings;
class SettingSynthesizer extends Synth
{
public static $key = 'setting-class';
public static function match($target)
{
return $target instanceof Settings;
}
public function dehydrate($target)
{
return [$target->toArray(), ['setting_class' => get_class($target)]];
}
public function hydrate($value, $meta)
{
return app($meta['setting_class'])->fill($value);
}
public function get(&$target, $key)
{
return $target->{$key};
}
public function set(&$target, $key, $value)
{
$target->{$key} = $value;
}
}

View File

@ -10,7 +10,7 @@ abstract class LocalSettings extends Settings
public function url(): string public function url(): string
{ {
return route('setting.view', ['settingGroup' => $this->group()]); return url('setting/' . $this->group());
} }
/** /**

View File

@ -2,9 +2,8 @@
namespace App\Setting; namespace App\Setting;
use App\Invoice\InvoiceSettings;
use App\Setting\Contracts\Storeable;
use Illuminate\Routing\Router; use Illuminate\Routing\Router;
use Illuminate\Support\Collection;
class SettingFactory class SettingFactory
{ {
@ -26,16 +25,11 @@ class SettingFactory
} }
/** /**
* @return array<int, array{url: string, is_active: bool}> * @return Collection<int, LocalSettings>
*/ */
public function getShare(): array public function all(): Collection
{ {
return collect($this->settings)->map(fn ($setting) => [ return collect($this->settings)->map(fn ($setting) => new $setting);
'url' => (new $setting)->url(),
'is_active' => url(request()->path()) === (new $setting)->url(),
'title' => $setting::title(),
])
->toArray();
} }
public function resolveGroupName(string $name): LocalSettings public function resolveGroupName(string $name): LocalSettings

View File

@ -4,14 +4,14 @@ namespace App\Setting;
use App\Fileshare\FileshareSettings; use App\Fileshare\FileshareSettings;
use App\Form\FormSettings; use App\Form\FormSettings;
use App\Invoice\InvoiceSettings;
use App\Mailgateway\MailgatewaySettings; use App\Mailgateway\MailgatewaySettings;
use App\Module\ModuleSettings; use Modules\Module\ModuleSettings;
use App\Prevention\PreventionSettings; use App\Prevention\PreventionSettings;
use App\Setting\Actions\StoreAction; use App\Setting\Data\SettingSynthesizer;
use App\Setting\Actions\ViewAction;
use Illuminate\Routing\Router; use Illuminate\Routing\Router;
use Illuminate\Support\ServiceProvider; use Illuminate\Support\ServiceProvider;
use Livewire\Livewire;
use Modules\Invoice\InvoiceSettings;
class SettingServiceProvider extends ServiceProvider class SettingServiceProvider extends ServiceProvider
{ {
@ -24,9 +24,6 @@ class SettingServiceProvider extends ServiceProvider
{ {
app()->singleton(SettingFactory::class, fn () => new SettingFactory()); app()->singleton(SettingFactory::class, fn () => new SettingFactory());
app(Router::class)->bind('settingGroup', fn ($param) => app(SettingFactory::class)->resolveGroupName($param)); app(Router::class)->bind('settingGroup', fn ($param) => app(SettingFactory::class)->resolveGroupName($param));
app(Router::class)->middleware(['web', 'auth:web'])->name('setting.view')->get('/setting/{settingGroup}', ViewAction::class);
app(Router::class)->middleware(['web', 'auth:web'])->name('setting.data')->get('/setting/{settingGroup}/data', ViewAction::class);
app(Router::class)->middleware(['web', 'auth:web'])->name('setting.store')->post('/setting/{settingGroup}', StoreAction::class);
} }
/** /**
@ -43,5 +40,7 @@ class SettingServiceProvider extends ServiceProvider
app(SettingFactory::class)->register(FormSettings::class); app(SettingFactory::class)->register(FormSettings::class);
app(SettingFactory::class)->register(FileshareSettings::class); app(SettingFactory::class)->register(FileshareSettings::class);
app(SettingFactory::class)->register(PreventionSettings::class); app(SettingFactory::class)->register(PreventionSettings::class);
Livewire::propertySynthesizer(SettingSynthesizer::class);
} }
} }

28
app/View/Form/Hint.php Normal file
View File

@ -0,0 +1,28 @@
<?php
namespace App\View\Form;
use App\View\Traits\HasFormDimensions;
use Illuminate\View\Component;
class Hint extends Component
{
use HasFormDimensions;
public function __construct(
public bool $required = false,
) {
}
public function render()
{
return <<<'HTML'
<div class="h-full items-center flex absolute top-0 right-0">
<div x-tooltip.raw="{{$slot}}" class="mr-2">
<x-ui::sprite src="info-button" class="w-5 h-5 text-primary-700"></x-ui::sprite>
</div>
</div>
HTML;
}
}

29
app/View/Form/Label.php Normal file
View File

@ -0,0 +1,29 @@
<?php
namespace App\View\Form;
use App\View\Traits\HasFormDimensions;
use Illuminate\View\Component;
class Label extends Component
{
use HasFormDimensions;
public function __construct(
public bool $required = false,
) {
}
public function render()
{
return <<<'HTML'
<span class="font-semibold leading-none text-gray-400 group-[.size-default]:text-sm group-[.size-sm]:text-xs">
{{ $slot }}
@if ($required)
<span x-if="required" class="text-red-800">&nbsp;*</span>
@endif
</span>
HTML;
}
}

60
app/View/Form/Lever.php Normal file
View File

@ -0,0 +1,60 @@
<?php
namespace App\View\Form;
use App\View\Traits\HasFormDimensions;
use Illuminate\View\Component;
class Lever extends Component
{
use HasFormDimensions;
public string $id;
public function __construct(
public string $name,
public string $size = 'default',
public $value = null,
public ?string $hint = null,
public bool $disabled = false,
public bool $required = false,
public string $label = '',
) {
$this->id = str()->uuid()->toString();
}
public function render()
{
return <<<'HTML'
<label class="flex flex-col items-start group {{$heightClass}} " for="{{$id}}" style="{{$heightVars}}">
@if ($label)
<x-form::label :required="$required">{{$label}}</x-form::label>
@endif
<span class="relative flex-none flex h-[var(--height)] @if($hint) pr-8 @endif">
<input id="{{$id}}" type="checkbox" name="{{$name}}" value="{{$value}}" @if($disabled) disabled="disabled" @endif class="absolute peer opacity-0" {{ $attributes }} />
<span class="relative cursor-pointer h-full w-[calc(var(--height)*2)] rounded peer-focus:bg-red-500 duration-300 bg-gray-700 peer-checked:bg-primary-700"></span>
<span class="absolute h-full top-0 left-0 flex-none flex justify-center items-center aspect-square">
<x-ui::sprite
class="relative text-gray-400 flex-none text-white duration-300 group-[.size-default]:size-3 group-[.size-sm]:size-2"
src="check"
></x-ui::sprite>
</span>
<span class="absolute h-full top-0 left-[var(--height)] flex-none flex justify-center items-center aspect-square">
<x-ui::sprite
class="relative text-gray-400 flex-none text-white duration-300 group-[.size-default]:size-3 group-[.size-sm]:size-2"
src="close"
></x-ui::sprite>
</span>
<var class="absolute duration-300 bg-gray-400 rounded
top-[var(--padding)] left-[var(--padding)]
size-[calc(var(--height)-var(--padding)*2)] peer-checked:left-[calc(var(--height)+var(--padding))]"
></var>
@if($hint)
<x-form::hint>{{$hint}}</x-form::hint>
@endif
</span>
</label>
HTML;
}
}

View File

@ -0,0 +1,22 @@
<?php
namespace App\View\Form;
use Illuminate\View\Component;
class SaveButton extends Component
{
public function __construct(public string $form = '')
{
}
public function render()
{
return <<<'HTML'
<button @if($form) form="{{$form}}" @endif type="submit" class="flex items-center transition-all justify-center w-8 h-8 bg-primary-700 hover:bg-primary-600 rounded" x-tooltip="`speichern`">
<x-ui::sprite class="w-4 h-4 text-white" src="save"></x-ui::sprite>
</button>
HTML;
}
}

53
app/View/Form/Text.php Normal file
View File

@ -0,0 +1,53 @@
<?php
namespace App\View\Form;
use App\View\Traits\HasFormDimensions;
use Illuminate\View\Component;
class Text extends Component
{
use HasFormDimensions;
public string $id;
public function __construct(
public string $name,
public string $size = 'default',
public ?string $hint = null,
public bool $required = false,
public string $label = '',
public string $type = 'text'
) {
$this->id = str()->uuid()->toString();
}
public function render()
{
return <<<'HTML'
<label class="flex flex-col group {{$heightClass}}" for="{{$id}}" style="{{$heightVars}}">
@if ($label)
<x-form::label :required="$required">{{$label}}</x-form::label>
@endif
<div class="relative flex-none flex">
<input
id="{{$id}}"
type="{{$type}}"
placeholder=""
class="
w-full h-[var(--height)] border-gray-600 border-solid text-gray-300 bg-gray-700 leading-none rounded-lg
group-[.size-default]:border-2 group-[.size-sm]:border
group-[.size-default]:text-sm group-[.size-sm]:text-xs
group-[.size-default]:p-2 group-[.size-sm]:p-1
"
{{ $attributes }}
/>
@if($hint)
<x-form::hint>{{$hint}}</x-form::hint>
@endif
</div>
</label>
HTML;
}
}

View File

@ -0,0 +1,37 @@
<?php
namespace App\View\Page;
use App\Setting\SettingFactory;
use Illuminate\View\Component;
class SettingLayout extends Component
{
public array $entries;
public function __construct(public string $active)
{
$this->entries = app(SettingFactory::class)->all()
->map(fn ($setting) => [
'url' => $setting->url(),
'is_active' => get_class($setting) === $active,
'title' => $setting->title(),
])->toArray();
}
public function render()
{
return <<<'HTML'
<x-page::layout>
<x-slot:right>
{{ $right }}
</x-slot:right>
<div class="flex grow relative">
<x-ui::menulist :entries="$entries"></x-ui::menulist>
{{ $slot }}
</div>
</x-page::layout>
HTML;
}
}

View File

@ -0,0 +1,23 @@
<?php
namespace App\View\Traits;
trait HasFormDimensions
{
public function heightVars(): string
{
return data_get([
'default' => '--height: 35px; --padding: 3px;',
'sm' => '--height: 23px; --padding: 2px;',
], $this->size);
}
public function heightClass(): string
{
return data_get([
'default' => 'size-default',
'sm' => 'size-sm',
], $this->size);
}
}

34
app/View/Ui/Menulist.php Normal file
View File

@ -0,0 +1,34 @@
<?php
namespace App\View\Ui;
use Illuminate\View\Component;
class Menulist extends Component
{
public function __construct(public array $entries)
{
}
public function activeClass($entry): string
{
return $entry['is_active'] ? 'bg-gray-600' : '';
}
public function render()
{
return <<<'HTML'
<div class="p-6 bg-gray-700 border-r border-gray-600 flex-none w-maxc flex flex-col justify-between">
<div class="grid gap-1">
@foreach($entries as $entry)
<a href="{{$entry['url']}}" class="rounded py-1 px-3 text-gray-400 duration-200 hover:bg-gray-600 {{$activeClass($entry)}}" @if($entry['is_active']) data-active @endif>
{{$entry['title']}}
</a>
@endforeach
</div>
<slot name="bottom"></slot>
</div>
HTML;
}
}

View File

@ -114,7 +114,6 @@
"autoload-dev": { "autoload-dev": {
"psr-4": { "psr-4": {
"Modules\\Dashboard\\Tests\\": "modules/dashboard/tests/", "Modules\\Dashboard\\Tests\\": "modules/dashboard/tests/",
"Modules\\Base\\Tests\\": "modules/base/tests/",
"Tests\\": "tests/", "Tests\\": "tests/",
"Zoomyboy\\LaravelNami\\Tests\\": "packages/laravel-nami/tests/" "Zoomyboy\\LaravelNami\\Tests\\": "packages/laravel-nami/tests/"
} }

View File

@ -177,8 +177,10 @@ return [
App\Setting\SettingServiceProvider::class, App\Setting\SettingServiceProvider::class,
// App\Dashboard\DashboardServiceProvider::class, // App\Dashboard\DashboardServiceProvider::class,
App\Providers\PluginServiceProvider::class, App\Providers\PluginServiceProvider::class,
Modules\Dashboard\DashboardServiceProvider::class,
App\Providers\BaseServiceProvider::class, App\Providers\BaseServiceProvider::class,
Modules\Dashboard\DashboardServiceProvider::class,
Modules\Module\ModuleServiceProvider::class,
Modules\Invoice\InvoiceServiceProvider::class,
], ],
/* /*

View File

@ -5,6 +5,11 @@ namespace Modules\Dashboard;
use Illuminate\Routing\Router; use Illuminate\Routing\Router;
use Illuminate\Support\ServiceProvider; use Illuminate\Support\ServiceProvider;
use Modules\Dashboard\Components\DashboardComponent; use Modules\Dashboard\Components\DashboardComponent;
use Modules\Invoice\MemberPaymentBlock;
use Modules\Member\AgeGroupCountBlock;
use Modules\Member\TestersBlock;
use Modules\Prevention\EfzPendingBlock;
use Modules\Prevention\PsPendingBlock;
class DashboardServiceProvider extends ServiceProvider class DashboardServiceProvider extends ServiceProvider
{ {
@ -28,5 +33,11 @@ class DashboardServiceProvider extends ServiceProvider
app(Router::class)->middleware(['web', 'auth:web'])->group(function ($router) { app(Router::class)->middleware(['web', 'auth:web'])->group(function ($router) {
$router->get('/', DashboardComponent::class)->name('home'); $router->get('/', DashboardComponent::class)->name('home');
}); });
app(DashboardFactory::class)->register(AgeGroupCountBlock::class);
app(DashboardFactory::class)->register(MemberPaymentBlock::class);
app(DashboardFactory::class)->register(TestersBlock::class);
app(DashboardFactory::class)->register(EfzPendingBlock::class);
app(DashboardFactory::class)->register(PsPendingBlock::class);
} }
} }

View File

@ -0,0 +1,53 @@
<?php
namespace Modules\Invoice\Components;
use App\Module\Module;
use Illuminate\Validation\Rule;
use Livewire\Component;
use Modules\Invoice\InvoiceSettings;
use Modules\Module\ModuleSettings;
class SettingView extends Component
{
public $settingClass = InvoiceSettings::class;
public InvoiceSettings $settings;
public function mount(): void
{
$this->settings = app(InvoiceSettings::class);
}
public function save(): void
{
$this->settings->save();
$this->dispatch('success', 'Einstellungen gespeichert.');
}
public function render()
{
return <<<'HTML'
<x-page::setting-layout :active="$settingClass">
<x-slot:right>
<x-form::save-button form="billsettingform"></x-form::save-button>
</x-slot:right>
<form id="billsettingform" class="grow p-6 grid grid-cols-2 gap-3 items-start content-start" wire:submit.prevent="save">
<x-form::text name="from" wire:model="settings.from" label="Absender" hint="Absender-Name in Kurzform, i.d.R. der kurze Stammesname"></x-form::text>
<x-form::text name="from_long" wire:model="settings.from_long" label="Absender (lang)" hint="Absender-Name in Langform, i.d.R. der Stammesname"></x-form::text>
<h2 class="text-lg font-semibold text-gray-300 col-span-2 mt-5">Kontaktdaten</h2>
<div class="col-span-2 text-gray-300 text-sm">Diese Kontaktdaten stehen im Absender-Bereich auf der Rechnung.</div>
<x-form::text name="address" wire:model="settings.address" label="Straße"></x-form::text>
<x-form::text name="zip" wire:model="settings.zip" label="PLZ"></x-form::text>
<x-form::text name="place" wire:model="settings.place" label="Ort"></x-form::text>
<x-form::text name="email" wire:model="settings.email" label="E-Mail-Adresse"></x-form::text>
<x-form::text name="mobile" wire:model="settings.mobile" label="Telefonnummer"></x-form::text>
<x-form::text name="website" wire:model="settings.website" label="Webseite"></x-form::text>
<x-form::text name="iban" wire:model="settings.iban" label="IBAN"></x-form::text>
<x-form::text name="bic" wire:model="settings.bic" label="BIC"></x-form::text>
<x-form::text name="remember_weeks" wire:model="settings.rememberWeeks" type="number" label="Erinnerung alle X Wochen versenden"></x-form::text>
</form>
</x-page::setting-layout>
HTML;
}
}

View File

@ -0,0 +1,31 @@
<?php
namespace Modules\Invoice;
use Illuminate\Routing\Router;
use Illuminate\Support\ServiceProvider;
use Modules\Invoice\Components\SettingView as ComponentsSettingView;
class InvoiceServiceProvider extends ServiceProvider
{
/**
* Register services.
*
* @return void
*/
public function register()
{
}
/**
* Bootstrap services.
*
* @return void
*/
public function boot()
{
app(Router::class)->middleware(['web', 'auth:web'])->group(function ($router) {
$router->get('/setting/bill', ComponentsSettingView::class)->name('setting.bill');
});
}
}

View File

@ -0,0 +1,72 @@
<?php
namespace Modules\Invoice;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Livewire\Livewire;
use Modules\Invoice\Components\SettingView;
use Tests\TestCase;
uses(TestCase::class);
uses(DatabaseTransactions::class);
it('it renders page', function () {
test()->withoutExceptionHandling()->login()->loginNami();
test()->get('/setting/bill')->assertSeeLivewire(SettingView::class);
});
it('it displays settings', function () {
$this->withoutExceptionHandling()->login()->loginNami();
app(InvoiceSettings::class)->fill([
'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',
'rememberWeeks' => 6
])->save();
Livewire::test(SettingView::class)
->assertSet('settings.from_long', 'DPSG Stamm Muster')
->assertSet('settings.from', 'Stamm Muster')
->assertSet('settings.mobile', '+49 176 55555')
->assertSet('settings.email', 'max@muster.de')
->assertSet('settings.website', 'https://example.com')
->assertSet('settings.address', 'Musterstr 4')
->assertSet('settings.place', 'Solingen')
->assertSet('settings.zip', '12345')
->assertSet('settings.iban', 'DE05')
->assertSet('settings.bic', 'SOLSDE')
->assertSet('settings.rememberWeeks', 6);
});
it('testItCanChangeSettings', function () {
test()->withoutExceptionHandling()->login()->loginNami();
Livewire::test(SettingView::class)
->set('settings.from_long', 'DPSG Stamm Muster')
->set('settings.from', 'Stamm Muster')
->set('settings.mobile', '+49 176 55555')
->set('settings.email', 'max@muster.de')
->set('settings.website', 'https://example.com')
->set('settings.address', 'Musterstr 4')
->set('settings.place', 'Solingen')
->set('settings.zip', '12345')
->set('settings.iban', 'DE05')
->set('settings.bic', 'SOLSDE')
->set('settings.rememberWeeks', 10)
->call('save')
->assertDispatched('success', 'Einstellungen gespeichert.');
$settings = app(InvoiceSettings::class);
$this->assertEquals('DPSG Stamm Muster', $settings->from_long);
$this->assertEquals('DE05', $settings->iban);
$this->assertEquals('SOLSDE', $settings->bic);
$this->assertEquals(10, $settings->rememberWeeks);
});

View File

@ -1,6 +1,6 @@
<?php <?php
namespace App\Invoice; namespace Modules\Invoice;
use App\Setting\Contracts\Storeable; use App\Setting\Contracts\Storeable;
use App\Setting\LocalSettings; use App\Setting\LocalSettings;

View File

@ -0,0 +1,57 @@
<?php
namespace Modules\Module\Components;
use App\Module\Module;
use Illuminate\Validation\Rule;
use Livewire\Component;
use Modules\Module\ModuleSettings;
class SettingView extends Component
{
public array $modules;
public array $all;
public $settingClass = ModuleSettings::class;
public function rules(): array
{
return [
'modules' => 'present|array',
'modules.*' => ['string', Rule::in(Module::values())],
];
}
public function mount(): void
{
$this->modules = app(ModuleSettings::class)->modules;
$this->all = Module::forSelect();
}
public function save(): void
{
app(ModuleSettings::class)->fill($this->validate())->save();
$this->dispatch('success', 'Einstellungen gespeichert.');
}
public function render()
{
return <<<'HTML'
<x-page::setting-layout :active="$settingClass">
<x-slot:right>
<x-form::save-button form="modulesettingform"></x-form::save-button>
</x-slot:right>
<form id="modulesettingform" class="grow p-6 grid grid-cols-2 gap-3 items-start content-start"
wire:submit.prevent="save">
<div class="col-span-full text-gray-100 mb-3">
<p class="text-sm">Hier kannst du Funktionen innerhalb von Adrema (Module) aktivieren oder deaktivieren
und so den Funktionsumfang auf deine Bedürfnisse anpassen.</p>
</div>
@foreach ($all as $module)
<x-form::lever wire:model="modules" hint="lala" :value="$module['id']" name="modules" size="sm" :label="$module['name']"></x-form::lever>
@endforeach
</form>
</x-page::setting-layout>
HTML;
}
}

View File

@ -0,0 +1,31 @@
<?php
namespace Modules\Module;
use Illuminate\Routing\Router;
use Illuminate\Support\ServiceProvider;
use Modules\Module\Components\SettingView;
class ModuleServiceProvider extends ServiceProvider
{
/**
* Register services.
*
* @return void
*/
public function register()
{
}
/**
* Bootstrap services.
*
* @return void
*/
public function boot()
{
app(Router::class)->middleware(['web', 'auth:web'])->group(function ($router) {
$router->get('/setting/module', SettingView::class)->name('setting.module');
});
}
}

View File

@ -0,0 +1,51 @@
<?php
namespace Modules\Module;
use App\View\Setting;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Livewire\Livewire;
use Modules\Module\Components\SettingView;
use Tests\TestCase;
uses(TestCase::class);
uses(DatabaseTransactions::class);
it('it renders page', function () {
test()->withoutExceptionHandling()->login()->loginNami();
test()->get('/setting/module')->assertSeeLivewire(SettingView::class);
});
it('it displays acive modules', function () {
test()->withoutExceptionHandling()->login()->loginNami();
app(ModuleSettings::class)->fill(['modules' => ['bill']])->save();
Livewire::test(SettingView::class)
->assertSee('Module')
->assertSee('Ausbildung')
->assertSet('modules', fn ($modules) => $modules === ['bill'])
->assertSeeHtml('data-active');
});
it('it saves modules', function () {
test()->withoutExceptionHandling()->login()->loginNami();
app(ModuleSettings::class)->fill(['modules' => ['bill']])->save();
Livewire::test(SettingView::class)
->set('modules', ['bill', 'course'])
->call('save')
->assertDispatched('success', 'Einstellungen gespeichert.');
test()->assertEquals(['bill', 'course'], app(ModuleSettings::class)->modules);
});
it('test module must exist', function () {
test()->withoutExceptionHandling()->login()->loginNami();
app(ModuleSettings::class)->fill(['modules' => ['bill']])->save();
Livewire::test(SettingView::class)
->set('modules', ['bill', 'lala'])
->call('save')
->assertHasErrors('modules.1');
});

View File

@ -1,6 +1,6 @@
<?php <?php
namespace App\Module; namespace Modules\Module;
use App\Setting\Contracts\Storeable; use App\Setting\Contracts\Storeable;
use App\Setting\LocalSettings; use App\Setting\LocalSettings;

2934
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -29,21 +29,26 @@
"@editorjs/nested-list": "^1.4.2", "@editorjs/nested-list": "^1.4.2",
"@editorjs/paragraph": "^2.11.3", "@editorjs/paragraph": "^2.11.3",
"@inertiajs/vue3": "^1.0.14", "@inertiajs/vue3": "^1.0.14",
"@ryangjchandler/alpine-tooltip": "^2.0.1",
"@tailwindcss/forms": "^0.5.7", "@tailwindcss/forms": "^0.5.7",
"@tailwindcss/typography": "^0.5.10", "@tailwindcss/typography": "^0.5.10",
"@vitejs/plugin-vue": "^4.6.2", "@vitejs/plugin-vue": "^4.6.2",
"change-case": "^4.1.2", "change-case": "^4.1.2",
"editorjs-alert": "^1.1.3", "editorjs-alert": "^1.1.3",
"floating-vue": "^2.0.0", "floating-vue": "^2.0.0",
"install": "^0.13.0",
"laravel-echo": "^1.15.3", "laravel-echo": "^1.15.3",
"laravel-vite-plugin": "^0.7.8", "laravel-vite-plugin": "^0.7.8",
"lodash": "^4.17.21", "lodash": "^4.17.21",
"merge": "^2.1.1", "merge": "^2.1.1",
"npm": "^10.9.0",
"pinia": "^2.1.7", "pinia": "^2.1.7",
"postcss-import": "^14.1.0", "postcss-import": "^14.1.0",
"prettier": "^2.8.8", "prettier": "^2.8.8",
"pusher-js": "^8.3.0", "pusher-js": "^8.3.0",
"svg-sprite": "^2.0.2", "svg-sprite": "^2.0.2",
"tippy.js": "^6.3.7",
"toastify-js": "^1.12.0",
"vite": "^4.5.2", "vite": "^4.5.2",
"vue": "^3.3.4", "vue": "^3.3.4",
"vue-toastification": "^2.0.0-rc.5", "vue-toastification": "^2.0.0-rc.5",

View File

@ -1,6 +1,21 @@
.v-popper--theme-tooltip .v-popper__inner { .tippy-box[data-theme~='primary'] {
@apply bg-primary-400 text-primary-800 px-3 py-1 text-sm; @apply bg-primary-800 text-primary-100 shadow-lg;
} }
.v-popper--theme-tooltip .v-popper__arrow-outer { .tippy-box[data-theme~='primary'][data-placement^='top'] > .tippy-arrow:before {
@apply border-primary-400; border-top-color: theme('colors.primary.800');
}
.tippy-box[data-theme~='primary'][data-placement^='bottom'] > .tippy-arrow:before {
border-bottom-color: theme('colors.primary.800');
}
.tippy-box[data-theme~='primary'][data-placement^='left'] > .tippy-arrow:before {
border-left-color: theme('colors.primary.800');
}
.tippy-box[data-theme~='primary'][data-placement^='right'] > .tippy-arrow:before {
border-right-color: theme('colors.primary.800');
}
.tippy-box[data-theme~='primary'] > .tippy-backdrop {
background-color: theme('colors.primary.800');
}
.tippy-box[data-theme~='primary'] > .tippy-svg-arrow {
fill: theme('colors.primary.800');
} }

View File

@ -1,16 +0,0 @@
<template>
<div class="h-full items-center flex absolute top-0 right-0">
<div v-tooltip="value" class="mr-2">
<ui-sprite src="info-button" class="w-5 h-5 text-primary-700"></ui-sprite>
</div>
</div>
</template>
<script setup>
const props = defineProps({
value: {
type: String,
required: true,
},
});
</script>

View File

@ -1,19 +0,0 @@
<template>
<span class="font-semibold leading-none text-gray-400 group-[.field-base]:text-sm group-[.field-sm]:text-xs">
{{ value }}
<span v-show="required" class="text-red-800">&nbsp;*</span>
</span>
</template>
<script setup>
const props = defineProps({
value: {
type: String,
required: true,
},
required: {
type: Boolean,
required: true,
},
});
</script>

View File

@ -1,102 +0,0 @@
<template>
<label class="flex flex-col items-start group" :for="id" :class="sizeClass(size)">
<f-label v-if="label" :required="false" :value="label"></f-label>
<span class="relative flex-none flex" :class="{'pr-8': hint, [fieldHeight]: true}">
<input :id="id" v-model="v" type="checkbox" :name="name" :value="value" :disabled="disabled" class="absolute peer opacity-0" @keypress="$emit('keypress', $event)" />
<span
class="relative cursor-pointer h-full rounded peer-focus:bg-red-500 transition-all duration-300 group-[.field-base]:w-[70px] group-[.field-sm]:w-[46px] bg-gray-700 peer-checked:bg-primary-700"
></span>
<span class="absolute h-full top-0 left-0 flex-none flex justify-center items-center aspect-square">
<ui-sprite
class="relative text-gray-400 flex-none text-white duration-300 group-[.field-base]:w-3 group-[.field-base]:h-3 group-[.field-sm]:w-2 group-[.field-sm]:h-2"
src="check"
></ui-sprite
></span>
<span class="absolute h-full top-0 group-[.field-base]:left-[35px] group-[.field-sm]:left-[23px] flex-none flex justify-center items-center aspect-square">
<ui-sprite
class="relative text-gray-400 flex-none text-white duration-300 group-[.field-base]:w-3 group-[.field-base]:h-3 group-[.field-sm]:w-2 group-[.field-sm]:h-2"
src="close"
></ui-sprite
></span>
<var
class="absolute transition-all duration-300 bg-gray-400 rounded group-[.field-base]:top-[3px] group-[.field-base]:left-[3px] group-[.field-sm]:top-[2px] group-[.field-sm]:left-[2px] group-[.field-base]:w-[29px] group-[.field-sm]:w-[19px] group-[.field-base]:h-[29px] group-[.field-sm]:h-[19px] group-[.field-base]:peer-checked:left-[37px] group-[.field-sm]:peer-checked:left-[25px]"
></var>
<f-hint v-if="hint" :value="hint"></f-hint>
</span>
</label>
</template>
<script setup>
import {computed} from 'vue';
import useFieldSize from '../../composables/useFieldSize.js';
const {sizeClass, fieldHeight} = useFieldSize();
const emit = defineEmits(['update:modelValue', 'keypress']);
const props = defineProps({
hint: {
type: String,
default: () => '',
},
size: {
type: String,
default: () => 'base',
},
id: {
type: String,
required: true,
},
name: {
required: true,
type: String,
},
disabled: {
type: Boolean,
default: () => false,
},
value: {
validator: (v) => true,
default: () => undefined,
},
label: {
type: String,
default: () => '',
},
modelValue: {
validator: (v) => true,
default: () => undefined,
},
});
const v = computed({
set: (v) => {
if (props.disabled === true) {
return;
}
if (typeof props.modelValue === 'boolean') {
emit('update:modelValue', v);
return;
}
var a = props.modelValue.filter((i) => i !== props.value);
if (v) {
a.push(props.value);
}
emit('update:modelValue', a);
},
get() {
if (typeof props.modelValue === 'boolean') {
return props.modelValue;
}
if (typeof props.modelValue === 'undefined') {
return emit('update:modelValue', false);
}
return props.modelValue.indexOf(props.value) !== -1;
},
});
</script>

View File

@ -1,154 +0,0 @@
<template>
<label class="flex flex-col group" :for="id" :class="sizeClass(size)">
<f-label v-if="label" :required="required" :value="label"></f-label>
<div class="relative flex-none flex">
<input
:id="id"
:type="type"
:value="transformedValue"
:disabled="disabled"
placeholder=""
:min="min"
:max="max"
:class="[fieldHeight, fieldAppearance, paddingX]"
class="w-full"
@input="onInput"
@change="onChange"
@focus="focus = true"
@blur="focus = false"
/>
<f-hint v-if="hint" :value="hint"></f-hint>
</div>
</label>
</template>
<script setup>
import wNumb from 'wnumb';
import {ref, computed} from 'vue';
import useFieldSize from '../../composables/useFieldSize';
const {fieldHeight, fieldAppearance, paddingX, sizeClass} = useFieldSize();
const emit = defineEmits(['update:modelValue']);
var numb = {
natural: wNumb({
mark: '',
thousand: '',
decimals: 0,
decoder: (a) => a * 100,
encoder: (a) => a / 100,
}),
area: wNumb({
mark: ',',
thousand: '',
decimals: 2,
decoder: (a) => a * 100,
encoder: (a) => a / 100,
}),
};
var transformers = {
none: {
display: {
to: (v) => v,
from: (v) => v,
},
edit: {
to: (v) => v,
from: (v) => v,
},
},
area: {
display: {
to: (v) => (v === null ? '' : numb.area.to(v)),
from: (v) => (v === '' ? null : numb.area.from(v)),
},
edit: {
to(v) {
if (v === null) {
return '';
}
if (Math.round(v / 100) * 100 === v) {
return numb.natural.to(v);
}
return numb.area.to(v);
},
from(v) {
if (v === '') {
return null;
}
if (v.indexOf(',') === -1) {
return numb.natural.from(v);
}
return numb.area.from(v);
},
},
},
};
const props = defineProps({
mode: {
type: String,
default: () => 'none',
},
required: {
type: Boolean,
default: () => false,
},
size: {
type: String,
default: () => 'base',
},
id: {
type: String,
required: true,
},
hint: {
type: String,
default: () => '',
},
modelValue: {
validator: (v) => typeof v === 'string' || v === null,
required: true,
},
label: {
type: String,
default: () => '',
},
type: {
type: String,
default: () => 'text',
},
disabled: {
default: () => false,
type: Boolean,
},
min: {
type: Number,
default: () => undefined,
},
max: {
type: Number,
default: () => undefined,
},
});
const focus = ref(false);
const transformedValue = computed({
get: () => transformers[props.mode][focus.value ? 'edit' : 'display'].to(props.modelValue),
set: (v) => emit('update:modelValue', transformers[props.mode][focus.value ? 'edit' : 'display'].from(v)),
});
function onChange(v) {
if (props.mode !== 'none') {
transformedValue.value = v.target.value;
}
}
function onInput(v) {
if (props.mode === 'none') {
transformedValue.value = v.target.value;
}
}
</script>

View File

@ -1,23 +0,0 @@
<template>
<div class="p-6 bg-gray-700 border-r border-gray-600 flex-none w-maxc flex flex-col justify-between">
<div class="grid gap-1">
<a v-for="(item, index) in entries" :key="index" href="#" class="rounded py-1 px-3 text-gray-400"
:class="index === modelValue ? `bg-gray-600` : ''" @click.prevent="openMenu(index)" v-text="item.title"></a>
</div>
<slot name="bottom"></slot>
</div>
</template>
<script>
export default {
props: {
modelValue: {},
entries: {},
},
methods: {
openMenu(index) {
this.$emit('update:modelValue', index);
},
},
};
</script>

View File

@ -1,49 +0,0 @@
<template>
<page-layout>
<template #right>
<f-save-button form="billsettingform"></f-save-button>
</template>
<setting-layout>
<form id="billsettingform" class="grow p-6 grid grid-cols-2 gap-3 items-start content-start" @submit.prevent="submit">
<f-text id="from" v-model="inner.from" label="Absender" hint="Absender-Name in Kurzform, i.d.R. der kurze Stammesname"></f-text>
<f-text id="from_long" v-model="inner.from_long" label="Absender (lang)" hint="Absender-Name in Langform, i.d.R. der Stammesname"></f-text>
<h2 class="text-lg font-semibold text-gray-300 col-span-2 mt-5">Kontaktdaten</h2>
<div class="col-span-2 text-gray-300 text-sm">Diese Kontaktdaten stehen im Absender-Bereich auf der Rechnung.</div>
<f-text id="address" v-model="inner.address" label="Straße"></f-text>
<f-text id="zip" v-model="inner.zip" label="PLZ"></f-text>
<f-text id="place" v-model="inner.place" label="Ort"></f-text>
<f-text id="email" v-model="inner.email" label="E-Mail-Adresse"></f-text>
<f-text id="mobile" v-model="inner.mobile" label="Telefonnummer"></f-text>
<f-text id="website" v-model="inner.website" label="Webseite"></f-text>
<f-text id="iban" v-model="inner.iban" label="IBAN"></f-text>
<f-text id="bic" v-model="inner.bic" label="BIC"></f-text>
<f-text id="remember_weeks" v-model="inner.rememberWeeks" type="number" label="Erinnerung alle X Wochen versenden"></f-text>
</form>
</setting-layout>
</page-layout>
</template>
<script>
import SettingLayout from './Layout.vue';
export default {
components: {
SettingLayout,
},
props: {
data: {},
},
data: function () {
return {
inner: {...this.data},
};
},
methods: {
submit() {
this.$inertia.post('/setting/bill', this.inner, {
onSuccess: () => this.$success('Einstellungen gespeichert.'),
});
},
},
};
</script>

View File

@ -1,31 +0,0 @@
<template>
<div class="flex grow relative">
<ui-menulist v-model="active" :entries="$page.props.setting_menu"></ui-menulist>
<slot></slot>
</div>
</template>
<script>
export default {
data: function () {
return {
innerActive: this.$page.props.setting_menu.findIndex((menu) => menu.is_active),
};
},
computed: {
active: {
get() {
return this.innerActive;
},
set(v) {
var _self = this;
this.$inertia.visit(this.$page.props.setting_menu[v].url, {
onSuccess() {
_self.innerActive = v;
},
});
},
},
},
};
</script>

View File

@ -1 +1,19 @@
import {Livewire, Alpine} from '../../vendor/livewire/livewire/dist/livewire.esm';
import Tooltip from '@ryangjchandler/alpine-tooltip';
import '../css/app.css'; import '../css/app.css';
import 'tippy.js/dist/tippy.css';
import 'tippy.js/animations/shift-toward.css';
import '../css/tooltip.css';
import {error, success} from './toastify.js';
Alpine.plugin(
Tooltip.defaultProps({
theme: 'primary',
animation: 'shift-toward',
})
);
window.addEventListener('success', (event) => success(event.detail[0]));
Livewire.start();

27
resources/livewire-js/toastify.js vendored Normal file
View File

@ -0,0 +1,27 @@
import Toastify from 'toastify-js';
import 'toastify-js/src/toastify.css';
const defaultToast = {
duration: 3000,
gravity: 'bottom', // `top` or `bottom`
position: 'right', // `left`, `center` or `right`
style: {
background: 'none',
},
};
export function success(message) {
Toastify({
...defaultToast,
text: message,
className: '!bg-green-700 !text-green-100',
}).showToast();
}
export function error(message) {
Toastify({
...defaultToast,
text: message,
className: '!bg-red-700 !text-red-100',
}).showToast();
}

View File

@ -16,5 +16,6 @@
<livewire:page.sidebar /> <livewire:page.sidebar />
{{ $slot }} {{ $slot }}
<page-search-modal v-if="searchVisible" @close="searchVisible = false"></page-search-modal> <page-search-modal v-if="searchVisible" @close="searchVisible = false"></page-search-modal>
@livewireScriptConfig
</body> </body>
</html> </html>

2
tailwind.config.js vendored
View File

@ -1,7 +1,7 @@
const {colors} = require('tailwindcss/defaultTheme'); const {colors} = require('tailwindcss/defaultTheme');
module.exports = { module.exports = {
content: ['app/View/**/*.php', 'resources/views/**/*.blade.php', 'modules/**/*.php'], content: ['app/View/**/*.php', 'resources/views/**/*.blade.php', 'modules/**/*.php', './resources/livewire-js/**/*.js'],
theme: { theme: {
extend: { extend: {
colors: { colors: {

View File

@ -7,12 +7,12 @@ use App\Contribution\Documents\RdpNrwDocument;
use App\Contribution\Documents\CitySolingenDocument; use App\Contribution\Documents\CitySolingenDocument;
use App\Country; use App\Country;
use App\Gender; use App\Gender;
use App\Invoice\InvoiceSettings;
use App\Member\Member; use App\Member\Member;
use Generator; use Generator;
use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Foundation\Testing\DatabaseTransactions;
use Laravel\Passport\Client; use Laravel\Passport\Client;
use Laravel\Passport\Passport; use Laravel\Passport\Passport;
use Modules\Invoice\InvoiceSettings;
use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\DataProvider;
use Tests\RequestFactories\ContributionMemberApiRequestFactory; use Tests\RequestFactories\ContributionMemberApiRequestFactory;
use Tests\RequestFactories\ContributionRequestFactory; use Tests\RequestFactories\ContributionRequestFactory;

View File

@ -6,7 +6,6 @@ use App\Invoice\Actions\InvoiceSendAction;
use App\Invoice\BillDocument; use App\Invoice\BillDocument;
use App\Invoice\BillKind; use App\Invoice\BillKind;
use App\Invoice\Enums\InvoiceStatus; use App\Invoice\Enums\InvoiceStatus;
use App\Invoice\InvoiceSettings;
use App\Invoice\Mails\BillMail; use App\Invoice\Mails\BillMail;
use App\Invoice\Mails\RememberMail; use App\Invoice\Mails\RememberMail;
use App\Invoice\Models\Invoice; use App\Invoice\Models\Invoice;
@ -15,6 +14,7 @@ use App\Invoice\RememberDocument;
use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Support\Facades\Mail; use Illuminate\Support\Facades\Mail;
use Illuminate\Support\Facades\Storage; use Illuminate\Support\Facades\Storage;
use Modules\Invoice\InvoiceSettings;
use Tests\TestCase; use Tests\TestCase;
use Zoomyboy\Tex\Tex; use Zoomyboy\Tex\Tex;

View File

@ -2,8 +2,8 @@
namespace Tests\Feature\Invoice; namespace Tests\Feature\Invoice;
use App\Invoice\InvoiceSettings;
use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Foundation\Testing\DatabaseTransactions;
use Modules\Invoice\InvoiceSettings;
use Tests\TestCase; use Tests\TestCase;
class SettingTest extends TestCase class SettingTest extends TestCase

View File

@ -4,10 +4,10 @@ namespace Tests\Feature\Invoice;
use App\Invoice\BillDocument; use App\Invoice\BillDocument;
use App\Invoice\BillKind; use App\Invoice\BillKind;
use App\Invoice\InvoiceSettings;
use App\Invoice\Models\Invoice; use App\Invoice\Models\Invoice;
use App\Invoice\Models\InvoicePosition; use App\Invoice\Models\InvoicePosition;
use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Foundation\Testing\DatabaseTransactions;
use Modules\Invoice\InvoiceSettings;
use Tests\TestCase; use Tests\TestCase;
use Zoomyboy\Tex\Tex; use Zoomyboy\Tex\Tex;

View File

@ -3,11 +3,11 @@
namespace Tests\Feature\Invoice; namespace Tests\Feature\Invoice;
use App\Invoice\BillKind; use App\Invoice\BillKind;
use App\Invoice\InvoiceSettings;
use App\Invoice\Models\Invoice; use App\Invoice\Models\Invoice;
use App\Invoice\Models\InvoicePosition; use App\Invoice\Models\InvoicePosition;
use App\Invoice\RememberDocument; use App\Invoice\RememberDocument;
use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Foundation\Testing\DatabaseTransactions;
use Modules\Invoice\InvoiceSettings;
use Tests\TestCase; use Tests\TestCase;
use Zoomyboy\Tex\Tex; use Zoomyboy\Tex\Tex;

View File

@ -8,7 +8,6 @@ use App\Form\Enums\NamiType;
use App\Form\Enums\SpecialType; use App\Form\Enums\SpecialType;
use App\Form\Models\Form; use App\Form\Models\Form;
use App\Form\Models\Participant; use App\Form\Models\Participant;
use App\Invoice\InvoiceSettings;
use App\Lib\Editor\Condition; use App\Lib\Editor\Condition;
use App\Prevention\Mails\PreventionRememberMail; use App\Prevention\Mails\PreventionRememberMail;
use App\Member\Member; use App\Member\Member;
@ -17,6 +16,7 @@ use App\Prevention\PreventionSettings;
use Generator; use Generator;
use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Support\Facades\Mail; use Illuminate\Support\Facades\Mail;
use Modules\Invoice\InvoiceSettings;
use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\DataProvider;
use Tests\Lib\CreatesFormFields; use Tests\Lib\CreatesFormFields;
use Tests\RequestFactories\EditorRequestFactory; use Tests\RequestFactories\EditorRequestFactory;

View File

@ -1,63 +0,0 @@
<?php
namespace Tests\Feature;
use App\Module\Module;
use App\Module\ModuleSettings;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Tests\TestCase;
class ModuleTest extends TestCase
{
use DatabaseTransactions;
public function testItGetsModuleSettings(): void
{
$this->login()->loginNami();
ModuleSettings::fake(['modules' => ['bill']]);
$response = $this->get('/setting/module');
$response->assertOk();
$this->assertCount(count(Module::cases()), $this->inertia($response, 'data.meta.modules'));
$this->assertInertiaHas([
'name' => 'Zahlungs-Management',
'id' => 'bill',
], $response, 'data.meta.modules.0');
$this->assertEquals(['bill'], $this->inertia($response, 'data.data.modules'));
}
public function testItSavesSettings(): void
{
$this->login()->loginNami();
$response = $this->from('/setting/module')->post('/setting/module', [
'modules' => ['bill'],
]);
$response->assertRedirect('/setting/module');
$this->assertEquals(['bill'], app(ModuleSettings::class)->modules);
}
public function testModuleMustExists(): void
{
$this->login()->loginNami();
$response = $this->from('/setting/module')->post('/setting/module', [
'modules' => ['lalala'],
]);
$response->assertSessionHasErrors('modules.0');
}
public function testItReturnsModulesOnEveryPage(): void
{
$this->login()->loginNami();
ModuleSettings::fake(['modules' => ['bill']]);
$response = $this->get('/');
$this->assertEquals(['bill'], $this->inertia($response, 'settings.modules'));
}
}

View File

@ -19,6 +19,7 @@ class InvoiceSettingsFake extends RequestFactory
'zip' => '12345', 'zip' => '12345',
'iban' => 'DE444', 'iban' => 'DE444',
'bic' => 'SOLSSSSS', 'bic' => 'SOLSSSSS',
'rememberWeeks' => 6
]; ];
} }
} }