فهرست منبع

modificato ordinamento gruppi utente

ferrari 2 ماه پیش
والد
کامیت
7e7b0c6f5d
3فایلهای تغییر یافته به همراه48 افزوده شده و 56 حذف شده
  1. 1 1
      app/Http/Livewire/Category.php
  2. 2 2
      app/Http/Livewire/Course.php
  3. 45 53
      resources/views/livewire/category.blade.php

+ 1 - 1
app/Http/Livewire/Category.php

@@ -40,7 +40,7 @@ class Category extends Component
 
     public function render()
     {
-        $this->records = \App\Models\Category::where('parent_id', null)->get();
+        $this->records = \App\Models\Category::where('parent_id', null)->orderBy('name')->get();
         return view('livewire.category');
     }
 

+ 2 - 2
app/Http/Livewire/Course.php

@@ -112,7 +112,7 @@ class Course extends Component
             // $this->categories[] = array('id' => $record->id, 'name' => str_repeat(" / ", $indentation) . $record->name);
             $this->categories[] = array('id' => $record->id, 'name' => $record->getTree(), 'indentation' => $indentation);
             if(count($record->childs))
-                $this->getCategories($record->childs, $indentation + 1);
+                $this->getCategories($record->childs->sortBy('name'), $indentation + 1);
         }
     }
 
@@ -123,7 +123,7 @@ class Course extends Component
 
         $this->categories = array();
 
-        $this->getCategories(\App\Models\Category::select('id', 'name')->where('parent_id', null)->get(), 0);
+        $this->getCategories(\App\Models\Category::select('id', 'name')->where('parent_id', null)->orderBy('name')->get(), 0);
 
         for($i=date("Y"); $i<=date("Y") + 1; $i++)
         {

+ 45 - 53
resources/views/livewire/category.blade.php

@@ -2,28 +2,24 @@
 
     @if(!$add && !$update)
 
-    <a class="btn--ui lightGrey" href="/settings?type=anagrafica"><i class="fa-solid fa-arrow-left"></i></a><br>
+        <a class="btn--ui lightGrey" href="/settings?type=anagrafica"><i class="fa-solid fa-arrow-left"></i></a>
 
-    <header id="title--section"  class="d-flex align-items-center justify-content-between">
-        <div class="title--section_name d-flex align-items-center justify-content-between" style="display:none !important" >
-            <i class="ico--ui title_section utenti me-2"></i>
-            <h2 class="primary">@if(!$add && !$update)Categorie @else Inserimento/modifica categoria @endif</h2>
-        </div>
+        <header id="title--section"  class="d-flex align-items-center justify-content-between" style="display:none !important">
+            <div class="title--section_name d-flex align-items-center justify-content-between">
+                <i class="ico--ui title_section utenti me-2"></i>
+                <h2 class="primary">@if(!$add && !$update)Categorie @else Inserimento/modifica categoria @endif</h2>
+            </div>
+        </header>
 
         @if(!$add && !$update)
-            <div class="title--section_addButton text-right "  wire:click="add()" style="cursor: pointer;margin-top:20px;">
-                <div class="btn--ui entrata d-flex justify-items-between">
+            <div class="title--section_addButton d-flex justify-content-end" >
+                {{-- <button type="button" class="btn--ui entrata" wire:click="openImportModal" onclick="openImportModal()">Importa</button> --}}
+                <div class="btn--ui entrata d-flex justify-items-between" wire:click="add()" style="cursor: pointer;">
                     <a href="#" wire:click="add()" style="color:white">AGGIUNGI</a>
                 </div>
-            </div>
-
+            </div><br>
         @endif
 
-    </header>
-
-
-
-
         <section id="resume-table">
             <div class="compare--chart_wrapper d-none"></div>
 
@@ -45,7 +41,7 @@
                             </td>
                         </tr>
                         @if(count($record->childs))
-                            @include('livewire/category_child',['records' => $record->childs, 'indentation' => 1])
+                            @include('livewire/category_child',['records' => $record->childs->sortBy('name'), 'indentation' => 1])
                         @endif
                     @endforeach
 
@@ -55,50 +51,46 @@
         </section>
 
     @else
+        <a class="btn--ui lightGrey" href="/categories"><i class="fa-solid fa-arrow-left"></i></a><br><br>
 
-        <div class="container">
-
-            <a class="btn--ui lightGrey" href="/categories"><i class="fa-solid fa-arrow-left"></i></a><br><br>
-
-            @if (session()->has('error'))
-                <div class="alert alert-danger" role="alert">
-                    {{ session()->get('error') }}
-                </div>
-            @endif
+        @if (session()->has('error'))
+            <div class="alert alert-danger" role="alert">
+                {{ session()->get('error') }}
+            </div>
+        @endif
 
-            <div class="row">
-                <div class="col">
+        <div class="row">
+            <div class="col">
 
-                    <form action="">
+                <form action="">
 
-                        @if($parent != '')
-                            <h3>Aggiungi livello a {{$parent}}</h3><br>
-                        @endif
+                    @if($parent != '')
+                        <h3>Aggiungi livello a {{$parent}}</h3><br>
+                    @endif
 
-                        <div class="row mb-3">
-                            <div class="col">
-                                <div class="form--item">
-                                    <label for="inputName" class="form-label">Nome</label>
-                                    <input class="form-control js-keyupTitle @error('name') is-invalid @enderror" type="text" id="name" placeholder="Nome" wire:model="name">
-                                    @error('name')
-                                        <div class="invalid-feedback">{{ $message }}</div>
-                                    @enderror
-                                </div>
+                    <div class="row mb-3">
+                        <div class="col">
+                            <div class="form--item">
+                                <label for="inputName" class="form-label">Nome</label>
+                                <input class="form-control js-keyupTitle @error('name') is-invalid @enderror" type="text" id="name" placeholder="Nome" wire:model="name">
+                                @error('name')
+                                    <div class="invalid-feedback">{{ $message }}</div>
+                                @enderror
                             </div>
                         </div>
-
-                        <div class="form--item">
-                            <button type="button" class="btn--ui lightGrey" wire:click="cancel()">Annulla</button>
-                        @if($add)
-                            <button type="submit" class="btn--ui" wire:click.prevent="store()">Salva</button>
-                        @endif
-                        @if($update)
-                            <button type="submit" class="btn--ui" wire:click.prevent="update()">Salva</button>
-                        @endif
-                        </div>
-
-                    </form>
-                </div>
+                    </div>
+
+                    <div class="form--item">
+                        <button type="button" class="btn--ui lightGrey" wire:click="cancel()">Annulla</button>
+                    @if($add)
+                        <button type="submit" class="btn--ui" wire:click.prevent="store()">Salva</button>
+                    @endif
+                    @if($update)
+                        <button type="submit" class="btn--ui" wire:click.prevent="update()">Salva</button>
+                    @endif
+                    </div>
+
+                </form>
             </div>
         </div>