From 889cbc69e18845294603d852d25a55eecb50c4f8 Mon Sep 17 00:00:00 2001 From: snipe Date: Mon, 20 Oct 2025 15:48:49 +0100 Subject: [PATCH] Starter improvements - needs testing --- app/Http/Controllers/GroupsController.php | 8 +- config/permissions.php | 6 +- resources/views/groups/edit.blade.php | 313 +++++++++--------- .../views/partials/bootstrap-table.blade.php | 22 ++ 4 files changed, 185 insertions(+), 164 deletions(-) diff --git a/app/Http/Controllers/GroupsController.php b/app/Http/Controllers/GroupsController.php index 577030390b..0c9823ca62 100755 --- a/app/Http/Controllers/GroupsController.php +++ b/app/Http/Controllers/GroupsController.php @@ -88,7 +88,10 @@ class GroupsController extends Controller $groupPermissions = []; } $selected_array = Helper::selectedPermissionsArray($permissions, $groupPermissions); - return view('groups.edit', compact('group', 'permissions', 'selected_array', 'groupPermissions')); + $associated_users = $group->users()->get(); + + //dd($associated_users->toArray()); + return view('groups.edit', compact('group', 'permissions', 'selected_array', 'groupPermissions'))->with('associated_users', $associated_users); } /** @@ -105,8 +108,11 @@ class GroupsController extends Controller $group->permissions = json_encode($request->input('permission')); $group->notes = $request->input('notes'); + \Log::error(print_r($request->input('associated_users'), true)); + if (! config('app.lock_passwords')) { if ($group->save()) { + $group->users()->sync($request->input('associated_users')); return redirect()->route('groups.index')->with('success', trans('admin/groups/message.success.update')); } diff --git a/config/permissions.php b/config/permissions.php index eaf7b3f785..ae90c566de 100644 --- a/config/permissions.php +++ b/config/permissions.php @@ -9,11 +9,11 @@ return [ - 'Global' => [ + 'Superuser' => [ [ 'permission' => 'superuser', 'label' => 'Super User', - 'note' => 'Determines whether the user has full access to all aspects of the admin. This setting overrides any more specific permissions throughout the system. ', + 'note' => 'Determines whether the user has full access to all aspects of the admin. This setting overrides ALL more specific and restrictive permissions throughout the system. ', 'display' => true, ], ], @@ -22,7 +22,7 @@ return [ [ 'permission' => 'admin', 'label' => '', - 'note' => 'Determines whether the user has access to most aspects of the admin. ', + 'note' => 'Determines whether the user has access to most aspects of the system EXCEPT the Admin Settings. These users will be able to manage users, locations, categories, etc, but ARE constrained by Full Multiple Company Support if it is enabled.', 'display' => true, ], ], diff --git a/resources/views/groups/edit.blade.php b/resources/views/groups/edit.blade.php index 4c387f73ef..77ca25db21 100755 --- a/resources/views/groups/edit.blade.php +++ b/resources/views/groups/edit.blade.php @@ -7,63 +7,25 @@ ]) @section('content') - @parent @stop @section('inputFields') +
- -
+ +
{!! $errors->first('name', '') !!}
- -
+ +
+ +
+ + + +
+ +
+ + {!! $errors->first('associated_users', '
') !!} + +
+ + +
+
+

{{ trans('admin/groups/titles.permission')}}

+
+
+

{{ trans('admin/groups/titles.grant')}}

+
+
+

{{ trans('admin/groups/titles.deny')}}

+
+
- - - - - - - - - @foreach ($permissions as $area => $area_permission) - - - @if (count($area_permission) == 1) - - - - - - - - @else - - - - - - + + {{ trans('admin/groups/titles.deny')}} + {{ $area }} + + + + + + + @if (count($area_permission) > 1) @foreach ($area_permission as $index => $this_permission) @if ($this_permission['display']) - - - - - - - - @endif + + + + + @endif @endforeach + @endif - @endif - - @endforeach -
{{ trans('admin/groups/titles.permission')}}{{ trans('admin/groups/titles.grant')}}{{ trans('admin/groups/titles.deny')}}
- @unless (empty($localPermission['label'])) -

{{ $area . ': ' . $localPermission['label'] }}

- @else -

{{ $area }}

- @endunless -
- - - - - -
-

{{ $area }}

+
+ @foreach ($permissions as $area => $area_permission) + + +
+
+
+

+ {{ $area }} +

+ @if ($localPermission['note']!='') +

{{ $localPermission['note'] }}

+ @endif -
- + + + +
+
- + + + {{ trans('admin/groups/titles.allow')}} + {{ $area }} + + + + + + +
+
- {{ $this_permission['label'] }} - - + +
+
+
+ {{ $this_permission['label'] }} +
+ +
+ + +
+ +
+
- - -
- + @endforeach
+ @stop @section('moar_scripts') @@ -209,26 +199,29 @@ $(document).ready(function(){ - $('.tooltip-base').tooltip({container: 'body'}); $(".superuser").change(function() { - var perms = $(this).val(); - if (perms =='1') { - $("#nonadmin").hide(); - } else { - $("#nonadmin").show(); + if ($(this).val() == '1') { + $(".nonsuperuser").fadeOut(); + } else if ($(this).val() == '0') { + $(".nonsuperuser").fadeIn(); } }); - // Check/Uncheck all radio buttons in the group - $('tr.header-row input:radio').change(function() { - value = $(this).attr('value'); - area = $(this).data('checker-group'); - $('.radiochecker-'+area+'[value='+value+']').prop('checked', true); + $(".admin").change(function() { + if ($(this).val() == '1') { + $(".nonadmin").fadeOut(); + } else if ($(this).val() == '0') { + $(".nonadmin").fadeIn(); + } }); - $('.header-name').click(function() { - $(this).parent().nextUntil('tr.header-row').slideToggle(500); + + // Check/Uncheck all radio buttons in the group + $('.header-row input:radio').change(function() { + value = $(this).attr('value'); + area = $(this).data('checker-group'); + $('.radiochecker-'+area+'[value='+value+']').prop('checked', true); }); diff --git a/resources/views/partials/bootstrap-table.blade.php b/resources/views/partials/bootstrap-table.blade.php index 3512438014..2fb8edbb72 100644 --- a/resources/views/partials/bootstrap-table.blade.php +++ b/resources/views/partials/bootstrap-table.blade.php @@ -294,6 +294,28 @@ @endcan + @can('create', \App\Models\Groups::class) + // Groups table buttons + window.groupButtons = () => ({ + btnAdd: { + text: '{{ trans('general.create') }}', + icon: 'fa fa-plus', + event () { + window.location.href = '{{ route('groups.create') }}'; + }, + attributes: { + class: 'btn-info', + title: '{{ trans('general.create') }}', + @if ($snipeSettings->shortcuts_enabled == 1) + accesskey: 'n' + @endif + } + }, + + }); // End Groups table buttons + @endcan + + // Asset table buttons window.assetButtons = () => ({ @can('create', \App\Models\Asset::class)