From 86b24f58ac9a1c7c8f3480627e7dcb5677acd082 Mon Sep 17 00:00:00 2001 From: Marc Ducobu Date: Thu, 2 Jul 2015 15:41:11 +0200 Subject: [PATCH] First step of integration code generated --- Controller/ActivityController.php | 63 ++++++++++++++++------ Form/ActivityType.php | 8 +-- Resources/config/routing.yml | 2 +- Resources/config/routing/activity.yml | 40 ++++++++------ Resources/views/Activity/edit.html.twig | 26 +++++++-- Resources/views/Activity/index.html.twig | 47 ----------------- Resources/views/Activity/list.html.twig | 67 ++++++++++++++++++++++++ Resources/views/Activity/new.html.twig | 28 ++++++++-- Resources/views/Activity/show.html.twig | 4 +- 9 files changed, 193 insertions(+), 92 deletions(-) delete mode 100644 Resources/views/Activity/index.html.twig create mode 100644 Resources/views/Activity/list.html.twig diff --git a/Controller/ActivityController.php b/Controller/ActivityController.php index 4ecc17ac3..0c89842db 100644 --- a/Controller/ActivityController.php +++ b/Controller/ActivityController.php @@ -1,5 +1,25 @@ , + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + namespace Chill\ActivityBundle\Controller; use Symfony\Component\HttpFoundation\Request; @@ -19,24 +39,28 @@ class ActivityController extends Controller * Lists all Activity entities. * */ - public function indexAction() + public function listAction($person_id, Request $request) { $em = $this->getDoctrine()->getManager(); + $person = $em->getRepository('ChillPersonBundle:Person')->find($person_id); + $activities = $em->getRepository('ChillActivityBundle:Activity')->findAll(); - $entities = $em->getRepository('ChillActivityBundle:Activity')->findAll(); - - return $this->render('ChillActivityBundle:Activity:index.html.twig', array( - 'entities' => $entities, + return $this->render('ChillActivityBundle:Activity:list.html.twig', array( + 'activities' => $activities, + 'person' => $person )); } /** * Creates a new Activity entity. * */ - public function createAction(Request $request) + public function createAction($person_id, Request $request) { + $em = $this->getDoctrine()->getManager(); + $person = $em->getRepository('ChillPersonBundle:Person')->find($person_id); + $entity = new Activity(); - $form = $this->createCreateForm($entity); + $form = $this->createCreateForm($entity, $person); $form->handleRequest($request); if ($form->isValid()) { @@ -44,12 +68,13 @@ class ActivityController extends Controller $em->persist($entity); $em->flush(); - return $this->redirect($this->generateUrl('activity_show', array('id' => $entity->getId()))); + return $this->redirect($this->generateUrl('chill_activity_activity_show', array('id' => $entity->getId()))); } return $this->render('ChillActivityBundle:Activity:new.html.twig', array( 'entity' => $entity, 'form' => $form->createView(), + 'person' => $person )); } @@ -60,10 +85,10 @@ class ActivityController extends Controller * * @return \Symfony\Component\Form\Form The form */ - private function createCreateForm(Activity $entity) + private function createCreateForm(Activity $entity, $person) { $form = $this->createForm(new ActivityType(), $entity, array( - 'action' => $this->generateUrl('activity_create'), + 'action' => $this->generateUrl('chill_activity_activity_create', ['person_id' => $person->getId()]), 'method' => 'POST', )); @@ -76,12 +101,16 @@ class ActivityController extends Controller * Displays a form to create a new Activity entity. * */ - public function newAction() + public function newAction($person_id) { + $em = $this->getDoctrine()->getManager(); + $person = $em->getRepository('ChillPersonBundle:Person')->find($person_id); + $entity = new Activity(); - $form = $this->createCreateForm($entity); + $form = $this->createCreateForm($entity, $person); return $this->render('ChillActivityBundle:Activity:new.html.twig', array( + 'person' => $person, 'entity' => $entity, 'form' => $form->createView(), )); @@ -113,9 +142,10 @@ class ActivityController extends Controller * Displays a form to edit an existing Activity entity. * */ - public function editAction($id) + public function editAction($person_id, $id) { $em = $this->getDoctrine()->getManager(); + $person = $em->getRepository('ChillPersonBundle:Person')->find($person_id); $entity = $em->getRepository('ChillActivityBundle:Activity')->find($id); @@ -130,6 +160,7 @@ class ActivityController extends Controller 'entity' => $entity, 'edit_form' => $editForm->createView(), 'delete_form' => $deleteForm->createView(), + 'person' => $$person )); } @@ -143,7 +174,7 @@ class ActivityController extends Controller private function createEditForm(Activity $entity) { $form = $this->createForm(new ActivityType(), $entity, array( - 'action' => $this->generateUrl('activity_update', array('id' => $entity->getId())), + 'action' => $this->generateUrl('chill_activity_activity_update', array('id' => $entity->getId())), 'method' => 'PUT', )); @@ -172,7 +203,7 @@ class ActivityController extends Controller if ($editForm->isValid()) { $em->flush(); - return $this->redirect($this->generateUrl('activity_edit', array('id' => $id))); + return $this->redirect($this->generateUrl('chill_activity_activity_edit', array('id' => $id))); } return $this->render('ChillActivityBundle:Activity:edit.html.twig', array( @@ -215,7 +246,7 @@ class ActivityController extends Controller private function createDeleteForm($id) { return $this->createFormBuilder() - ->setAction($this->generateUrl('activity_delete', array('id' => $id))) + ->setAction($this->generateUrl('chill_activity_activity_delete', array('id' => $id))) ->setMethod('DELETE') ->add('submit', 'submit', array('label' => 'Delete')) ->getForm() diff --git a/Form/ActivityType.php b/Form/ActivityType.php index b51e9af28..80be41de9 100644 --- a/Form/ActivityType.php +++ b/Form/ActivityType.php @@ -20,10 +20,10 @@ class ActivityType extends AbstractType ->add('remark') ->add('attendee') ->add('user') - ->add('scope') - ->add('reason') - ->add('type') - ->add('person') + //->add('scope') + //->add('reason') + //->add('type') + //->add('person') ; } diff --git a/Resources/config/routing.yml b/Resources/config/routing.yml index a3fde0da5..0f18ae49f 100644 --- a/Resources/config/routing.yml +++ b/Resources/config/routing.yml @@ -1,6 +1,6 @@ chill_activity_activity: resource: "@ChillActivityBundle/Resources/config/routing/activity.yml" - prefix: /activity + prefix: / chill_activity_activityreason: resource: "@ChillActivityBundle/Resources/config/routing/activityreason.yml" diff --git a/Resources/config/routing/activity.yml b/Resources/config/routing/activity.yml index 9efeac928..63d4c5723 100644 --- a/Resources/config/routing/activity.yml +++ b/Resources/config/routing/activity.yml @@ -1,30 +1,40 @@ -activity: - path: / - defaults: { _controller: "ChillActivityBundle:Activity:index" } +chill_activity_activity_list: + path: /{_locale}/person/{person_id}/activity/ + defaults: { _controller: "ChillActivityBundle:Activity:list" } + options: + menus: + person: + order: 201 + label: Activity list -activity_show: - path: /{id}/show +chill_activity_activity_show: + path: /{_locale}/person/{person_id}/activity/{id}/show defaults: { _controller: "ChillActivityBundle:Activity:show" } -activity_new: - path: /new +chill_activity_activity_new: + path: /{_locale}/person/{person_id}/activity/new defaults: { _controller: "ChillActivityBundle:Activity:new" } + options: + menus: + person: + order: 200 + label: Add an activity -activity_create: - path: /create +chill_activity_activity_create: + path: /{_locale}/person/{person_id}/activity/create defaults: { _controller: "ChillActivityBundle:Activity:create" } methods: POST -activity_edit: - path: /{id}/edit +chill_activity_activity_edit: + path: /{_locale}/person/{person_id}/activity/{id}/edit defaults: { _controller: "ChillActivityBundle:Activity:edit" } -activity_update: - path: /{id}/update +chill_activity_activity_update: + path: /{_locale}/person/{person_id}/activity/{id}/update defaults: { _controller: "ChillActivityBundle:Activity:update" } methods: [POST, PUT] -activity_delete: - path: /{id}/delete +chill_activity_activity_delete: + path: /{_locale}/person/{person_id}/activity/{id}/delete defaults: { _controller: "ChillActivityBundle:Activity:delete" } methods: [POST, DELETE] diff --git a/Resources/views/Activity/edit.html.twig b/Resources/views/Activity/edit.html.twig index 846ec0bc5..4c04aae3b 100644 --- a/Resources/views/Activity/edit.html.twig +++ b/Resources/views/Activity/edit.html.twig @@ -1,13 +1,33 @@ -{% extends '::base.html.twig' %} +{# + * Copyright (C) 2014, Champs Libres Cooperative SCRLFS, + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . +#} +{% extends "ChillPersonBundle::layout.html.twig" %} -{% block body -%} +{% set activeRouteKey = 'chill_activity_activity_list' %} + +{% block title %}{{ 'Activity edit' |trans }}{% endblock title %} + +{% block personcontent %}

Activity edit

{{ form(edit_form) }}
  • - + Back to the list
  • diff --git a/Resources/views/Activity/index.html.twig b/Resources/views/Activity/index.html.twig deleted file mode 100644 index c13361585..000000000 --- a/Resources/views/Activity/index.html.twig +++ /dev/null @@ -1,47 +0,0 @@ -{% extends '::base.html.twig' %} - -{% block body -%} -

    Activity list

    - - - - - - - - - - - - - - {% for entity in entities %} - - - - - - - - - {% endfor %} - -
    IdDateDurationtimeRemarkAttendeeActions
    {{ entity.id }}{% if entity.date %}{{ entity.date|date('Y-m-d H:i:s') }}{% endif %}{{ entity.durationTime }}{{ entity.remark }}{{ entity.attendee }} - -
    - - - {% endblock %} diff --git a/Resources/views/Activity/list.html.twig b/Resources/views/Activity/list.html.twig new file mode 100644 index 000000000..b39338eb8 --- /dev/null +++ b/Resources/views/Activity/list.html.twig @@ -0,0 +1,67 @@ +{# + * Copyright (C) 2014, Champs Libres Cooperative SCRLFS, + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . +#} +{% extends "ChillPersonBundle::layout.html.twig" %} + +{% set activeRouteKey = 'chill_activity_activity_list' %} + +{% block title %}{{ 'Activity list' |trans }}{% endblock title %} + +{% block personcontent %} +

    Activity list

    + + + + + + + + + + + + + + {% for activity in activities %} + + + + + + + + + {% endfor %} + +
    IdDateDurationtimeRemarkAttendeeActions
    {{ activity.id }}{% if activity.date %}{{ activity.date|date('Y-m-d H:i:s') }}{% endif %}{{ activity.durationTime }}{{ activity.remark }}{{ activity.attendee }} + +
    + + +{% endblock %} diff --git a/Resources/views/Activity/new.html.twig b/Resources/views/Activity/new.html.twig index 94c3169e7..645bf3cf7 100644 --- a/Resources/views/Activity/new.html.twig +++ b/Resources/views/Activity/new.html.twig @@ -1,15 +1,35 @@ -{% extends '::base.html.twig' %} +{# + * Copyright (C) 2014, Champs Libres Cooperative SCRLFS, + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . +#} +{% extends "ChillPersonBundle::layout.html.twig" %} -{% block body -%} +{% set activeRouteKey = 'chill_activity_activity_new' %} + +{% block title %}{{ 'Activity create' |trans }}{% endblock title %} + +{% block personcontent %}

    Activity creation

    {{ form(form) }} -{% endblock %} +{% endblock %} \ No newline at end of file diff --git a/Resources/views/Activity/show.html.twig b/Resources/views/Activity/show.html.twig index eb939fcc4..c405a4a87 100644 --- a/Resources/views/Activity/show.html.twig +++ b/Resources/views/Activity/show.html.twig @@ -30,12 +30,12 @@