diff --git a/app/Admin/Controllers/Management/AccessController.php b/app/Admin/Controllers/Management/AccessController.php index 0a456b495..23e79fa6e 100644 --- a/app/Admin/Controllers/Management/AccessController.php +++ b/app/Admin/Controllers/Management/AccessController.php @@ -119,6 +119,8 @@ public function index(Content $content) $grid->addFields([ 'description' => 'textarea', 'comment' => 'text' + ], [ + "comment" => "Commentaire", ], false); $grid->column('validated_by.lastname', 'Validé par')->display(function () { @@ -131,6 +133,9 @@ public function index(Content $content) 'validated' => 'switch', 'validated_at' => 'datetime', 'created_at' => 'datetime', + ], [ + "validated" => "Validé", + "validated_at" => "Validé le", ]); $grid->tools(function ($tools) { diff --git a/app/Admin/Controllers/Management/UserPermissionController.php b/app/Admin/Controllers/Management/UserPermissionController.php index 1b4c1f32a..580f6ceb2 100644 --- a/app/Admin/Controllers/Management/UserPermissionController.php +++ b/app/Admin/Controllers/Management/UserPermissionController.php @@ -3,6 +3,7 @@ * Manage User Permissions. * * @author Samy Nastuzzi + * @author Corentin Mercier * * @copyright Copyright (c) 2019, SiMDE-UTC * @license GNU GPL-3.0 @@ -63,6 +64,27 @@ public function getFields(bool $withAll=true) ); } + /** + * Fields to display labels definition. + * + * @param boolean $withAll Default:true. + * @return array + */ + public function getLabels(bool $withAll=true) + { + + $labels = [ + 'user' => 'Utilisateur', + ]; + + if ($withAll) { + $labels['validated_by'] = "Validé par"; + $labels['semester'] = 'Semestre'; + } + + return $labels; + } + /** * Global display interface. * @@ -75,7 +97,7 @@ public function index(Content $content) $userPermissions = Permission::where('owned_by_type', User::class)->get(); $grid::$simplePrint = true; - $grid->addFields($this->getFields()); + $grid->addFields($this->getFields(), $this->getLabels()); $grid->tools(function ($tools) { $tools->disableBatchActions(); diff --git a/app/Admin/Controllers/Management/UserRoleController.php b/app/Admin/Controllers/Management/UserRoleController.php index b1b3f7c11..18b3dcf0e 100644 --- a/app/Admin/Controllers/Management/UserRoleController.php +++ b/app/Admin/Controllers/Management/UserRoleController.php @@ -3,6 +3,7 @@ * Manage User roles. * * @author Samy Nastuzzi + * @author Corentin Mercier * * @copyright Copyright (c) 2019, SiMDE-UTC * @license GNU GPL-3.0 @@ -63,6 +64,28 @@ public function getFields(bool $withAll=true) ); } + /** + * Fields to display labels definition. + * + * @param boolean $withAll Default:true. + * @return array + */ + public function getLabels(bool $withAll=true) + { + + $labels = [ + 'role' => 'Rôle', + 'user' => 'Utilisateur', + ]; + + if ($withAll) { + $labels['validated_by'] = "Validé par"; + $labels['semester'] = 'Semestre'; + } + + return $labels; + } + /** * Global display interface. * @@ -75,7 +98,7 @@ public function index(Content $content) $userRoles = Role::where('owned_by_type', User::class)->get(); $grid::$simplePrint = true; - $grid->addFields($this->getFields()); + $grid->addFields($this->getFields(), $this->getLabels()); $grid->tools(function ($tools) { $tools->disableBatchActions(); diff --git a/app/Admin/Controllers/Resource/AccessController.php b/app/Admin/Controllers/Resource/AccessController.php index 4667175ea..979b5d05f 100644 --- a/app/Admin/Controllers/Resource/AccessController.php +++ b/app/Admin/Controllers/Resource/AccessController.php @@ -3,6 +3,7 @@ * Manage Accesses as admin. * * @author Samy Nastuzzi + * @author Corentin Mercier * * @copyright Copyright (c) 2018, SiMDE-UTC * @license GNU GPL-3.0 @@ -16,6 +17,8 @@ class AccessController extends ResourceController { protected $model = Access::class; + protected $name = "Accès"; + /** * Fields to display definition. * @@ -33,4 +36,17 @@ protected function getFields(): array 'updated_at' => 'date' ]; } + + /** + * Fields to display labels definition. + * + * @return array + */ + protected function getLabels(): array + { + return [ + 'name' => 'Nom', + 'utc_access' => 'Numéro d\'accès UTC', + ]; + } } diff --git a/app/Admin/Controllers/Resource/ArticleActionController.php b/app/Admin/Controllers/Resource/ArticleActionController.php index cac51c392..51b8d8f62 100644 --- a/app/Admin/Controllers/Resource/ArticleActionController.php +++ b/app/Admin/Controllers/Resource/ArticleActionController.php @@ -3,6 +3,7 @@ * Manage ArticleActions as admin. * * @author Samy Nastuzzi + * @author Corentin Mercier * * @copyright Copyright (c) 2018, SiMDE-UTC * @license GNU GPL-3.0 @@ -18,6 +19,8 @@ class ArticleActionController extends ResourceController { protected $model = ArticleAction::class; + protected $name = "Actions d'articles"; + /** * Fields to display definition. * @@ -41,6 +44,20 @@ protected function getFields(): array ]; } + /** + * Fields to display labels definition. + * + * @return array + */ + protected function getLabels(): array + { + return [ + 'user' => "Utilisateur", + 'key' => 'Clé', + 'value' => 'Valeur', + ]; + } + /** * Default values definition of the fields to display. * diff --git a/app/Admin/Controllers/Resource/ArticleController.php b/app/Admin/Controllers/Resource/ArticleController.php index 5ce395e81..92d81b89b 100644 --- a/app/Admin/Controllers/Resource/ArticleController.php +++ b/app/Admin/Controllers/Resource/ArticleController.php @@ -3,6 +3,7 @@ * Manage Articles as admin. * * @author Samy Nastuzzi + * @author Corentin Mercier * * @copyright Copyright (c) 2018, SiMDE-UTC * @license GNU GPL-3.0 @@ -19,6 +20,8 @@ class ArticleController extends ResourceController { protected $model = Article::class; + protected $name = "Article"; + /** * Fields to display definition. * @@ -42,6 +45,23 @@ protected function getFields(): array ]; } + /** + * Fields to display labels definition. + * + * @return array + */ + protected function getLabels(): array + { + return [ + 'title' => 'Titre', + 'content' => 'Contenu', + 'event' => 'Évènement', + 'visibility' => 'Visibilité', + 'created_by' => 'Créé par', + 'owned_by' => 'Possédé par', + ]; + } + /** * Default values definition of the fields to display. * diff --git a/app/Admin/Controllers/Resource/AssoAccessController.php b/app/Admin/Controllers/Resource/AssoAccessController.php index 51b02be5c..6fcb12e29 100644 --- a/app/Admin/Controllers/Resource/AssoAccessController.php +++ b/app/Admin/Controllers/Resource/AssoAccessController.php @@ -3,6 +3,7 @@ * Manage AssosAccesses as admin. * * @author Samy Nastuzzi + * @author Corentin Mercier * * @copyright Copyright (c) 2018, SiMDE-UTC * @license GNU GPL-3.0 @@ -20,6 +21,8 @@ class AssoAccessController extends ResourceController { protected $model = AssoAccess::class; + protected $name = "Accès par association"; + /** * Fields to display definition. * @@ -44,6 +47,26 @@ protected function getFields(): array ]; } + /** + * Fields to display labels definition. + * + * @return array + */ + protected function getLabels(): array + { + return [ + 'asso' => 'Association', + 'access' => 'Accès', + 'member' => 'Membre', + 'semester' => 'Semestre', + 'confirmed_by' => 'Confirmé par', + 'validated_by' => 'Validé par', + 'comment' => 'Commentaire', + 'validated_at' => 'Validé le', + 'validated' => 'Validé', + ]; + } + /** * Default values definition of the fields to display. * diff --git a/app/Admin/Controllers/Resource/AssoController.php b/app/Admin/Controllers/Resource/AssoController.php index a48796db6..63d9a9050 100644 --- a/app/Admin/Controllers/Resource/AssoController.php +++ b/app/Admin/Controllers/Resource/AssoController.php @@ -3,6 +3,7 @@ * Manage Associations as admin. * * @author Samy Nastuzzi + * @author Corentin Mercier * * @copyright Copyright (c) 2018, SiMDE-UTC * @license GNU GPL-3.0 @@ -17,6 +18,8 @@ class AssoController extends ResourceController { protected $model = Asso::class; + protected $name = "Association"; + /** * Fields to display definition. * @@ -40,6 +43,20 @@ protected function getFields(): array ]; } + /** + * Fields to display labels definition. + * + * @return array + */ + protected function getLabels(): array + { + return [ + 'name' => 'Nom Officiel', + 'shortname' => 'Nom D\'usage', + 'in_cemetery_at' => 'Mis au cimetière le', + ]; + } + /** * Return dependencies. * diff --git a/app/Admin/Controllers/Resource/AssoTypeController.php b/app/Admin/Controllers/Resource/AssoTypeController.php index 398cf6c84..505082c8a 100644 --- a/app/Admin/Controllers/Resource/AssoTypeController.php +++ b/app/Admin/Controllers/Resource/AssoTypeController.php @@ -3,6 +3,7 @@ * Manage Association Types as admin. * * @author Samy Nastuzzi + * @author Corentin Mercier * * @copyright Copyright (c) 2018, SiMDE-UTC * @license GNU GPL-3.0 @@ -16,6 +17,8 @@ class AssoTypeController extends ResourceController { protected $model = AssoType::class; + protected $name = "Types d'association"; + /** * Fields to display definition. * @@ -31,4 +34,16 @@ protected function getFields(): array 'updated_at' => 'date', ]; } + + /** + * Fields to display labels definition. + * + * @return array + */ + protected function getLabels(): array + { + return [ + 'name' => 'Name', + ]; + } } diff --git a/app/Admin/Controllers/Resource/AuthAppController.php b/app/Admin/Controllers/Resource/AuthAppController.php index 14962fa5f..8cd25e89e 100644 --- a/app/Admin/Controllers/Resource/AuthAppController.php +++ b/app/Admin/Controllers/Resource/AuthAppController.php @@ -3,6 +3,7 @@ * Manage Applications Authentification as admin. * * @author Samy Nastuzzi + * @author Corentin Mercier * * @copyright Copyright (c) 2018, SiMDE-UTC * @license GNU GPL-3.0 @@ -17,6 +18,8 @@ class AuthAppController extends ResourceController { protected $model = AuthApp::class; + protected $name = "Autentification par application"; + /** * Fields to display definition. * @@ -35,6 +38,21 @@ protected function getFields(): array ]; } + /** + * Fields to display labels definition. + * + * @return array + */ + protected function getLabels(): array + { + return [ + 'user' => 'Utilisateur', + 'app_id' => 'Id de l\'application', + 'password' => 'Mot de passe', + 'key' => 'Clé', + ]; + } + /** * Return dependencies. * diff --git a/app/Admin/Controllers/Resource/AuthCasController.php b/app/Admin/Controllers/Resource/AuthCasController.php index d7bf29793..8bc91f12b 100644 --- a/app/Admin/Controllers/Resource/AuthCasController.php +++ b/app/Admin/Controllers/Resource/AuthCasController.php @@ -3,6 +3,7 @@ * Manage CAS authentifications as admin. * * @author Samy Nastuzzi + * @author Corentin Mercier * * @copyright Copyright (c) 2018, SiMDE-UTC * @license GNU GPL-3.0 @@ -17,6 +18,8 @@ class AuthCasController extends ResourceController { protected $model = AuthCas::class; + protected $name = "Autentification par CAS"; + /** * Fields to display definition. * @@ -37,6 +40,21 @@ protected function getFields(): array ]; } + /** + * Fields to display labels definition. + * + * @return array + */ + protected function getLabels(): array + { + return [ + 'user' => "Utilisateur", + 'is_active' => 'Est actif', + 'is_confirmed' => 'Est confirmé', + 'last_login_at' => 'Dernière connexion le', + ]; + } + /** * Return dependencies. * diff --git a/app/Admin/Controllers/Resource/AuthPasswordController.php b/app/Admin/Controllers/Resource/AuthPasswordController.php index ed5a808c2..ed6ec1c6e 100644 --- a/app/Admin/Controllers/Resource/AuthPasswordController.php +++ b/app/Admin/Controllers/Resource/AuthPasswordController.php @@ -3,6 +3,7 @@ * Manage Password Authentifications as admin. * * @author Samy Nastuzzi + * @author Corentin Mercier * * @copyright Copyright (c) 2018, SiMDE-UTC * @license GNU GPL-3.0 @@ -17,6 +18,8 @@ class AuthPasswordController extends ResourceController { protected $model = AuthPassword::class; + protected $name = "Autentification par Mot de passe"; + /** * Fields to display definition. * @@ -34,6 +37,20 @@ protected function getFields(): array ]; } + /** + * Fields to display labels definition. + * + * @return array + */ + protected function getLabels(): array + { + return [ + 'user' => "Utilisateur", + 'password' => 'Mot de passe', + 'last_login_at' => 'Dernière connexion le', + ]; + } + /** * Return dependencies. * diff --git a/app/Admin/Controllers/Resource/BookingController.php b/app/Admin/Controllers/Resource/BookingController.php index 91663e7de..4c706e160 100644 --- a/app/Admin/Controllers/Resource/BookingController.php +++ b/app/Admin/Controllers/Resource/BookingController.php @@ -3,6 +3,7 @@ * Manage Bookings as admin. * * @author Samy Nastuzzi + * @author Corentin Mercier * * @copyright Copyright (c) 2018, SiMDE-UTC * @license GNU GPL-3.0 @@ -18,6 +19,8 @@ class BookingController extends ResourceController { protected $model = Booking::class; + protected $name = "Réservation"; + /** * Fields to display definition. * @@ -39,6 +42,22 @@ protected function getFields(): array ]; } + /** + * Fields to display labels definition. + * + * @return array + */ + protected function getLabels(): array + { + return [ + 'room' => 'Salle', + 'event' => 'Évènement', + 'created_by' => 'Créé par', + 'owned_by' => 'Possédé par', + 'validated_by' => 'Validé par', + ]; + } + /** * Default values definition of the fields to display. * diff --git a/app/Admin/Controllers/Resource/BookingTypeController.php b/app/Admin/Controllers/Resource/BookingTypeController.php index 73ef52ac3..f1b622906 100644 --- a/app/Admin/Controllers/Resource/BookingTypeController.php +++ b/app/Admin/Controllers/Resource/BookingTypeController.php @@ -3,6 +3,7 @@ * Manage BookingTypes as admin. * * @author Samy Nastuzzi + * @author Corentin Mercier * * @copyright Copyright (c) 2018, SiMDE-UTC * @license GNU GPL-3.0 @@ -16,6 +17,8 @@ class BookingTypeController extends ResourceController { protected $model = BookingType::class; + protected $name = "Type de réservation"; + /** * Fields to display definition. * @@ -32,4 +35,17 @@ protected function getFields(): array 'updated_at' => 'date' ]; } + + /** + * Fields to display labels definition. + * + * @return array + */ + protected function getLabels(): array + { + return [ + 'name' => 'Nom', + 'need_validation' => 'Doit être validé', + ]; + } } diff --git a/app/Admin/Controllers/Resource/CalendarController.php b/app/Admin/Controllers/Resource/CalendarController.php index e70eeceaa..c34cb4bea 100644 --- a/app/Admin/Controllers/Resource/CalendarController.php +++ b/app/Admin/Controllers/Resource/CalendarController.php @@ -3,6 +3,7 @@ * Manage Calendars as admin. * * @author Samy Nastuzzi + * @author Corentin Mercier * * @copyright Copyright (c) 2018, SiMDE-UTC * @license GNU GPL-3.0 @@ -18,6 +19,8 @@ class CalendarController extends ResourceController { protected $model = Calendar::class; + protected $name = "Calendrier"; + /** * Fields to display definition. * @@ -38,6 +41,22 @@ protected function getFields(): array ]; } + /** + * Fields to display labels definition. + * + * @return array + */ + protected function getLabels(): array + { + return [ + 'name' => 'Nom', + 'color' => 'Couleur', + 'visibility' => 'Visibilité', + 'created_by' => 'Créé par', + 'owned_by' => 'Possédé par', + ]; + } + /** * Default values definition of the fields to display. * diff --git a/app/Admin/Controllers/Resource/ClientController.php b/app/Admin/Controllers/Resource/ClientController.php index 2539d4745..8495bdc91 100644 --- a/app/Admin/Controllers/Resource/ClientController.php +++ b/app/Admin/Controllers/Resource/ClientController.php @@ -3,6 +3,7 @@ * Manage Clients as admin. * * @author Samy Nastuzzi + * @author Corentin Mercier * * @copyright Copyright (c) 2018, SiMDE-UTC * @license GNU GPL-3.0 @@ -18,6 +19,8 @@ class ClientController extends ResourceController { protected $model = Client::class; + protected $name = "Client OAuth"; + /** * Fields to display definition. * @@ -42,6 +45,17 @@ protected function getFields(): array ]; } + /** + * Fields to display labels definition. + * + * @return array + */ + protected function getLabels(): array + { + // Keep fields names as label. + return []; + } + /** * Default values definition of the fields to display. * diff --git a/app/Admin/Controllers/Resource/CommentController.php b/app/Admin/Controllers/Resource/CommentController.php index 38442ed7f..8df71e002 100644 --- a/app/Admin/Controllers/Resource/CommentController.php +++ b/app/Admin/Controllers/Resource/CommentController.php @@ -3,6 +3,7 @@ * Manage Comments as admin. * * @author Samy Nastuzzi + * @author Corentin Mercier * * @copyright Copyright (c) 2018, SiMDE-UTC * @license GNU GPL-3.0 @@ -18,6 +19,8 @@ class CommentController extends ResourceController { protected $model = Comment::class; + protected $name = "Commentaire"; + /** * Fields to display definition. * @@ -35,6 +38,20 @@ protected function getFields(): array ]; } + /** + * Fields to display labels definition. + * + * @return array + */ + protected function getLabels(): array + { + return [ + 'body' => 'Contenu', + 'created_by' => 'Créé par', + 'owned_by' => 'Possédé par', + ]; + } + /** * Default values definition of the fields to display. * diff --git a/app/Admin/Controllers/Resource/ContactController.php b/app/Admin/Controllers/Resource/ContactController.php index 89cd439fe..d43fa0d73 100644 --- a/app/Admin/Controllers/Resource/ContactController.php +++ b/app/Admin/Controllers/Resource/ContactController.php @@ -3,6 +3,7 @@ * Manage Contacts as admin. * * @author Samy Nastuzzi + * @author Corentin Mercier * * @copyright Copyright (c) 2018, SiMDE-UTC * @license GNU GPL-3.0 @@ -11,13 +12,15 @@ namespace App\Admin\Controllers\Resource; use App\Models\{ - User, Contact, ContactType, Visibility + Contact, ContactType, Visibility }; class ContactController extends ResourceController { protected $model = Contact::class; + protected $name = "Moyen de contact"; + /** * Fields to display definition. * @@ -37,6 +40,21 @@ protected function getFields(): array ]; } + /** + * Fields to display labels definition. + * + * @return array + */ + protected function getLabels(): array + { + return [ + 'name' => 'Nom', + 'value' => 'Valeur', + 'visibility' => 'Visibilité', + 'owned_by' => 'Possédé par', + ]; + } + /** * Default values definition of the fields to display. * diff --git a/app/Admin/Controllers/Resource/ContactTypeController.php b/app/Admin/Controllers/Resource/ContactTypeController.php index 93cd80982..faaafab6d 100644 --- a/app/Admin/Controllers/Resource/ContactTypeController.php +++ b/app/Admin/Controllers/Resource/ContactTypeController.php @@ -3,6 +3,7 @@ * Manage ContactTypes as admin. * * @author Samy Nastuzzi + * @author Corentin Mercier * * @copyright Copyright (c) 2018, SiMDE-UTC * @license GNU GPL-3.0 @@ -16,6 +17,8 @@ class ContactTypeController extends ResourceController { protected $model = ContactType::class; + protected $name = "Type de contact"; + /** * Fields to display definition. * @@ -24,12 +27,22 @@ class ContactTypeController extends ResourceController protected function getFields(): array { return [ - 'id' => 'display', 'type' => 'display', 'name' => 'text', 'pattern' => 'text', - 'created_at' => 'date', - 'updated_at' => 'date', + ]; + } + + /** + * Fields to display labels definition. + * + * @return array + */ + protected function getLabels(): array + { + return [ + 'name' => 'Nom', + 'pattern' => 'Structure', ]; } } diff --git a/app/Admin/Controllers/Resource/EventController.php b/app/Admin/Controllers/Resource/EventController.php index 6aceba0fd..8b9f17b91 100644 --- a/app/Admin/Controllers/Resource/EventController.php +++ b/app/Admin/Controllers/Resource/EventController.php @@ -3,6 +3,7 @@ * Manage Events as admin. * * @author Samy Nastuzzi + * @author Corentin Mercier * * @copyright Copyright (c) 2018, SiMDE-UTC * @license GNU GPL-3.0 @@ -18,6 +19,8 @@ class EventController extends ResourceController { protected $model = Event::class; + protected $name = "Évènement"; + /** * Fields to display definition. * @@ -40,6 +43,25 @@ protected function getFields(): array ]; } + /** + * Fields to display labels definition. + * + * @return array + */ + protected function getLabels(): array + { + return [ + 'name' => 'Nom', + 'location' => 'Lieu', + 'visibility' => 'Visibilité', + 'begin_at' => 'Commence le', + 'end_at' => 'Fini le', + 'full_day' => 'Journée entière', + 'created_by' => 'Créé par', + 'owned_by' => 'Possédé par', + ]; + } + /** * Default values definition of the fields to display. * diff --git a/app/Admin/Controllers/Resource/EventDetailController.php b/app/Admin/Controllers/Resource/EventDetailController.php index 0b73091dc..9492a9a0d 100644 --- a/app/Admin/Controllers/Resource/EventDetailController.php +++ b/app/Admin/Controllers/Resource/EventDetailController.php @@ -3,6 +3,7 @@ * Manage EventDetails as admin. * * @author Samy Nastuzzi + * @author Corentin Mercier * * @copyright Copyright (c) 2018, SiMDE-UTC * @license GNU GPL-3.0 @@ -18,6 +19,8 @@ class EventDetailController extends ResourceController { protected $model = EventDetail::class; + protected $name = "Détail d'évènements"; + /** * Fields to display definition. * @@ -36,6 +39,20 @@ protected function getFields(): array ]; } + /** + * Fields to display labels definition. + * + * @return array + */ + protected function getLabels(): array + { + return [ + 'event' => 'Évènement', + 'key' => 'Clé', + 'value' => 'Valeur', + ]; + } + /** * Return dependencies. * diff --git a/app/Admin/Controllers/Resource/FaqCategoryController.php b/app/Admin/Controllers/Resource/FaqCategoryController.php index cac6841ed..c74acd661 100644 --- a/app/Admin/Controllers/Resource/FaqCategoryController.php +++ b/app/Admin/Controllers/Resource/FaqCategoryController.php @@ -3,6 +3,7 @@ * Manage FAQ questions categories as admin. * * @author Samy Nastuzzi + * @author Corentin Mercier * * @copyright Copyright (c) 2019, SiMDE-UTC * @license GNU GPL-3.0 @@ -18,6 +19,8 @@ class FaqCategoryController extends ResourceController { protected $model = FaqCategory::class; + protected $name = "Catégorie de FAQ"; + /** * Field to display definition. * @@ -37,6 +40,20 @@ protected function getFields(): array ]; } + /** + * Fields to display labels definition. + * + * @return array + */ + protected function getLabels(): array + { + return [ + 'name' => 'Nom', + 'lang' => 'Langue', + 'visibility' => "Visibilité", + ]; + } + /** * Default values definition of the fields to display. * diff --git a/app/Admin/Controllers/Resource/FaqController.php b/app/Admin/Controllers/Resource/FaqController.php index 5dfa46b49..9f4d199fc 100644 --- a/app/Admin/Controllers/Resource/FaqController.php +++ b/app/Admin/Controllers/Resource/FaqController.php @@ -3,6 +3,7 @@ * Manage FAQ questions as admin. * * @author Samy Nastuzzi + * @author Corentin Mercier * * @copyright Copyright (c) 2019, SiMDE-UTC * @license GNU GPL-3.0 @@ -18,6 +19,8 @@ class FaqController extends ResourceController { protected $model = Faq::class; + protected $name = "FAQ"; + /** * Fields to display definition. * @@ -36,6 +39,20 @@ protected function getFields(): array ]; } + /** + * Fields to display labels definition. + * + * @return array + */ + protected function getLabels(): array + { + return [ + 'answer' => 'Réponse', + 'category' => "Catégorie", + 'visibility' => "Visibilité", + ]; + } + /** * Default values definition of the fields to display. * @@ -44,8 +61,9 @@ protected function getFields(): array protected function getDefaults(): array { return [ - 'category_id' => FaqCategory::orderBy('created_at', 'DESC')->first()->id, - 'visibility_id' => Visibility::first()->id, + // We'll uncomment this once FaqCategories will be filled. + // 'category_id' => FaqCategory::orderBy('created_at', 'DESC')->first()->id. + 'visibility_id' => Visibility::where('type', "public")->first()->id, ]; } diff --git a/app/Admin/Controllers/Resource/GroupController.php b/app/Admin/Controllers/Resource/GroupController.php index 8e64aaed2..966d1ce0a 100644 --- a/app/Admin/Controllers/Resource/GroupController.php +++ b/app/Admin/Controllers/Resource/GroupController.php @@ -3,6 +3,7 @@ * Manage Groups as admin. * * @author Samy Nastuzzi + * @author Corentin Mercier * * @copyright Copyright (c) 2018, SiMDE-UTC * @license GNU GPL-3.0 @@ -18,6 +19,8 @@ class GroupController extends ResourceController { protected $model = Group::class; + protected $name = "Groupe"; + /** * Fields to display definition. * @@ -27,6 +30,7 @@ protected function getFields(): array { return [ 'id' => 'display', + 'name' => 'text', 'user' => User::get(['id', 'lastname', 'firstname']), 'icon' => 'text', 'visibility' => Visibility::get(['id', 'name']), @@ -35,6 +39,21 @@ protected function getFields(): array ]; } + /** + * Fields to display labels definition. + * + * @return array + */ + protected function getLabels(): array + { + return [ + 'name' => 'Nom', + 'user' => 'Utilisateur', + 'icon' => 'Icône', + 'visibility' => 'Visibilité', + ]; + } + /** * Default values definition of the fields to display. * diff --git a/app/Admin/Controllers/Resource/LocationController.php b/app/Admin/Controllers/Resource/LocationController.php index 44711f219..db6078ba9 100644 --- a/app/Admin/Controllers/Resource/LocationController.php +++ b/app/Admin/Controllers/Resource/LocationController.php @@ -3,6 +3,7 @@ * Manage Locations as admin. * * @author Samy Nastuzzi + * @author Corentin Mercier * * @copyright Copyright (c) 2018, SiMDE-UTC * @license GNU GPL-3.0 @@ -18,6 +19,8 @@ class LocationController extends ResourceController { protected $model = Location::class; + protected $name = "Lieu"; + /** * Fields to display definition. * @@ -35,6 +38,19 @@ protected function getFields(): array ]; } + /** + * Fields to display labels definition. + * + * @return array + */ + protected function getLabels(): array + { + return [ + 'name' => 'Nom', + 'place' => 'Emplacement', + ]; + } + /** * Return dependencies. * diff --git a/app/Admin/Controllers/Resource/NotificationController.php b/app/Admin/Controllers/Resource/NotificationController.php index fb5ce2fd7..c772ff436 100644 --- a/app/Admin/Controllers/Resource/NotificationController.php +++ b/app/Admin/Controllers/Resource/NotificationController.php @@ -3,6 +3,7 @@ * Manage Notifications as admin. * * @author Samy Nastuzzi + * @author Corentin Mercier * * @copyright Copyright (c) 2018, SiMDE-UTC * @license GNU GPL-3.0 @@ -34,6 +35,19 @@ protected function getFields(): array ]; } + /** + * Fields to display labels definition. + * + * @return array + */ + protected function getLabels(): array + { + return [ + 'data' => 'Contenu', + 'read_at' => 'Lue le', + ]; + } + /** * Return dependencies. * diff --git a/app/Admin/Controllers/Resource/PartnerController.php b/app/Admin/Controllers/Resource/PartnerController.php index e5ef706ea..ffa538a39 100644 --- a/app/Admin/Controllers/Resource/PartnerController.php +++ b/app/Admin/Controllers/Resource/PartnerController.php @@ -17,6 +17,8 @@ class PartnerController extends ResourceController { protected $model = Partner::class; + protected $name = "Partenaire"; + /** * Fields to display definition. * @@ -36,4 +38,20 @@ protected function getFields(): array 'updated_at' => 'date' ]; } + + /** + * Fields to display labels definition. + * + * @return array + */ + protected function getLabels(): array + { + return [ + 'name' => 'Nom', + 'website' => 'Site web', + 'address' => 'Adresse', + 'postal_code' => 'Code Postal', + 'city' => 'Ville', + ]; + } } diff --git a/app/Admin/Controllers/Resource/PermissionController.php b/app/Admin/Controllers/Resource/PermissionController.php index 4b4ea5cd5..dbb4593d2 100644 --- a/app/Admin/Controllers/Resource/PermissionController.php +++ b/app/Admin/Controllers/Resource/PermissionController.php @@ -3,6 +3,7 @@ * Manage Permissions as admin. * * @author Samy Nastuzzi + * @author Corentin Mercier * * @copyright Copyright (c) 2018, SiMDE-UTC * @license GNU GPL-3.0 @@ -16,6 +17,8 @@ class PermissionController extends ResourceController { protected $model = Permission::class; + protected $name = "Permission"; + /** * Fields to display definition. * @@ -34,6 +37,19 @@ protected function getFields(): array ]; } + /** + * Fields to display labels definition. + * + * @return array + */ + protected function getLabels(): array + { + return [ + 'name' => 'nom', + 'owned_by' => 'Possédé par', + ]; + } + /** * Returns dependencies. * diff --git a/app/Admin/Controllers/Resource/PlaceController.php b/app/Admin/Controllers/Resource/PlaceController.php index a5620ed00..6eee402bd 100644 --- a/app/Admin/Controllers/Resource/PlaceController.php +++ b/app/Admin/Controllers/Resource/PlaceController.php @@ -3,6 +3,7 @@ * Manages Places as admin. * * @author Samy Nastuzzi + * @author Corentin Mercier * * @copyright Copyright (c) 2018, SiMDE-UTC * @license GNU GPL-3.0 @@ -16,6 +17,8 @@ class PlaceController extends ResourceController { protected $model = Place::class; + protected $name = "Emplacement"; + /** * Fields to display definition. * @@ -34,4 +37,19 @@ protected function getFields(): array 'updated_at' => 'date', ]; } + + /** + * Fields to display labels definition. + * + * @return array + */ + protected function getLabels(): array + { + return [ + 'name' => 'Nom', + 'address' => 'Adresse', + 'city' => 'Ville', + 'country' => 'Pays', + ]; + } } diff --git a/app/Admin/Controllers/Resource/ResourceController.php b/app/Admin/Controllers/Resource/ResourceController.php index ab285ae5a..79b3c5173 100644 --- a/app/Admin/Controllers/Resource/ResourceController.php +++ b/app/Admin/Controllers/Resource/ResourceController.php @@ -3,6 +3,7 @@ * Generate a management of an admin resource. * * @author Samy Nastuzzi + * @author Corentin Mercier * * @copyright Copyright (c) 2018, SiMDE-UTC * @license GNU GPL-3.0 @@ -13,9 +14,7 @@ use App\Http\Controllers\Controller; use Encore\Admin\Controllers\HasResourceActions; use Encore\Admin\Form; -use Encore\Admin\Grid; use Encore\Admin\Layout\Content; -use Encore\Admin\Show; use App\Admin\{ GridGenerator, ShowGenerator, FormGenerator }; @@ -31,6 +30,13 @@ abstract class ResourceController extends Controller */ protected $model; + /** + * Resource display name + * + * @var string + */ + protected $name = null; + /** * Give access only if the user hs the right permission. */ @@ -46,6 +52,13 @@ public function __construct() */ abstract protected function getFields(): array; + /** + * Fields to display definition. + * + * @return array + */ + abstract protected function getLabels(): array; + /** * Default values definition of the fields to display. * @@ -73,7 +86,7 @@ protected function getWith(): array */ protected function getName(): string { - return ucfirst(\ModelResolver::getName($this->model)); + return $this->name ? $this->name : ucfirst(\ModelResolver::getName($this->model)); } /** @@ -86,7 +99,7 @@ public function index(Content $content) { $grid = new GridGenerator($this->model); - $grid->addFields($this->getFields()); + $grid->addFields($this->getFields(), $this->getLabels()); return $content ->header($this->getName()) @@ -111,7 +124,7 @@ public function show($model_id, Content $content) $show = new ShowGenerator($model->findOrFail($model_id)); - $show->addFields(array_keys($this->getFields())); + $show->addFields(array_keys($this->getFields()), $this->getLabels()); return $content ->header($this->getName()) @@ -158,7 +171,7 @@ protected function form() $form = new FormGenerator($this->model); $defaults = $this->getDefaults(); - $form->addFields($this->getFields(), $defaults); + $form->addFields($this->getFields(), $this->getLabels(), $defaults); $form->saving(function (Form $form) use ($defaults) { foreach ($defaults as $key => $default) { $form->$key = $form->$key ?: $default; diff --git a/app/Admin/Controllers/Resource/RoleController.php b/app/Admin/Controllers/Resource/RoleController.php index a573ee7d0..612db2476 100644 --- a/app/Admin/Controllers/Resource/RoleController.php +++ b/app/Admin/Controllers/Resource/RoleController.php @@ -3,6 +3,7 @@ * Manage Roles as admin. * * @author Samy Nastuzzi + * @author Corentin Mercier * * @copyright Copyright (c) 2018, SiMDE-UTC * @license GNU GPL-3.0 @@ -10,12 +11,15 @@ namespace App\Admin\Controllers\Resource; +use App\Models\Asso; use App\Models\Role; class RoleController extends ResourceController { protected $model = Role::class; + protected $name = "Rôle"; + /** * Fields to display definition. * @@ -35,6 +39,20 @@ protected function getFields(): array ]; } + /** + * Fields to display labels definition. + * + * @return array + */ + protected function getLabels(): array + { + return [ + 'name' => 'Nom', + 'limited_at' => 'Limité à', + 'owned_by' => 'Possédé par', + ]; + } + /** * Return dependencies. * diff --git a/app/Admin/Controllers/Resource/RoomController.php b/app/Admin/Controllers/Resource/RoomController.php index 443343279..f31dd481d 100644 --- a/app/Admin/Controllers/Resource/RoomController.php +++ b/app/Admin/Controllers/Resource/RoomController.php @@ -3,6 +3,7 @@ * Manage Rooms as admin. * * @author Samy Nastuzzi + * @author Corentin Mercier * * @copyright Copyright (c) 2018, SiMDE-UTC * @license GNU GPL-3.0 @@ -18,6 +19,8 @@ class RoomController extends ResourceController { protected $model = Room::class; + protected $name = "Salle"; + /** * Fields to display definition. * @@ -38,6 +41,23 @@ protected function getFields(): array ]; } + /** + * Fields to display labels definition. + * + * @return array + */ + protected function getLabels(): array + { + return [ + 'location' => 'Lieu', + 'visibility' => 'Visibilité', + 'calendar' => 'Calendrier', + 'created_by' => 'Créé par', + 'owned_by' => 'Possédé par', + 'capacity' => 'Capacité', + ]; + } + /** * Default values definition of the fields to display. * diff --git a/app/Admin/Controllers/Resource/SemesterController.php b/app/Admin/Controllers/Resource/SemesterController.php index 63f068ad3..847625703 100644 --- a/app/Admin/Controllers/Resource/SemesterController.php +++ b/app/Admin/Controllers/Resource/SemesterController.php @@ -3,6 +3,7 @@ * Manage Semesters as admin. * * @author Samy Nastuzzi + * @author Corentin Mercier * * @copyright Copyright (c) 2018, SiMDE-UTC * @license GNU GPL-3.0 @@ -16,6 +17,8 @@ class SemesterController extends ResourceController { protected $model = Semester::class; + protected $name = "Semestre"; + /** * Fields to display definition. * @@ -34,4 +37,21 @@ protected function getFields(): array 'updated_at' => 'date', ]; } + + /** + * Fields to display labels definition. + * + * @return array + */ + protected function getLabels(): array + { + return [ + 'location' => 'Lieu', + 'visibility' => 'Visibilité', + 'calendar' => 'Calendrier', + 'created_by' => 'Créé par', + 'owned_by' => 'Possédé par', + 'capacity' => 'Capacité', + ]; + } } diff --git a/app/Admin/Controllers/Resource/ServiceController.php b/app/Admin/Controllers/Resource/ServiceController.php index 9e0de9d83..542ade2a2 100644 --- a/app/Admin/Controllers/Resource/ServiceController.php +++ b/app/Admin/Controllers/Resource/ServiceController.php @@ -3,6 +3,7 @@ * Manage Services as admin. * * @author Samy Nastuzzi + * @author Corentin Mercier * * @copyright Copyright (c) 2018, SiMDE-UTC * @license GNU GPL-3.0 @@ -39,6 +40,20 @@ protected function getFields(): array ]; } + /** + * Fields to display labels definition. + * + * @return array + */ + protected function getLabels(): array + { + return [ + 'name' => 'Nom', + 'shortname' => 'Nom court', + 'visibility' => 'Visibilité', + ]; + } + /** * Default values definition of the fields to display. * diff --git a/app/Admin/Controllers/Resource/TagController.php b/app/Admin/Controllers/Resource/TagController.php index a4883f868..7c0cefb8d 100644 --- a/app/Admin/Controllers/Resource/TagController.php +++ b/app/Admin/Controllers/Resource/TagController.php @@ -3,6 +3,7 @@ * Manage Tags as admin. * * @author Samy Nastuzzi + * @author Corentin Mercier * * @copyright Copyright (c) 2018, SiMDE-UTC * @license GNU GPL-3.0 @@ -31,4 +32,16 @@ protected function getFields(): array 'updated_at' => 'date' ]; } + + /** + * Fields to display labels definition. + * + * @return array + */ + protected function getLabels(): array + { + return [ + 'name' => 'Nom', + ]; + } } diff --git a/app/Admin/Controllers/Resource/UserController.php b/app/Admin/Controllers/Resource/UserController.php index 92e283e12..17a96354d 100644 --- a/app/Admin/Controllers/Resource/UserController.php +++ b/app/Admin/Controllers/Resource/UserController.php @@ -3,6 +3,7 @@ * Display Users as admin. * * @author Samy Nastuzzi + * @author Corentin Mercier * * @copyright Copyright (c) 2018, SiMDE-UTC * @license GNU GPL-3.0 @@ -12,19 +13,18 @@ use App\Http\Controllers\Controller; use App\Traits\Controller\v1\HasUsers; -use Encore\Admin\Grid\Filter; use Encore\Admin\Layout\{ Content, Column, Row }; use Encore\Admin\{ - Grid, Show, Form + Grid, Show }; use Illuminate\Http\Request; use App\Models\{ - User, AuthCas + User, }; use App\Notifications\Admin\{ - AdminImpersonation, UserImpersonation + UserImpersonation }; use App\Notifications\User\UserContributionBde; use App\Models\Semester; @@ -46,6 +46,20 @@ class UserController extends Controller 'updated_at' => 'date' ]; + /** + * Fields to display labels definition. + * + * @return array + */ + protected function getLabels(): array + { + return [ + 'firstname' => 'Prénom', + 'lastname' => 'Nom', + 'last_login_at' => 'Dernière connexion le', + ]; + } + /** * Give access only if user has the right permission. */ @@ -65,7 +79,7 @@ public function index(Content $content) { $grid = new GridGenerator(User::class); - $grid->addFields($this->fields); + $grid->addFields($this->fields, $this->getLabels()); $grid->types()->display(function () { $badges = ''; diff --git a/app/Admin/Controllers/Resource/UserDetailController.php b/app/Admin/Controllers/Resource/UserDetailController.php index ddb318161..d099e3ecc 100644 --- a/app/Admin/Controllers/Resource/UserDetailController.php +++ b/app/Admin/Controllers/Resource/UserDetailController.php @@ -3,6 +3,7 @@ * Manage UserDetails as admin. * * @author Samy Nastuzzi + * @author Corentin Mercier * * @copyright Copyright (c) 2018, SiMDE-UTC * @license GNU GPL-3.0 @@ -18,6 +19,8 @@ class UserDetailController extends ResourceController { protected $model = UserDetail::class; + protected $name = "Détails utilisateur"; + /** * Fields to display definition. * @@ -36,6 +39,20 @@ protected function getFields(): array ]; } + /** + * Fields to display labels definition. + * + * @return array + */ + protected function getLabels(): array + { + return [ + 'user' => 'Utilisateur', + 'key' => 'Clé', + 'value' => 'Valeur', + ]; + } + /** * Default values definition of the fields to display. * diff --git a/app/Admin/Controllers/Resource/UserPreferenceController.php b/app/Admin/Controllers/Resource/UserPreferenceController.php index 0fdfb33aa..b58580e45 100644 --- a/app/Admin/Controllers/Resource/UserPreferenceController.php +++ b/app/Admin/Controllers/Resource/UserPreferenceController.php @@ -3,6 +3,7 @@ * Manage UserPreferences as admin. * * @author Samy Nastuzzi + * @author Corentin Mercier * * @copyright Copyright (c) 2018, SiMDE-UTC * @license GNU GPL-3.0 @@ -18,6 +19,8 @@ class UserPreferenceController extends ResourceController { protected $model = UserPreference::class; + protected $name = "Préférences utilisateur"; + /** * Field to display definition. * @@ -37,6 +40,21 @@ protected function getFields(): array ]; } + /** + * Fields to display labels definition. + * + * @return array + */ + protected function getLabels(): array + { + return [ + 'user' => 'Utilisateur', + 'key' => 'Clé', + 'value' => 'Valeur', + 'only_for' => 'Seulement pour', + ]; + } + /** * Default values definition of the fields to display. * diff --git a/app/Admin/Controllers/Resource/VisibilityController.php b/app/Admin/Controllers/Resource/VisibilityController.php index 5921f3f7d..a5cf9b713 100644 --- a/app/Admin/Controllers/Resource/VisibilityController.php +++ b/app/Admin/Controllers/Resource/VisibilityController.php @@ -3,6 +3,7 @@ * Manage visibilities as admin. * * @author Samy Nastuzzi + * @author Corentin Mercier * * @copyright Copyright (c) 2018, SiMDE-UTC * @license GNU GPL-3.0 @@ -16,6 +17,8 @@ class VisibilityController extends ResourceController { protected $model = Visibility::class; + protected $name = "Visibilité"; + /** * Field to display definition. * @@ -33,6 +36,18 @@ protected function getFields(): array ]; } + /** + * Fields to display labels definition. + * + * @return array + */ + protected function getLabels(): array + { + return [ + 'name' => 'Nom', + ]; + } + /** * Default values definition of the fields to display. * diff --git a/app/Admin/FormGenerator.php b/app/Admin/FormGenerator.php index 6994b1adb..5dc3126a8 100644 --- a/app/Admin/FormGenerator.php +++ b/app/Admin/FormGenerator.php @@ -15,6 +15,9 @@ use Illuminate\Support\Collection; use Illuminate\Database\Eloquent\Relations\Relation; use App\Facades\ModelResolver; +use App\Models\EventDetail; +use App\Models\Faq; +use App\Models\Room; class FormGenerator extends Generator { @@ -50,20 +53,22 @@ protected function callCustomMethods($field) * Allow us to add several fields * * @param array $fields + * @param array $labels * @param array $defaults * @return FormGenerator */ - public function addFields(array $fields, array $defaults=null) + public function addFields(array $fields, array $labels=[], array $defaults=null) { $model = $this->model; foreach ($fields as $field => $type) { + $name = $this->getLabel($field, $labels); + if (method_exists($this->generatedModel, $field) && (($relation = $this->generatedModel->$field()) instanceof Relation) && $type instanceof Collection) { $options = []; - $name = ucfirst($field); $field .= '_id'; $generatedField = $this->generated->select($field, $name); @@ -74,10 +79,10 @@ public function addFields(array $fields, array $defaults=null) $generatedField->options($options); } else { if (is_array($type)) { - $generatedField = $this->generated->select($field); + $generatedField = $this->generated->select($field, $name); $generatedField->options($type); } else { - $generatedField = $this->generated->$type($field); + $generatedField = $this->generated->$type($field, $name); if ($type === 'image') { $this->get()->submitted(function (Form $form) { $form->model()->id = ($form->model()->id ?? \Uuid::generate()->string); diff --git a/app/Admin/Generator.php b/app/Admin/Generator.php index 905b7dba2..92081bec3 100644 --- a/app/Admin/Generator.php +++ b/app/Admin/Generator.php @@ -179,6 +179,33 @@ public static function adminValue($value, $field=null, $model=null) } } + /** + * Function to retrieve field label based on the field name and an array of labels + * + * @param string $field + * @param array $labels Default: empty array. + * @return string + */ + protected function getLabel(string $field, array $labels=[]) + { + $label = null; + + switch ($field) { + case 'created_at': + $label = "Créé le"; + break; + case 'updated_at': + $label = "Mis à jour le"; + break; + case 'deleted_at': + $label = "Supprimé le"; + break; + } + + $label = key_exists($field, $labels) ? $labels[$field] : $label; + return $label; + } + /** * Specific definition from the form type. * @@ -191,9 +218,10 @@ abstract protected function callCustomMethods($field); * Allow to add several fields. * * @param array $fields + * @param array $labels Default: empty array. * @return Generator */ - public function addFields(array $fields) + public function addFields(array $fields, array $labels=[]) { foreach ($fields as $field) { if (static::$simplePrint) { @@ -202,7 +230,7 @@ public function addFields(array $fields) } } - $this->generateField($field); + $this->generateField($field, $this->getLabel($field, $labels)); } return $this; @@ -212,13 +240,14 @@ public function addFields(array $fields) * Generate a new field. * * @param string $field + * @param string $label * @return void */ - protected function generateField(string $field) + protected function generateField(string $field, string $label=null) { $model = $this->model; - $this->callCustomMethods($this->generated->$field()) + $this->callCustomMethods($this->generated->$field($label)) ->{$this->valueMethod}(function ($value) use ($field, $model) { return Generator::adminValue($value, $field, $model); }); diff --git a/app/Admin/GridGenerator.php b/app/Admin/GridGenerator.php index fd32dba48..d331b969e 100644 --- a/app/Admin/GridGenerator.php +++ b/app/Admin/GridGenerator.php @@ -109,12 +109,13 @@ public static function generateFilter($filter, string $field, $data, $model) * Allow to add several fields * * @param array $fields + * @param array $labels * @param boolean $generateFilters * @return Generator */ - public function addFields(array $fields, bool $generateFilters=true) + public function addFields(array $fields, array $labels=[], bool $generateFilters=true) { - parent::addFields(array_keys($fields)); + parent::addFields(array_keys($fields), $labels); $model = $this->generatedModel; diff --git a/app/Admin/ShowGenerator.php b/app/Admin/ShowGenerator.php index 256150ba2..e6fa1e447 100644 --- a/app/Admin/ShowGenerator.php +++ b/app/Admin/ShowGenerator.php @@ -50,16 +50,17 @@ protected function callCustomMethods($field) * Generate a new field and linked field. * * @param string $field + * @param string $label * @return void */ - protected function generateField(string $field) + protected function generateField(string $field, string $label=null) { if (method_exists($this->generatedModel, $field) && (($relation = $this->generatedModel->$field()) instanceof Relation)) { $must = $relation->getModel()->getMustFields(); $resource = Str::plural($relation->getModel()); - $this->generated->$field($field, function ($value) use ($must, $resource) { + $this->generated->$field($label, function ($value) use ($must, $resource) { $value->setResource('/admin/'.$resource); foreach ($must as $key) { @@ -70,7 +71,7 @@ protected function generateField(string $field) } }); } else { - parent::generateField($field); + parent::generateField($field, $label); } } } diff --git a/app/Models/EventDetail.php b/app/Models/EventDetail.php index 9b3fa62c6..26704cdfb 100644 --- a/app/Models/EventDetail.php +++ b/app/Models/EventDetail.php @@ -10,6 +10,7 @@ namespace App\Models; +use Illuminate\Database\Eloquent\Builder; use App\Traits\Model\HasKeyValue; use App\Models\Event; @@ -33,6 +34,6 @@ class EventDetail extends Model */ public function event() { - $this->belongsTo(Event::class); + return $this->belongsTo(Event::class, 'event_id'); } }