]> _ Git - cubedesigners_userdatabase.git/commitdiff
wait #4189 @2
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 12 Jan 2021 12:35:02 +0000 (13:35 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 12 Jan 2021 12:35:02 +0000 (13:35 +0100)
src/app/Models/Company.php
src/resources/views/columns/users.blade.php
src/resources/views/fields/users.blade.php

index 9ec58046f6150a0b1320bdcca740155cfddb85c4..003f75ba62ec921df782534c058d436d6fb30f53 100644 (file)
@@ -63,12 +63,18 @@ class Company extends CubistMagicAbstractModel
             ]
         );
 
+        $buid = null;
+        if (null !== backpack_user()) {
+            $buid = backpack_user()->id;
+        }
+
         $this->addField(['name' => 'admin',
             'type' => 'SelectFromModel',
             'optionsmodel' => User::class,
             'attribute' => 'nameWithCompany',
             'label' => __('Administrateur'),
             'tab' => __('Informations'),
+            'default' => $buid,
         ]);
 
         $this->addField([
@@ -77,6 +83,7 @@ class Company extends CubistMagicAbstractModel
             'label' => 'Contacts',
             'column' => true,
             'tab' => __('Contacts'),
+            'form' => 'update',
         ]);
 
         $this->addField(['name' => 'website',
index 344f74e592b93d0ae03e3ec2be1d34410db0e405..2e78aadb0877b5f29bdeaeb66461d768b14cc61c 100644 (file)
@@ -2,12 +2,19 @@
 @php
     $c=[];
     foreach ($entry->getUsers() as $id=>$name) {
-        $c[]='<a data-featherlight="iframe" data-featherlight-iframe-style="display:block;width:85vw;height:85vh;" href="'.backpack_url('users/'.$id.'/edit?embeded=1').'">'.$name.'</a>';
+        $c[]='<a data-featherlight="iframe" data-featherlight-iframe-style="display:block;width:85vw;height:85vh;" href="'.backpack_url('users/'.$id.'/edit?embeded=1').'">'.$name.' <i class="la la-edit"></i></a> <a title="'.__('Se connecter comme').'" href="'.backpack_url('users/'.$id.'/loginas').'"><i
+                                class="las la-key"></i></a>';
+    }
+
+    $chunked=array_chunk($c,4);
+    $c=[];
+    foreach ($chunked as $item) {
+        $c[]=implode(', ',$item);
     }
 @endphp
 
 <span>
     @includeWhen(!empty($column['wrapper']), 'crud::columns.inc.wrapper_start')
-    <span class="textarea-value">{!! implode(', ',$c) !!}</span>
+    <span class="textarea-value">{!! implode('<br>', $c) !!}</span>
     @includeWhen(!empty($column['wrapper']), 'crud::columns.inc.wrapper_end')
 </span>
index 2c9ce24ede901ff221ded21aaf01396ca00cf981..34c90fea0b372723e49ad787c4008233405fb355 100644 (file)
@@ -1,20 +1,50 @@
-{{-- regular object attribute --}}
-<div class="company-userlist">
-    <div class="add">
-    <a data-featherlight="iframe" data-featherlight-iframe-style="display:block;width:85vw;height:85vh;"
-       href="{!! backpack_url('users/createfromcompany/'.$entry->id.'?embeded=1') !!}" class="btn btn-light btn-small"><i class="la la-plus"></i> {{__('Ajouter un contact')}}</a>
+@if(isset($entry))
+    {{-- regular object attribute --}}
+    <div class="company-userlist">
+        <div class="add">
+            <a data-featherlight="iframe" data-featherlight-iframe-style="display:block;width:85vw;height:85vh;"
+               href="{!! backpack_url('users/createfromcompany/'.$entry->id.'?embeded=1') !!}"
+               class="btn btn-light btn-small"><i class="la la-plus"></i> {{__('Ajouter un contact')}}</a>
+        </div>
+        <table id="cubedesigners-user-list">
+            @foreach($entry->getUsers() as $id=>$name)
+                <tr>
+                    <td>{{$id}}</td>
+                    <td>{{$name}}</td>
+                    <td class="min"><a href="{!! backpack_url('users/'.$id.'/loginas')!!}"><i
+                                class="las la-key"></i> {{__('Se connecter comme')}}</a></td>
+                    <td class="min"><a data-featherlight="iframe"
+                                       data-featherlight-iframe-style="display:block;width:85vw;height:85vh;"
+                                       href="{!! backpack_url('users/'.$id.'/edit?embeded=1') !!}"><i
+                                class="la la-edit"></i> {{__('Modifier')}}</a></td>
+                </tr>
+            @endforeach
+        </table>
     </div>
-    <table>
-        @foreach($entry->getUsers() as $id=>$name)
-            <tr>
-                <td>{{$id}}</td>
-                <td>{{$name}}</td>
-                <td><a data-featherlight="iframe" data-featherlight-iframe-style="display:block;width:85vw;height:85vh;"
-                       href="{!! backpack_url('users/'.$id.'/edit?embeded=1') !!}">{{__('Modifier')}}</a></td>
-            </tr>
-        @endforeach
-    </table>
-</div>
-@push('crud_fields_styles')
+    @push('crud_fields_styles')
+        <style>
+            #cubedesigners-user-list .min {
+                width: 1px;
+                white-space: nowrap;
+            }
 
-@endpush
+            #cubedesigners-user-list tr{
+                border:1px solid #dce1e8;
+                background-color:#fff;
+            }
+
+            #cubedesigners-user-list tr:hover{
+                border:1px solid #dce1e8;
+                background-color:#ebebee;
+            }
+
+            #cubedesigners-user-list tr:nth-child(even){
+                background-color:#fafafa;
+            }
+
+            #cubedesigners-user-list td{
+                padding:5px 7px;
+            }
+        </style>
+    @endpush
+@endif