Commit 6f7eb5eb authored by Sarun Mungthanya's avatar Sarun Mungthanya
Browse files

issue configuration

parent 6499b290
......@@ -23,18 +23,20 @@ class CompanyCreate extends Component
public $tax_incentive;
public $action ;
protected $rules = [
'companyType' => 'required|exists:company_types,id',
'name' => 'required|string|max:255',
'tax' => 'required|integer|max:9999999999999',
'branch' => 'required|integer|max:999999',
'tax' => 'required|string|max:13',
'branch' => 'required|string|max:6',
'name_en' => 'required|string|max:255',
'address' => 'required|string|max:255',
'district' => 'required|string|max:255',
'sub_province' => 'required|string|max:255',
'province' => 'required|string|max:255',
'postcode' => 'required|string|max:10',
'phone' => 'required|string|max:15',
'address' => 'nullable|string|max:255',
'district' => 'nullable|string|max:255',
'sub_province' => 'nullable|string|max:255',
'province' => 'nullable|string|max:255',
'postcode' => 'nullable|string|max:10',
'phone' => 'nullable|string|max:15',
'fax' => 'nullable|string|max:15',
'tax_incentive' => 'nullable|string|max:255',
];
......@@ -96,15 +98,15 @@ class CompanyCreate extends Component
$newCompany->name = $this->name;
$newCompany->tax = $this->tax;
$newCompany->branch = $this->branch;
$newCompany->name_en = $this->name_en;
$newCompany->address = $this->address;
$newCompany->district = $this->district;
$newCompany->sub_province = $this->sub_province;
$newCompany->province = $this->province;
$newCompany->postcode = $this->postcode;
$newCompany->phone = $this->phone;
$newCompany->fax = $this->fax;
$newCompany->tax_incentive = $this->tax_incentive;
$newCompany->name_en = $this->name_en ??' ';
$newCompany->address = $this->address ??' ';
$newCompany->district = $this->district ??' ';
$newCompany->sub_province = $this->sub_province ??' ';
$newCompany->province = $this->province ??' ';
$newCompany->postcode = $this->postcode ??' ';
$newCompany->phone = $this->phone ??' ';
$newCompany->fax = $this->fax ??' ';
$newCompany->tax_incentive = $this->tax_incentive ??' ';
// Save the new company to the database
$newCompany->save();
......
......@@ -15,15 +15,15 @@ class CompanyEdit extends Component
protected $rules = [
'company.company_type_id' => 'required|exists:company_types,id',
'company.name' => 'required|string|max:255',
'company.tax' => 'required|integer|max:9999999999999',
'company.branch' => 'required|integer|max:999999',
'company.tax' => 'required|string|max:13',
'company.branch' => 'required|string|max:6',
'company.name_en' => 'required|string|max:255',
'company.address' => 'required|string|max:255',
'company.district' => 'required|string|max:255',
'company.sub_province' => 'required|string|max:255',
'company.province' => 'required|string|max:255',
'company.postcode' => 'required|string|max:10',
'company.phone' => 'required|string|max:15',
'company.address' => 'nullable|string|max:255',
'company.district' => 'nullable|string|max:255',
'company.sub_province' => 'nullable|string|max:255',
'company.province' => 'nullable|string|max:255',
'company.postcode' => 'nullable|string|max:10',
'company.phone' => 'nullable|string|max:15',
'company.fax' => 'nullable|string|max:15',
'company.tax_incentive' => 'nullable|string|max:255',
];
......
......@@ -16,6 +16,7 @@ class RoleCreate extends Component
public $permission_lists_temp = [];
protected $rules = [
'name' => 'required',
'description' => 'required',
];
public function mount($permissions)
{
......@@ -30,7 +31,7 @@ class RoleCreate extends Component
{
$validatedData = $this->validate([
'name' => 'required',
'description' => 'nullable',
'description' => 'required',
'permission_lists' => 'array',
]);
$this->permission_lists = $selectedList;
......
......@@ -18,6 +18,7 @@ class RoleEdit extends Component
public $permissionLists = [];
protected $rules = [
'role.name' => 'required',
'role.description' => 'required',
];
public function mount($editRoleId, $permissions)
{
......
......@@ -7,7 +7,10 @@ use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Validator;
use App\Models\Role;
use App\Models\Permission;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Log;
use Livewire\WithPagination;
use Illuminate\Support\FacadesAuth;
class RoleIndex extends Component
{
......@@ -25,12 +28,10 @@ class RoleIndex extends Component
public $menu;
public $action = 'list';
public $message;
public $selectedRoles ;
public $permissionLists= [];
public $selectedRoles ,$permission_lists= [];
public $showDeleteListModal = false;
public $showNoPermissionModal = false;
public $showMessage = false;
public $totalItems;
protected $listeners = [ 'showRoleList', 'deleteItem' , 'deleteSelected'];
public function mount()
......@@ -73,8 +74,8 @@ class RoleIndex extends Component
public function showRoleCreateForm()
{
if (!\Auth::user()->hasPermissions(['add-role'])) {
$this->showNoPermissionModal = true;
if (!Auth::user()->hasPermissions(['add-role'])) {
$this->showNoPermissionModal = TRUE;
return;
}
$this->action = 'create';
......@@ -82,8 +83,8 @@ class RoleIndex extends Component
public function showRoleEditForm($roleId)
{
if (!\Auth::user()->hasPermissions(['edit-role'])) {
$this->showNoPermissionModal = true;
if (!Auth::user()->hasPermissions(['edit-role'])) {
$this->showNoPermissionModal = TRUE;
return;
}
$this->action = 'edit';
......@@ -106,8 +107,8 @@ class RoleIndex extends Component
}
public function deleteItem($deleteRoleId)
{
if (!\Auth::user()->hasPermissions(['delete-role'])) {
$this->showNoPermissionModal = true;
if (!Auth::user()->hasPermissions(['delete-role'])) {
$this->showNoPermissionModal = TRUE;
return;
}
$role = Role::find($deleteRoleId);
......@@ -116,6 +117,7 @@ class RoleIndex extends Component
$role->delete();
$message = "Deleted Successfully";
$this->message = $message;
Log::info("Deleted Role ID : $deleteRoleId by User ".auth()->user()->id);
if ($this->message) {
$this->dispatchBrowserEvent('show-message', ['message' => $this->message]);
}
......@@ -123,15 +125,16 @@ class RoleIndex extends Component
}
public function deleteSelected($selectedRoles)
{
if (!\Auth::user()->hasPermissions(['delete-role'])) {
$this->showNoPermissionModal = true;
if (!Auth::user()->hasPermissions(['delete-role'])) {
$this->showNoPermissionModal = TRUE;
return;
}
$roleDeleted= Role::whereIn("id", $selectedRoles)->pluck('name')->toArray();
$roleStr = implode("," ,$roleDeleted);
Role::destroy($selectedRoles);
$message = "Deleted : (". $roleStr." )Successfully";
$message = "Deleted Role : (". $roleStr." ) Successfully";
Log::info("Deleted Role ID: $roleStr by User ".auth()->user()->id);
$this->message = $message;
$this->selectedRoles = [];
if ($this->message) {
......
......@@ -14,7 +14,7 @@ class UserCreate extends Component
public $action;
public $group_lists;
protected $rules = [
'username' => 'required|string|max:255',
'username' => 'required|string|max:255|unique:users,username',
'email' => 'required|string|email|max:255|unique:users,email',
'password' => 'required|string|min:8|confirmed',
];
......
......@@ -37,6 +37,7 @@ class UserIndex extends Component
{
$this->searchBy = [
'username' => 'Username',
'id'=> 'ID',
];
// $this->message = session('message');
// $this->showMessage = true;
......
......@@ -19,6 +19,7 @@
'pages.group.group-create' => 'App\\Http\\Livewire\\Pages\\Group\\GroupCreate',
'pages.group.group-edit' => 'App\\Http\\Livewire\\Pages\\Group\\GroupEdit',
'pages.group.group-index' => 'App\\Http\\Livewire\\Pages\\Group\\GroupIndex',
'pages.manual-response.manual-response' => 'App\\Http\\Livewire\\Pages\\ManualResponse\\ManualResponse',
'pages.news.news-create' => 'App\\Http\\Livewire\\Pages\\News\\NewsCreate',
'pages.news.news-edit' => 'App\\Http\\Livewire\\Pages\\News\\NewsEdit',
'pages.news.news-index' => 'App\\Http\\Livewire\\Pages\\News\\NewsIndex',
......@@ -45,6 +46,7 @@
'pages.server-license.server-license-create' => 'App\\Http\\Livewire\\Pages\\ServerLicense\\ServerLicenseCreate',
'pages.server-license.server-license-edit' => 'App\\Http\\Livewire\\Pages\\ServerLicense\\ServerLicenseEdit',
'pages.server-license.server-license-index' => 'App\\Http\\Livewire\\Pages\\ServerLicense\\ServerLicenseIndex',
'pages.user.config-manual-response' => 'App\\Http\\Livewire\\Pages\\User\\ConfigManualResponse',
'pages.user.user-create' => 'App\\Http\\Livewire\\Pages\\User\\UserCreate',
'pages.user.user-edit' => 'App\\Http\\Livewire\\Pages\\User\\UserEdit',
'pages.user.user-index' => 'App\\Http\\Livewire\\Pages\\User\\UserIndex',
......
......@@ -56,10 +56,10 @@ class DatabaseSeeder extends Seeder
$user = User::create($userData);
// Assign groups to users
$groups = Group::inRandomOrder()->take(2)->get(); // Assign 2 random groups to each user
foreach ($groups as $group) {
$group = Group::first();
// foreach ($groups as $group) {
$user->groups()->attach($group);
}
// }
}
}
}
......@@ -16,14 +16,12 @@ class GroupSeeder extends Seeder
{
$company = Company::first();
// Create groups
$group1 = Group::create(['name' => 'Group 1', 'company_id' => $company->id]);
$group2 = Group::create(['name' => 'Group 2', 'company_id' => $company->id]);
$group3 = Group::create(['name' => 'Group 3', 'company_id' => $company->id]);
$group1 = Group::create(['name' => 'Admin', 'company_id' => $company->id]);
$group2 = Group::create(['name' => 'User', 'company_id' => $company->id]);
// Assign roles to groups
$this->assignRoles($group1, ['Admin', 'Manager']);
$this->assignRoles($group2, ['Manager', 'User']);
$this->assignRoles($group3, ['User']);
$this->assignRoles($group1, ['Admin']);
$this->assignRoles($group2, [ 'User']);
}
private function assignRoles($group, $roles)
......
......@@ -19,31 +19,37 @@ class PermissionSeeder extends Seeder
// User Management
['name' => 'list-user', 'description' => 'List a user', 'permission_group_name' => 'User Management'],
['name' => 'add-user', 'description' => 'Add a user', 'permission_group_name' => 'User Management'],
['name' => 'edit-user', 'description' => 'Edit a user', 'permission_group_name' => 'User Management'],
['name' => 'delete-user', 'description' => 'Delete a user', 'permission_group_name' => 'User Management'],
// Role Management
['name' => 'list-role', 'description' => 'List a role', 'permission_group_name' => 'Role Management'],
['name' => 'add-role', 'description' => 'Add a role', 'permission_group_name' => 'Role Management'],
['name' => 'edit-role', 'description' => 'Edit a role', 'permission_group_name' => 'Role Management'],
['name' => 'delete-role', 'description' => 'Delete a role', 'permission_group_name' => 'Role Management'],
// Group Management
['name' => 'list-group', 'description' => 'List a group', 'permission_group_name' => 'Group Management'],
['name' => 'add-group', 'description' => 'Add a group', 'permission_group_name' => 'Group Management'],
['name' => 'edit-group', 'description' => 'Edit a group', 'permission_group_name' => 'Group Management'],
['name' => 'delete-group', 'description' => 'Delete a group', 'permission_group_name' => 'Group Management'],
// Company Management
['name' => 'list-company', 'description' => 'List a company', 'permission_group_name' => 'Company Management'],
['name' => 'add-company', 'description' => 'Add a company', 'permission_group_name' => 'Company Management'],
['name' => 'edit-company', 'description' => 'Edit a company', 'permission_group_name' => 'Company Management'],
['name' => 'delete-company', 'description' => 'Delete a company', 'permission_group_name' => 'Company Management'],
// Company Type Management
['name' => 'list-company-type', 'description' => 'List a company type', 'permission_group_name' => 'Company Type Management'],
['name' => 'add-company-type', 'description' => 'Add a company type', 'permission_group_name' => 'Company Type Management'],
['name' => 'edit-company-type', 'description' => 'Edit a company type', 'permission_group_name' => 'Company Type Management'],
['name' => 'delete-company-type', 'description' => 'Delete a company type', 'permission_group_name' => 'Company Type Management'],
// Server License Management
['name' => 'list-server-license', 'description' => 'List a server license', 'permission_group_name' => 'Server License Management'],
['name' => 'add-server-license', 'description' => 'Add a server license', 'permission_group_name' => 'Server License Management'],
['name' => 'edit-server-license', 'description' => 'Edit a server license', 'permission_group_name' => 'Server License Management'],
['name' => 'edit-csv-mapping', 'description' => 'Edit CSV mapping', 'permission_group_name' => 'Server License Management'],
......@@ -60,26 +66,30 @@ class PermissionSeeder extends Seeder
['name' => 'delete-server-license', 'description' => 'Delete a server license', 'permission_group_name' => 'Server License Management'],
// Patch Management
['name' => 'list-patch', 'description' => 'List a patch', 'permission_group_name' => 'Patch Management'],
['name' => 'add-patch', 'description' => 'Add a patch', 'permission_group_name' => 'Patch Management'],
['name' => 'edit-patch', 'description' => 'Edit a patch', 'permission_group_name' => 'Patch Management'],
['name' => 'delete-patch', 'description' => 'Delete a patch', 'permission_group_name' => 'Patch Management'],
// Send Patch Management
['name' => 'list-send-patch', 'description' => 'List a send patch', 'permission_group_name' => 'Send Patch Management'],
['name' => 'send-patch', 'description' => 'Send Patch', 'permission_group_name' => 'Send Patch Management'],
['name' => 'resend-patch', 'description' => 'ReSend Patch', 'permission_group_name' => 'Send Patch Management'],
['name' => 'delete-send-patch', 'description' => 'Delete a Send Patch', 'permission_group_name' => 'Send Patch Management'],
// Parameter Management
['name' => 'list-parameter', 'description' => 'List a parameter', 'permission_group_name' => 'Parameter Management'],
['name' => 'add-parameter', 'description' => 'Add a parameter', 'permission_group_name' => 'Parameter Management'],
['name' => 'edit-parameter', 'description' => 'Edit a parameter', 'permission_group_name' => 'Parameter Management'],
['name' => 'delete-parameter', 'description' => 'Delete a parameter', 'permission_group_name' => 'Parameter Management'],
// Patch Exchange Rate Management
['name' => 'list-exchange-rate', 'description' => 'List a exchange-rate', 'permission_group_name' => 'Patch Enchangerate Management'],
['name' => 'add-exchange-rate', 'description' => 'Add a Exchange Rate', 'permission_group_name' => 'Patch Enchangerate Management'],
['name' => 'upload-exchange-rate', 'description' => 'Upload Exchange Rate', 'permission_group_name' => 'Patch Enchangerate Management'],
['name' => 'edit-exchange-rate', 'description' => 'Edit a Exchange Rate', 'permission_group_name' => 'Patch Enchangerate Management'],
['name' => 'delete-exchange-rate', 'description' => 'Delete a Exchange Rate', 'permission_group_name' => 'Patch Enchangerate Management'],
// Discharge Port Management
['name' => 'upload-discharge-port', 'description' => 'Uplaod Discharge Port', 'permission_group_name' => 'Patch Enchangerate Management'],
// ['name' => 'upload-discharge-port', 'description' => 'Uplaod Discharge Port', 'permission_group_name' => 'Patch Enchangerate Management'],
];
......
......@@ -18,39 +18,38 @@ class RoleSeeder extends Seeder
public function run()
{
$permissions = [
'admin' => [
'add-user', 'edit-user', 'delete-user',
'add-role', 'edit-role', 'delete-role',
'add-group', 'edit-group', 'delete-group',
'add-company', 'edit-company', 'delete-company',
'add-company-type', 'edit-company-type', 'delete-company-type',
'add-server-license', 'edit-server-license', 'edit-csv-mapping', 'edit-print-form',
'Admin' => [
'list-user','add-user', 'edit-user', 'delete-user',
'list-role','add-role', 'edit-role', 'delete-role',
'list-group','add-group', 'edit-group', 'delete-group',
'list-company','add-company', 'edit-company', 'delete-company',
'list-company-type', 'add-company-type', 'edit-company-type', 'delete-company-type',
'list-server-license','add-server-license', 'edit-server-license', 'edit-csv-mapping', 'edit-print-form',
'edit-user-interface', 'edit-global', 'edit-parameter', 'edit-onload',
'edit-validate', 'edit-mapto', 'edit-mainvar', 'download-file-server-license',
'list-history-patch', 'delete-server-license',
'add-patch', 'edit-patch', 'delete-patch',
'send-patch', 'resend-patch', 'delete-send-patch',
'list-patch', 'add-patch', 'edit-patch', 'delete-patch',
'list-send-patch', 'send-patch', 'resend-patch', 'delete-send-patch',
'add-parameter', 'edit-parameter', 'delete-parameter',
'add-exchange-rate', 'upload-exchange-rate', 'edit-exchange-rate', 'delete-exchange-rate',
'list-exchange-rate', 'add-exchange-rate', 'upload-exchange-rate', 'edit-exchange-rate', 'delete-exchange-rate',
'upload-discharge-port'
],
'developer' => [
'add-server-license', 'edit-server-license', 'edit-csv-mapping', 'edit-print-form',
'User' => [
'list-server-license', 'add-server-license', 'edit-server-license', 'edit-csv-mapping', 'edit-print-form',
'edit-user-interface', 'edit-global', 'edit-parameter', 'edit-onload',
'edit-validate', 'edit-mapto', 'edit-mainvar', 'download-file-server-license',
'add-patch', 'edit-patch', 'delete-patch',
'add-parameter', 'edit-parameter', 'delete-parameter'
'list-patch'
],
'sales' => [
'add-company', 'edit-company', 'delete-company',
'add-company-type', 'edit-company-type', 'delete-company-type',
'send-patch'
],
'qa' => [
'add-patch', 'edit-patch', 'delete-patch',
'add-exchange-rate', 'upload-exchange-rate', 'edit-exchange-rate', 'delete-exchange-rate',
'upload-discharge-port'
]
// 'sales' => [
// 'add-company', 'edit-company', 'delete-company',
// 'add-company-type', 'edit-company-type', 'delete-company-type',
// 'send-patch'
// ],
// 'qa' => [
// 'add-patch', 'edit-patch', 'delete-patch',
// 'add-exchange-rate', 'upload-exchange-rate', 'edit-exchange-rate', 'delete-exchange-rate',
// 'upload-discharge-port'
// ]
];
// Create roles and assign permissions
......
<div x-cloak>
<div>
@include('components.no-permission')
<div wire:loading.class="flex" wire:loading.class.remove="hidden" wire:target="showRoleList"
class="absolute inset-0 items-center justify-center z-50 bg-slate-50 dark:bg-navy-900 hidden">
<div class="app-preloader grid h-full w-full place-content-center">
<div class="app-preloader-inner relative inline-block h-48 w-48"></div>
</div>
</div>
<div class="my-5 flex h-8 place-content-center px-4 ">
<h2 class="text-xl text-slate-800">
Role Management
</h2>
<h2 class="ml-3 text-xl text-slate-800 font-semibold underline underline-offset-4">
{{ $action === 'create' ? 'Create' : ($action === 'edit' ? 'Edit' : '') }}
</h2>
<div class="flex items-center space-x-4 py-5 lg:py-6 ">
<ul class="hidden flex-wrap items-center space-x-2 sm:flex">
<li class="flex items-center space-x-2">
<a class="text-primary transition-colors hover:text-primary-focus dark:text-accent-light dark:hover:text-accent"
href="/">Home</a>
<svg x-ignore xmlns="http://www.w3.org/2000/svg" class="h-4 w-4" fill="none" viewBox="0 0 24 24"
stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5l7 7-7 7" />
</svg>
</li>
<li class="flex items-center space-x-2">
<a class="text-primary transition-colors hover:text-primary-focus dark:text-accent-light dark:hover:text-accent"
wire:click="$emit('menuClicked', 'Role')">Role Management</a>
</li>
</ul>
</div>
@if ($action === 'list')
<div x-data="{ show: @entangle('showMessage'), message: '' }" x-init="window.addEventListener('show-message', event => {
......@@ -44,18 +48,34 @@
selectedRoles: @entangle('selectedRoles')
}" class="grid grid-cols-1 gap-4 sm:gap-5 lg:gap-6 ">
<div class="card pb-4 py-4 ">
<div class="card pb-4">
<div class="my-3 flex h-8 items-center justify-between px-4 sm:px-5">
<h2 class="font-medium tracking-wide text-slate-700 line-clamp-1 dark:text-navy-100 lg:text-base">
Role Management
</h2>
</div>
{{-- @include('components/search-by', ['searchBy' => $searchBy ?? []]) --}}
<div class="flex justify-between">
<div class="flex ">
<div class="px-1 ml-5">
<button type="button"
class="py-2 px-3 bg-primary rounded-md text-white hover:bg-primary-focus"
wire:click="showRoleCreateForm"><i aria-hidden="true" aria-hidden="true"
class="fa fa-add fa-solid"></i>Add</button>
</div>
<div class=" ml-1">
<div class="px-2 ml-4">
@if (Auth::user()->hasPermissions(['add-role']))
<button wire:click="showRoleCreateForm()"
class="btn h-6 w-28 rounded space-x-1 bg-primary px-3 text-xs font-medium text-white hover:bg-primary-focus focus:bg-primary-focus active:bg-primary-focus/90 dark:bg-accent dark:hover:bg-accent-focus dark:focus:bg-accent-focus dark:active:bg-accent/90">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"
stroke-width="1.5" stroke="currentColor" class="w-3 h-3">
<path stroke-linecap="round" stroke-linejoin="round"
d="M19.5 14.25v-2.625a3.375 3.375 0 00-3.375-3.375h-1.5A1.125 1.125 0 0113.5 7.125v-1.5a3.375 3.375 0 00-3.375-3.375H8.25m2.25 0H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 00-9-9z">
</path>
</svg>
<span>Create</span>
</button>
@endif
@if (Auth::user()->hasPermissions(['delete-role']))
<a @click.prevent="if (selectedRolesAlpine.length > 0) { showDeleteListModal = true; } else { showAlert = true;}"
class="py-2 px-3 bg-primary rounded-md text-white hover:bg-primary-focus flex items-center space-x-1">
class="btn h-6 w-28 rounded space-x-1 bg-primary px-3 text-xs font-medium text-white hover:bg-primary-focus focus:bg-primary-focus active:bg-primary-focus/90 dark:bg-accent dark:hover:bg-accent-focus dark:focus:bg-accent-focus dark:active:bg-accent/90">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"
stroke-width="1.5" stroke="currentColor" class="w-3 h-3">
<path stroke-linecap="round" stroke-linejoin="round"
......@@ -64,15 +84,15 @@
</svg>
<span>Delete</span>
</a>
</div>
@endif
</div>
<div class="inline-flex flex-initial">
<div x-data="{ isInputActive: true }">
<div class="flex flex-wrap gap-4 px-5 items-center">
<div class="flex gap-4 px-5 items-center">
<button @click="isInputActive = !isInputActive"
class="btn h-8 w-14 rounded-full p-0 hover:bg-slate-300/20 focus:bg-slate-300/20 active:bg-slate-300/25 dark:hover:bg-navy-300/20 dark:focus:bg-navy-300/20 dark:active:bg-navy-300/25">
<svg xmlns="http://www.w3.org/2000/svg" class="h-4.5 w-4.5" fill="none"
viewBox="0 0 24 24" stroke="black">
viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5"
d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z" />
</svg>
......@@ -97,7 +117,7 @@
@include('livewire.select-atleast-modal')
<div class="mx-3 mt-3 px-4">
<div class="is-scrollbar-hidden min-w-full overflow-x-auto" x-data="pages.tables.initExample1">
<table aria-describedby="mydesc" class="is-hoverable w-full text-left text-black">
<table aria-describedby="mydesc" class="is-hoverable w-full text-left">
<thead>
<tr>
<th scope="col"
......@@ -129,15 +149,17 @@
<label class="inline-flex items-center space-x-2">
<input @change="toggleGroup($event)"
class="form-checkbox is-basic h-4 w-4 rounded border-slate-400/70 checked:bg-primary checked:border-primary hover:border-primary focus:border-primary dark:bg-navy-900 dark:border-navy-500 dark:checked:bg-accent dark:checked:border-accent dark:hover:border-accent dark:focus:border-accent"
type="checkbox" wire:model="selectedRoles"
type="checkbox"
value="{{ $role->id }}" />
</label>
</td>
<td class="whitespace-nowrap px-4 py-3 sm:px-5">{{ $role->name }}</td>
<td class="whitespace-nowrap px-4 py-3 sm:px-5">
<ul>
@php
$permissions = $role->permissions->take(5); // Take the first 5 permissions
$remainingCount = $role->permissions->count() - $permissions->count();
$remainingCount =
$role->permissions->count() - $permissions->count();
@endphp
@foreach ($permissions as $permission)
......@@ -147,23 +169,30 @@
@endforeach
@if ($remainingCount > 0)
<li class="inline-block px-2 py-1 bg-gray-300 text-gray-700 rounded">+
<li
class="inline-block px-2 py-1 bg-gray-300 text-gray-700 rounded">
+
{{ $remainingCount }} more</li>
@endif
</ul>
</td>
<td class="whitespace-nowrap px-4 py-3 sm:px-5">{{ $role->created_at }}</td>
<td class="whitespace-nowrap px-4 py-3 sm:px-5">
<div class="flex justify-center space-x-1">
<div class="flex justify-center space-x-2">
@if (Auth::user()->hasPermissions(['edit-role']))
<a wire:click="showRoleEditForm({{ $role->id }})"
class="btn h-8 w-8 p-0 hover:bg-info/20 focus:bg-info/20 active:bg-info/25">
class="btn h-8 w-8 p-0 text-info hover:bg-info/20 focus:bg-info/20 active:bg-info/25">
<i aria-hidden="true" class="fa fa-edit"></i>
</a>
@endif
@if (Auth::user()->hasPermissions(['delete-role']))
<div>
<a @click="$wire.emit('showDeleteModal', {{ $role->id }})"
class="btn h-8 w-8 p-0 hover:text-white focus:text-white active:bg-error/25">
class="btn h-8 w-8 p-0 text-error hover:bg-error/20 focus:bg-error/20 active:bg-error/25">
<i aria-hidden="true" class="fa fa-trash-alt"></i>
</a>
</div>
@endif
</div>
</td>
</tr>
......@@ -196,7 +225,7 @@
Close
</button>
<button
@click="$wire.emitSelf('deleteSelected', selectedRoles ); showDeleteListModal = false"
@click="$wire.emitSelf('deleteSelected', selectedRolesAlpine ); showDeleteListModal = false; selectedRolesAlpine = []"
class="btn mt-6 bg-error font-medium text-white hover:bg-error-focus focus:bg-error-focus active:bg-error-focus/90">
Confirm
</button>
......
......@@ -16,7 +16,8 @@
{{ $action === 'create' ? 'Create' : ($action === 'edit' ? 'Edit' : '') }}
</h2>
</div>
<div class="m-2">
<div class="m-2" x-data="{
showDeleteListModal: @entangle('showDeleteListModal') }">
@if ($action === 'list')
@if ($message)
<div class="alert alert-success">
......@@ -75,7 +76,7 @@
<tr>
<th scope="col"
class="whitespace-nowrap rounded-tl-lg bg-slate-300 px-4 py-3 font-semibold uppercase text-black dark:bg-navy-800 dark:text-navy-100 lg:px-5">
#
ID
</th>
<th scope="col"
class="whitespace-nowrap bg-slate-300 px-4 py-3 font-semibold uppercase text-black dark:bg-navy-800 dark:text-navy-100 lg:px-5">
......@@ -101,18 +102,19 @@
</thead>
<tbody>
@foreach ($results as $user)
@foreach ($results as $index => $user)
<tr
class="border-y border-transparent border-b-slate-200 dark:border-b-navy-500">
<td class="whitespace-nowrap px-4 py-3 sm:px-5">
<label for="selectedUsers-{{ $user->id }}"
{{-- <label for="selectedUsers-{{ $user->id }}"
class="inline-flex items-center space-x-2">
<input @change="toggleGroup($event)"
class="form-checkbox is-basic h-4 w-4 rounded border-slate-400/70 checked:bg-primary checked:border-primary hover:border-primary focus:border-primary dark:bg-navy-900 dark:border-navy-500 dark:checked:bg-accent dark:checked:border-accent dark:hover:border-accent dark:focus:border-accent"
type="checkbox" wire:model.defer="selectedUsers"
id="selectedUsers-{{ $user->id }}"
value="{{ $user->id }}" />
</label>
</label> --}}
{{ $user->id }}
</td>
<td class="whitespace-nowrap px-4 py-3 sm:px-5">{{ $user->username }}</td>
<td class="whitespace-nowrap px-4 py-3 sm:px-5">{{ $user->email }}</td>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment