mirror of
https://github.com/filamentphp/filament.git
synced 2026-10-24 01:58:00 +08:00
Account tabs
This commit is contained in:
+1
-1
@@ -22,7 +22,7 @@ return [
|
||||
|
|
||||
*/
|
||||
|
||||
'path' => env('FILAMENT_PATH_NAME', 'cp'),
|
||||
'path' => env('FILAMENT_PATH_NAME', 'filament'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
|
||||
Vendored
+142953
-1
File diff suppressed because one or more lines are too long
Vendored
+1804
-1
File diff suppressed because one or more lines are too long
Vendored
+2
-2
@@ -1,4 +1,4 @@
|
||||
{
|
||||
"/js/app.js": "/js/app.js?id=f6e8984136ad30e3b70c",
|
||||
"/css/app.css": "/css/app.css?id=af6052f5e242cd6f74e6"
|
||||
"/js/app.js": "/js/app.js?id=a996ac7f2a8afb2ad2e7",
|
||||
"/css/app.css": "/css/app.css?id=fe89a3abc3e5090bfdc5"
|
||||
}
|
||||
|
||||
@@ -26,6 +26,6 @@ return [
|
||||
|
||||
'account_settings' => 'Account settings',
|
||||
|
||||
'user_edit' => 'Edit user',
|
||||
'user_account' => ':name\'s Account',
|
||||
|
||||
];
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<label class="inline-flex items-center">
|
||||
<input type="{{ $type }}" name={{ $name }} {{ $checked ? 'checked' : '' }} {{ $attributes->merge(['class' => 'form-checkbox h-4 w-4 text-gray-600 transition duration-150 ease-in-out']) }} />
|
||||
<input type="{{ $type }}" name={{ $name }} {{ $checked ? 'checked' : '' }} {{ $attributes->merge(['class' => 'form-checkbox h-4 w-4 text-blue-500 transition duration-150 ease-in-out']) }} />
|
||||
<span class="ml-2 text-sm leading-5 text-gray-700">{{ __($label) }}</span>
|
||||
</label>
|
||||
@@ -0,0 +1,12 @@
|
||||
<div x-data="{ tab: '{{ $tab }}' }" {{ $attributes->merge(['class' => 'bg-white overflow-hidden shadow rounded-lg']) }}>
|
||||
<div role="tablist" class="border-b border-gray-200 bg-gray-50 flex">
|
||||
@foreach($tabs as $value => $label)
|
||||
<button role="tab" aria-controls="{{ $value }}-tab" :tabindex="tab === '{{ $value }}' ? 0 : -1" :aria-selected="tab === '{{ $value }}' ? 'true' : 'false'" class="border-r border-gray-200 px-4 py-3 text-gray-500 text-sm leading-tight -mb-px transition duration-200 ease-in-out" :class="{ 'text-current bg-white': tab === '{{ $value }}' }" @click.prevent="tab = '{{ $value }}'">
|
||||
{{ $label }}
|
||||
</button>
|
||||
@endforeach
|
||||
</div>
|
||||
<div class="px-4 py-5 sm:p-6">
|
||||
{{ $slot }}
|
||||
</div>
|
||||
</div>
|
||||
@@ -1,31 +1,47 @@
|
||||
<form wire:submit.prevent="update">
|
||||
<div class="grid grid-cols-1 md:grid-cols-3 md:gap-4 lg:gap-8">
|
||||
|
||||
<x-filament-input-group wire:key="input-name" id="name" label="Name" required>
|
||||
<x-filament-input id="name" name="name" wire:model="name" required />
|
||||
</x-filament-input-group>
|
||||
<form wire:submit.prevent="update" class="col-span-2">
|
||||
|
||||
<x-filament-input-group wire:key="input-email" id="email" label="E-Mail Address" required>
|
||||
<x-filament-input id="email" type="email" name="email" wire:model="email" required />
|
||||
</x-filament-input-group>
|
||||
<x-filament-tabs tab="account" :tabs="['account' => 'Account', 'permissions' => 'Permissions']">
|
||||
|
||||
<x-filament-input-group>
|
||||
<x-filament-checkbox name="is_super_admin" label="Super admin?" wire:model="is_super_admin" />
|
||||
<x-slot name="info">
|
||||
Super admins have access to the entire admin.
|
||||
</x-slot>
|
||||
</x-filament-input-group>
|
||||
<x-filament-tab id="account">
|
||||
|
||||
@if (count($roles))
|
||||
<fieldset>
|
||||
<legend>Roles</legend>
|
||||
<ol>
|
||||
@foreach($roles as $role)
|
||||
<li>{{ $role->name }}</li>
|
||||
@endforeach
|
||||
</ol>
|
||||
</fieldset>
|
||||
@endif
|
||||
<x-filament-input-group wire:key="input-name" id="name" label="Name" required>
|
||||
<x-filament-input id="name" name="name" wire:model="name" required />
|
||||
</x-filament-input-group>
|
||||
|
||||
<x-filament-input-group wire:key="input-email" id="email" label="E-Mail Address" required>
|
||||
<x-filament-input id="email" type="email" name="email" wire:model="email" required />
|
||||
</x-filament-input-group>
|
||||
|
||||
</x-filament-tab>
|
||||
|
||||
<x-filament-tab id="permissions">
|
||||
|
||||
<x-filament-input-group>
|
||||
<x-filament-checkbox name="is_super_admin" label="Super admin?" wire:model="is_super_admin" />
|
||||
<x-slot name="info">
|
||||
Super admins have access to all of {{ config('app.name') }}.
|
||||
</x-slot>
|
||||
</x-filament-input-group>
|
||||
|
||||
@if (count($roles) && !$is_super_admin)
|
||||
<fieldset>
|
||||
<legend>Roles</legend>
|
||||
<ol>
|
||||
@foreach($roles as $role)
|
||||
<li>{{ $role->name }}</li>
|
||||
@endforeach
|
||||
</ol>
|
||||
</fieldset>
|
||||
@endif
|
||||
|
||||
</x-filament-tab>
|
||||
|
||||
<x-filament-button wire:key="input-submit" label="Update" />
|
||||
|
||||
</x-filament-tabs>
|
||||
|
||||
<x-filament-button wire:key="input-submit" label="Update" />
|
||||
</form>
|
||||
|
||||
</form>
|
||||
</div>
|
||||
@@ -3,7 +3,5 @@
|
||||
@section('title', $title)
|
||||
|
||||
@section('main')
|
||||
<div class="max-w-xl bg-white py-8 px-4 shadow rounded-md sm:px-10">
|
||||
@livewire('filament::user-edit-form', ['user' => $user])
|
||||
</div>
|
||||
@livewire('filament::user-edit-form', ['user' => $user])
|
||||
@endsection
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace Filament\Http\Components;
|
||||
|
||||
use Illuminate\View\Component;
|
||||
|
||||
class Tab extends Component
|
||||
{
|
||||
/**
|
||||
* The tab id.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $id;
|
||||
|
||||
/**
|
||||
* Create the component instance.
|
||||
*
|
||||
* @param string $id
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($id)
|
||||
{
|
||||
$this->id = $id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*
|
||||
* @return \Illuminate\View\View|string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
return <<<'blade'
|
||||
<div role="tabpanel" id="{{ $id }}-tab" aria-labelledby="{{ $id }}" x-show="tab === '{{ $id }}'" :hidden="tab !== '{{ $id }}'">
|
||||
{{ $slot }}
|
||||
</div>
|
||||
blade;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace Filament\Http\Components;
|
||||
|
||||
use Illuminate\View\Component;
|
||||
|
||||
class Tabs extends Component
|
||||
{
|
||||
/**
|
||||
* The initally selected tab.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $tab;
|
||||
|
||||
/**
|
||||
* The tabs.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $tabs;
|
||||
|
||||
/**
|
||||
* Create the component instance.
|
||||
*
|
||||
* @param string $tab
|
||||
* @param array $tabs
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(string $tab, array $tabs)
|
||||
{
|
||||
$this->tab = $tab;
|
||||
$this->tabs = $tabs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*
|
||||
* @return \Illuminate\View\View|string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
return view('filament::components.tabs');
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace Filament\Http\Controllers;
|
||||
|
||||
use Filament\Contracts\User as UserContract;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class UserController extends Controller
|
||||
{
|
||||
@@ -34,7 +35,7 @@ class UserController extends Controller
|
||||
|
||||
$this->authorize('edit', $user);
|
||||
|
||||
$title = __('filament::admin.user_edit');
|
||||
$title = __('filament::admin.user_account', ['name' => $user->name]);
|
||||
|
||||
return view('filament::users.edit', compact('title', 'user'));
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ class UserEditForm extends Component
|
||||
public $name;
|
||||
public $email;
|
||||
public $is_super_admin;
|
||||
public $user_roles;
|
||||
|
||||
public function mount($user)
|
||||
{
|
||||
@@ -19,6 +20,7 @@ class UserEditForm extends Component
|
||||
$this->name = $user->name;
|
||||
$this->email = $user->email;
|
||||
$this->is_super_admin = $user->is_super_admin;
|
||||
$this->user_roles = $user->roles;
|
||||
}
|
||||
|
||||
public function update()
|
||||
@@ -32,6 +34,7 @@ class UserEditForm extends Component
|
||||
Rule::unique('users')->ignore($this->user->id),
|
||||
],
|
||||
'is_super_admin' => 'boolean',
|
||||
'user_roles.*' => 'exists:roles,id',
|
||||
]);
|
||||
|
||||
$this->user->update($validatedData);
|
||||
|
||||
Reference in New Issue
Block a user