-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(admin): add admin controllers for organizational elements
- Loading branch information
Showing
6 changed files
with
221 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
|
||
namespace App\Controller\Admin; | ||
|
||
use App\Entity\Degree; | ||
use EasyCorp\Bundle\EasyAdminBundle\Config\Crud; | ||
use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractCrudController; | ||
use EasyCorp\Bundle\EasyAdminBundle\Field\FormField; | ||
use EasyCorp\Bundle\EasyAdminBundle\Field\IdField; | ||
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField; | ||
|
||
class DegreeCrudController extends AbstractCrudController | ||
{ | ||
public static function getEntityFqcn(): string | ||
{ | ||
return Degree::class; | ||
} | ||
|
||
public function configureCrud(Crud $crud): Crud | ||
{ | ||
return $crud | ||
->setEntityLabelInPlural('Degrees') | ||
->setEntityLabelInSingular('Degree') | ||
; | ||
} | ||
|
||
public function configureFields(string $pageName): iterable | ||
{ | ||
yield FormField::addPanel('General'); | ||
yield IdField::new('id') | ||
->onlyOnIndex() | ||
; | ||
yield TextField::new('name'); | ||
yield TextField::new('slug') | ||
->onlyOnDetail() | ||
; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
|
||
namespace App\Controller\Admin; | ||
|
||
use App\Entity\Group; | ||
use EasyCorp\Bundle\EasyAdminBundle\Config\Crud; | ||
use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractCrudController; | ||
use EasyCorp\Bundle\EasyAdminBundle\Field\FormField; | ||
use EasyCorp\Bundle\EasyAdminBundle\Field\IdField; | ||
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField; | ||
|
||
class GroupCrudController extends AbstractCrudController | ||
{ | ||
public static function getEntityFqcn(): string | ||
{ | ||
return Group::class; | ||
} | ||
|
||
public function configureCrud(Crud $crud): Crud | ||
{ | ||
return $crud | ||
->setEntityLabelInPlural('Groups') | ||
->setEntityLabelInSingular('Group') | ||
; | ||
} | ||
|
||
public function configureFields(string $pageName): iterable | ||
{ | ||
yield FormField::addPanel('General'); | ||
yield IdField::new('id') | ||
->onlyOnIndex() | ||
; | ||
yield TextField::new('name'); | ||
yield TextField::new('icon'); | ||
yield TextField::new('slug') | ||
->onlyOnDetail() | ||
; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
<?php | ||
|
||
namespace App\Controller\Admin; | ||
|
||
use App\Entity\User; | ||
use EasyCorp\Bundle\EasyAdminBundle\Config\Crud; | ||
use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractCrudController; | ||
use EasyCorp\Bundle\EasyAdminBundle\Field\ArrayField; | ||
use EasyCorp\Bundle\EasyAdminBundle\Field\AssociationField; | ||
use EasyCorp\Bundle\EasyAdminBundle\Field\BooleanField; | ||
use EasyCorp\Bundle\EasyAdminBundle\Field\ChoiceField; | ||
use EasyCorp\Bundle\EasyAdminBundle\Field\FormField; | ||
use EasyCorp\Bundle\EasyAdminBundle\Field\IdField; | ||
use EasyCorp\Bundle\EasyAdminBundle\Field\ImageField; | ||
use EasyCorp\Bundle\EasyAdminBundle\Field\TextareaField; | ||
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField; | ||
use Vich\UploaderBundle\Form\Type\VichImageType; | ||
|
||
class UserCrudController extends AbstractCrudController | ||
{ | ||
public static function getEntityFqcn(): string | ||
{ | ||
return User::class; | ||
} | ||
|
||
|
||
public function configureCrud(Crud $crud): Crud | ||
{ | ||
return $crud | ||
->setEntityLabelInPlural('Users') | ||
->setEntityLabelInSingular('User') | ||
; | ||
} | ||
|
||
public function configureFields(string $pageName): iterable | ||
{ | ||
yield FormField::addPanel('General'); | ||
yield TextField::new('username'); | ||
yield TextField::new('email') | ||
->hideOnIndex() | ||
; | ||
|
||
|
||
yield FormField::addPanel('Security'); | ||
yield BooleanField::new('enabled'); | ||
yield ChoiceField::new('roles') | ||
->setChoices([ | ||
'Usuario' => 'ROLE_USER', | ||
'Gestor' => 'ROLE_ADMIN', | ||
'Administrador' => 'ROLE_SUPER_ADMIN', | ||
]) | ||
->allowMultipleChoices() | ||
; | ||
yield AssociationField::new('versions') | ||
->setLabel('Policies') | ||
->setTemplatePath('admin/user/policies.html.twig') | ||
->onlyOnDetail(); | ||
|
||
yield FormField::addPanel('Profile'); | ||
yield IdField::new('id') | ||
->onlyOnIndex() | ||
; | ||
yield TextField::new('firstname'); | ||
yield TextField::new('lastname'); | ||
yield ChoiceField::new('collective') | ||
->setChoices(User::getCollectives()) | ||
; | ||
yield TextField::new('nic') | ||
->hideOnIndex() | ||
; | ||
yield AssociationField::new('degree') | ||
->hideOnIndex() | ||
; | ||
yield TextField::new('year') | ||
->hideOnIndex() | ||
; | ||
yield TextareaField::new('imageFile') | ||
->setFormType(VichImageType::class) | ||
->onlyOnForms() | ||
; | ||
yield ImageField::new('image.name') | ||
->setBasePath('/images/avatars') | ||
->setCssClass('ea-vich-image') | ||
->onlyOnDetail() | ||
; | ||
} | ||
|
||
/* | ||
public function configureFields(string $pageName): iterable | ||
{ | ||
return [ | ||
IdField::new('id'), | ||
TextField::new('title'), | ||
TextEditorField::new('description'), | ||
]; | ||
} | ||
*/ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<ul> | ||
{% for logPolicy in field.value %} | ||
<li>{{ logPolicy.version }} ({{ logPolicy.createAt | date('d-m-Y H:i') }})</li> | ||
{% else %} | ||
<li>No ha aceptado ninguna política de uso</li> | ||
{% endfor %} | ||
</ul> |