Hide Fee button when no bill mode enabled
This commit is contained in:
parent
144487a881
commit
e004bbfca1
|
@ -3,6 +3,7 @@
|
|||
namespace App\Http\Middleware;
|
||||
|
||||
use App\Http\Resources\UserResource;
|
||||
use App\Setting\GeneralSettings;
|
||||
use Closure;
|
||||
use Session;
|
||||
|
||||
|
@ -14,6 +15,7 @@ class InertiaShareMiddleware
|
|||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @param GeneralSettings $settings
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle($request, Closure $next)
|
||||
|
@ -32,7 +34,10 @@ class InertiaShareMiddleware
|
|||
},
|
||||
'title' => function() {
|
||||
return session()->get('title', '');
|
||||
}
|
||||
},
|
||||
'settings' => [
|
||||
'modules' => app(GeneralSettings::class)->modules,
|
||||
]
|
||||
]);
|
||||
|
||||
$response = $next($request);
|
||||
|
|
|
@ -18,10 +18,10 @@ class SettingController extends Controller
|
|||
{
|
||||
return Inertia::render('setting/Index', [
|
||||
'options' => [
|
||||
'modes' => $generalSettings->modeOptions()
|
||||
'modules' => $generalSettings->moduleOptions()
|
||||
],
|
||||
'general' => [
|
||||
'modes' => $generalSettings->modes
|
||||
'modules' => $generalSettings->modules
|
||||
]
|
||||
]);
|
||||
}
|
||||
|
|
|
@ -8,12 +8,14 @@ class GeneralSettings extends Settings
|
|||
{
|
||||
|
||||
/** @var array<int, string> */
|
||||
public array $modes;
|
||||
public array $modules;
|
||||
|
||||
public bool $single_view;
|
||||
|
||||
/**
|
||||
* @return array<int, string>
|
||||
*/
|
||||
public function modeOptions(): array
|
||||
public function moduleOptions(): array
|
||||
{
|
||||
return [
|
||||
'bill',
|
||||
|
|
|
@ -13,10 +13,12 @@ class CreateGeneralSettings extends SettingsMigration
|
|||
{
|
||||
$defaults = [
|
||||
'diözese' => [
|
||||
'modes' => []
|
||||
'modules' => [],
|
||||
'single_view' => false,
|
||||
],
|
||||
'stamm' => [
|
||||
'modes' => ['bill']
|
||||
'modules' => ['bill'],
|
||||
'single_view' => true,
|
||||
]
|
||||
];
|
||||
|
||||
|
@ -26,6 +28,7 @@ class CreateGeneralSettings extends SettingsMigration
|
|||
public function up(): void
|
||||
{
|
||||
$defaults = $this->defaults(config('app.mode'));
|
||||
$this->migrator->add('general.modes', $defaults['modes']);
|
||||
$this->migrator->add('general.modules', $defaults['modules']);
|
||||
$this->migrator->add('general.single_view', $defaults['single_view']);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ import Pages from './components/Pages.vue';
|
|||
import VBool from './components/VBool.vue';
|
||||
import App from './layouts/App.vue';
|
||||
import VTooltip from 'v-tooltip'
|
||||
import hasModule from './mixins/hasModule.js';
|
||||
|
||||
Vue.use(plugin)
|
||||
Vue.use(VTooltip);
|
||||
|
@ -25,6 +26,8 @@ Vue.component('v-bool', VBool);
|
|||
|
||||
const el = document.getElementById('app')
|
||||
|
||||
Vue.mixin(hasModule);
|
||||
|
||||
new Vue({
|
||||
render: h => h(InertiaApp, {
|
||||
props: {
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
<div class="grid gap-2">
|
||||
<v-link href="/" menu="dashboard" icon="loss">Dashboard</v-link>
|
||||
<v-link href="/member" menu="member" icon="user">Mitglieder</v-link>
|
||||
<v-link href="/subscription" menu="subscription" icon="money">Beiträge</v-link>
|
||||
<v-link href="/subscription" v-show="hasModule('bill')" menu="subscription" icon="money">Beiträge</v-link>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
export default {
|
||||
methods: {
|
||||
hasModule(module) {
|
||||
return this.$page.props.settings.modules.indexOf(module) !== -1;
|
||||
}
|
||||
}
|
||||
};
|
|
@ -15,7 +15,7 @@ class GlobalSettingTest extends TestCase
|
|||
public function testItLoadsGeneralSettings(): void
|
||||
{
|
||||
GeneralSettings::fake([
|
||||
'modes' => ['bill']
|
||||
'modules' => ['bill']
|
||||
]);
|
||||
$this->withoutExceptionHandling();
|
||||
$this->login()->init();
|
||||
|
@ -23,7 +23,7 @@ class GlobalSettingTest extends TestCase
|
|||
$response = $this->get('/setting');
|
||||
|
||||
$response->assertInertiaComponent('setting/Index');
|
||||
$this->assertEquals(['bill'], $response->inertia('general.modes'));
|
||||
$this->assertEquals(['bill'], $response->inertia('general.modules'));
|
||||
}
|
||||
|
||||
public function testItGetsOptionsForModels(): void
|
||||
|
@ -33,7 +33,7 @@ class GlobalSettingTest extends TestCase
|
|||
|
||||
$response = $this->get('/setting');
|
||||
|
||||
$this->assertContains('bill', $response->inertia('options.modes'));
|
||||
$this->assertContains('bill', $response->inertia('options.modules'));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue