[FIX] 修正新增角色時系統權限與單位顯示消失之問題
All checks were successful
star-cloud-deploy-demo / deploy-demo (push) Successful in 49s
All checks were successful
star-cloud-deploy-demo / deploy-demo (push) Successful in 49s
This commit is contained in:
@@ -4,8 +4,9 @@
|
||||
<div class="space-y-6" x-data="{
|
||||
selectedPermissions: {{ json_encode($role->permissions->pluck('name')->toArray()) }},
|
||||
@php
|
||||
$isSystemLevel = $role->is_system || (!$role->exists && auth()->user()->isSystemAdmin() && !request()->routeIs('*.sub-account-roles.*'));
|
||||
$availablePermissions = $all_permissions->flatten();
|
||||
if (!$role->is_system) {
|
||||
if (!$isSystemLevel) {
|
||||
$availablePermissions = $availablePermissions->filter(function($p) {
|
||||
return !str_starts_with($p->name, 'menu.basic') &&
|
||||
!str_starts_with($p->name, 'menu.permissions');
|
||||
@@ -81,7 +82,7 @@
|
||||
<span class="px-2.5 py-0.5 rounded-lg bg-cyan-500/10 text-cyan-500 text-[10px] font-black tracking-widest uppercase">
|
||||
{{ $role->name ?: __('New Role') }}
|
||||
</span>
|
||||
@if($role->is_system)
|
||||
@if($isSystemLevel)
|
||||
<span class="text-[10px] font-black text-emerald-500 uppercase tracking-widest">
|
||||
• {{ __('System Role') }}
|
||||
</span>
|
||||
@@ -151,21 +152,21 @@
|
||||
<label class="text-[11px] font-black text-slate-400 uppercase tracking-widest pl-1">{{ __('Affiliated Unit') }}</label>
|
||||
<div class="px-4 py-3 rounded-2xl bg-slate-50 dark:bg-slate-800/50 border border-slate-200/50 dark:border-slate-700/50 flex items-center gap-3 group">
|
||||
<div class="w-8 h-8 rounded-xl bg-cyan-500/10 text-cyan-500 flex items-center justify-center">
|
||||
@if($role->is_system || (!$role->exists && auth()->user()->isSystemAdmin()))
|
||||
@if($isSystemLevel)
|
||||
<svg class="w-4 h-4" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2.5"><path stroke-linecap="round" stroke-linejoin="round" d="M9 12l2 2 4-4m5.618-4.016A11.955 11.955 0 0112 2.944a11.955 11.955 0 01-8.618 3.04A12.02 12.02 0 003 9c0 5.591 3.824 10.29 9 11.622 5.176-1.332 9-6.03 9-11.622 0-1.042-.133-2.052-.382-3.016z" /></svg>
|
||||
@else
|
||||
<svg class="w-4 h-4" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2.5"><path stroke-linecap="round" stroke-linejoin="round" d="M19 21V5a2 2 0 00-2-2H7a2 2 0 00-2 2v16m14 0h2m-2 0h-5m-9 0H3m2 0h5M9 7h1m-1 4h1m4-4h1m-1 4h1m-5 10v-5a1 1 0 011-1h2a1 1 0 011 1v5m-4 0h4" /></svg>
|
||||
@endif
|
||||
</div>
|
||||
<span class="text-sm font-black text-slate-700 dark:text-slate-200">
|
||||
@if($role->is_system || (!$role->exists && auth()->user()->isSystemAdmin()))
|
||||
@if($isSystemLevel)
|
||||
{{ __('System Official') }}
|
||||
@else
|
||||
{{ $role->company->name ?? auth()->user()->company->name ?? '-' }}
|
||||
@endif
|
||||
</span>
|
||||
@if(auth()->user()->isSystemAdmin())
|
||||
<input type="hidden" name="is_system" value="{{ $role->exists ? ($role->is_system ? 1 : 0) : 1 }}">
|
||||
<input type="hidden" name="is_system" value="{{ $role->exists ? ($role->is_system ? 1 : 0) : ($isSystemLevel ? 1 : 0) }}">
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
@@ -193,7 +194,7 @@
|
||||
@foreach($all_permissions as $group => $permissions)
|
||||
@php
|
||||
// 如果非系統角色,過濾掉敏感權限
|
||||
if (!$role->is_system && $group === 'menu') {
|
||||
if (!$isSystemLevel && $group === 'menu') {
|
||||
$permissions = $permissions->filter(function($p) {
|
||||
return !str_starts_with($p->name, 'menu.basic') &&
|
||||
!str_starts_with($p->name, 'menu.permissions');
|
||||
|
||||
Reference in New Issue
Block a user