diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 4b6da4216..86e65c390 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -11,9 +11,10 @@ before_script: - PGPASSWORD=$POSTGRES_PASSWORD psql -U $POSTGRES_USER -h db -c "CREATE EXTENSION IF NOT EXISTS unaccent; CREATE EXTENSION IF NOT EXISTS pg_trgm;" # Install and run Composer - curl -sS https://getcomposer.org/installer | php - - php composer.phar install + - php -d memory_limit=2G composer.phar install - php tests/app/bin/console doctrine:migrations:migrate -n - - php tests/app/bin/console doctrine:fixtures:load -n + - php -d memory_limit=2G tests/app/bin/console doctrine:fixtures:load -n + - echo "before_script finished" # Bring in any services we need http://docs.gitlab.com/ee/ci/docker/using_docker_images.html#what-is-a-service # See http://docs.gitlab.com/ee/ci/services/README.html for examples. @@ -38,4 +39,4 @@ variables: # Run our tests test: script: - - bin/phpunit --colors=never + - php -d memory_limit=3G bin/phpunit --colors=never diff --git a/phpunit.xml.dist b/phpunit.xml.dist index ab9e69052..6fd80f9f1 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -18,11 +18,13 @@ src/Bundle/ChillMainBundle/Tests/ + + diff --git a/src/Bundle/ChillMainBundle/CRUD/Controller/AbstractCRUDController.php b/src/Bundle/ChillMainBundle/CRUD/Controller/AbstractCRUDController.php index df7d065cb..71476fb78 100644 --- a/src/Bundle/ChillMainBundle/CRUD/Controller/AbstractCRUDController.php +++ b/src/Bundle/ChillMainBundle/CRUD/Controller/AbstractCRUDController.php @@ -40,6 +40,20 @@ class AbstractCRUDController extends AbstractController return $e; } + /** + * Create an entity. + * + * @param string $action + * @param Request $request + * @return object + */ + protected function createEntity(string $action, Request $request): object + { + $type = $this->getEntityClass(); + + return new $type; + } + /** * Count the number of entities * diff --git a/src/Bundle/ChillMainBundle/CRUD/Controller/ApiController.php b/src/Bundle/ChillMainBundle/CRUD/Controller/ApiController.php index 14b0473da..9686a7b98 100644 --- a/src/Bundle/ChillMainBundle/CRUD/Controller/ApiController.php +++ b/src/Bundle/ChillMainBundle/CRUD/Controller/ApiController.php @@ -85,11 +85,75 @@ class ApiController extends AbstractCRUDController case Request::METHOD_PUT: case Request::METHOD_PATCH: return $this->entityPut('_entity', $request, $id, $_format); + case Request::METHOD_POST: + return $this->entityPostAction('_entity', $request, $id, $_format); + default: + throw new \Symfony\Component\HttpFoundation\Exception\BadRequestException("This method is not implemented"); + } + } + public function entityPost(Request $request, $_format): Response + { + switch($request->getMethod()) { + case Request::METHOD_POST: + return $this->entityPostAction('_entity', $request, $_format); default: throw new \Symfony\Component\HttpFoundation\Exception\BadRequestException("This method is not implemented"); } } + protected function entityPostAction($action, Request $request, string $_format): Response + { + $entity = $this->createEntity($action, $request); + + try { + $entity = $this->deserialize($action, $request, $_format, $entity); + } catch (NotEncodableValueException $e) { + throw new BadRequestException("invalid json", 400, $e); + } + + $errors = $this->validate($action, $request, $_format, $entity); + + $response = $this->onAfterValidation($action, $request, $_format, $entity, $errors); + if ($response instanceof Response) { + return $response; + } + + if ($errors->count() > 0) { + $response = $this->json($errors); + $response->setStatusCode(Response::HTTP_UNPROCESSABLE_ENTITY); + + return $response; + } + + $response = $this->checkACL($action, $request, $_format, $entity); + if ($response instanceof Response) { + return $response; + } + + $response = $this->onPostCheckACL($action, $request, $_format, $entity); + if ($response instanceof Response) { + return $response; + } + + $this->getDoctrine()->getManager()->persist($entity); + $this->getDoctrine()->getManager()->flush(); + + $response = $this->onAfterFlush($action, $request, $_format, $entity, $errors); + if ($response instanceof Response) { + return $response; + } + $response = $this->onBeforeSerialize($action, $request, $_format, $entity); + if ($response instanceof Response) { + return $response; + } + + return $this->json( + $entity, + Response::HTTP_OK, + [], + $this->getContextForSerializationPostAlter($action, $request, $_format, $entity) + ); + } public function entityPut($action, Request $request, $id, string $_format): Response { $entity = $this->getEntity($action, $id, $request, $_format); @@ -407,6 +471,7 @@ class ApiController extends AbstractCRUDController return [ 'groups' => [ 'read' ]]; case Request::METHOD_PUT: case Request::METHOD_PATCH: + case Request::METHOD_POST: return [ 'groups' => [ 'write' ]]; default: throw new \LogicException("get context for serialization is not implemented for this method"); diff --git a/src/Bundle/ChillMainBundle/CRUD/Routing/CRUDRoutesLoader.php b/src/Bundle/ChillMainBundle/CRUD/Routing/CRUDRoutesLoader.php index 32068e518..9d61d6233 100644 --- a/src/Bundle/ChillMainBundle/CRUD/Routing/CRUDRoutesLoader.php +++ b/src/Bundle/ChillMainBundle/CRUD/Routing/CRUDRoutesLoader.php @@ -183,48 +183,26 @@ class CRUDRoutesLoader extends Loader $methods = \array_keys(\array_filter($action['methods'], function($value, $key) { return $value; }, ARRAY_FILTER_USE_BOTH)); - $route = new Route($path, $defaults, $requirements); - $route->setMethods($methods); - - $collection->add('chill_api_single_'.$crudConfig['name'].'_'.$name, $route); - } + if (count($methods) === 0) { + throw new \RuntimeException("The api configuration named \"{$crudConfig['name']}\", action \"{$name}\", ". + "does not have any allowed methods. You should remove this action from the config ". + "or allow, at least, one method"); + } - return $collection; - } + if ('_entity' === $name && \in_array(Request::METHOD_POST, $methods)) { + unset($methods[\array_search(Request::METHOD_POST, $methods)]); + $entityPostRoute = $this->createEntityPostRoute($name, $crudConfig, $action, + $controller); + $collection->add("chill_api_single_{$crudConfig['name']}_{$name}_create", + $entityPostRoute); + } - /** - * Load routes for api multi - * - * @param $crudConfig - * @return RouteCollection - */ - protected function loadApiMultiConfig(array $crudConfig): RouteCollection - { - $collection = new RouteCollection(); - $controller ='csapi_'.$crudConfig['name'].'_controller'; - - foreach ($crudConfig['actions'] as $name => $action) { - // filter only on single actions - $singleCollection = $action['single-collection'] ?? $name === '_index' ? 'collection' : NULL; - if ('single' === $singleCollection) { + if (count($methods) === 0) { + // the only method was POST, + // continue to next continue; } - $defaults = [ - '_controller' => $controller.':'.($action['controller_action'] ?? '_entity' === $name ? 'entityApi' : $name.'Api') - ]; - - // path are rewritten - // if name === 'default', we rewrite it to nothing :-) - $localName = '_entity' === $name ? '' : '/'.$name; - $localPath = $action['path'] ?? '/{id}'.$localName.'.{_format}'; - $path = $crudConfig['base_path'].$localPath; - - $requirements = $action['requirements'] ?? [ '{id}' => '\d+' ]; - - $methods = \array_keys(\array_filter($action['methods'], function($value, $key) { return $value; }, - ARRAY_FILTER_USE_BOTH)); - $route = new Route($path, $defaults, $requirements); $route->setMethods($methods); @@ -233,4 +211,18 @@ class CRUDRoutesLoader extends Loader return $collection; } + + private function createEntityPostRoute(string $name, $crudConfig, array $action, $controller): Route + { + $localPath = $action['path'].'.{_format}'; + $defaults = [ + '_controller' => $controller.':'.($action['controller_action'] ?? 'entityPost') + ]; + $path = $crudConfig['base_path'].$localPath; + $requirements = $action['requirements'] ?? []; + $route = new Route($path, $defaults, $requirements); + $route->setMethods([ Request::METHOD_POST ]); + + return $route; + } } diff --git a/src/Bundle/ChillMainBundle/DependencyInjection/ChillMainExtension.php b/src/Bundle/ChillMainBundle/DependencyInjection/ChillMainExtension.php index 277e916a8..5644138e6 100644 --- a/src/Bundle/ChillMainBundle/DependencyInjection/ChillMainExtension.php +++ b/src/Bundle/ChillMainBundle/DependencyInjection/ChillMainExtension.php @@ -35,6 +35,8 @@ use Chill\MainBundle\Doctrine\DQL\OverlapsI; use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\DependencyInjection\Reference; use Chill\MainBundle\Doctrine\DQL\Replace; +use Chill\MainBundle\Doctrine\Type\NativeDateIntervalType; +use Chill\MainBundle\Doctrine\Type\PointType; use Symfony\Component\HttpFoundation\Request; /** @@ -167,37 +169,49 @@ class ChillMainExtension extends Extension implements PrependExtensionInterface, $container->prependExtensionConfig('twig', $twigConfig); //add DQL function to ORM (default entity_manager) - $container->prependExtensionConfig('doctrine', array( - 'orm' => array( - 'dql' => array( - 'string_functions' => array( - 'unaccent' => Unaccent::class, - 'GET_JSON_FIELD_BY_KEY' => GetJsonFieldByKey::class, - 'AGGREGATE' => JsonAggregate::class, - 'REPLACE' => Replace::class, - ), - 'numeric_functions' => [ - 'JSONB_EXISTS_IN_ARRAY' => JsonbExistsInArray::class, - 'SIMILARITY' => Similarity::class, - 'OVERLAPSI' => OverlapsI::class - ] - ) - ) - )); + $container + ->prependExtensionConfig( + 'doctrine', + [ + 'orm' => [ + 'dql' => [ + 'string_functions' => [ + 'unaccent' => Unaccent::class, + 'GET_JSON_FIELD_BY_KEY' => GetJsonFieldByKey::class, + 'AGGREGATE' => JsonAggregate::class, + 'REPLACE' => Replace::class, + ], + 'numeric_functions' => [ + 'JSONB_EXISTS_IN_ARRAY' => JsonbExistsInArray::class, + 'SIMILARITY' => Similarity::class, + 'OVERLAPSI' => OverlapsI::class, + ], + ], + ], + ], + ); //add dbal types (default entity_manager) - $container->prependExtensionConfig('doctrine', array( - 'dbal' => [ - 'types' => [ - 'dateinterval' => [ - 'class' => \Chill\MainBundle\Doctrine\Type\NativeDateIntervalType::class - ], - 'point' => [ - 'class' => \Chill\MainBundle\Doctrine\Type\PointType::class - ] - ] - ] - )); + $container + ->prependExtensionConfig( + 'doctrine', + [ + 'dbal' => [ + // This is mandatory since we are using postgis as database. + 'mapping_types' => [ + 'geometry' => 'string', + ], + 'types' => [ + 'dateinterval' => [ + 'class' => NativeDateIntervalType::class + ], + 'point' => [ + 'class' => PointType::class + ] + ] + ] + ] + ); //add current route to chill main $container->prependExtensionConfig('chill_main', array( diff --git a/src/Bundle/ChillMainBundle/Entity/Address.php b/src/Bundle/ChillMainBundle/Entity/Address.php index 36eda09c2..2003a7910 100644 --- a/src/Bundle/ChillMainBundle/Entity/Address.php +++ b/src/Bundle/ChillMainBundle/Entity/Address.php @@ -137,7 +137,7 @@ class Address * @var ThirdParty|null * * @ORM\ManyToOne(targetEntity="Chill\ThirdPartyBundle\Entity\ThirdParty") - * @ORM\JoinColumn(nullable=true) + * @ORM\JoinColumn(nullable=true, onDelete="SET NULL") */ private $linkedToThirdParty; diff --git a/src/Bundle/ChillMainBundle/Resources/public/modules/scratch/custom/_address.scss b/src/Bundle/ChillMainBundle/Resources/public/modules/scratch/custom/_address.scss index 1ee37632f..afe4e573f 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/modules/scratch/custom/_address.scss +++ b/src/Bundle/ChillMainBundle/Resources/public/modules/scratch/custom/_address.scss @@ -9,6 +9,12 @@ div.chill_address { margin: 0 0 0 1.5em; text-indent: -1.5em; } + + &.chill_address_address--multiline { + p { + display: block; + } + } } } diff --git a/src/Bundle/ChillMainBundle/Resources/public/modules/scratch/custom/_record_actions.scss b/src/Bundle/ChillMainBundle/Resources/public/modules/scratch/custom/_record_actions.scss index 64ee66077..ccbc5912a 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/modules/scratch/custom/_record_actions.scss +++ b/src/Bundle/ChillMainBundle/Resources/public/modules/scratch/custom/_record_actions.scss @@ -9,6 +9,11 @@ ul.record_actions li { ul.record_actions, ul.record_actions_column { display: flex; justify-content: flex-end; + + &.record_actions--left { + justify-content: flex-start; + } + padding: 0.5em 0; flex-wrap: wrap-reverse; diff --git a/src/Bundle/ChillMainBundle/Resources/public/scss/chillmain.scss b/src/Bundle/ChillMainBundle/Resources/public/scss/chillmain.scss index f5eb1dc09..b91aadb42 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/scss/chillmain.scss +++ b/src/Bundle/ChillMainBundle/Resources/public/scss/chillmain.scss @@ -1,45 +1,23 @@ /* * NOTE 2021.04 - * scss/chill.scss is the main sass file for the new chill.2 + * scss/chillmain.scss is the main sass file for the new chill.2 * scratch will be replaced by bootstrap, please avoid to edit in modules/scratch/_custom.scss * - * when possible, try to use bootstrap class naming + * when possible, try to use bootstrap html class */ -/* - * Header custom for Accompanying Course - */ -div#header-accompanying_course-name { - background: none repeat scroll 0 0 #718596; - color: #FFF; - padding-top: 1em; - padding-bottom: 1em; - - span { - a { - color: white; - } - a:hover { - text-decoration: underline; - } - } -} - -div#header-accompanying_course-details { - background: none repeat scroll 0 0 #718596ab; - color: #FFF; - padding-top: 1em; - padding-bottom: 1em; -} - -/* /!\ Contourne le positionnement problématique du div#content_conainter suivant, +/* [hack] /!\ Contourne le positionnement problématique du div#content_conainter suivant, * car sa position: relative le place au-dessus du bandeau et les liens sont incliquables */ div.subheader { height: 130px; } -//// SCRATCH BUTTONS +/* + * Specific rules + */ + +// [scratch] un bouton 'disabled' non clickable .sc-button { &.disabled { cursor: default; @@ -49,148 +27,199 @@ div.subheader { } } -//// VUEJS //// -div.vue-component { - padding: 1.5em; - margin: 2em 0; - border: 2px dashed grey; - position: relative; - &:before { - content: "vuejs component"; - position: absolute; - left: 1.5em; - top: -0.9em; - background-color: white; - color: grey; - padding: 0 0.3em; - } - dd { margin-left: 1em; } -} - -//// MODAL //// -.modal-mask { - position: fixed; - z-index: 9998; - top: 0; - left: 0; - width: 100%; - height: 100%; - background-color: rgba(0, 0, 0, 0.75); - display: table; - transition: opacity 0.3s ease; -} -.modal-header .close { // bootstrap classes, override sc-button 0 radius - border-top-right-radius: 0.3rem; -} - -/* -* The following styles are auto-applied to elements with -* transition="modal" when their visibility is toggled -* by Vue.js. -* -* You can easily play with the modal transition by editing -* these styles. -*/ -.modal-enter { - opacity: 0; -} -.modal-leave-active { - opacity: 0; -} -.modal-enter .modal-container, -.modal-leave-active .modal-container { - -webkit-transform: scale(1.1); - transform: scale(1.1); -} - -//// AddPersons modal -div.body-head { - overflow-y: unset; - div.modal-body:first-child { - margin: auto 4em; - div.search { - position: relative; - input { - padding: 1.2em 1.5em 1.2em 2.5em; - margin: 1em 0; - } - i { - position: absolute; - opacity: 0.5; - padding: 0.65em 0; - top: 50%; - } - i.fa-search { - left: 0.5em; - } - i.fa-times { - right: 1em; - padding: 0.75em 0; - cursor: pointer; - } - } - } - div.modal-body:last-child { - padding-bottom: 0; - } -} -div.count { - margin: -0.5em 0 0.7em; - display: flex; - justify-content: space-between; - a { - cursor: pointer; - } -} -div.results { - div.list-item { - padding: 0.4em 0.8em; - display: flex; - flex-direction: row; - &.checked { - background-color: #ececec; - border-bottom: 1px dotted #8b8b8b; - } - div.container { - & > input { - margin-right: 0.8em; - } - span:not(.name) { - margin-left: 0.5em; - opacity: 0.5; - font-size: 90%; - font-style: italic; - } - } - div.right_actions { - margin: 0 0 0 auto; - display: flex; - align-items: flex-end; - & > * { - margin-left: 0.5em; - align-self: baseline; - } - a.sc-button { - border: 1px solid lightgrey; - font-size: 70%; - padding: 4px; - } - } - } -} +// [debug] un affichage discret pour le debug .discret { color: grey; margin-right: 1em; } -a.flag-toggle { - color: white; - padding: 0 10px; - cursor: pointer; - &:hover { - color: white; - //border: 1px solid rgba(255,255,255,0.2); - text-decoration: underline; - border-radius: 20px; +// reserre la hauteur des rangées de tableau (ul.record_actions prennait trop de place) +table { + ul.record_actions { + margin: 0; + padding: 0.5em; } } + +/* + * ACCOMPANYING_COURSE + * Header custom for Accompanying Course + */ + +div#header-accompanying_course-name { + background: none repeat scroll 0 0 #718596; + color: #FFF; + h1 { + margin: 0.4em 0; + } + span { + a { + color: white; + } + a:hover { + text-decoration: underline; + } + } +} +div#header-accompanying_course-details { + background: none repeat scroll 0 0 #718596ab; + color: #FFF; + padding-top: 1em; + padding-bottom: 1em; +} + +/* +* FLEX RESPONSIVE TABLE/BLOCK PRESENTATION +*/ +div.flex-bloc, +div.flex-table { + h2, h3, h4, dl, p { + margin: 0; + } + h2, h3, h4 { + color: var(--chill-blue); + } +} + +/* +* Bloc appearance +*/ +div.flex-bloc { + box-sizing: border-box; + display: flex; + flex-direction: row; + flex-wrap: wrap; + align-items: stretch; + align-content: stretch; + + div.item-bloc { + flex-grow: 0; flex-shrink: 1; flex-basis: 50%; + + margin: 0; + border: 1px solid #000; + padding: 1em; + + border-top: 0; + &:nth-child(1), &:nth-child(2) { + border-top: 1px solid #000; + } + border-left: 0; + &:nth-child(odd) { + border-left: 1px solid #000; + } + + //background-color: #e6e6e6; + display: flex; + flex-direction: column; + + div.item-row { + flex-grow: 1; flex-shrink: 1; flex-basis: auto; + display: flex; + flex-direction: column; + + div.item-col { + &:first-child { + flex-grow: 0; flex-shrink: 0; flex-basis: auto; + } + &:last-child { + flex-grow: 1; flex-shrink: 1; flex-basis: auto; + display: flex; + + .list-content { // ul, dl, or div + } + ul.record_actions { + margin: 0; + align-self: flex-end; + flex-grow: 1; flex-shrink: 0; flex-basis: auto; + li { + margin-right: 5px; + } + } + } + } + } + } + @media only screen and (max-width: 945px) { margin: auto -0.2em; } + @media only screen and (max-width: 935px) { margin: auto -0.5em; } + @media only screen and (max-width: 920px) { margin: auto -0.9em; } + @media only screen and (max-width: 900px) { + flex-direction: column; + margin: auto 0; + div.item-bloc { + border-left: 1px solid #000; + &:nth-child(2) { + border-top: 0; + } + } + } +} + +/* +* Table appearance +*/ +div.flex-table { + display: flex; + flex-direction: column; + align-items: stretch; + align-content: stretch; + + div.item-bloc { + display: flex; + flex-direction: column; + padding: 1em; + border: 1px solid #000; + border-top: 0; + &:first-child { + border-top: 1px solid #000; + } + &:nth-child(even) { + background-color: #e6e6e6; + } + + div.item-row { + display: flex; + flex-direction: row; + &:not(:first-child) { + margin-top: 0.5em; + border-top: 1px dotted #0000004f; + padding-top: 0.5em; + flex-direction: column; + } + + div.item-col { + &:first-child { + flex-grow: 0; flex-shrink: 0; flex-basis: 33%; + } + &:last-child { + flex-grow: 1; flex-shrink: 1; flex-basis: auto; + display: flex; + justify-content: flex-end; + + .list-content { // ul, dl, or div + } + ul.record_actions { + margin: 0; + align-self: flex-start; + flex-grow: 1; flex-shrink: 0; flex-basis: auto; + li { + margin-right: 5px; + } + } + } + } + @media only screen and (max-width: 900px) { + flex-direction: column; + div.item-col { + &:last-child { + ul.record_actions { + align-self: flex-end; + } + } + } + } + + // neutralize + div.chill_address div.chill_address_address p { text-indent: 0; } + } + } +} diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/_components/Modal.vue b/src/Bundle/ChillMainBundle/Resources/public/vuejs/_components/Modal.vue index e6c1475e2..7498d66f3 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/_components/Modal.vue +++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/_components/Modal.vue @@ -1,41 +1,40 @@ + + diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/_js/i18n.js b/src/Bundle/ChillMainBundle/Resources/public/vuejs/_js/i18n.js index dee070804..319378d7e 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/_js/i18n.js +++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/_js/i18n.js @@ -37,12 +37,16 @@ const messages = { ok: "OK", cancel: "Annuler", close: "Fermer", - next: "Suivant", - previous: "Précédent", back: "Retour", check_all: "cocher tout", reset: "réinitialiser" }, + nav: { + next: "Suivant", + previous: "Précédent", + top: "Haut", + bottom: "Bas", + } } }; diff --git a/src/Bundle/ChillMainBundle/Resources/views/Address/entity_render.html.twig b/src/Bundle/ChillMainBundle/Resources/views/Address/entity_render.html.twig new file mode 100644 index 000000000..fa7a13645 --- /dev/null +++ b/src/Bundle/ChillMainBundle/Resources/views/Address/entity_render.html.twig @@ -0,0 +1,16 @@ +
+ {% if options['has_no_address'] == true and address.isNoAddress == true %} +
{{ 'address.consider homeless'|trans }}
+ {% endif %} +
+ {% if address.street is not empty %}

{{ address.street }}

{% endif %} + {% if address.streetNumber is not empty %}

{{ address.streetNumber }}

{% endif %} + {% if address.postCode is not empty %} +

{{ address.postCode.code }} {{ address.postCode.name }}

+

{{ address.postCode.country.name|localize_translatable_string }}

+ {% endif %} +
+{%- if options['with_valid_from'] == true -%} +{{ 'Since %date%'|trans( { '%date%' : address.validFrom|format_date('long') } ) }} +{%- endif -%} +
diff --git a/src/Bundle/ChillMainBundle/Resources/views/Address/macro.html.twig b/src/Bundle/ChillMainBundle/Resources/views/Address/macro.html.twig index 5de175169..990dbc043 100644 --- a/src/Bundle/ChillMainBundle/Resources/views/Address/macro.html.twig +++ b/src/Bundle/ChillMainBundle/Resources/views/Address/macro.html.twig @@ -1,11 +1,12 @@ {%- macro _render(address, options) -%} {%- set options = { 'with_valid_from' : true }|merge(options|default({})) -%} {%- set options = { 'has_no_address' : false }|merge(options|default({})) -%} + {%- set options = { 'with_icon' : false }|merge(options|default({})) -%}
{% if options['has_no_address'] == true and address.isNoAddress == true %}
{{ 'address.consider homeless'|trans }}
{% endif %} -
+
{% if options['with_icon'] == true %}{% endif %} {% if address.street is not empty %}

{{ address.street }}

{% endif %} {% if address.streetNumber is not empty %}

{{ address.streetNumber }}

{% endif %} {% if address.postCode is not empty %} diff --git a/src/Bundle/ChillMainBundle/Resources/views/Layout/_footer.html.twig b/src/Bundle/ChillMainBundle/Resources/views/Layout/_footer.html.twig index 132e81a3e..0d23d499d 100644 --- a/src/Bundle/ChillMainBundle/Resources/views/Layout/_footer.html.twig +++ b/src/Bundle/ChillMainBundle/Resources/views/Layout/_footer.html.twig @@ -1,4 +1,4 @@

{{ 'This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License'|trans|raw }} -
{{ 'User manual'|trans }}

-
\ No newline at end of file +
{{ 'User manual'|trans }}

+ diff --git a/src/Bundle/ChillMainBundle/Resources/views/Layout/_header-logo.html.twig b/src/Bundle/ChillMainBundle/Resources/views/Layout/_header-logo.html.twig index be59b454f..f619dc151 100644 --- a/src/Bundle/ChillMainBundle/Resources/views/Layout/_header-logo.html.twig +++ b/src/Bundle/ChillMainBundle/Resources/views/Layout/_header-logo.html.twig @@ -1 +1 @@ - \ No newline at end of file + diff --git a/src/Bundle/ChillMainBundle/Serializer/Normalizer/CenterNormalizer.php b/src/Bundle/ChillMainBundle/Serializer/Normalizer/CenterNormalizer.php index 26182d936..f1681c60a 100644 --- a/src/Bundle/ChillMainBundle/Serializer/Normalizer/CenterNormalizer.php +++ b/src/Bundle/ChillMainBundle/Serializer/Normalizer/CenterNormalizer.php @@ -20,19 +20,32 @@ namespace Chill\MainBundle\Serializer\Normalizer; use Chill\MainBundle\Entity\Center; +use Chill\MainBundle\Repository\CenterRepository; +use Symfony\Component\Serializer\Normalizer\DenormalizerInterface; use Symfony\Component\Serializer\Normalizer\NormalizerInterface; +use Symfony\Component\Serializer\Exception\InvalidArgumentException; +use Symfony\Component\Serializer\Exception\UnexpectedValueException; /** * * */ -class CenterNormalizer implements NormalizerInterface +class CenterNormalizer implements NormalizerInterface, DenormalizerInterface { + private CenterRepository $repository; + + + public function __construct(CenterRepository $repository) + { + $this->repository = $repository; + } + public function normalize($center, string $format = null, array $context = array()) { /** @var Center $center */ return [ 'id' => $center->getId(), + 'type' => 'center', 'name' => $center->getName() ]; } @@ -41,4 +54,30 @@ class CenterNormalizer implements NormalizerInterface { return $data instanceof Center; } + + public function denormalize($data, string $type, string $format = null, array $context = []) + { + if (FALSE === \array_key_exists('type', $data)) { + throw new InvalidArgumentException('missing "type" key in data'); + } + if ('center' !== $data['type']) { + throw new InvalidArgumentException('type should be equal to "center"'); + } + if (FALSE === \array_key_exists('id', $data)) { + throw new InvalidArgumentException('missing "id" key in data'); + } + + $center = $this->repository->find($data['id']); + + if (null === $center) { + throw new UnexpectedValueException("The type with id {$data['id']} does not exists"); + } + + return $center; + } + + public function supportsDenormalization($data, string $type, string $format = null) + { + return $type === Center::class; + } } diff --git a/src/Bundle/ChillMainBundle/Templating/Entity/AddressRender.php b/src/Bundle/ChillMainBundle/Templating/Entity/AddressRender.php new file mode 100644 index 000000000..90a707e40 --- /dev/null +++ b/src/Bundle/ChillMainBundle/Templating/Entity/AddressRender.php @@ -0,0 +1,67 @@ + true, + 'has_no_address' => false, + 'multiline' => true, + ]; + + public function __construct(EngineInterface $templating) + { + $this->templating = $templating; + } + + /** + * {@inheritDoc} + */ + public function supports($entity, array $options): bool + { + return $entity instanceof Address; + } + + /** + * @param Address addr + */ + public function renderString($addr, array $options): string + { + $lines = []; + if (!empty($addr->getStreet())) { + $lines[0] = $addr->getStreet(); + } + if (!empty($addr->getStreetNumber())) { + $lines[0] .= ", ".$addr->getStreetNumber(); + } + if (!empty($addr->getPostcode())) { + $lines[1] = \strtr("{postcode} {label}", [ + '{postcode}' => $addr->getPostcode()->getCode(), + '{label}' => $addr->getPostcode()->getName() + ]); + } + + return implode(" - ", $lines); + } + + /** + * {@inheritDoc} + * @param Address addr + */ + public function renderBox($addr, array $options): string + { + $options = \array_merge(self::DEFAULT_OPTIONS, $options); + + return $this->templating + ->render('@ChillMain/Address/entity_render.html.twig', [ + 'address' => $addr, + 'options' => $options + ]); + } +} diff --git a/src/Bundle/ChillMainBundle/Tests/Templating/Entity/AddressRenderTest.php b/src/Bundle/ChillMainBundle/Tests/Templating/Entity/AddressRenderTest.php new file mode 100644 index 000000000..79551d23c --- /dev/null +++ b/src/Bundle/ChillMainBundle/Tests/Templating/Entity/AddressRenderTest.php @@ -0,0 +1,55 @@ +get(EngineInterface::class); + $renderer = new AddressRender($engine); + + $this->assertEquals($expectedString, $renderer->renderString($addr, [])); + return; + $this->assertIsString($renderer->renderBox($addr, [])); + } + + + public function addressDataProvider(): \Iterator + { + $addr = new Address(); + $country = (new Country()) + ->setName([ "fr" => "Pays" ]) + ->setCountryCode("BE") + ; + $postCode = new PostalCode(); + $postCode->setName("Locality") + ->setCode("012345") + ->setCountry($country) + ; + + $addr->setStreet("Rue ABC") + ->setStreetNumber("5") + ->setPostcode($postCode) + ; + + yield[ $addr, "Rue ABC, 5 - 012345 Locality"]; + } + +} diff --git a/src/Bundle/ChillMainBundle/chill.api.specs.yaml b/src/Bundle/ChillMainBundle/chill.api.specs.yaml index ada65b08a..68a3eb764 100644 --- a/src/Bundle/ChillMainBundle/chill.api.specs.yaml +++ b/src/Bundle/ChillMainBundle/chill.api.specs.yaml @@ -9,15 +9,14 @@ servers: description: "Your current dev server" components: - parameters: - _format: - name: _format - in: path - required: true - schema: - type: string - enum: - - json + schemas: + Center: + type: object + properties: + id: + type: integer + name: + type: string paths: /1.0/search.json: diff --git a/src/Bundle/ChillMainBundle/config/services/templating.yaml b/src/Bundle/ChillMainBundle/config/services/templating.yaml index 29dc676d1..9d103f690 100644 --- a/src/Bundle/ChillMainBundle/config/services/templating.yaml +++ b/src/Bundle/ChillMainBundle/config/services/templating.yaml @@ -41,3 +41,10 @@ services: Chill\MainBundle\Templating\ChillMarkdownRenderExtension: tags: - { name: twig.extension } + + Chill\MainBundle\Templating\Entity\AddressRender: + arguments: + - '@Symfony\Component\Templating\EngineInterface' + tags: + - { name: 'chill.render_entity' } + diff --git a/src/Bundle/ChillMainBundle/migrations/Version20210525144016.php b/src/Bundle/ChillMainBundle/migrations/Version20210525144016.php new file mode 100644 index 000000000..3be8d9ea1 --- /dev/null +++ b/src/Bundle/ChillMainBundle/migrations/Version20210525144016.php @@ -0,0 +1,31 @@ +addSql('ALTER TABLE chill_main_address DROP CONSTRAINT FK_165051F6114B8DD9'); + $this->addSql('ALTER TABLE chill_main_address ADD CONSTRAINT FK_165051F6114B8DD9 FOREIGN KEY (linkedToThirdParty_id) REFERENCES chill_3party.third_party (id) ON DELETE SET NULL NOT DEFERRABLE INITIALLY IMMEDIATE'); + } + + public function down(Schema $schema): void + { + $this->addSql('ALTER TABLE chill_main_address DROP CONSTRAINT fk_165051f6114b8dd9'); + $this->addSql('ALTER TABLE chill_main_address ADD CONSTRAINT fk_165051f6114b8dd9 FOREIGN KEY (linkedtothirdparty_id) REFERENCES chill_3party.third_party (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + } +} diff --git a/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseApiController.php b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseApiController.php index 0d8189b6a..860cdfad7 100644 --- a/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseApiController.php +++ b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseApiController.php @@ -75,10 +75,10 @@ $workflow = $this->registry->get($accompanyingPeriod); switch ($request->getMethod()) { case Request::METHOD_POST: - $participation = $accompanyingPeriod->addPerson($person); + $participation = $accompanyingPeriod->createParticipationFor($person); break; case Request::METHOD_DELETE: - $participation = $accompanyingPeriod->removePerson($person); + $participation = $accompanyingPeriod->closeParticipationFor($person); break; default: throw new BadRequestException("This method is not supported"); diff --git a/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseController.php b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseController.php index 6786cb05f..e5b0cdda7 100644 --- a/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseController.php +++ b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseController.php @@ -72,7 +72,7 @@ class AccompanyingCourseController extends Controller $em->persist($period); $em->flush(); - return $this->redirectToRoute('chill_person_accompanying_course_show', [ + return $this->redirectToRoute('chill_person_accompanying_course_edit', [ 'accompanying_period_id' => $period->getId() ]); @@ -92,17 +92,16 @@ class AccompanyingCourseController extends Controller } /** - * Show page of Accompanying Course section + * Edit page of Accompanying Course section * - * the page show all blocks except one active edit block, managed by vuejs component - * that's why title of page is 'edit accompanying course' + * the page edit all blocks managed by vuejs component * - * @Route("/{_locale}/parcours/{accompanying_period_id}/show", name="chill_person_accompanying_course_show") + * @Route("/{_locale}/parcours/{accompanying_period_id}/edit", name="chill_person_accompanying_course_edit") * @ParamConverter("accompanyingCourse", options={"id": "accompanying_period_id"}) */ - public function showAction(AccompanyingPeriod $accompanyingCourse): Response + public function editAction(AccompanyingPeriod $accompanyingCourse): Response { - return $this->render('@ChillPerson/AccompanyingCourse/show.html.twig', [ + return $this->render('@ChillPerson/AccompanyingCourse/edit.html.twig', [ 'accompanyingCourse' => $accompanyingCourse ]); } diff --git a/src/Bundle/ChillPersonBundle/Controller/ApiPersonController.php b/src/Bundle/ChillPersonBundle/Controller/ApiPersonController.php deleted file mode 100644 index bfaf22d7b..000000000 --- a/src/Bundle/ChillPersonBundle/Controller/ApiPersonController.php +++ /dev/null @@ -1,30 +0,0 @@ - - * - * 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\PersonBundle\Controller; - -use Symfony\Bundle\FrameworkBundle\Controller\Controller; -use Symfony\Component\HttpFoundation\JsonResponse; - - -class ApiPersonController extends Controller -{ - public function viewAction($id, $_format) - { - - } -} diff --git a/src/Bundle/ChillPersonBundle/Controller/PersonApiController.php b/src/Bundle/ChillPersonBundle/Controller/PersonApiController.php new file mode 100644 index 000000000..84f1ebf66 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Controller/PersonApiController.php @@ -0,0 +1,50 @@ + + * + * 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\PersonBundle\Controller; + +use Chill\PersonBundle\Security\Authorization\PersonVoter; +use Chill\MainBundle\Security\Authorization\AuthorizationHelper; +use Symfony\Component\Security\Core\Role\Role; +use Chill\MainBundle\CRUD\Controller\ApiController; +use Symfony\Component\HttpFoundation\Request; + + +class PersonApiController extends ApiController +{ + private AuthorizationHelper $authorizationHelper; + + /** + * @param AuthorizationHelper $authorizationHelper + */ + public function __construct(AuthorizationHelper $authorizationHelper) + { + $this->authorizationHelper = $authorizationHelper; + } + + protected function createEntity(string $action, Request $request): object + { + $person = parent::createEntity($action, $request); + + // TODO temporary hack to allow creation of person with fake center + $centers = $this->authorizationHelper->getReachableCenters($this->getUser(), + new Role(PersonVoter::CREATE)); + $person->setCenter($centers[0]); + + return $person; + } +} diff --git a/src/Bundle/ChillPersonBundle/DependencyInjection/ChillPersonExtension.php b/src/Bundle/ChillPersonBundle/DependencyInjection/ChillPersonExtension.php index 0d6346c01..27721012d 100644 --- a/src/Bundle/ChillPersonBundle/DependencyInjection/ChillPersonExtension.php +++ b/src/Bundle/ChillPersonBundle/DependencyInjection/ChillPersonExtension.php @@ -476,7 +476,6 @@ class ChillPersonExtension extends Extension implements PrependExtensionInterfac 'class' => \Chill\PersonBundle\Entity\SocialWork\SocialIssue::class, 'name' => 'social_work_social_issue', 'base_path' => '/api/1.0/person/social-work/social-issue', -// 'controller' => \Chill\PersonBundle\Controller\OpeningApiController::class, 'base_role' => 'ROLE_USER', 'actions' => [ '_index' => [ @@ -493,6 +492,28 @@ class ChillPersonExtension extends Extension implements PrependExtensionInterfac ], ] ], + [ + 'class' => \Chill\PersonBundle\Entity\Person::class, + 'name' => 'person', + 'base_path' => '/api/1.0/person/person', + 'base_role' => \Chill\PersonBundle\Security\Authorization\PersonVoter::SEE, + 'controller' => \Chill\PersonBundle\Controller\PersonApiController::class, + 'actions' => [ + '_entity' => [ + 'methods' => [ + Request::METHOD_GET => true, + Request::METHOD_HEAD => true, + Request::METHOD_POST=> true, + ], + 'roles' => [ + Request::METHOD_GET => \Chill\PersonBundle\Security\Authorization\PersonVoter::SEE, + Request::METHOD_HEAD => \Chill\PersonBundle\Security\Authorization\PersonVoter::SEE, + Request::METHOD_POST => \Chill\PersonBundle\Security\Authorization\PersonVoter::CREATE, + + ] + ], + ] + ], ] ]); } diff --git a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php index d5b43446c..9841a99f3 100644 --- a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php +++ b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php @@ -483,9 +483,9 @@ class AccompanyingPeriod implements TrackCreationInterface, TrackUpdateInterface } /** - * Add Person + * Open a new participation for a person */ - public function addPerson(Person $person = null): AccompanyingPeriodParticipation + public function createParticipationFor(Person $person): AccompanyingPeriodParticipation { $participation = new AccompanyingPeriodParticipation($this, $person); $this->participations[] = $participation; @@ -493,10 +493,24 @@ class AccompanyingPeriod implements TrackCreationInterface, TrackUpdateInterface return $participation; } + public function addPerson(Person $person = null): self + { + if (NULL !== $person) { + $this->createParticipationFor($person); + } + + return $this; + } + /** - * Remove Person + * Close a participation for a person + * + * Search for the person's participation and set the end date at + * 'now'. + * + * @return void */ - public function removePerson(Person $person): ?AccompanyingPeriodParticipation + public function closeParticipationFor($person): ?AccompanyingPeriodParticipation { $participation = $this->getOpenParticipationContainsPerson($person); @@ -506,6 +520,17 @@ class AccompanyingPeriod implements TrackCreationInterface, TrackUpdateInterface return $participation; } + + + /** + * Remove Person + */ + public function removePerson(Person $person): self + { + $this->closeParticipationFor($person); + + return $this; + } public function getClosingMotive(): ?ClosingMotive diff --git a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/Comment.php b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/Comment.php index 0d64da0fc..18b5bd38d 100644 --- a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/Comment.php +++ b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/Comment.php @@ -51,7 +51,7 @@ class Comment implements TrackCreationInterface, TrackUpdateInterface * @ORM\ManyToOne( * targetEntity="Chill\PersonBundle\Entity\AccompanyingPeriod", * inversedBy="comments") - * @ORM\JoinColumn(nullable=false) + * @ORM\JoinColumn(nullable=false, onDelete="CASCADE") */ private $accompanyingPeriod; diff --git a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/Resource.php b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/Resource.php index cf796722a..a50e28621 100644 --- a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/Resource.php +++ b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/Resource.php @@ -32,7 +32,7 @@ use Symfony\Component\Serializer\Annotation\DiscriminatorMap; use Symfony\Component\Serializer\Annotation\Groups; /** - * @ORM\Entity(repositoryClass=ResourceRepository::class) + * @ORM\Entity * @ORM\Table(name="chill_person_accompanying_period_resource") * @DiscriminatorMap(typeProperty="type", mapping={ * "accompanying_period_resource"=Resource::class diff --git a/src/Bundle/ChillPersonBundle/Entity/Person.php b/src/Bundle/ChillPersonBundle/Entity/Person.php index 1afa6278c..a4fb185fb 100644 --- a/src/Bundle/ChillPersonBundle/Entity/Person.php +++ b/src/Bundle/ChillPersonBundle/Entity/Person.php @@ -421,6 +421,31 @@ class Person implements HasCenterInterface return $this->accompanyingPeriodParticipations; } + /** + * Return a collection of participation, where the participation + * is still opened, not a draft, and the period is still opened + */ + public function getOpenedParticipations(): Collection + { + // create a criteria for filtering easily + $criteria = Criteria::create(); + $criteria + ->andWhere(Criteria::expr()->eq('endDate', NULL)) + ->orWhere(Criteria::expr()->gt('endDate', new \DateTime('now'))) + ; + + return $this->getAccompanyingPeriodParticipations() + ->matching($criteria) + ->filter(function (AccompanyingPeriodParticipation $app) { + $period = $app->getAccompanyingPeriod(); + return ( + NULL === $period->getClosingDate() + || new \DateTime('now') < $period->getClosingDate() + ) + && AccompanyingPeriod::STEP_DRAFT !== $period->getStep(); + }); + } + /** * Get the accompanying periods of a give person with the chronological order. */ diff --git a/src/Bundle/ChillPersonBundle/Menu/AccompanyingCourseMenuBuilder.php b/src/Bundle/ChillPersonBundle/Menu/AccompanyingCourseMenuBuilder.php index e9ce20b53..49543c42d 100644 --- a/src/Bundle/ChillPersonBundle/Menu/AccompanyingCourseMenuBuilder.php +++ b/src/Bundle/ChillPersonBundle/Menu/AccompanyingCourseMenuBuilder.php @@ -43,7 +43,7 @@ class AccompanyingCourseMenuBuilder implements LocalMenuBuilderInterface ->setExtras(['order' => 10]); $menu->addChild($this->translator->trans('Edit Accompanying Course'), [ - 'route' => 'chill_person_accompanying_course_show', + 'route' => 'chill_person_accompanying_course_edit', 'routeParameters' => [ 'accompanying_period_id' => $period->getId() ]]) diff --git a/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/ClosingMotiveRepository.php b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/ClosingMotiveRepository.php index c99ca8efc..5c1525b52 100644 --- a/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/ClosingMotiveRepository.php +++ b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/ClosingMotiveRepository.php @@ -27,46 +27,41 @@ use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityRepository; use Doctrine\ORM\Query\ResultSetMappingBuilder; -/** - * Class ClosingMotiveRepository - * Entity repository for closing motives - * - * @package Chill\PersonBundle\Repository - */ final class ClosingMotiveRepository { private EntityRepository $repository; + private EntityManagerInterface $entityManager; + public function __construct(EntityManagerInterface $entityManager) { + $this->entityManager = $entityManager; $this->repository = $entityManager->getRepository(ClosingMotive::class); } /** - * @param bool $onlyLeaf * @return mixed */ public function getActiveClosingMotive(bool $onlyLeaf = true) { - $rsm = new ResultSetMappingBuilder($this->repository->getEntityManager()); + $rsm = new ResultSetMappingBuilder($this->entityManager); $rsm->addRootEntityFromClassMetadata($this->repository->getClassName(), 'cm'); - $sql = "SELECT ".(string) $rsm." + $sql = "SELECT " . (string) $rsm . " FROM chill_person_accompanying_period_closingmotive AS cm WHERE active IS TRUE "; - + if ($onlyLeaf) { $sql .= "AND cm.id NOT IN ( SELECT DISTINCT parent_id FROM chill_person_accompanying_period_closingmotive WHERE parent_id IS NOT NULL )"; } - + $sql .= " ORDER BY cm.ordering ASC"; return $this - ->repository - ->getEntityManager() + ->entityManager ->createNativeQuery($sql, $rsm) ->getResult(); } diff --git a/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/CommentRepository.php b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/CommentRepository.php index aca7a9c68..b3a20780e 100644 --- a/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/CommentRepository.php +++ b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/CommentRepository.php @@ -26,12 +26,6 @@ use Chill\PersonBundle\Entity\AccompanyingPeriod\Comment; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityRepository; -/** - * @method Comment|null find($id, $lockMode = null, $lockVersion = null) - * @method Comment|null findOneBy(array $criteria, array $orderBy = null) - * @method Comment[] findAll() - * @method Comment[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) - */ final class CommentRepository { private EntityRepository $repository; diff --git a/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/OriginRepository.php b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/OriginRepository.php index c2851b851..596bfc2ee 100644 --- a/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/OriginRepository.php +++ b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/OriginRepository.php @@ -26,12 +26,6 @@ use Chill\PersonBundle\Entity\AccompanyingPeriod\Origin; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityRepository; -/** - * @method Origin|null find($id, $lockMode = null, $lockVersion = null) - * @method Origin|null findOneBy(array $criteria, array $orderBy = null) - * @method Origin[] findAll() - * @method Origin[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) - */ final class OriginRepository { private EntityRepository $repository; diff --git a/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/ResourceRepository.php b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/ResourceRepository.php index c32f74762..3923126aa 100644 --- a/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/ResourceRepository.php +++ b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/ResourceRepository.php @@ -24,21 +24,19 @@ namespace Chill\PersonBundle\Repository\AccompanyingPeriod; use Chill\PersonBundle\Entity\AccompanyingPeriod\Resource; use Doctrine\ORM\EntityRepository; -use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; -use Doctrine\Persistence\ManagerRegistry; +use Doctrine\ORM\EntityManagerInterface; -/** - * @method Resource|null find($id, $lockMode = null, $lockVersion = null) - * @method Resource|null findOneBy(array $criteria, array $orderBy = null) - * @method Resource[] findAll() - * @method Resource[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) - */ -final class ResourceRepository extends ServiceEntityRepository +final class ResourceRepository { private EntityRepository $repository; - public function __construct(ManagerRegistry $registry) + public function __construct(EntityManagerInterface $entityManager) { - parent::__construct($registry, Resource::class); + $this->repository = $entityManager->getRepository(Resource::class); + } + + public function find($id, $lockMode = null, $lockVersion = null): ?Resource + { + return $this->repository->find($id, $lockMode, $lockVersion); } } diff --git a/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriodParticipationRepository.php b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriodParticipationRepository.php index 0f157ed42..f902c7cc8 100644 --- a/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriodParticipationRepository.php +++ b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriodParticipationRepository.php @@ -26,12 +26,6 @@ use Chill\PersonBundle\Entity\AccompanyingPeriodParticipation; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityRepository; -/** - * @method AccompanyingPeriodParticipation|null find($id, $lockMode = null, $lockVersion = null) - * @method AccompanyingPeriodParticipation|null findOneBy(array $criteria, array $orderBy = null) - * @method AccompanyingPeriodParticipation[] findAll() - * @method AccompanyingPeriodParticipation[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) - */ final class AccompanyingPeriodParticipationRepository { private EntityRepository $repository; diff --git a/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriodRepository.php b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriodRepository.php index 07aa0a55f..c2a8299fc 100644 --- a/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriodRepository.php +++ b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriodRepository.php @@ -26,12 +26,6 @@ use Chill\PersonBundle\Entity\AccompanyingPeriod; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityRepository; -/** - * @method AccompanyingPeriod|null find($id, $lockMode = null, $lockVersion = null) - * @method AccompanyingPeriod|null findOneBy(array $criteria, array $orderBy = null) - * @method AccompanyingPeriod[] findAll() - * @method AccompanyingPeriod[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) - */ final class AccompanyingPeriodRepository { private EntityRepository $repository; diff --git a/src/Bundle/ChillPersonBundle/Repository/Household/HouseholdMembersRepository.php b/src/Bundle/ChillPersonBundle/Repository/Household/HouseholdMembersRepository.php index b11d3d93a..1a634f451 100644 --- a/src/Bundle/ChillPersonBundle/Repository/Household/HouseholdMembersRepository.php +++ b/src/Bundle/ChillPersonBundle/Repository/Household/HouseholdMembersRepository.php @@ -6,12 +6,6 @@ use Chill\PersonBundle\Entity\Household\HouseholdMembers; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityRepository; -/** - * @method HouseholdMembers|null find($id, $lockMode = null, $lockVersion = null) - * @method HouseholdMembers|null findOneBy(array $criteria, array $orderBy = null) - * @method HouseholdMembers[] findAll() - * @method HouseholdMembers[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) - */ final class HouseholdMembersRepository { private EntityRepository $repository; @@ -20,33 +14,4 @@ final class HouseholdMembersRepository { $this->repository = $entityManager->getRepository(HouseholdMembers::class); } - - // /** - // * @return HouseholdMembers[] Returns an array of HouseholdMembers objects - // */ - /* - public function findByExampleField($value) - { - return $this->createQueryBuilder('h') - ->andWhere('h.exampleField = :val') - ->setParameter('val', $value) - ->orderBy('h.id', 'ASC') - ->setMaxResults(10) - ->getQuery() - ->getResult() - ; - } - */ - - /* - public function findOneBySomeField($value): ?HouseholdMembers - { - return $this->createQueryBuilder('h') - ->andWhere('h.exampleField = :val') - ->setParameter('val', $value) - ->getQuery() - ->getOneOrNullResult() - ; - } - */ } diff --git a/src/Bundle/ChillPersonBundle/Repository/Household/HouseholdRepository.php b/src/Bundle/ChillPersonBundle/Repository/Household/HouseholdRepository.php index 78a68f56d..b7a8816b3 100644 --- a/src/Bundle/ChillPersonBundle/Repository/Household/HouseholdRepository.php +++ b/src/Bundle/ChillPersonBundle/Repository/Household/HouseholdRepository.php @@ -6,12 +6,6 @@ use Chill\PersonBundle\Entity\Household\Household; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityRepository; -/** - * @method Household|null find($id, $lockMode = null, $lockVersion = null) - * @method Household|null findOneBy(array $criteria, array $orderBy = null) - * @method Household[] findAll() - * @method Household[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) - */ final class HouseholdRepository { private EntityRepository $repository; @@ -20,33 +14,4 @@ final class HouseholdRepository { $this->repository = $entityManager->getRepository(Household::class); } - - // /** - // * @return Household[] Returns an array of Household objects - // */ - /* - public function findByExampleField($value) - { - return $this->createQueryBuilder('h') - ->andWhere('h.exampleField = :val') - ->setParameter('val', $value) - ->orderBy('h.id', 'ASC') - ->setMaxResults(10) - ->getQuery() - ->getResult() - ; - } - */ - - /* - public function findOneBySomeField($value): ?Household - { - return $this->createQueryBuilder('h') - ->andWhere('h.exampleField = :val') - ->setParameter('val', $value) - ->getQuery() - ->getOneOrNullResult() - ; - } - */ } diff --git a/src/Bundle/ChillPersonBundle/Repository/PersonAltNameRepository.php b/src/Bundle/ChillPersonBundle/Repository/PersonAltNameRepository.php index c5dea689a..eed330c8a 100644 --- a/src/Bundle/ChillPersonBundle/Repository/PersonAltNameRepository.php +++ b/src/Bundle/ChillPersonBundle/Repository/PersonAltNameRepository.php @@ -6,12 +6,6 @@ use Chill\PersonBundle\Entity\PersonAltName; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityRepository; -/** - * PersonAltNameRepository - * - * This class was generated by the Doctrine ORM. Add your own custom - * repository methods below. - */ final class PersonAltNameRepository { private EntityRepository $repository; diff --git a/src/Bundle/ChillPersonBundle/Repository/PersonNotDuplicateRepository.php b/src/Bundle/ChillPersonBundle/Repository/PersonNotDuplicateRepository.php index 989baaeec..b899f06c1 100644 --- a/src/Bundle/ChillPersonBundle/Repository/PersonNotDuplicateRepository.php +++ b/src/Bundle/ChillPersonBundle/Repository/PersonNotDuplicateRepository.php @@ -7,11 +7,6 @@ use Chill\PersonBundle\Entity\PersonNotDuplicate; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityRepository; -/** - * Class PersonNotDuplicateRepository - * - * @package Chill\PersonBundle\Repository - */ final class PersonNotDuplicateRepository { private EntityRepository $repository; @@ -21,12 +16,7 @@ final class PersonNotDuplicateRepository $this->repository = $entityManager->getRepository(PersonNotDuplicate::class); } - /** - * @param \Chill\PersonBundle\Entity\Person $person - * - * @return array - */ - public function findNotDuplicatePerson(Person $person) + public function findNotDuplicatePerson(Person $person): array { $qb = $this->repository->createQueryBuilder('pnd'); $qb->select('pnd') @@ -36,6 +26,7 @@ final class PersonNotDuplicateRepository $result = $qb->getQuery()->getResult(); $persons = []; + foreach ($result as $row) { if ($row->getPerson1() === $person) { $persons[] = $row->getPerson2(); diff --git a/src/Bundle/ChillPersonBundle/Repository/PersonRepository.php b/src/Bundle/ChillPersonBundle/Repository/PersonRepository.php index 12733a668..fdd0f054e 100644 --- a/src/Bundle/ChillPersonBundle/Repository/PersonRepository.php +++ b/src/Bundle/ChillPersonBundle/Repository/PersonRepository.php @@ -32,105 +32,88 @@ final class PersonRepository $this->repository = $entityManager->getRepository(Person::class); } - public function find($id, $lockMode = null, $lockVersion = null) + public function find($id, $lockMode = null, $lockVersion = null): ?Person { return $this->repository->find($id, $lockMode, $lockVersion); } /** - * @param string $phonenumber * @param $centers * @param $firstResult * @param $maxResults - * @param array $only * @return mixed * @throws \Exception */ public function findByPhone( - string $phonenumber, - $centers, + string $phonenumber, + $centers, $firstResult, $maxResults, array $only = ['mobile', 'phone'] ) { $qb = $this->repository->createQueryBuilder('p'); $qb->select('p'); - + $this->addByCenters($qb, $centers); $this->addPhoneNumber($qb, $phonenumber, $only); - + $qb->setFirstResult($firstResult) ->setMaxResults($maxResults) ; - + return $qb->getQuery()->getResult(); } - + /** - * @param string $phonenumber * @param $centers - * @param array $only - * @return int * @throws \Doctrine\ORM\NoResultException * @throws \Doctrine\ORM\NonUniqueResultException */ public function countByPhone( - string $phonenumber, - $centers, + string $phonenumber, + $centers, array $only = ['mobile', 'phone'] - ): int - { + ): int { $qb = $this->repository->createQueryBuilder('p'); $qb->select('COUNT(p)'); - + $this->addByCenters($qb, $centers); $this->addPhoneNumber($qb, $phonenumber, $only); - + return $qb->getQuery()->getSingleScalarResult(); } - + /** - * @param QueryBuilder $qb - * @param string $phonenumber - * @param array $only * @throws \Exception */ - protected function addPhoneNumber(QueryBuilder $qb, string $phonenumber, array $only) + protected function addPhoneNumber(QueryBuilder $qb, string $phonenumber, array $only): void { if (count($only) === 0) { throw new \Exception("No array field to search"); } - + $phonenumber = $this->parsePhoneNumber($phonenumber); - + $orX = $qb->expr()->orX(); - + if (\in_array('mobile', $only)) { $orX->add($qb->expr()->like("REPLACE(p.mobilenumber, ' ', '')", ':phonenumber')); } if (\in_array('phone', $only)) { $orX->add($qb->expr()->like("REPLACE(p.phonenumber, ' ', '')", ':phonenumber')); } - + $qb->andWhere($orX); - + $qb->setParameter('phonenumber', '%'.$phonenumber.'%'); } - - /** - * @param $phonenumber - * @return string - */ - protected function parsePhoneNumber($phonenumber): string + + protected function parsePhoneNumber(string $phonenumber): string { return \str_replace(' ', '', $phonenumber); } - - /** - * @param QueryBuilder $qb - * @param array $centers - */ - protected function addByCenters(QueryBuilder $qb, array $centers) + + protected function addByCenters(QueryBuilder $qb, array $centers): void { if (count($centers) > 0) { $qb->andWhere($qb->expr()->in('p.center', ':centers')); diff --git a/src/Bundle/ChillPersonBundle/Repository/SocialWork/EvaluationRepository.php b/src/Bundle/ChillPersonBundle/Repository/SocialWork/EvaluationRepository.php index c9ab3c931..f554e4e8c 100644 --- a/src/Bundle/ChillPersonBundle/Repository/SocialWork/EvaluationRepository.php +++ b/src/Bundle/ChillPersonBundle/Repository/SocialWork/EvaluationRepository.php @@ -6,12 +6,6 @@ use Chill\PersonBundle\Entity\SocialWork\Evaluation; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityRepository; -/** - * @method Evaluation|null find($id, $lockMode = null, $lockVersion = null) - * @method Evaluation|null findOneBy(array $criteria, array $orderBy = null) - * @method Evaluation[] findAll() - * @method Evaluation[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) - */ final class EvaluationRepository { private EntityRepository $repository; diff --git a/src/Bundle/ChillPersonBundle/Repository/SocialWork/GoalRepository.php b/src/Bundle/ChillPersonBundle/Repository/SocialWork/GoalRepository.php index 30576b4ed..bd7c6a738 100644 --- a/src/Bundle/ChillPersonBundle/Repository/SocialWork/GoalRepository.php +++ b/src/Bundle/ChillPersonBundle/Repository/SocialWork/GoalRepository.php @@ -6,12 +6,6 @@ use Chill\PersonBundle\Entity\SocialWork\Goal; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityRepository; -/** - * @method Goal|null find($id, $lockMode = null, $lockVersion = null) - * @method Goal|null findOneBy(array $criteria, array $orderBy = null) - * @method Goal[] findAll() - * @method Goal[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) - */ final class GoalRepository { private EntityRepository $repository; diff --git a/src/Bundle/ChillPersonBundle/Repository/SocialWork/ResultRepository.php b/src/Bundle/ChillPersonBundle/Repository/SocialWork/ResultRepository.php index 004a2f82c..1c4d8d013 100644 --- a/src/Bundle/ChillPersonBundle/Repository/SocialWork/ResultRepository.php +++ b/src/Bundle/ChillPersonBundle/Repository/SocialWork/ResultRepository.php @@ -6,12 +6,6 @@ use Chill\PersonBundle\Entity\SocialWork\Result; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityRepository; -/** - * @method Result|null find($id, $lockMode = null, $lockVersion = null) - * @method Result|null findOneBy(array $criteria, array $orderBy = null) - * @method Result[] findAll() - * @method Result[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) - */ final class ResultRepository { private EntityRepository $repository; diff --git a/src/Bundle/ChillPersonBundle/Repository/SocialWork/SocialActionRepository.php b/src/Bundle/ChillPersonBundle/Repository/SocialWork/SocialActionRepository.php index cfa9adbd7..3c86d2397 100644 --- a/src/Bundle/ChillPersonBundle/Repository/SocialWork/SocialActionRepository.php +++ b/src/Bundle/ChillPersonBundle/Repository/SocialWork/SocialActionRepository.php @@ -6,12 +6,6 @@ use Chill\PersonBundle\Entity\SocialWork\SocialAction; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityRepository; -/** - * @method SocialAction|null find($id, $lockMode = null, $lockVersion = null) - * @method SocialAction|null findOneBy(array $criteria, array $orderBy = null) - * @method SocialAction[] findAll() - * @method SocialAction[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) - */ final class SocialActionRepository { private EntityRepository $repository; diff --git a/src/Bundle/ChillPersonBundle/Repository/SocialWork/SocialIssueRepository.php b/src/Bundle/ChillPersonBundle/Repository/SocialWork/SocialIssueRepository.php index 2f6eb3ba1..1100d8136 100644 --- a/src/Bundle/ChillPersonBundle/Repository/SocialWork/SocialIssueRepository.php +++ b/src/Bundle/ChillPersonBundle/Repository/SocialWork/SocialIssueRepository.php @@ -7,12 +7,6 @@ use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityRepository; -/** - * @method SocialIssue|null find($id, $lockMode = null, $lockVersion = null) - * @method SocialIssue|null findOneBy(array $criteria, array $orderBy = null) - * @method SocialIssue[] findAll() - * @method SocialIssue[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) - */ final class SocialIssueRepository { private EntityRepository $repository; diff --git a/src/Bundle/ChillPersonBundle/Resources/public/index.js b/src/Bundle/ChillPersonBundle/Resources/public/index.js index f4bcba7fb..e3563b4ff 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/index.js +++ b/src/Bundle/ChillPersonBundle/Resources/public/index.js @@ -1 +1,2 @@ -require('./sass/person.scss'); \ No newline at end of file +require('./sass/person.scss'); +require('./sass/person_with_period.scss'); diff --git a/src/Bundle/ChillPersonBundle/Resources/public/sass/index.js b/src/Bundle/ChillPersonBundle/Resources/public/sass/index.js index 35945c7ff..89e749e5c 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/sass/index.js +++ b/src/Bundle/ChillPersonBundle/Resources/public/sass/index.js @@ -1,5 +1,5 @@ require('./phone-alt-solid.svg'); require('./mobile-alt-solid.svg'); require('./person_by_phonenumber.scss'); - +require('./person_with_period.scss'); diff --git a/src/Bundle/ChillPersonBundle/Resources/public/sass/person_with_period.scss b/src/Bundle/ChillPersonBundle/Resources/public/sass/person_with_period.scss new file mode 100644 index 000000000..6f52d2cae --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Resources/public/sass/person_with_period.scss @@ -0,0 +1,50 @@ +/// complete and overwrite flex-table in chillmain.scss +div.list-with-period { + div.person { + ul.record_actions { + li { + margin-right: 0 !important; + } + } + } + div.periods { + div.header, + div.list-content { + width: calc(100% - 40px); + margin-left: 40px; + } + div.header { + position: relative; + a.sc-button { + position: absolute; + width: 30px; + height: 30px; + top: 10px; + left: -40px; + padding: 0; + i { + padding: 5px; + } + } + abbr.referrer { + font-size: 70%; + } + span.user { + margin-left: 1em; + } + } + div.list-content { + span.more { + font-style: italic; + } + } + } +} + +.chill-entity__person { + .chill-entity__person__first-name, + .chill-entity__person__last-name { + font-size: 1.3em; + font-weight: 700; + } +} diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/App.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/App.vue index 758b49313..8dd66d0f2 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/App.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/App.vue @@ -1,19 +1,24 @@ + + diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/api.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/api.js index 5e3210536..70b2ba56e 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/api.js +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/api.js @@ -36,6 +36,33 @@ const patchAccompanyingCourse = (id, body) => { }); }; +/* +* Endpoint to change 'DRAFT' step to 'CONFIRMED' +*/ +const confirmAccompanyingCourse = (id) => { + const url = `/api/1.0/person/accompanying-course/${id}/confirm.json` + return fetch(url, { + method: 'POST', + headers: {'Content-Type': 'application/json;charset=utf-8'} + }) + .then(response => { + if (response.ok) { return response.json(); } + throw Error('Error with request resource response'); + }); +}; + +/* +* Endpoint +*/ +const getSocialIssues = () => { + const url = `/api/1.0/person/social-work/social-issue.json`; + return fetch(url) + .then(response => { + if (response.ok) { return response.json(); } + throw Error('Error with request resource response'); + }); +}; + /* * Endpoint v.2 chill_api_single_accompanying_course_participation, * method POST/DELETE, add/close a participation to the accompanyingCourse @@ -119,10 +146,32 @@ const postResource = (id, payload, method) => { }); }; +/* +* Endpoint to Add/remove SocialIssue +*/ +const postSocialIssue = (id, body, method) => { + //console.log('api body and method', body, method); + const url = `/api/1.0/person/accompanying-course/${id}/socialissue.json`; + return fetch(url, { + method: method, + headers: { + 'Content-Type': 'application/json;charset=utf-8' + }, + body: JSON.stringify(body) + }) + .then(response => { + if (response.ok) { return response.json(); } + throw Error('Error with request resource response'); + }); +}; + export { getAccompanyingCourse, patchAccompanyingCourse, + confirmAccompanyingCourse, + getSocialIssues, postParticipation, postRequestor, postResource, + postSocialIssue }; diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/AccompanyingCourse.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/AccompanyingCourse.vue deleted file mode 100644 index b94d73338..000000000 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/AccompanyingCourse.vue +++ /dev/null @@ -1,41 +0,0 @@ - - - diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Banner.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Banner.vue new file mode 100644 index 000000000..7a91e39c3 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Banner.vue @@ -0,0 +1,92 @@ + + + + + diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Banner/SocialIssue.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Banner/SocialIssue.vue new file mode 100644 index 000000000..7ed78355d --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Banner/SocialIssue.vue @@ -0,0 +1,20 @@ + + + + + diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/ToggleFlags.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Banner/ToggleFlags.vue similarity index 62% rename from src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/ToggleFlags.vue rename to src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Banner/ToggleFlags.vue index ac5960d19..67ef8c193 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/ToggleFlags.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Banner/ToggleFlags.vue @@ -1,24 +1,20 @@ + + diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Comment.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Comment.vue index 2aaced056..858d6d04e 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Comment.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Comment.vue @@ -1,44 +1,48 @@ @@ -82,9 +86,14 @@ export default { } /* * TODO -* - patch endpoint to update Content -* - delete/reset button ? -* - manage flash messages => specific component ? -* - ckeditor +* - [x] delete button in ul record_actions, but not in form +* - [ ] display updatedAt => initialComment fetch PATCH content changes MUST NOT change object id !! +* - [ ] ckeditor integration */ + + diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Confirm.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Confirm.vue index 83f2c4c90..c2143b72a 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Confirm.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Confirm.vue @@ -1,42 +1,63 @@ + + diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/PersonsAssociated.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/PersonsAssociated.vue index a01e4dc33..7c61b066c 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/PersonsAssociated.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/PersonsAssociated.vue @@ -1,8 +1,12 @@ diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Requestor.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Requestor.vue index 96860b048..32fbb86c2 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Requestor.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Requestor.vue @@ -1,64 +1,76 @@ @@ -95,6 +107,13 @@ export default { get() { return this.$store.state.accompanyingCourse.requestorAnonymous; } + }, + url() { + return (this.accompanyingCourse.requestor.type === 'person') ? { + show: `/fr/person/${this.accompanyingCourse.requestor.id}/general`, + } : { + show: `/fr/thirdparty/thirdparty/${this.accompanyingCourse.requestor.id}/show`, + } } }, methods: { @@ -111,3 +130,28 @@ export default { } } + + diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Resources.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Resources.vue index 07e808691..596da7483 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Resources.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Resources.vue @@ -1,10 +1,13 @@ @@ -37,7 +42,7 @@ + + + diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/StickyNav.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/StickyNav.vue new file mode 100644 index 000000000..3bc1ea33a --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/StickyNav.vue @@ -0,0 +1,191 @@ + + + + + diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/StickyNav/Item.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/StickyNav/Item.vue new file mode 100644 index 000000000..413f216cc --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/StickyNav/Item.vue @@ -0,0 +1,30 @@ + + + diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Test.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Test.vue index 7f3a49f1c..a72902b25 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Test.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Test.vue @@ -1,6 +1,6 @@