diff --git a/config/packages/catalyst_auth.yaml b/config/packages/catalyst_auth.yaml index e5f8e972..b66bbcd9 100644 --- a/config/packages/catalyst_auth.yaml +++ b/config/packages/catalyst_auth.yaml @@ -673,20 +673,29 @@ catalyst_auth: - id: item_pricing.update label: Update - - id: test_list - label: TestTypes + - id: entity_list + label: EntityTypes acls: - - id: test.menu + - id: entity.menu label: Menu - - id: test.add + - id: entity.add label: Add - - id: test.update + - id: entity.update label: Update - - id: test.delete + - id: entity.delete label: Delete - - id: test.list + - id: entity.list label: List - + + - id: send_EDA + label: sendeda + acls: + - id: eda.menu + label: Menu + - id: eda.update + label: Update + - id: eda.list + label: List api: diff --git a/config/packages/catalyst_menu.yaml b/config/packages/catalyst_menu.yaml index 12b98965..100c3b05 100644 --- a/config/packages/catalyst_menu.yaml +++ b/config/packages/catalyst_menu.yaml @@ -307,6 +307,11 @@ catalyst_menu: label: Item Pricing parent: item - - id: test_list - acl: test.menu - label: TestTypes + - id: entity_list + acl: entity.menu + label: EntityTypes + + - id: send_EDA + acl: eda.menu + label: Notifs + parent: entity_list diff --git a/config/routes/test.yaml b/config/routes/test.yaml index 5c9e4288..17efe8ac 100644 --- a/config/routes/test.yaml +++ b/config/routes/test.yaml @@ -1,34 +1,34 @@ -test_list: +entity_list: path: /test controller: App\Controller\EntityController::index methods: [GET] -test_type_rows: +entity_rows: path: /test/rowdata controller: App\Controller\EntityController::datatableRows methods: [POST] -test_type_add_form: +entity_add_form: path: /test/newform controller: App\Controller\EntityController::addForm methods: [GET] -test_type_add_submit: +entity_add_submit: path: /test controller: App\Controller\EntityController::addSubmit methods: [POST] -test_type_update_form: +entity_update_form: path: /test/{id} controller: App\Controller\EntityController::updateForm methods: [GET] -test_type_update_submit: +entity_update_submit: path: /test/{id} controller: App\Controller\EntityController::updateSubmit methods: [POST] -test_type_delete: +entity_delete: path: /test/{id} controller: App\Controller\EntityController::deleteSubmit methods: [DELETE] diff --git a/src/Controller/EntityController.php b/src/Controller/EntityController.php index 4c558d9f..1ed4509c 100644 --- a/src/Controller/EntityController.php +++ b/src/Controller/EntityController.php @@ -2,7 +2,7 @@ namespace App\Controller; -use App\Entity\Test; +use App\Entity\Entity; use Doctrine\ORM\Query; use Doctrine\ORM\QueryBuilder; use Doctrine\ORM\EntityManagerInterface; @@ -21,8 +21,8 @@ use Catalyst\MenuBundle\Annotation\Menu; class EntityController extends Controller{ /** - * @Menu(selected="test_list") - * @IsGranted("test.list") + * @Menu(selected="entity_list") + * @IsGranted("entity.list") */ public function index () { @@ -30,14 +30,14 @@ class EntityController extends Controller{ } /** - * @Menu(selected="test_list") - * @IsGranted("test.add") + * @Menu(selected="entity_list") + * @IsGranted("entity.add") */ public function addForm() { - $test = new Test(); + $entity = new Entity(); $params = [ - 'obj' => $test, + 'obj' => $entity, 'mode' => 'create', ]; @@ -46,11 +46,11 @@ class EntityController extends Controller{ } /** - * @IsGranted("test.add") + * @IsGranted("entity.add") */ public function addSubmit(Request $req, EntityManagerInterface $em, ValidatorInterface $validator) { - $test = new Test(); + $test = new Entity(); $this->setObject($test, $req); @@ -86,13 +86,13 @@ class EntityController extends Controller{ /** - * @Menu(selected="test_list") - * @IsGranted("test.update") + * @Menu(selected="entity_list") + * @IsGranted("entity.update") */ - public function updateForm($id, EntityManagerInterface $em, Test $test) + public function updateForm($id, EntityManagerInterface $em, Entity $e) { $params = []; - $params['obj'] = $test; + $params['obj'] = $e; $params['mode'] = 'update'; // response @@ -100,14 +100,14 @@ class EntityController extends Controller{ } /** - * @IsGranted("test.update") + * @IsGranted("entity.update") */ - public function updateSubmit(Request $req, EntityManagerInterface $em, ValidatorInterface $validator, Test $test) + public function updateSubmit(Request $req, EntityManagerInterface $em, ValidatorInterface $validator, Entity $e) { - $this->setObject($test, $req); + $this->setObject($e, $req); // validate - $errors = $validator->validate($test); + $errors = $validator->validate($e); // initialize error list $error_array = []; @@ -136,12 +136,12 @@ class EntityController extends Controller{ } /** - * @IsGranted("test.delete") + * @IsGranted("entity.delete") */ - public function deleteSubmit(EntityManagerInterface $em, Test $test) + public function deleteSubmit(EntityManagerInterface $em, Entity $entity) { // delete this object - $em->remove($test); + $em->remove($entity); $em->flush(); // response @@ -150,7 +150,7 @@ class EntityController extends Controller{ $response->send(); } - protected function setObject(Test $obj, Request $req) + protected function setObject(Entity $obj, Request $req) { // set and save values $obj->setItem($req->request->get('item')) @@ -168,13 +168,13 @@ class EntityController extends Controller{ } /** - * @IsGranted("test.list") + * @IsGranted("entity.list") */ public function datatableRows(Request $req) { // get query builder $qb = $this->getDoctrine() - ->getRepository(Test::class) + ->getRepository(Entity::class) ->createQueryBuilder('q'); // get datatable params @@ -237,10 +237,10 @@ class EntityController extends Controller{ ]; // add crud urls - if ($this->isGranted('test.update')) - $row['meta']['update_url'] = $this->generateUrl('test_type_update_form', ['id' => $row['id']]); - if ($this->isGranted('test.delete')) - $row['meta']['delete_url'] = $this->generateUrl('test_type_delete', ['id' => $row['id']]); + if ($this->isGranted('entity.update')) + $row['meta']['update_url'] = $this->generateUrl('entity_update_form', ['id' => $row['id']]); + if ($this->isGranted('entity.delete')) + $row['meta']['delete_url'] = $this->generateUrl('entity_delete', ['id' => $row['id']]); $rows[] = $row; } diff --git a/src/Entity/Test.php b/src/Entity/Entity.php similarity index 98% rename from src/Entity/Test.php rename to src/Entity/Entity.php index 960174b7..287f91c0 100644 --- a/src/Entity/Test.php +++ b/src/Entity/Entity.php @@ -8,7 +8,7 @@ use Doctrine\ORM\Mapping as ORM; /** * @ORM\Entity(repositoryClass=TestRepository::class) */ -class Test +class Entity { /** * @ORM\Id diff --git a/src/Migrations/Version20241023070137.php b/src/Migrations/Version20241023070137.php new file mode 100644 index 00000000..1a3651cb --- /dev/null +++ b/src/Migrations/Version20241023070137.php @@ -0,0 +1,37 @@ +abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.'); + + $this->addSql('ALTER TABLE battery CHANGE date_update date_update timestamp default current_timestamp on update current_timestamp'); + $this->addSql('ALTER TABLE sap_battery CHANGE date_update date_update timestamp default current_timestamp on update current_timestamp'); + } + + public function down(Schema $schema) : void + { + // this down() migration is auto-generated, please modify it to your needs + $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.'); + + $this->addSql('ALTER TABLE battery CHANGE date_update date_update DATETIME DEFAULT CURRENT_TIMESTAMP'); + $this->addSql('ALTER TABLE sap_battery CHANGE date_update date_update DATETIME DEFAULT CURRENT_TIMESTAMP'); + } +} diff --git a/src/Repository/NotifsRepository.php b/src/Repository/NotifsRepository.php new file mode 100644 index 00000000..b0e2fb62 --- /dev/null +++ b/src/Repository/NotifsRepository.php @@ -0,0 +1,50 @@ +createQueryBuilder('n') + ->andWhere('n.exampleField = :val') + ->setParameter('val', $value) + ->orderBy('n.id', 'ASC') + ->setMaxResults(10) + ->getQuery() + ->getResult() + ; + } + */ + + /* + public function findOneBySomeField($value): ?Notifs + { + return $this->createQueryBuilder('n') + ->andWhere('n.exampleField = :val') + ->setParameter('val', $value) + ->getQuery() + ->getOneOrNullResult() + ; + } + */ +} diff --git a/src/Repository/TestRepository.php b/src/Repository/TestRepository.php index f2ff134a..d059447f 100644 --- a/src/Repository/TestRepository.php +++ b/src/Repository/TestRepository.php @@ -2,7 +2,7 @@ namespace App\Repository; -use App\Entity\Test; +use App\Entity\Entity; use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; use Doctrine\Persistence\ManagerRegistry; @@ -16,7 +16,7 @@ class TestRepository extends ServiceEntityRepository { public function __construct(ManagerRegistry $registry) { - parent::__construct($registry, Test::class); + parent::__construct($registry, Entity::class); } // /** diff --git a/templates/entity/form.html.twig b/templates/entity/form.html.twig index 784a7413..684375ee 100644 --- a/templates/entity/form.html.twig +++ b/templates/entity/form.html.twig @@ -5,7 +5,7 @@
-

Test Types

+

Product list

@@ -23,16 +23,16 @@

{% if mode == 'update' %} - Edit Test Type + Edit Product Type {{ obj.getItem() }} {% else %} - New Test Type + New Product Type {% endif %}

-
+
@@ -99,7 +99,7 @@ $(function() { text: 'Your changes have been saved!', type: 'success', onClose: function() { - window.location.href = "{{ url('test_list') }}"; + window.location.href = "{{ url('entity_list') }}"; } }); }).fail(function(response) { diff --git a/templates/entity/list.html.twig b/templates/entity/list.html.twig index b995a51f..742ad0fe 100644 --- a/templates/entity/list.html.twig +++ b/templates/entity/list.html.twig @@ -33,7 +33,7 @@
- + New Item @@ -61,7 +61,7 @@ $(function() { type: 'remote', source: { read: { - url: '{{ url("test_type_rows") }}', + url: '{{ url("entity_rows") }}', method: 'POST' } },