mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-27 09:05:01 +00:00
Compare commits
1 Commits
use-sympli
...
fix-timeli
Author | SHA1 | Date | |
---|---|---|---|
|
8364518282 |
@@ -11,15 +11,14 @@ 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;"
|
- 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
|
# Install and run Composer
|
||||||
- curl -sS https://getcomposer.org/installer | php
|
- curl -sS https://getcomposer.org/installer | php
|
||||||
- php -d memory_limit=2G composer.phar install
|
- php composer.phar install
|
||||||
- php tests/app/bin/console doctrine:migrations:migrate -n
|
- php tests/app/bin/console doctrine:migrations:migrate -n
|
||||||
- php -d memory_limit=2G tests/app/bin/console doctrine:fixtures:load -n
|
- php 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
|
# 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.
|
# See http://docs.gitlab.com/ee/ci/services/README.html for examples.
|
||||||
services:
|
services:
|
||||||
- name: postgis/postgis:12-3.1-alpine
|
- name: postgres:12
|
||||||
alias: db
|
alias: db
|
||||||
- name: redis
|
- name: redis
|
||||||
alias: redis
|
alias: redis
|
||||||
@@ -39,4 +38,4 @@ variables:
|
|||||||
# Run our tests
|
# Run our tests
|
||||||
test:
|
test:
|
||||||
script:
|
script:
|
||||||
- php -d memory_limit=3G bin/phpunit --colors=never
|
- bin/phpunit --colors=never
|
||||||
|
168
composer.json
168
composer.json
@@ -1,110 +1,88 @@
|
|||||||
{
|
{
|
||||||
"name": "chill-project/chill-bundles",
|
"name": "chill-project/chill-bundles",
|
||||||
"license": "AGPL-3.0-only",
|
"license": "AGPL-3.0-only",
|
||||||
|
"type": "library",
|
||||||
"description": "Most used bundles for chill-project",
|
"description": "Most used bundles for chill-project",
|
||||||
"keywords": ["chill", "social worker"],
|
"keywords": ["chill", "social worker"],
|
||||||
"authors": [
|
|
||||||
{
|
|
||||||
"name": "Champs-Libres",
|
|
||||||
"email": "info@champs-libres.coop",
|
|
||||||
"homepage": "http://www.champs-libres.coop"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"type": "library",
|
|
||||||
"require": {
|
|
||||||
"components/jquery": ">=1.7.1",
|
|
||||||
"league/csv": "^9.6",
|
|
||||||
"phpoffice/phpspreadsheet": "~1.2",
|
|
||||||
"robloach/component-installer": "*"
|
|
||||||
},
|
|
||||||
"config": {
|
|
||||||
"vendor-dir": "tests/app/vendor",
|
|
||||||
"bin-dir": "bin"
|
|
||||||
},
|
|
||||||
"require-dev": {
|
|
||||||
"doctrine/doctrine-fixtures-bundle": "^3.3",
|
|
||||||
"fakerphp/faker": "^1.13",
|
|
||||||
"nelmio/alice": "^3.8",
|
|
||||||
"phpunit/phpunit": "^9.5",
|
|
||||||
"symfony/debug-bundle": "^5.1",
|
|
||||||
"symfony/dotenv": "^5.1",
|
|
||||||
"symfony/maker-bundle": "^1.20",
|
|
||||||
"symfony/phpunit-bridge": "^5.2",
|
|
||||||
"symfony/stopwatch": "^5.1",
|
|
||||||
"symfony/var-dumper": "4.*",
|
|
||||||
"symfony/web-profiler-bundle": "^5.0",
|
|
||||||
"symplify/monorepo-builder": "^9.2"
|
|
||||||
},
|
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-4": {
|
"psr-4": {
|
||||||
"Chill\\AMLI\\BudgetBundle\\": "src/Bundle/ChillBudgetBundle/",
|
"Chill\\ActivityBundle\\": "src/Bundle/ChillActivityBundle",
|
||||||
"Chill\\AMLI\\FamilyMembersBundle\\": "src/Bundle/ChillFamilyMembersBundle/",
|
"Chill\\BudgetBundle\\": "src/Bundle/ChillBudgetBundle",
|
||||||
"Chill\\ActivityBundle\\": "src/Bundle/ChillActivityBundle/",
|
"Chill\\CustomFieldsBundle\\": "src/Bundle/ChillCustomFieldsBundle",
|
||||||
"Chill\\CustomFieldsBundle\\": "src/Bundle/ChillCustomFieldsBundle/",
|
"Chill\\DocStoreBundle\\": "src/Bundle/ChillDocStoreBundle",
|
||||||
"Chill\\DocStoreBundle\\": "src/Bundle/ChillDocStoreBundle/",
|
"Chill\\EventBundle\\": "src/Bundle/ChillEventBundle",
|
||||||
"Chill\\EventBundle\\": "src/Bundle/ChillEventBundle/",
|
"Chill\\FamilyMemberBundle\\": "src/Bundle/ChillFamilyMemberBundle",
|
||||||
"Chill\\MainBundle\\": "src/Bundle/ChillMainBundle/",
|
"Chill\\MainBundle\\": "src/Bundle/ChillMainBundle",
|
||||||
"Chill\\PersonBundle\\": "src/Bundle/ChillPersonBundle/",
|
"Chill\\PersonBundle\\": "src/Bundle/ChillPersonBundle",
|
||||||
"Chill\\ReportBundle\\": "src/Bundle/ChillReportBundle/",
|
"Chill\\ReportBundle\\": "src/Bundle/ChillReportBundle",
|
||||||
"Chill\\TaskBundle\\": "src/Bundle/ChillTaskBundle/",
|
"Chill\\TaskBundle\\": "src/Bundle/ChillTaskBundle",
|
||||||
"Chill\\ThirdPartyBundle\\": "src/Bundle/ChillThirdPartyBundle/"
|
"Chill\\ThirdPartyBundle\\": "src/Bundle/ChillThirdPartyBundle"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"autoload-dev": {
|
"autoload-dev": {
|
||||||
"classmap": [
|
"psr-4": {
|
||||||
"src/Bundle/ChillActivityBundle/Resources/test/Fixtures/App/app/AppKernel.php",
|
"App\\": "tests/app/src/"
|
||||||
"src/Bundle/ChillCustomFieldsBundle/Resources/test/Fixtures/App/app/AppKernel.php",
|
}
|
||||||
"src/Bundle/ChillMainBundle/Resources/test/Fixtures/App/app/AppKernel.php",
|
|
||||||
"src/Bundle/ChillPersonBundle/Resources/test/Fixtures/App/app/AppKernel.php",
|
|
||||||
"src/Bundle/ChillReportBundle/Resources/test/Fixtures/App/app/AppKernel.php"
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
"extra": {
|
"require": {
|
||||||
"component": {
|
"champs-libres/async-uploader-bundle": "dev-sf4",
|
||||||
"scripts": [
|
"graylog2/gelf-php": "^1.5",
|
||||||
"select2.js"
|
"symfony/form": "4.*",
|
||||||
],
|
"symfony/twig-bundle": "^4.4",
|
||||||
"files": [
|
"twig/extra-bundle": "^2.12|^3.0",
|
||||||
"select2.js",
|
"twig/twig": "^2.12|^3.0",
|
||||||
"select2_locale_*.js",
|
"composer/package-versions-deprecated": "^1.10",
|
||||||
"select2.css",
|
"doctrine/doctrine-bundle": "^2.1",
|
||||||
"select2-bootstrap.css",
|
"doctrine/doctrine-migrations-bundle": "^3.0",
|
||||||
"select2-spinner.gif",
|
"doctrine/orm": "^2.7",
|
||||||
"select2.png",
|
"symfony/asset": "4.*",
|
||||||
"select2x2.png"
|
"symfony/monolog-bundle": "^3.5",
|
||||||
]
|
"symfony/security-bundle": "4.*",
|
||||||
},
|
"symfony/translation": "4.*",
|
||||||
"app-migrations-dir": [
|
"symfony/validator": "4.*",
|
||||||
"Resources/test/Fixtures/App/app/DoctrineMigrations",
|
"sensio/framework-extra-bundle": "^5.5",
|
||||||
"Resources/test/Fixtures/App/DoctrineMigrations"
|
"symfony/yaml": "4.*",
|
||||||
],
|
"symfony/webpack-encore-bundle": "^1.11",
|
||||||
"symfony-app-dir": [
|
"knplabs/knp-menu": "^3.1",
|
||||||
"Tests/Fixtures/App/app",
|
"knplabs/knp-menu-bundle": "^3.0",
|
||||||
"Tests/Fixtures/App/",
|
"symfony/templating": "4.*",
|
||||||
"Test/Fixtures/App/app/"
|
"twig/intl-extra": "^3.0",
|
||||||
]
|
"symfony/workflow": "4.*",
|
||||||
|
"symfony/expression-language": "4.*",
|
||||||
|
"knplabs/knp-time-bundle": "^1.12",
|
||||||
|
"symfony/intl": "4.*",
|
||||||
|
"symfony/swiftmailer-bundle": "^3.5",
|
||||||
|
"league/csv": "^9.6",
|
||||||
|
"phpoffice/phpspreadsheet": "^1.16",
|
||||||
|
"symfony/browser-kit": "^5.2",
|
||||||
|
"symfony/css-selector": "^5.2",
|
||||||
|
"twig/markdown-extra": "^3.3",
|
||||||
|
"erusev/parsedown": "^1.7",
|
||||||
|
"symfony/serializer": "^5.2"
|
||||||
|
},
|
||||||
|
"conflict": {
|
||||||
|
"symfony/symfony": "*"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"fakerphp/faker": "^1.13",
|
||||||
|
"phpunit/phpunit": "^7.0",
|
||||||
|
"symfony/dotenv": "^5.1",
|
||||||
|
"symfony/maker-bundle": "^1.20",
|
||||||
|
"doctrine/doctrine-fixtures-bundle": "^3.3",
|
||||||
|
"symfony/stopwatch": "^5.1",
|
||||||
|
"symfony/web-profiler-bundle": "^5.0",
|
||||||
|
"symfony/var-dumper": "4.*",
|
||||||
|
"symfony/debug-bundle": "^5.1",
|
||||||
|
"symfony/phpunit-bridge": "^5.2"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"merge": "vendor/bin/monorepo-builder merge --ansi",
|
"auto-scripts": {
|
||||||
"propagate": "vendor/bin/monorepo-builder propagate --ansi",
|
"cache:clear": "symfony-cmd",
|
||||||
"validate-monorepo": "vendor/bin/monorepo-builder validate --ansi",
|
"assets:install %PUBLIC_DIR%": "symfony-cmd"
|
||||||
"release": "vendor/bin/monorepo-builder release patch --ansi",
|
}
|
||||||
"localize": "vendor/bin/monorepo-builder localize-composer-paths"
|
|
||||||
},
|
},
|
||||||
"replace": {
|
"config": {
|
||||||
"chill-project/activity": "self.version",
|
"vendor-dir": "tests/app/vendor",
|
||||||
"chill-project/budget": "self.version",
|
"bin-dir": "bin"
|
||||||
"chill-project/chill-doc-store": "self.version",
|
}
|
||||||
"chill-project/custom-fields": "self.version",
|
|
||||||
"chill-project/event": "self.version",
|
|
||||||
"chill-project/family-members": "self.version",
|
|
||||||
"chill-project/main": "self.version",
|
|
||||||
"chill-project/person": "self.version",
|
|
||||||
"chill-project/report": "self.version",
|
|
||||||
"chill-project/task": "self.version",
|
|
||||||
"chill-project/third-party": "self.version",
|
|
||||||
"ivaynberg/select2": "self.version"
|
|
||||||
},
|
|
||||||
"minimum-stability": "dev",
|
|
||||||
"prefer-stable": true
|
|
||||||
}
|
}
|
||||||
|
@@ -13,9 +13,6 @@ API
|
|||||||
|
|
||||||
Chill provides a basic framework to build REST api.
|
Chill provides a basic framework to build REST api.
|
||||||
|
|
||||||
Basic configuration
|
|
||||||
*******************
|
|
||||||
|
|
||||||
Configure a route
|
Configure a route
|
||||||
=================
|
=================
|
||||||
|
|
||||||
@@ -37,7 +34,7 @@ You can also:
|
|||||||
* `How to create your custom normalizer <https://symfony.com/doc/current/serializer/custom_normalizer.html>`_
|
* `How to create your custom normalizer <https://symfony.com/doc/current/serializer/custom_normalizer.html>`_
|
||||||
|
|
||||||
Auto-loading the routes
|
Auto-loading the routes
|
||||||
=======================
|
***********************
|
||||||
|
|
||||||
Ensure that those lines are present in your file `app/config/routing.yml`:
|
Ensure that those lines are present in your file `app/config/routing.yml`:
|
||||||
|
|
||||||
@@ -50,7 +47,7 @@ Ensure that those lines are present in your file `app/config/routing.yml`:
|
|||||||
|
|
||||||
|
|
||||||
Create your model
|
Create your model
|
||||||
=================
|
*****************
|
||||||
|
|
||||||
Create your model on the usual way:
|
Create your model on the usual way:
|
||||||
|
|
||||||
@@ -90,7 +87,7 @@ Create your model on the usual way:
|
|||||||
|
|
||||||
|
|
||||||
Configure api
|
Configure api
|
||||||
=============
|
*************
|
||||||
|
|
||||||
Configure the api using Yaml (see the full configuration: :ref:`api_full_configuration`):
|
Configure the api using Yaml (see the full configuration: :ref:`api_full_configuration`):
|
||||||
|
|
||||||
@@ -174,7 +171,7 @@ Configure the api using Yaml (see the full configuration: :ref:`api_full_configu
|
|||||||
}
|
}
|
||||||
|
|
||||||
The :code:`_index` and :code:`_entity` action
|
The :code:`_index` and :code:`_entity` action
|
||||||
*********************************************
|
=============================================
|
||||||
|
|
||||||
The :code:`_index` and :code:`_entity` action are default actions:
|
The :code:`_index` and :code:`_entity` action are default actions:
|
||||||
|
|
||||||
@@ -192,7 +189,7 @@ Entity:
|
|||||||
Path: :code:`/api/1.0/person/accompanying-period/origin/{id}.{_format}`
|
Path: :code:`/api/1.0/person/accompanying-period/origin/{id}.{_format}`
|
||||||
|
|
||||||
Role
|
Role
|
||||||
****
|
====
|
||||||
|
|
||||||
By default, the key `base_role` is used to check ACL. Take care of creating the :code:`Voter` required to take that into account.
|
By default, the key `base_role` is used to check ACL. Take care of creating the :code:`Voter` required to take that into account.
|
||||||
|
|
||||||
@@ -219,7 +216,7 @@ You can also define a role for each method. In this case, this role is used for
|
|||||||
HEAD: MY ROLE_SEE
|
HEAD: MY ROLE_SEE
|
||||||
|
|
||||||
Customize the controller
|
Customize the controller
|
||||||
************************
|
========================
|
||||||
|
|
||||||
You can customize the controller by hooking into the default actions. Take care of extending :code:`Chill\MainBundle\CRUD\Controller\ApiController`.
|
You can customize the controller by hooking into the default actions. Take care of extending :code:`Chill\MainBundle\CRUD\Controller\ApiController`.
|
||||||
|
|
||||||
@@ -267,7 +264,7 @@ And set your controller in configuration:
|
|||||||
HEAD: true
|
HEAD: true
|
||||||
|
|
||||||
Create your own actions
|
Create your own actions
|
||||||
***********************
|
=======================
|
||||||
|
|
||||||
You can add your own actions:
|
You can add your own actions:
|
||||||
|
|
||||||
@@ -364,297 +361,8 @@ Then, create the corresponding action into your controller:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Managing association
|
|
||||||
********************
|
|
||||||
|
|
||||||
ManyToOne association
|
|
||||||
=====================
|
|
||||||
|
|
||||||
In ManyToOne association, you can add associated entities using the :code:`PATCH` request. By default, the serializer deserialize entities only with their id and discriminator type, if any.
|
|
||||||
|
|
||||||
Example:
|
|
||||||
|
|
||||||
.. code-block:: bash
|
|
||||||
|
|
||||||
curl -X 'PATCH' \
|
|
||||||
'http://localhost:8001/api/1.0/person/accompanying-course/2668.json' \
|
|
||||||
-H 'accept: */*' \
|
|
||||||
-H 'Content-Type: application/json' \
|
|
||||||
# see the data sent to the server: \
|
|
||||||
-d '{
|
|
||||||
"type": "accompanying_period",
|
|
||||||
"id": 2668,
|
|
||||||
"origin": { "id": 11 }
|
|
||||||
}'
|
|
||||||
|
|
||||||
ManyToMany associations
|
|
||||||
=======================
|
|
||||||
|
|
||||||
In OneToMany association, you can easily create route for adding and removing entities, using :code:`POST` and :code:`DELETE` requests.
|
|
||||||
|
|
||||||
Prepare your entity, creating the methods :code:`addYourEntity` and :code:`removeYourEntity`:
|
|
||||||
|
|
||||||
.. code-block:: php
|
|
||||||
|
|
||||||
namespace Chill\PersonBundle\Entity;
|
|
||||||
|
|
||||||
use Chill\MainBundle\Entity\Scope;
|
|
||||||
use Doctrine\Common\Collections\ArrayCollection;
|
|
||||||
use Doctrine\Common\Collections\Collection;
|
|
||||||
use Doctrine\ORM\Mapping as ORM;
|
|
||||||
use Symfony\Component\Serializer\Annotation\Groups;
|
|
||||||
use Symfony\Component\Serializer\Annotation\DiscriminatorMap;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* AccompanyingPeriod Class
|
|
||||||
*
|
|
||||||
* @ORM\Entity
|
|
||||||
* @ORM\Table(name="chill_person_accompanying_period")
|
|
||||||
* @DiscriminatorMap(typeProperty="type", mapping={
|
|
||||||
* "accompanying_period"=AccompanyingPeriod::class
|
|
||||||
* })
|
|
||||||
*/
|
|
||||||
class AccompanyingPeriod
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @var Collection
|
|
||||||
* @ORM\ManyToMany(
|
|
||||||
* targetEntity=Scope::class,
|
|
||||||
* cascade={}
|
|
||||||
* )
|
|
||||||
* @Groups({"read"})
|
|
||||||
*/
|
|
||||||
private $scopes;
|
|
||||||
|
|
||||||
public function addScope(Scope $scope): self
|
|
||||||
{
|
|
||||||
$this->scopes[] = $scope;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function removeScope(Scope $scope): void
|
|
||||||
{
|
|
||||||
$this->scopes->removeElement($scope);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Create your route into the configuration:
|
|
||||||
|
|
||||||
.. code-block:: yaml
|
|
||||||
|
|
||||||
chill_main:
|
|
||||||
apis:
|
|
||||||
-
|
|
||||||
class: Chill\PersonBundle\Entity\AccompanyingPeriod
|
|
||||||
name: accompanying_course
|
|
||||||
base_path: /api/1.0/person/accompanying-course
|
|
||||||
controller: Chill\PersonBundle\Controller\AccompanyingCourseApiController
|
|
||||||
actions:
|
|
||||||
scope:
|
|
||||||
methods:
|
|
||||||
POST: true
|
|
||||||
DELETE: true
|
|
||||||
GET: false
|
|
||||||
HEAD: false
|
|
||||||
PUT: false
|
|
||||||
PATCH: false
|
|
||||||
roles:
|
|
||||||
POST: CHILL_PERSON_ACCOMPANYING_PERIOD_SEE
|
|
||||||
DELETE: CHILL_PERSON_ACCOMPANYING_PERIOD_SEE
|
|
||||||
GET: null
|
|
||||||
HEAD: null
|
|
||||||
PUT: null
|
|
||||||
PATCH: null
|
|
||||||
controller_action: null
|
|
||||||
path: null
|
|
||||||
single-collection: single
|
|
||||||
|
|
||||||
This will create a new route, which will accept two methods: DELETE and POST:
|
|
||||||
|
|
||||||
.. code-block:: raw
|
|
||||||
|
|
||||||
+--------------+---------------------------------------------------------------------------------------+
|
|
||||||
| Property | Value |
|
|
||||||
+--------------+---------------------------------------------------------------------------------------+
|
|
||||||
| Route Name | chill_api_single_accompanying_course_scope |
|
|
||||||
| Path | /api/1.0/person/accompanying-course/{id}/scope.{_format} |
|
|
||||||
| Path Regex | {^/api/1\.0/person/accompanying\-course/(?P<id>[^/]++)/scope\.(?P<_format>[^/]++)$}sD |
|
|
||||||
| Host | ANY |
|
|
||||||
| Host Regex | |
|
|
||||||
| Scheme | ANY |
|
|
||||||
| Method | POST|DELETE |
|
|
||||||
| Requirements | {id}: \d+ |
|
|
||||||
| Class | Symfony\Component\Routing\Route |
|
|
||||||
| Defaults | _controller: csapi_accompanying_course_controller:scopeApi |
|
|
||||||
| Options | compiler_class: Symfony\Component\Routing\RouteCompiler |
|
|
||||||
+--------------+---------------------------------------------------------------------------------------+
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Then, create the controller action. Call the method:
|
|
||||||
|
|
||||||
.. code-block:: php
|
|
||||||
|
|
||||||
namespace Chill\PersonBundle\Controller;
|
|
||||||
|
|
||||||
use Chill\MainBundle\CRUD\Controller\ApiController;
|
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
|
||||||
use Chill\MainBundle\Entity\Scope;
|
|
||||||
|
|
||||||
class MyController extends ApiController
|
|
||||||
{
|
|
||||||
public function scopeApi($id, Request $request, string $_format): Response
|
|
||||||
{
|
|
||||||
return $this->addRemoveSomething('scope', $id, $request, $_format, 'scope', Scope::class, [ 'groups' => [ 'read' ] ]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
This will allow to add a scope by his id, and delete them.
|
|
||||||
|
|
||||||
Curl requests:
|
|
||||||
|
|
||||||
.. code-block:: bash
|
|
||||||
|
|
||||||
# add a scope with id 5
|
|
||||||
curl -X 'POST' \
|
|
||||||
'http://localhost:8001/api/1.0/person/accompanying-course/2868/scope.json' \
|
|
||||||
-H 'accept: */*' \
|
|
||||||
-H 'Content-Type: application/json' \
|
|
||||||
-d '{
|
|
||||||
"type": "scope",
|
|
||||||
"id": 5
|
|
||||||
}'
|
|
||||||
|
|
||||||
# remove a scope with id 5
|
|
||||||
curl -X 'DELETE' \
|
|
||||||
'http://localhost:8001/api/1.0/person/accompanying-course/2868/scope.json' \
|
|
||||||
-H 'accept: */*' \
|
|
||||||
-H 'Content-Type: application/json' \
|
|
||||||
-d '{
|
|
||||||
"id": 5,
|
|
||||||
"type": "scope"
|
|
||||||
}'
|
|
||||||
|
|
||||||
Deserializing an association where multiple types are allowed
|
|
||||||
=============================================================
|
|
||||||
|
|
||||||
Sometimes, multiples types are allowed as association to one entity:
|
|
||||||
|
|
||||||
.. code-block:: php
|
|
||||||
|
|
||||||
namespace Chill\PersonBundle\Entity\AccompanyingPeriod;
|
|
||||||
|
|
||||||
use Chill\PersonBundle\Entity\Person;
|
|
||||||
use Chill\ThirdPartyBundle\Entity\ThirdParty;
|
|
||||||
use Doctrine\ORM\Mapping as ORM;
|
|
||||||
|
|
||||||
class Resource
|
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @ORM\ManyToOne(targetEntity=ThirdParty::class)
|
|
||||||
* @ORM\JoinColumn(nullable=true)
|
|
||||||
*/
|
|
||||||
private $thirdParty;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @ORM\ManyToOne(targetEntity=Person::class)
|
|
||||||
* @ORM\JoinColumn(nullable=true)
|
|
||||||
*/
|
|
||||||
private $person;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param $resource Person|ThirdParty
|
|
||||||
*/
|
|
||||||
public function setResource($resource): self
|
|
||||||
{
|
|
||||||
// ...
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return ThirdParty|Person
|
|
||||||
* @Groups({"read", "write"})
|
|
||||||
*/
|
|
||||||
public function getResource()
|
|
||||||
{
|
|
||||||
return $this->person ?? $this->thirdParty;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
This is not well taken into account by the Symfony serializer natively.
|
|
||||||
|
|
||||||
You must, then, create your own CustomNormalizer. You can help yourself using this:
|
|
||||||
|
|
||||||
.. code-block:: php
|
|
||||||
|
|
||||||
namespace Chill\PersonBundle\Serializer\Normalizer;
|
|
||||||
|
|
||||||
use Chill\PersonBundle\Entity\Person;
|
|
||||||
use Chill\ThirdPartyBundle\Entity\ThirdParty;
|
|
||||||
use Chill\PersonBundle\Entity\AccompanyingPeriod\Resource;
|
|
||||||
use Chill\PersonBundle\Repository\AccompanyingPeriod\ResourceRepository;
|
|
||||||
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
|
|
||||||
use Symfony\Component\Serializer\Normalizer\DenormalizerAwareInterface;
|
|
||||||
use Symfony\Component\Serializer\Normalizer\DenormalizerAwareTrait;
|
|
||||||
use Symfony\Component\Serializer\Normalizer\ObjectToPopulateTrait;
|
|
||||||
use Symfony\Component\Serializer\Exception;
|
|
||||||
use Chill\MainBundle\Serializer\Normalizer\DiscriminatedObjectDenormalizer;
|
|
||||||
|
|
||||||
|
|
||||||
class AccompanyingPeriodResourceNormalizer implements DenormalizerInterface, DenormalizerAwareInterface
|
|
||||||
{
|
|
||||||
use DenormalizerAwareTrait;
|
|
||||||
use ObjectToPopulateTrait;
|
|
||||||
|
|
||||||
public function __construct(ResourceRepository $repository)
|
|
||||||
{
|
|
||||||
$this->repository = $repository;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function denormalize($data, string $type, string $format = null, array $context = [])
|
|
||||||
{
|
|
||||||
// .. snipped for brevity
|
|
||||||
|
|
||||||
if ($resource === NULL) {
|
|
||||||
$resource = new Resource();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (\array_key_exists('resource', $data)) {
|
|
||||||
$res = $this->denormalizer->denormalize(
|
|
||||||
$data['resource'],
|
|
||||||
// call for a "multiple type"
|
|
||||||
DiscriminatedObjectDenormalizer::TYPE,
|
|
||||||
$format,
|
|
||||||
// into the context, we add the list of allowed types:
|
|
||||||
[
|
|
||||||
DiscriminatedObjectDenormalizer::ALLOWED_TYPES =>
|
|
||||||
[
|
|
||||||
Person::class, ThirdParty::class
|
|
||||||
]
|
|
||||||
]
|
|
||||||
);
|
|
||||||
|
|
||||||
$resource->setResource($res);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $resource;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public function supportsDenormalization($data, string $type, string $format = null)
|
|
||||||
{
|
|
||||||
return $type === Resource::class;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Serialization for collection
|
Serialization for collection
|
||||||
****************************
|
============================
|
||||||
|
|
||||||
A specific model has been defined for returning collection:
|
A specific model has been defined for returning collection:
|
||||||
|
|
||||||
@@ -673,9 +381,8 @@ A specific model has been defined for returning collection:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Where this is relevant, this model should be re-used in custom controller actions.
|
|
||||||
|
|
||||||
In custom actions, this can be achieved quickly by assembling results into a :code:`Chill\MainBundle\Serializer\Model\Collection`. The pagination information is given by using :code:`Paginator` (see :ref:`Pagination <pagination-ref>`).
|
This can be achieved quickly by assembling results into a :code:`Chill\MainBundle\Serializer\Model\Collection`. The pagination information is given by using :code:`Paginator` (see :ref:`Pagination <pagination-ref>`).
|
||||||
|
|
||||||
.. code-block:: php
|
.. code-block:: php
|
||||||
|
|
||||||
@@ -693,11 +400,10 @@ In custom actions, this can be achieved quickly by assembling results into a :co
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
.. _api_full_configuration:
|
.. _api_full_configuration:
|
||||||
|
|
||||||
Full configuration example
|
Full configuration example
|
||||||
**************************
|
==========================
|
||||||
|
|
||||||
.. code-block:: yaml
|
.. code-block:: yaml
|
||||||
|
|
||||||
|
@@ -97,7 +97,7 @@ The has the following signature :
|
|||||||
*
|
*
|
||||||
* @param string $context
|
* @param string $context
|
||||||
* @param mixed[] $args the argument to the context.
|
* @param mixed[] $args the argument to the context.
|
||||||
* @return TimelineSingleQuery
|
* @return string[]
|
||||||
* @throw \LogicException if the context is not supported
|
* @throw \LogicException if the context is not supported
|
||||||
*/
|
*/
|
||||||
public function fetchQuery($context, array $args);
|
public function fetchQuery($context, array $args);
|
||||||
@@ -163,16 +163,18 @@ The has the following signature :
|
|||||||
The `fetchQuery` function
|
The `fetchQuery` function
|
||||||
^^^^^^^^^^^^^^^^^^^^^^^^^
|
^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
The fetchQuery function help to build the UNION query to gather events. This function should return an instance of :code:`TimelineSingleQuery`. For you convenience, this object may be build using an associative array with the following keys:
|
The fetchQuery function help to build the UNION query to gather events. This function should return an associative array MUST have the following key :
|
||||||
|
|
||||||
* `id` : the name of the id column
|
* `id` : the name of the id column
|
||||||
* `type`: a string to indicate the type
|
* `type`: a string to indicate the type
|
||||||
* `date`: the name of the datetime column, used to order entities by date
|
* `date`: the name of the datetime column, used to order entities by date
|
||||||
* `FROM`: the FROM clause. May contains JOIN instructions
|
* `FROM` (in capital) : the FROM clause. May contains JOIN instructions
|
||||||
* `WHERE`: the WHERE clause;
|
|
||||||
* `parameters`: the parameters to pass to the query
|
|
||||||
|
|
||||||
The parameters should be replaced into the query by :code:`?`. They will be replaced into the query using prepared statements.
|
Those key are optional:
|
||||||
|
|
||||||
|
* `WHERE` (in capital) : the WHERE clause.
|
||||||
|
|
||||||
|
Where relevant, the data must be quoted to avoid SQL injection.
|
||||||
|
|
||||||
`$context` and `$args` are defined by the bundle which will call the timeline rendering. You may use them to build a different query depending on this context.
|
`$context` and `$args` are defined by the bundle which will call the timeline rendering. You may use them to build a different query depending on this context.
|
||||||
|
|
||||||
@@ -184,15 +186,6 @@ For instance, if the context is `'person'`, the args will be this array :
|
|||||||
'person' => $person //a \Chill\PersonBundle\Entity\Person entity
|
'person' => $person //a \Chill\PersonBundle\Entity\Person entity
|
||||||
);
|
);
|
||||||
|
|
||||||
For the context :code:`center`, the args will be:
|
|
||||||
|
|
||||||
.. code-block:: php
|
|
||||||
|
|
||||||
array(
|
|
||||||
'centers' => [ ] // an array of \Chill\MainBundle\Entity\Center entities
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
You should find in the bundle documentation which contexts are arguments the bundle defines.
|
You should find in the bundle documentation which contexts are arguments the bundle defines.
|
||||||
|
|
||||||
.. note::
|
.. note::
|
||||||
@@ -206,12 +199,13 @@ Example of an implementation :
|
|||||||
namespace Chill\ReportBundle\Timeline;
|
namespace Chill\ReportBundle\Timeline;
|
||||||
|
|
||||||
use Chill\MainBundle\Timeline\TimelineProviderInterface;
|
use Chill\MainBundle\Timeline\TimelineProviderInterface;
|
||||||
use Chill\MainBundle\Timeline\TimelineSingleQuery;
|
|
||||||
use Doctrine\ORM\EntityManager;
|
use Doctrine\ORM\EntityManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provide report for inclusion in timeline
|
* Provide report for inclusion in timeline
|
||||||
*
|
*
|
||||||
|
* @author Julien Fastré <julien.fastre@champs-libres.coop>
|
||||||
|
* @author Champs Libres <info@champs-libres.coop>
|
||||||
*/
|
*/
|
||||||
class TimelineReportProvider implements TimelineProviderInterface
|
class TimelineReportProvider implements TimelineProviderInterface
|
||||||
{
|
{
|
||||||
@@ -233,17 +227,16 @@ Example of an implementation :
|
|||||||
|
|
||||||
$metadata = $this->em->getClassMetadata('ChillReportBundle:Report');
|
$metadata = $this->em->getClassMetadata('ChillReportBundle:Report');
|
||||||
|
|
||||||
return TimelineSingleQuery::fromArray([
|
return array(
|
||||||
'id' => $metadata->getColumnName('id'),
|
'id' => $metadata->getColumnName('id'),
|
||||||
'type' => 'report',
|
'type' => 'report',
|
||||||
'date' => $metadata->getColumnName('date'),
|
'date' => $metadata->getColumnName('date'),
|
||||||
'FROM' => $metadata->getTableName(),
|
'FROM' => $metadata->getTableName(),
|
||||||
'WHERE' => sprintf('%s = ?',
|
'WHERE' => sprintf('%s = %d',
|
||||||
$metadata
|
$metadata
|
||||||
->getAssociationMapping('person')['joinColumns'][0]['name'])
|
->getAssociationMapping('person')['joinColumns'][0]['name'],
|
||||||
)
|
$args['person']->getId())
|
||||||
'parameters' => [ $args['person']->getId() ]
|
);
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//....
|
//....
|
||||||
|
@@ -82,7 +82,7 @@ Chill will be available at ``http://localhost:8001.`` Currently, there isn't any
|
|||||||
|
|
||||||
.. code-block:: bash
|
.. code-block:: bash
|
||||||
|
|
||||||
docker-compose exec --user $(id -u) php bin/console doctrine:fixtures:load --purge-with-truncate
|
docker-compose exec --user $(id -u) php bin/console doctrine:fixtures:load
|
||||||
|
|
||||||
There are several users available:
|
There are several users available:
|
||||||
|
|
||||||
|
@@ -1,45 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
|
||||||
use Symplify\ComposerJsonManipulator\ValueObject\ComposerJsonSection;
|
|
||||||
use Symplify\MonorepoBuilder\Release\ReleaseWorker\PushNextDevReleaseWorker;
|
|
||||||
use Symplify\MonorepoBuilder\Release\ReleaseWorker\PushTagReleaseWorker;
|
|
||||||
use Symplify\MonorepoBuilder\Release\ReleaseWorker\SetCurrentMutualDependenciesReleaseWorker;
|
|
||||||
use Symplify\MonorepoBuilder\Release\ReleaseWorker\SetNextMutualDependenciesReleaseWorker;
|
|
||||||
use Symplify\MonorepoBuilder\Release\ReleaseWorker\TagVersionReleaseWorker;
|
|
||||||
use Symplify\MonorepoBuilder\Release\ReleaseWorker\UpdateBranchAliasReleaseWorker;
|
|
||||||
use Symplify\MonorepoBuilder\Release\ReleaseWorker\UpdateReplaceReleaseWorker;
|
|
||||||
use Symplify\MonorepoBuilder\ValueObject\Option;
|
|
||||||
|
|
||||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
|
||||||
$parameters = $containerConfigurator->parameters();
|
|
||||||
|
|
||||||
// where are the packages located?
|
|
||||||
$parameters->set(Option::PACKAGE_DIRECTORIES, [
|
|
||||||
// default value
|
|
||||||
__DIR__ . '/src/Bundle',
|
|
||||||
]);
|
|
||||||
|
|
||||||
// for "merge" command
|
|
||||||
$parameters->set(
|
|
||||||
Option::DATA_TO_APPEND,
|
|
||||||
[
|
|
||||||
ComposerJsonSection::REQUIRE_DEV => [
|
|
||||||
'phpunit/phpunit' => '^9.5',
|
|
||||||
],
|
|
||||||
]
|
|
||||||
);
|
|
||||||
|
|
||||||
$services = $containerConfigurator->services();
|
|
||||||
|
|
||||||
# release workers - in order to execute
|
|
||||||
$services->set(UpdateReplaceReleaseWorker::class);
|
|
||||||
$services->set(SetCurrentMutualDependenciesReleaseWorker::class);
|
|
||||||
$services->set(TagVersionReleaseWorker::class);
|
|
||||||
$services->set(PushTagReleaseWorker::class);
|
|
||||||
$services->set(SetNextMutualDependenciesReleaseWorker::class);
|
|
||||||
$services->set(UpdateBranchAliasReleaseWorker::class);
|
|
||||||
$services->set(PushNextDevReleaseWorker::class);
|
|
||||||
};
|
|
@@ -18,20 +18,12 @@
|
|||||||
<testsuite name="MainBundle">
|
<testsuite name="MainBundle">
|
||||||
<directory suffix="Test.php">src/Bundle/ChillMainBundle/Tests/</directory>
|
<directory suffix="Test.php">src/Bundle/ChillMainBundle/Tests/</directory>
|
||||||
</testsuite>
|
</testsuite>
|
||||||
|
<!--
|
||||||
<testsuite name="PersonBundle">
|
<testsuite name="PersonBundle">
|
||||||
<directory suffix="Test.php">src/Bundle/ChillPersonBundle/Tests/</directory>
|
<directory suffix="Test.php">src/Bundle/ChillPersonBundle/Tests/</directory>
|
||||||
<!-- test for export will be runned later -->
|
|
||||||
<exclude>src/Bundle/ChillPersonBundle/Tests/Export/*</exclude>
|
|
||||||
<!-- we are rewriting accompanying periods... Work in progress -->
|
|
||||||
<exclude>src/Bundle/ChillPersonBundle/Tests/Controller/AccompanyingPeriodControllerTest.php</exclude>
|
|
||||||
<!-- we are rewriting address, Work in progress -->
|
|
||||||
<exclude>src/Bundle/ChillPersonBundle/Tests/Controller/PersonAddressControllerTest.php</exclude>
|
|
||||||
<!-- find a solution to create multiple configs -->
|
|
||||||
<exclude>src/Bundle/ChillPersonBundle/Tests/Controller/PersonControllerUpdateWithHiddenFieldsTest.php</exclude>
|
|
||||||
<!-- temporarily removed, the time to find a fix -->
|
|
||||||
<exclude>src/Bundle/ChillPersonBundle/Tests/Controller/PersonDuplicateControllerViewTest.php</exclude>
|
|
||||||
</testsuite>
|
</testsuite>
|
||||||
</testsuites>
|
-->
|
||||||
|
</testsuites>
|
||||||
|
|
||||||
<listeners>
|
<listeners>
|
||||||
<listener class="Symfony\Bridge\PhpUnit\SymfonyTestsListener" />
|
<listener class="Symfony\Bridge\PhpUnit\SymfonyTestsListener" />
|
||||||
|
@@ -52,6 +52,7 @@ class ChillActivityExtension extends Extension implements PrependExtensionInterf
|
|||||||
$loader->load('services/export.yaml');
|
$loader->load('services/export.yaml');
|
||||||
$loader->load('services/repositories.yaml');
|
$loader->load('services/repositories.yaml');
|
||||||
$loader->load('services/fixtures.yaml');
|
$loader->load('services/fixtures.yaml');
|
||||||
|
$loader->load('services/menu.yaml');
|
||||||
$loader->load('services/controller.yaml');
|
$loader->load('services/controller.yaml');
|
||||||
$loader->load('services/form.yaml');
|
$loader->load('services/form.yaml');
|
||||||
$loader->load('services/templating.yaml');
|
$loader->load('services/templating.yaml');
|
||||||
|
@@ -38,7 +38,7 @@ use Chill\MainBundle\Validator\Constraints\Entity\UserCircleConsistency;
|
|||||||
* Class Activity
|
* Class Activity
|
||||||
*
|
*
|
||||||
* @package Chill\ActivityBundle\Entity
|
* @package Chill\ActivityBundle\Entity
|
||||||
* @ORM\Entity(repositoryClass="Chill\ActivityBundle\Repository\ActivityRepository")
|
* @ORM\Entity()
|
||||||
* @ORM\Table(name="activity")
|
* @ORM\Table(name="activity")
|
||||||
* @ORM\HasLifecycleCallbacks()
|
* @ORM\HasLifecycleCallbacks()
|
||||||
* @UserCircleConsistency(
|
* @UserCircleConsistency(
|
||||||
|
@@ -1,169 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Chill is a software for social workers
|
|
||||||
*
|
|
||||||
* Copyright (C) 2021, Champs Libres Cooperative SCRLFS,
|
|
||||||
* <http://www.champs-libres.coop>, <info@champs-libres.coop>
|
|
||||||
*
|
|
||||||
* 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 <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Chill\ActivityBundle\Repository;
|
|
||||||
|
|
||||||
use Chill\ActivityBundle\Entity\Activity;
|
|
||||||
use Chill\PersonBundle\Entity\Person;
|
|
||||||
use Chill\ActivityBundle\Repository\ActivityRepository;
|
|
||||||
use Chill\ActivityBundle\Security\Authorization\ActivityVoter;
|
|
||||||
use Chill\MainBundle\Entity\Scope;
|
|
||||||
use Doctrine\ORM\QueryBuilder;
|
|
||||||
use Doctrine\ORM\Query\Expr\Orx;
|
|
||||||
use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
|
|
||||||
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
|
|
||||||
use Symfony\Component\Security\Core\Role\Role;
|
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
|
||||||
|
|
||||||
|
|
||||||
final class ActivityACLAwareRepository
|
|
||||||
{
|
|
||||||
private AuthorizationHelper $authorizationHelper;
|
|
||||||
|
|
||||||
private TokenStorageInterface $tokenStorage;
|
|
||||||
|
|
||||||
private ActivityRepository $repository;
|
|
||||||
|
|
||||||
private EntityManagerInterface $em;
|
|
||||||
|
|
||||||
public function __construct(
|
|
||||||
AuthorizationHelper $authorizationHelper,
|
|
||||||
TokenStorageInterface $tokenStorage,
|
|
||||||
ActivityRepository $repository,
|
|
||||||
EntityManagerInterface $em
|
|
||||||
) {
|
|
||||||
$this->authorizationHelper = $authorizationHelper;
|
|
||||||
$this->tokenStorage = $tokenStorage;
|
|
||||||
$this->repository = $repository;
|
|
||||||
$this->em = $em;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function queryTimelineIndexer(string $context, array $args = []): array
|
|
||||||
{
|
|
||||||
$metadataActivity = $this->em->getClassMetadata(Activity::class);
|
|
||||||
|
|
||||||
$from = $this->getFromClauseCenter($args);
|
|
||||||
[$where, $parameters] = $this->getWhereClause($context, $args);
|
|
||||||
|
|
||||||
return [
|
|
||||||
'id' => $metadataActivity->getTableName()
|
|
||||||
.'.'.$metadataActivity->getColumnName('id'),
|
|
||||||
'type' => 'activity',
|
|
||||||
'date' => $metadataActivity->getTableName()
|
|
||||||
.'.'.$metadataActivity->getColumnName('date'),
|
|
||||||
'FROM' => $from,
|
|
||||||
'WHERE' => $where,
|
|
||||||
'parameters' => $parameters
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
private function getFromClauseCenter(array $args): string
|
|
||||||
{
|
|
||||||
$metadataActivity = $this->em->getClassMetadata(Activity::class);
|
|
||||||
$metadataPerson = $this->em->getClassMetadata(Person::class);
|
|
||||||
$associationMapping = $metadataActivity->getAssociationMapping('person');
|
|
||||||
|
|
||||||
return $metadataActivity->getTableName().' JOIN '
|
|
||||||
.$metadataPerson->getTableName().' ON '
|
|
||||||
.$metadataPerson->getTableName().'.'.
|
|
||||||
$associationMapping['joinColumns'][0]['referencedColumnName']
|
|
||||||
.' = '
|
|
||||||
.$associationMapping['joinColumns'][0]['name']
|
|
||||||
;
|
|
||||||
}
|
|
||||||
|
|
||||||
private function getWhereClause(string $context, array $args): array
|
|
||||||
{
|
|
||||||
$where = '';
|
|
||||||
$parameters = [];
|
|
||||||
|
|
||||||
$metadataActivity = $this->em->getClassMetadata(Activity::class);
|
|
||||||
$metadataPerson = $this->em->getClassMetadata(Person::class);
|
|
||||||
$activityToPerson = $metadataActivity->getAssociationMapping('person')['joinColumns'][0]['name'];
|
|
||||||
$activityToScope = $metadataActivity->getAssociationMapping('scope')['joinColumns'][0]['name'];
|
|
||||||
$personToCenter = $metadataPerson->getAssociationMapping('center')['joinColumns'][0]['name'];
|
|
||||||
|
|
||||||
|
|
||||||
// acls:
|
|
||||||
$role = new Role(ActivityVoter::SEE);
|
|
||||||
$reachableCenters = $this->authorizationHelper->getReachableCenters($this->tokenStorage->getToken()->getUser(),
|
|
||||||
$role);
|
|
||||||
|
|
||||||
if (count($reachableCenters) === 0) {
|
|
||||||
// insert a dummy condition
|
|
||||||
return 'FALSE = TRUE';
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($context === 'person') {
|
|
||||||
// we start with activities having the person_id linked to person
|
|
||||||
$where .= sprintf('%s = ? AND ', $activityToPerson);
|
|
||||||
$parameters[] = $person->getId();
|
|
||||||
}
|
|
||||||
|
|
||||||
// we add acl (reachable center and scopes)
|
|
||||||
$where .= '('; // first loop for the for centers
|
|
||||||
$centersI = 0; // like centers#i
|
|
||||||
foreach ($reachableCenters as $center) {
|
|
||||||
// we pass if not in centers
|
|
||||||
if (!\in_array($center, $args['centers'])) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
// we get all the reachable scopes for this center
|
|
||||||
$reachableScopes = $this->authorizationHelper->getReachableScopes($this->tokenStorage->getToken()->getUser(), $role, $center);
|
|
||||||
// we get the ids for those scopes
|
|
||||||
$reachablesScopesId = array_map(
|
|
||||||
function(Scope $scope) { return $scope->getId(); },
|
|
||||||
$reachableScopes
|
|
||||||
);
|
|
||||||
|
|
||||||
// if not the first center
|
|
||||||
if ($centersI > 0) {
|
|
||||||
$where .= ') OR (';
|
|
||||||
}
|
|
||||||
|
|
||||||
// condition for the center
|
|
||||||
$where .= sprintf(' %s.%s = ? ', $metadataPerson->getTableName(), $personToCenter);
|
|
||||||
$parameters[] = $center->getId();
|
|
||||||
|
|
||||||
// begin loop for scopes
|
|
||||||
$where .= ' AND (';
|
|
||||||
$scopesI = 0; //like scope#i
|
|
||||||
|
|
||||||
foreach ($reachablesScopesId as $scopeId) {
|
|
||||||
if ($scopesI > 0) {
|
|
||||||
$where .= ' OR ';
|
|
||||||
}
|
|
||||||
$where .= sprintf(' %s.%s = ? ', $metadataActivity->getTableName(), $activityToScope);
|
|
||||||
$parameters[] = $scopeId;
|
|
||||||
$scopesI ++;
|
|
||||||
}
|
|
||||||
// close loop for scopes
|
|
||||||
$where .= ') ';
|
|
||||||
$centersI++;
|
|
||||||
}
|
|
||||||
// close loop for centers
|
|
||||||
$where .= ')';
|
|
||||||
|
|
||||||
return [$where, $parameters];
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@@ -1,42 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Chill is a software for social workers
|
|
||||||
*
|
|
||||||
* Copyright (C) 2021, Champs Libres Cooperative SCRLFS,
|
|
||||||
* <http://www.champs-libres.coop>, <info@champs-libres.coop>
|
|
||||||
*
|
|
||||||
* 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 <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Chill\ActivityBundle\Repository;
|
|
||||||
|
|
||||||
use Chill\ActivityBundle\Entity\Activity;
|
|
||||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
|
||||||
use Doctrine\Persistence\ManagerRegistry;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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)
|
|
||||||
*/
|
|
||||||
class ActivityRepository extends ServiceEntityRepository
|
|
||||||
{
|
|
||||||
public function __construct(ManagerRegistry $registry)
|
|
||||||
{
|
|
||||||
parent::__construct($registry, Activity::class);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@@ -1,11 +1,11 @@
|
|||||||
{% import 'ChillActivityBundle:ActivityReason:macro.html.twig' as m %}
|
{% import 'ChillActivityBundle:ActivityReason:macro.html.twig' as m %}
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<h3>{{ activity.date|format_date('long') }}<span class="activity"> / {{ 'Activity'|trans }}</span>{% if 'person' != context %} / {{ activity.person|chill_entity_render_box({'addLink': true}) }}{% endif %}</h3>
|
<h3>{{ activity.date|format_date('long') }}<span class="activity"> / {{ 'Activity'|trans }}</span></h3>
|
||||||
<div class="statement">
|
<div class="statement">
|
||||||
<span class="statement">{{ '%user% has done an %activity_type%'|trans(
|
<span class="statement">{{ '%user% has done an %activity_type%'|trans(
|
||||||
{
|
{
|
||||||
'%user%' : activity.user,
|
'%user%' : user,
|
||||||
'%activity_type%': activity.type.name|localize_translatable_string,
|
'%activity_type%': activity.type.name|localize_translatable_string,
|
||||||
'%date%' : activity.date|format_date('long') }
|
'%date%' : activity.date|format_date('long') }
|
||||||
) }}</span>
|
) }}</span>
|
||||||
@@ -29,13 +29,13 @@
|
|||||||
|
|
||||||
<ul class="record_actions">
|
<ul class="record_actions">
|
||||||
<li>
|
<li>
|
||||||
<a href="{{ path('chill_activity_activity_show', { 'person_id': activity.person.id, 'id': activity.id} ) }}" class="sc-button bt-view">
|
<a href="{{ path('chill_activity_activity_show', { 'person_id': person.id, 'id': activity.id} ) }}" class="sc-button bt-view">
|
||||||
{{ 'Show the activity'|trans }}
|
{{ 'Show the activity'|trans }}
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
{% if is_granted('CHILL_ACTIVITY_UPDATE', activity) %}
|
{% if is_granted('CHILL_ACTIVITY_UPDATE', activity) %}
|
||||||
<li>
|
<li>
|
||||||
<a href="{{ path('chill_activity_activity_edit', { 'person_id': activity.person.id, 'id': activity.id} ) }}" class="sc-button bt-edit">
|
<a href="{{ path('chill_activity_activity_edit', { 'person_id': person.id, 'id': activity.id} ) }}" class="sc-button bt-edit">
|
||||||
{{ 'Edit the activity'|trans }}
|
{{ 'Edit the activity'|trans }}
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
@@ -21,7 +21,6 @@
|
|||||||
namespace Chill\ActivityBundle\Timeline;
|
namespace Chill\ActivityBundle\Timeline;
|
||||||
|
|
||||||
use Chill\MainBundle\Timeline\TimelineProviderInterface;
|
use Chill\MainBundle\Timeline\TimelineProviderInterface;
|
||||||
use Chill\ActivityBundle\Repository\ActivityACLAwareRepository;
|
|
||||||
use Doctrine\ORM\EntityManager;
|
use Doctrine\ORM\EntityManager;
|
||||||
use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
|
use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
|
||||||
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
|
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
|
||||||
@@ -29,13 +28,13 @@ use Symfony\Component\Security\Core\Role\Role;
|
|||||||
use Doctrine\ORM\Mapping\ClassMetadata;
|
use Doctrine\ORM\Mapping\ClassMetadata;
|
||||||
use Chill\PersonBundle\Entity\Person;
|
use Chill\PersonBundle\Entity\Person;
|
||||||
use Chill\MainBundle\Entity\Scope;
|
use Chill\MainBundle\Entity\Scope;
|
||||||
use Chill\ActivityBundle\Entity\Activity;
|
|
||||||
use Chill\MainBundle\Timeline\TimelineSingleQuery;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provide activity for inclusion in timeline
|
* Provide activity for inclusion in timeline
|
||||||
*
|
*
|
||||||
*/
|
* @author Julien Fastré <julien.fastre@champs-libres.coop>
|
||||||
|
* @author Champs Libres <info@champs-libres.coop>
|
||||||
|
*/
|
||||||
class TimelineActivityProvider implements TimelineProviderInterface
|
class TimelineActivityProvider implements TimelineProviderInterface
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -56,10 +55,6 @@ class TimelineActivityProvider implements TimelineProviderInterface
|
|||||||
* @var \Chill\MainBundle\Entity\User
|
* @var \Chill\MainBundle\Entity\User
|
||||||
*/
|
*/
|
||||||
protected $user;
|
protected $user;
|
||||||
|
|
||||||
protected ActivityACLAwareRepository $aclAwareRepository;
|
|
||||||
|
|
||||||
private const SUPPORTED_CONTEXTS = [ 'center', 'person'];
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TimelineActivityProvider constructor.
|
* TimelineActivityProvider constructor.
|
||||||
@@ -71,13 +66,11 @@ class TimelineActivityProvider implements TimelineProviderInterface
|
|||||||
public function __construct(
|
public function __construct(
|
||||||
EntityManager $em,
|
EntityManager $em,
|
||||||
AuthorizationHelper $helper,
|
AuthorizationHelper $helper,
|
||||||
TokenStorageInterface $storage,
|
TokenStorageInterface $storage
|
||||||
ActivityACLAwareRepository $aclAwareRepository
|
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
$this->em = $em;
|
$this->em = $em;
|
||||||
$this->helper = $helper;
|
$this->helper = $helper;
|
||||||
$this->aclAwareRepository = $aclAwareRepository;
|
|
||||||
|
|
||||||
if (!$storage->getToken()->getUser() instanceof \Chill\MainBundle\Entity\User)
|
if (!$storage->getToken()->getUser() instanceof \Chill\MainBundle\Entity\User)
|
||||||
{
|
{
|
||||||
@@ -93,69 +86,67 @@ class TimelineActivityProvider implements TimelineProviderInterface
|
|||||||
*/
|
*/
|
||||||
public function fetchQuery($context, array $args)
|
public function fetchQuery($context, array $args)
|
||||||
{
|
{
|
||||||
if ('center' === $context) {
|
$this->checkContext($context);
|
||||||
return TimelineSingleQuery::fromArray($this->aclAwareRepository
|
|
||||||
->queryTimelineIndexer($context, $args));
|
|
||||||
}
|
|
||||||
|
|
||||||
$metadataActivity = $this->em->getClassMetadata(Activity::class);
|
$metadataActivity = $this->em->getClassMetadata('ChillActivityBundle:Activity');
|
||||||
|
$metadataPerson = $this->em->getClassMetadata('ChillPersonBundle:Person');
|
||||||
[$where, $parameters] = $this->getWhereClauseForPerson($args['person']);
|
|
||||||
|
|
||||||
return TimelineSingleQuery::fromArray([
|
return array(
|
||||||
'id' => $metadataActivity->getTableName()
|
'id' => $metadataActivity->getTableName()
|
||||||
.'.'.$metadataActivity->getColumnName('id'),
|
.'.'.$metadataActivity->getColumnName('id'),
|
||||||
'type' => 'activity',
|
'type' => 'activity',
|
||||||
'date' => $metadataActivity->getTableName()
|
'date' => $metadataActivity->getTableName()
|
||||||
.'.'.$metadataActivity->getColumnName('date'),
|
.'.'.$metadataActivity->getColumnName('date'),
|
||||||
'FROM' => $this->getFromClausePerson($args['person']),
|
'FROM' => $this->getFromClause($metadataActivity, $metadataPerson),
|
||||||
'WHERE' => $where,
|
'WHERE' => $this->getWhereClause($metadataActivity, $metadataPerson,
|
||||||
'parameters' => $parameters
|
$args['person'])
|
||||||
]);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getWhereClauseForPerson(Person $person)
|
private function getWhereClause(ClassMetadata $metadataActivity,
|
||||||
|
ClassMetadata $metadataPerson, Person $person)
|
||||||
{
|
{
|
||||||
$parameters = [];
|
|
||||||
$metadataActivity = $this->em->getClassMetadata(Activity::class);
|
|
||||||
$associationMapping = $metadataActivity->getAssociationMapping('person');
|
|
||||||
$role = new Role('CHILL_ACTIVITY_SEE');
|
$role = new Role('CHILL_ACTIVITY_SEE');
|
||||||
$reachableScopes = $this->helper->getReachableScopes($this->user,
|
$reachableCenters = $this->helper->getReachableCenters($this->user,
|
||||||
$role, $person->getCenter());
|
$role);
|
||||||
$whereClause = sprintf(' {activity.person_id} = ? AND {activity.scope_id} IN ({scopes_ids}) ');
|
$associationMapping = $metadataActivity->getAssociationMapping('person');
|
||||||
$scopes_ids = [];
|
|
||||||
|
if (count($reachableCenters) === 0) {
|
||||||
// first parameter: activity.person_id
|
return 'FALSE = TRUE';
|
||||||
$parameters[] = $person->getId();
|
|
||||||
|
|
||||||
// loop on reachable scopes
|
|
||||||
foreach ($reachableScopes as $scope) {
|
|
||||||
if (\in_array($scope->getId(), $scopes_ids)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
$scopes_ids[] = '?';
|
|
||||||
$parameters[] = $scope->getId();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return [
|
// we start with activities having the person_id linked to person
|
||||||
\strtr(
|
// (currently only context "person" is supported)
|
||||||
$whereClause,
|
$whereClause = sprintf('%s = %d',
|
||||||
[
|
$associationMapping['joinColumns'][0]['name'],
|
||||||
'{activity.person_id}' => $associationMapping['joinColumns'][0]['name'],
|
$person->getId());
|
||||||
'{activity.scope_id}' => $metadataActivity->getTableName().'.'.
|
|
||||||
|
// we add acl (reachable center and scopes)
|
||||||
|
$centerAndScopeLines = array();
|
||||||
|
foreach ($reachableCenters as $center) {
|
||||||
|
$reachablesScopesId = array_map(
|
||||||
|
function(Scope $scope) { return $scope->getId(); },
|
||||||
|
$this->helper->getReachableScopes($this->user, $role,
|
||||||
|
$person->getCenter())
|
||||||
|
);
|
||||||
|
|
||||||
|
$centerAndScopeLines[] = sprintf('(%s = %d AND %s IN (%s))',
|
||||||
|
$metadataPerson->getTableName().'.'.
|
||||||
|
$metadataPerson->getAssociationMapping('center')['joinColumns'][0]['name'],
|
||||||
|
$center->getId(),
|
||||||
|
$metadataActivity->getTableName().'.'.
|
||||||
$metadataActivity->getAssociationMapping('scope')['joinColumns'][0]['name'],
|
$metadataActivity->getAssociationMapping('scope')['joinColumns'][0]['name'],
|
||||||
'{scopes_ids}' => \implode(", ", $scopes_ids)
|
implode(',', $reachablesScopesId));
|
||||||
,
|
|
||||||
]
|
}
|
||||||
),
|
$whereClause .= ' AND ('.implode(' OR ', $centerAndScopeLines).')';
|
||||||
$parameters
|
|
||||||
];
|
return $whereClause;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getFromClausePerson()
|
private function getFromClause(ClassMetadata $metadataActivity,
|
||||||
|
ClassMetadata $metadataPerson)
|
||||||
{
|
{
|
||||||
$metadataActivity = $this->em->getClassMetadata(Activity::class);
|
|
||||||
$metadataPerson = $this->em->getClassMetadata(Person::class);
|
|
||||||
$associationMapping = $metadataActivity->getAssociationMapping('person');
|
$associationMapping = $metadataActivity->getAssociationMapping('person');
|
||||||
|
|
||||||
return $metadataActivity->getTableName().' JOIN '
|
return $metadataActivity->getTableName().' JOIN '
|
||||||
@@ -166,14 +157,14 @@ class TimelineActivityProvider implements TimelineProviderInterface
|
|||||||
.$associationMapping['joinColumns'][0]['name']
|
.$associationMapping['joinColumns'][0]['name']
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function getEntities(array $ids)
|
public function getEntities(array $ids)
|
||||||
{
|
{
|
||||||
$activities = $this->em->getRepository(Activity::class)
|
$activities = $this->em->getRepository('ChillActivityBundle:Activity')
|
||||||
->findBy(array('id' => $ids));
|
->findBy(array('id' => $ids));
|
||||||
|
|
||||||
$result = array();
|
$result = array();
|
||||||
@@ -192,13 +183,14 @@ class TimelineActivityProvider implements TimelineProviderInterface
|
|||||||
{
|
{
|
||||||
$this->checkContext($context);
|
$this->checkContext($context);
|
||||||
|
|
||||||
return [
|
return array(
|
||||||
'template' => 'ChillActivityBundle:Timeline:activity_person_context.html.twig',
|
'template' => 'ChillActivityBundle:Timeline:activity_person_context.html.twig',
|
||||||
'template_data' => [
|
'template_data' => array(
|
||||||
'activity' => $entity,
|
'activity' => $entity,
|
||||||
'context' => $context
|
'person' => $args['person'],
|
||||||
]
|
'user' => $entity->getUser()
|
||||||
];
|
)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -218,7 +210,7 @@ class TimelineActivityProvider implements TimelineProviderInterface
|
|||||||
*/
|
*/
|
||||||
private function checkContext($context)
|
private function checkContext($context)
|
||||||
{
|
{
|
||||||
if (FALSE === \in_array($context, self::SUPPORTED_CONTEXTS)) {
|
if ($context !== 'person') {
|
||||||
throw new \LogicException("The context '$context' is not "
|
throw new \LogicException("The context '$context' is not "
|
||||||
. "supported. Currently only 'person' is supported");
|
. "supported. Currently only 'person' is supported");
|
||||||
}
|
}
|
||||||
|
@@ -3,17 +3,13 @@
|
|||||||
"description": "This bundle extend chill for recording the different activities of the user",
|
"description": "This bundle extend chill for recording the different activities of the user",
|
||||||
"type": "symfony-bundle",
|
"type": "symfony-bundle",
|
||||||
"license": "AGPL-3.0",
|
"license": "AGPL-3.0",
|
||||||
"keywords": ["chill", "social work"],
|
"keywords" : ["chill", "social work"],
|
||||||
"homepage": "https://github.com/Chill-project/Activity",
|
"homepage" : "https://github.com/Chill-project/Activity",
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-4": {
|
"psr-4": { "Chill\\ActivityBundle\\": "" }
|
||||||
"Chill\\ActivityBundle\\": ""
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
"autoload-dev": {
|
"autoload-dev": {
|
||||||
"classmap": [
|
"classmap": [ "Resources/test/Fixtures/App/app/AppKernel.php" ]
|
||||||
"Resources/test/Fixtures/App/app/AppKernel.php"
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
"authors": [
|
"authors": [
|
||||||
{
|
{
|
||||||
@@ -21,6 +17,10 @@
|
|||||||
"email": "info@champs-libres.coop"
|
"email": "info@champs-libres.coop"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
"require": {
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"post-install-cmd": [
|
"post-install-cmd": [
|
||||||
"ComposerBundleMigration\\Composer\\Migrations::synchronizeMigrations",
|
"ComposerBundleMigration\\Composer\\Migrations::synchronizeMigrations",
|
||||||
|
@@ -22,14 +22,6 @@ services:
|
|||||||
- '@doctrine.orm.entity_manager'
|
- '@doctrine.orm.entity_manager'
|
||||||
- '@chill.main.security.authorization.helper'
|
- '@chill.main.security.authorization.helper'
|
||||||
- '@security.token_storage'
|
- '@security.token_storage'
|
||||||
- '@Chill\ActivityBundle\Repository\ActivityACLAwareRepository'
|
|
||||||
public: true
|
public: true
|
||||||
tags:
|
tags:
|
||||||
- { name: chill.timeline, context: 'person' }
|
- { name: chill.timeline, context: 'person' }
|
||||||
- { name: chill.timeline, context: 'center' }
|
|
||||||
|
|
||||||
Chill\ActivityBundle\Menu\:
|
|
||||||
autowire: true
|
|
||||||
autoconfigure: true
|
|
||||||
resource: '../Menu/'
|
|
||||||
tags: ['chill.menu_builder']
|
|
||||||
|
8
src/Bundle/ChillActivityBundle/config/services/menu.yaml
Normal file
8
src/Bundle/ChillActivityBundle/config/services/menu.yaml
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
services:
|
||||||
|
Chill\ActivityBundle\Menu\MenuBuilder:
|
||||||
|
arguments:
|
||||||
|
$authorizationHelper: '@Chill\MainBundle\Security\Authorization\AuthorizationHelper'
|
||||||
|
$tokenStorage: '@Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface'
|
||||||
|
$translator: '@Symfony\Component\Translation\TranslatorInterface'
|
||||||
|
tags:
|
||||||
|
- { name: 'chill.menu_builder' }
|
@@ -1,32 +1,18 @@
|
|||||||
---
|
|
||||||
services:
|
services:
|
||||||
chill_activity.repository.activity_type:
|
chill_activity.repository.activity_type:
|
||||||
class: Doctrine\ORM\EntityRepository
|
class: Doctrine\ORM\EntityRepository
|
||||||
factory: ['@doctrine.orm.entity_manager', getRepository]
|
factory: ['@doctrine.orm.entity_manager', getRepository]
|
||||||
arguments:
|
arguments:
|
||||||
- 'Chill\ActivityBundle\Entity\ActivityType'
|
- 'Chill\ActivityBundle\Entity\ActivityType'
|
||||||
|
|
||||||
chill_activity.repository.reason:
|
chill_activity.repository.reason:
|
||||||
class: Doctrine\ORM\EntityRepository
|
class: Doctrine\ORM\EntityRepository
|
||||||
factory: ['@doctrine.orm.entity_manager', getRepository]
|
factory: ['@doctrine.orm.entity_manager', getRepository]
|
||||||
arguments:
|
arguments:
|
||||||
- 'Chill\ActivityBundle\Entity\ActivityReason'
|
- 'Chill\ActivityBundle\Entity\ActivityReason'
|
||||||
|
|
||||||
chill_activity.repository.reason_category:
|
chill_activity.repository.reason_category:
|
||||||
class: Doctrine\ORM\EntityRepository
|
class: Doctrine\ORM\EntityRepository
|
||||||
factory: ['@doctrine.orm.entity_manager', getRepository]
|
factory: ['@doctrine.orm.entity_manager', getRepository]
|
||||||
arguments:
|
arguments:
|
||||||
- 'Chill\ActivityBundle\Entity\ActivityReasonCategory'
|
- 'Chill\ActivityBundle\Entity\ActivityReasonCategory'
|
||||||
|
|
||||||
Chill\ActivityBundle\Repository\ActivityRepository:
|
|
||||||
tags: [doctrine.repository_service]
|
|
||||||
arguments:
|
|
||||||
- '@Doctrine\Persistence\ManagerRegistry'
|
|
||||||
|
|
||||||
Chill\ActivityBundle\Repository\ActivityACLAwareRepository:
|
|
||||||
arguments:
|
|
||||||
$tokenStorage: '@Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface'
|
|
||||||
$authorizationHelper: '@Chill\MainBundle\Security\Authorization\AuthorizationHelper'
|
|
||||||
$repository: '@Chill\ActivityBundle\Repository\ActivityRepository'
|
|
||||||
$em: '@Doctrine\ORM\EntityManagerInterface'
|
|
||||||
|
|
||||||
|
@@ -3,12 +3,13 @@
|
|||||||
"description": "This bundle extend chill for recording element of a budget for peoples",
|
"description": "This bundle extend chill for recording element of a budget for peoples",
|
||||||
"type": "symfony-bundle",
|
"type": "symfony-bundle",
|
||||||
"license": "AGPL-3.0",
|
"license": "AGPL-3.0",
|
||||||
"keywords": ["chill", "social work"],
|
"keywords" : ["chill", "social work"],
|
||||||
"homepage": "https://framagit.org/Chill-project/BudgetBundle",
|
"homepage" : "https://framagit.org/Chill-project/BudgetBundle",
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-4": {
|
"psr-4": { "Chill\\AMLI\\BudgetBundle\\": "" }
|
||||||
"Chill\\AMLI\\BudgetBundle\\": ""
|
},
|
||||||
}
|
"autoload-dev": {
|
||||||
|
"classmap": [ "Resources/test/Fixtures/App/app/AppKernel.php" ]
|
||||||
},
|
},
|
||||||
"authors": [
|
"authors": [
|
||||||
{
|
{
|
||||||
@@ -16,8 +17,13 @@
|
|||||||
"email": "info@champs-libres.coop"
|
"email": "info@champs-libres.coop"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
"require": {
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
},
|
||||||
"extra": {
|
"extra": {
|
||||||
"app-migrations-dir": "Resources/test/Fixtures/App/app/DoctrineMigrations"
|
"app-migrations-dir": "Resources/test/Fixtures/App/app/DoctrineMigrations",
|
||||||
|
"symfony-app-dir": "Test/Fixtures/App/app/"
|
||||||
},
|
},
|
||||||
"minimum-stability": "dev",
|
"minimum-stability": "dev",
|
||||||
"prefer-stable": true
|
"prefer-stable": true
|
||||||
|
@@ -3,25 +3,25 @@
|
|||||||
"license": "AGPL-3.0",
|
"license": "AGPL-3.0",
|
||||||
"type": "symfony-bundle",
|
"type": "symfony-bundle",
|
||||||
"description": "This bundle allow to add custom fields on entities.",
|
"description": "This bundle allow to add custom fields on entities.",
|
||||||
"keywords": ["chill", "social work"],
|
"keywords" : ["chill", "social work"],
|
||||||
"homepage": "https://github.com/Chill-project/CustomFields",
|
"homepage" : "https://github.com/Chill-project/CustomFields",
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-4": {
|
"psr-4": { "Chill\\CustomFieldsBundle\\": "" }
|
||||||
"Chill\\CustomFieldsBundle\\": ""
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
"autoload-dev": {
|
"autoload-dev": {
|
||||||
"classmap": [
|
"classmap": [ "Resources/test/Fixtures/App/app/AppKernel.php" ]
|
||||||
"Resources/test/Fixtures/App/app/AppKernel.php"
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
"authors": [
|
"authors" : [
|
||||||
{
|
{
|
||||||
"name": "Champs-Libres",
|
"name": "Champs-Libres",
|
||||||
"email": "info@champs-libres.coop",
|
"email": "info@champs-libres.coop",
|
||||||
"homepage": "http://www.champs-libres.coop"
|
"homepage": "http://www.champs-libres.coop"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
"require": {
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
},
|
||||||
"minimum-stability": "dev",
|
"minimum-stability": "dev",
|
||||||
"prefer-stable": true,
|
"prefer-stable": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
@@ -3,9 +3,9 @@
|
|||||||
"description": "A Chill bundle to store documents",
|
"description": "A Chill bundle to store documents",
|
||||||
"type": "symfony-bundle",
|
"type": "symfony-bundle",
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-4": {
|
"psr-4": { "Chill\\DocStoreBundle\\" : "" }
|
||||||
"Chill\\DocStoreBundle\\": ""
|
},
|
||||||
}
|
"require": {
|
||||||
},
|
},
|
||||||
"license": "AGPL-3.0"
|
"license": "AGPL-3.0"
|
||||||
}
|
}
|
||||||
|
@@ -23,7 +23,6 @@ namespace Chill\EventBundle\Timeline;
|
|||||||
use Chill\EventBundle\Entity\Event;
|
use Chill\EventBundle\Entity\Event;
|
||||||
use Chill\MainBundle\Entity\Scope;
|
use Chill\MainBundle\Entity\Scope;
|
||||||
use Chill\MainBundle\Timeline\TimelineProviderInterface;
|
use Chill\MainBundle\Timeline\TimelineProviderInterface;
|
||||||
use Chill\MainBundle\Timeline\TimelineSingleQuery;
|
|
||||||
use Doctrine\ORM\EntityManager;
|
use Doctrine\ORM\EntityManager;
|
||||||
use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
|
use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
|
||||||
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
|
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
|
||||||
@@ -89,14 +88,13 @@ class TimelineEventProvider implements TimelineProviderInterface
|
|||||||
$metadataParticipation = $this->em->getClassMetadata('ChillEventBundle:Participation');
|
$metadataParticipation = $this->em->getClassMetadata('ChillEventBundle:Participation');
|
||||||
$metadataPerson = $this->em->getClassMetadata('ChillPersonBundle:Person');
|
$metadataPerson = $this->em->getClassMetadata('ChillPersonBundle:Person');
|
||||||
|
|
||||||
$query = TimelineSingleQuery::fromArray([
|
$query = array(
|
||||||
'id' => $metadataEvent->getTableName().'.'.$metadataEvent->getColumnName('id'),
|
'id' => $metadataEvent->getTableName().'.'.$metadataEvent->getColumnName('id'),
|
||||||
'type' => 'event',
|
'type' => 'event',
|
||||||
'date' => $metadataEvent->getTableName().'.'.$metadataEvent->getColumnName('date'),
|
'date' => $metadataEvent->getTableName().'.'.$metadataEvent->getColumnName('date'),
|
||||||
'FROM' => $this->getFromClause($metadataEvent, $metadataParticipation, $metadataPerson),
|
'FROM' => $this->getFromClause($metadataEvent, $metadataParticipation, $metadataPerson),
|
||||||
'WHERE' => $this->getWhereClause($metadataEvent, $metadataParticipation, $metadataPerson, $args['person']),
|
'WHERE' => $this->getWhereClause($metadataEvent, $metadataParticipation, $metadataPerson, $args['person'])
|
||||||
'parameters' => []
|
);
|
||||||
]);
|
|
||||||
|
|
||||||
return $query;
|
return $query;
|
||||||
}
|
}
|
||||||
@@ -240,4 +238,4 @@ class TimelineEventProvider implements TimelineProviderInterface
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@@ -3,18 +3,16 @@
|
|||||||
"description": "This bundle extend chill software. This bundle allow to define event and participation to those events.",
|
"description": "This bundle extend chill software. This bundle allow to define event and participation to those events.",
|
||||||
"type": "symfony-bundle",
|
"type": "symfony-bundle",
|
||||||
"license": "AGPL-3.0-only",
|
"license": "AGPL-3.0-only",
|
||||||
"keywords": ["chill", "social work"],
|
"keywords" : ["chill", "social work"],
|
||||||
"homepage": "https://git.framasoft.org/Chill-project/Chill-Group",
|
"homepage" : "https://git.framasoft.org/Chill-project/Chill-Group",
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-4": {
|
"psr-4": { "Chill\\EventBundle\\": "" }
|
||||||
"Chill\\EventBundle\\": ""
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
"support": {
|
"support": {
|
||||||
"issues": "https://git.framasoft.org/Chill-project/Chill-Event/issues",
|
"issues": "https://git.framasoft.org/Chill-project/Chill-Event/issues",
|
||||||
"source": "https://git.framasoft.org/Chill-project/Chill-Event",
|
"source": "https://git.framasoft.org/Chill-project/Chill-Event",
|
||||||
"docs": "http://docs.chill.social",
|
"docs" : "http://docs.chill.social",
|
||||||
"email": "dev@listes.chill.social"
|
"email": "dev@listes.chill.social"
|
||||||
},
|
},
|
||||||
"authors": [
|
"authors": [
|
||||||
{
|
{
|
||||||
@@ -22,7 +20,11 @@
|
|||||||
"email": "info@champs-libres.coop"
|
"email": "info@champs-libres.coop"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"suggest": {
|
"require": {
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
},
|
||||||
|
"suggest" : {
|
||||||
"chill-project/group": "dev-master@dev"
|
"chill-project/group": "dev-master@dev"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
@@ -3,12 +3,13 @@
|
|||||||
"description": "This bundle extend chill for recording family members into a file",
|
"description": "This bundle extend chill for recording family members into a file",
|
||||||
"type": "symfony-bundle",
|
"type": "symfony-bundle",
|
||||||
"license": "AGPL-3.0-or-later",
|
"license": "AGPL-3.0-or-later",
|
||||||
"keywords": ["chill", "social work"],
|
"keywords" : ["chill", "social work"],
|
||||||
"homepage": "https://framagit.org/Chill-project/Chill-FamilyMembers",
|
"homepage" : "https://framagit.org/Chill-project/Chill-FamilyMembers",
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-4": {
|
"psr-4": { "Chill\\AMLI\\FamilyMembersBundle\\": "" }
|
||||||
"Chill\\AMLI\\FamilyMembersBundle\\": ""
|
},
|
||||||
}
|
"autoload-dev": {
|
||||||
|
"classmap": [ "Resources/test/Fixtures/App/app/AppKernel.php" ]
|
||||||
},
|
},
|
||||||
"authors": [
|
"authors": [
|
||||||
{
|
{
|
||||||
@@ -16,8 +17,13 @@
|
|||||||
"email": "info@champs-libres.coop"
|
"email": "info@champs-libres.coop"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
"require": {
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
},
|
||||||
"extra": {
|
"extra": {
|
||||||
"app-migrations-dir": "Resources/test/Fixtures/App/app/DoctrineMigrations"
|
"app-migrations-dir": "Resources/test/Fixtures/App/app/DoctrineMigrations",
|
||||||
|
"symfony-app-dir": "Test/Fixtures/App/app/"
|
||||||
},
|
},
|
||||||
"minimum-stability": "dev",
|
"minimum-stability": "dev",
|
||||||
"prefer-stable": true
|
"prefer-stable": true
|
||||||
|
@@ -5,7 +5,7 @@ namespace Chill\MainBundle\CRUD\Controller;
|
|||||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\Validator\Validator\ValidatorInterface;
|
use Symfony\Component\Routing\Annotation\Route;
|
||||||
use Chill\MainBundle\Pagination\PaginatorFactory;
|
use Chill\MainBundle\Pagination\PaginatorFactory;
|
||||||
use Chill\MainBundle\Pagination\PaginatorInterface;
|
use Chill\MainBundle\Pagination\PaginatorInterface;
|
||||||
|
|
||||||
@@ -25,33 +25,12 @@ class AbstractCRUDController extends AbstractController
|
|||||||
*
|
*
|
||||||
* @param string $id
|
* @param string $id
|
||||||
* @return object
|
* @return object
|
||||||
* @throw Symfony\Component\HttpKernel\Exception\NotFoundHttpException if the object is not found
|
|
||||||
*/
|
*/
|
||||||
protected function getEntity($action, $id, Request $request): object
|
protected function getEntity($action, $id, Request $request): ?object
|
||||||
{
|
{
|
||||||
$e = $this->getDoctrine()
|
return $this->getDoctrine()
|
||||||
->getRepository($this->getEntityClass())
|
->getRepository($this->getEntityClass())
|
||||||
->find($id);
|
->find($id);
|
||||||
|
|
||||||
if (NULL === $e) {
|
|
||||||
throw $this->createNotFoundException(sprintf("The object %s for id %s is not found", $this->getEntityClass(), $id));
|
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -243,9 +222,4 @@ class AbstractCRUDController extends AbstractController
|
|||||||
{
|
{
|
||||||
return $this->container->get('chill_main.paginator_factory');
|
return $this->container->get('chill_main.paginator_factory');
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getValidator(): ValidatorInterface
|
|
||||||
{
|
|
||||||
return $this->get('validator');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@@ -8,10 +8,6 @@ use Symfony\Component\Routing\Annotation\Route;
|
|||||||
use Symfony\Component\Serializer\SerializerInterface;
|
use Symfony\Component\Serializer\SerializerInterface;
|
||||||
use Chill\MainBundle\Serializer\Model\Collection;
|
use Chill\MainBundle\Serializer\Model\Collection;
|
||||||
use Chill\MainBundle\Pagination\PaginatorInterface;
|
use Chill\MainBundle\Pagination\PaginatorInterface;
|
||||||
use Symfony\Component\Serializer\Normalizer\AbstractNormalizer;
|
|
||||||
use Symfony\Component\Validator\ConstraintViolationListInterface;
|
|
||||||
use Symfony\Component\Serializer\Exception\NotEncodableValueException;
|
|
||||||
use Symfony\Component\HttpFoundation\Exception\BadRequestException;
|
|
||||||
|
|
||||||
class ApiController extends AbstractCRUDController
|
class ApiController extends AbstractCRUDController
|
||||||
{
|
{
|
||||||
@@ -42,6 +38,11 @@ class ApiController extends AbstractCRUDController
|
|||||||
return $postFetch;
|
return $postFetch;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (NULL === $entity) {
|
||||||
|
throw $this->createNotFoundException(sprintf("The %s with id %s "
|
||||||
|
. "is not found", $this->getCrudName(), $id));
|
||||||
|
}
|
||||||
|
|
||||||
$response = $this->checkACL($action, $request, $_format, $entity);
|
$response = $this->checkACL($action, $request, $_format, $entity);
|
||||||
if ($response instanceof Response) {
|
if ($response instanceof Response) {
|
||||||
return $response;
|
return $response;
|
||||||
@@ -80,186 +81,12 @@ class ApiController extends AbstractCRUDController
|
|||||||
{
|
{
|
||||||
switch ($request->getMethod()) {
|
switch ($request->getMethod()) {
|
||||||
case Request::METHOD_GET:
|
case Request::METHOD_GET:
|
||||||
case Request::METHOD_HEAD:
|
case REQUEST::METHOD_HEAD:
|
||||||
return $this->entityGet('_entity', $request, $id, $_format);
|
return $this->entityGet('_entity', $request, $id, $_format);
|
||||||
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:
|
default:
|
||||||
throw new \Symfony\Component\HttpFoundation\Exception\BadRequestException("This method is not implemented");
|
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);
|
|
||||||
|
|
||||||
$postFetch = $this->onPostFetchEntity($action, $request, $entity, $_format);
|
|
||||||
if ($postFetch instanceof Response) {
|
|
||||||
return $postFetch;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (NULL === $entity) {
|
|
||||||
throw $this->createNotFoundException(sprintf("The %s with id %s "
|
|
||||||
. "is not found", $this->getCrudName(), $id));
|
|
||||||
}
|
|
||||||
|
|
||||||
$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;
|
|
||||||
}
|
|
||||||
|
|
||||||
$response = $this->onBeforeSerialize($action, $request, $_format, $entity);
|
|
||||||
if ($response instanceof Response) {
|
|
||||||
return $response;
|
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->getDoctrine()->getManager()->flush();
|
|
||||||
|
|
||||||
$response = $this->onAfterFlush($action, $request, $_format, $entity, $errors);
|
|
||||||
if ($response instanceof Response) {
|
|
||||||
return $response;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->json(
|
|
||||||
$entity,
|
|
||||||
Response::HTTP_OK,
|
|
||||||
[],
|
|
||||||
$this->getContextForSerializationPostAlter($action, $request, $_format, $entity)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function onAfterValidation(string $action, Request $request, string $_format, $entity, ConstraintViolationListInterface $errors, array $more = []): ?Response
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
protected function onAfterFlush(string $action, Request $request, string $_format, $entity, ConstraintViolationListInterface $errors, array $more = []): ?Response
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function getValidationGroups(string $action, Request $request, string $_format, $entity): ?array
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function validate(string $action, Request $request, string $_format, $entity, array $more = []): ConstraintViolationListInterface
|
|
||||||
{
|
|
||||||
$validationGroups = $this->getValidationGroups($action, $request, $_format, $entity);
|
|
||||||
|
|
||||||
return $this->getValidator()->validate($entity, null, $validationGroups);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Deserialize the content of the request into the class associated with the curd
|
|
||||||
*/
|
|
||||||
protected function deserialize(string $action, Request $request, string $_format, $entity = null): object
|
|
||||||
{
|
|
||||||
$default = [];
|
|
||||||
|
|
||||||
if (NULL !== $entity) {
|
|
||||||
$default[AbstractNormalizer::OBJECT_TO_POPULATE] = $entity;
|
|
||||||
}
|
|
||||||
|
|
||||||
$context = \array_merge(
|
|
||||||
$default,
|
|
||||||
$this->getContextForSerialization($action, $request, $_format, $entity)
|
|
||||||
);
|
|
||||||
|
|
||||||
return $this->getSerializer()->deserialize($request->getContent(), $this->getEntityClass(), $_format, $context);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base action for indexing entities
|
* Base action for indexing entities
|
||||||
@@ -345,110 +172,6 @@ class ApiController extends AbstractCRUDController
|
|||||||
|
|
||||||
return $this->serializeCollection($action, $request, $_format, $paginator, $entities);
|
return $this->serializeCollection($action, $request, $_format, $paginator, $entities);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Add or remove an associated entity, using `add` and `remove` methods.
|
|
||||||
*
|
|
||||||
* This method:
|
|
||||||
*
|
|
||||||
* 1. Fetch the base entity (throw 404 if not found)
|
|
||||||
* 2. checkACL,
|
|
||||||
* 3. run onPostCheckACL, return response if any,
|
|
||||||
* 4. deserialize posted data into the entity given by $postedDataType, with the context in $postedDataContext
|
|
||||||
* 5. run 'add+$property' for POST method, or 'remove+$property' for DELETE method
|
|
||||||
* 6. validate the base entity (not the deserialized one). Groups are fetched from getValidationGroups, validation is perform by `validate`
|
|
||||||
* 7. run onAfterValidation
|
|
||||||
* 8. if errors, return a 422 response with errors
|
|
||||||
* 9. flush the data
|
|
||||||
* 10. run onAfterFlush
|
|
||||||
* 11. return a 202 response for DELETE with empty body, or HTTP 200 for post with serialized posted entity
|
|
||||||
*
|
|
||||||
* @param string action
|
|
||||||
* @param mixed id
|
|
||||||
* @param Request $request
|
|
||||||
* @param string $_format
|
|
||||||
* @param string $property the name of the property. This will be used to make a `add+$property` and `remove+$property` method
|
|
||||||
* @param string $postedDataType the type of the posted data (the content)
|
|
||||||
* @param string $postedDataContext a context to deserialize posted data (the content)
|
|
||||||
* @throw BadRequestException if unable to deserialize the posted data
|
|
||||||
* @throw BadRequestException if the method is not POST or DELETE
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
protected function addRemoveSomething(string $action, $id, Request $request, string $_format, string $property, string $postedDataType, $postedDataContext = []): Response
|
|
||||||
{
|
|
||||||
$entity = $this->getEntity($action, $id, $request);
|
|
||||||
|
|
||||||
$postFetch = $this->onPostFetchEntity($action, $request, $entity, $_format);
|
|
||||||
if ($postFetch instanceof Response) {
|
|
||||||
return $postFetch;
|
|
||||||
}
|
|
||||||
|
|
||||||
$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;
|
|
||||||
}
|
|
||||||
|
|
||||||
$response = $this->onBeforeSerialize($action, $request, $_format, $entity);
|
|
||||||
if ($response instanceof Response) {
|
|
||||||
return $response;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
$postedData = $this->getSerializer()->deserialize($request->getContent(), $postedDataType, $_format, $postedDataContext);
|
|
||||||
} catch (\Symfony\Component\Serializer\Exception\UnexpectedValueException $e) {
|
|
||||||
throw new BadRequestException(sprintf("Unable to deserialize posted ".
|
|
||||||
"data: %s", $e->getMessage()), 0, $e);
|
|
||||||
}
|
|
||||||
|
|
||||||
switch ($request->getMethod()) {
|
|
||||||
case Request::METHOD_DELETE:
|
|
||||||
// oups... how to use property accessor to remove element ?
|
|
||||||
$entity->{'remove'.\ucfirst($property)}($postedData);
|
|
||||||
break;
|
|
||||||
case Request::METHOD_POST:
|
|
||||||
$entity->{'add'.\ucfirst($property)}($postedData);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
throw new BadRequestException("this method is not supported");
|
|
||||||
}
|
|
||||||
|
|
||||||
$errors = $this->validate($action, $request, $_format, $entity, [$postedData]);
|
|
||||||
|
|
||||||
$response = $this->onAfterValidation($action, $request, $_format, $entity, $errors, [$postedData]);
|
|
||||||
if ($response instanceof Response) {
|
|
||||||
return $response;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($errors->count() > 0) {
|
|
||||||
// only format accepted
|
|
||||||
return $this->json($errors, 422);
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->getDoctrine()->getManager()->flush();
|
|
||||||
|
|
||||||
|
|
||||||
$response = $this->onAfterFlush($action, $request, $_format, $entity, $errors, [$postedData]);
|
|
||||||
if ($response instanceof Response) {
|
|
||||||
return $response;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch ($request->getMethod()) {
|
|
||||||
case Request::METHOD_DELETE:
|
|
||||||
return $this->json('', Response::HTTP_OK);
|
|
||||||
case Request::METHOD_POST:
|
|
||||||
return $this->json(
|
|
||||||
$postedData,
|
|
||||||
Response::HTTP_OK,
|
|
||||||
[],
|
|
||||||
$this->getContextForSerializationPostAlter($action, $request, $_format, $entity, [$postedData])
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Serialize collections
|
* Serialize collections
|
||||||
@@ -466,27 +189,7 @@ class ApiController extends AbstractCRUDController
|
|||||||
|
|
||||||
protected function getContextForSerialization(string $action, Request $request, string $_format, $entity): array
|
protected function getContextForSerialization(string $action, Request $request, string $_format, $entity): array
|
||||||
{
|
{
|
||||||
switch ($request->getMethod()) {
|
return [];
|
||||||
case Request::METHOD_GET:
|
|
||||||
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");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the context for serialization post alter query (in case of
|
|
||||||
* PATCH, PUT, or POST method)
|
|
||||||
*
|
|
||||||
* This is called **after** the entity was altered.
|
|
||||||
*/
|
|
||||||
protected function getContextForSerializationPostAlter(string $action, Request $request, string $_format, $entity, array $more = []): array
|
|
||||||
{
|
|
||||||
return [ 'groups' => [ 'read' ]];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
File diff suppressed because it is too large
Load Diff
@@ -183,26 +183,6 @@ class CRUDRoutesLoader extends Loader
|
|||||||
$methods = \array_keys(\array_filter($action['methods'], function($value, $key) { return $value; },
|
$methods = \array_keys(\array_filter($action['methods'], function($value, $key) { return $value; },
|
||||||
ARRAY_FILTER_USE_BOTH));
|
ARRAY_FILTER_USE_BOTH));
|
||||||
|
|
||||||
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");
|
|
||||||
}
|
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (count($methods) === 0) {
|
|
||||||
// the only method was POST,
|
|
||||||
// continue to next
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
$route = new Route($path, $defaults, $requirements);
|
$route = new Route($path, $defaults, $requirements);
|
||||||
$route->setMethods($methods);
|
$route->setMethods($methods);
|
||||||
|
|
||||||
@@ -212,17 +192,45 @@ class CRUDRoutesLoader extends Loader
|
|||||||
return $collection;
|
return $collection;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function createEntityPostRoute(string $name, $crudConfig, array $action, $controller): Route
|
/**
|
||||||
|
* Load routes for api multi
|
||||||
|
*
|
||||||
|
* @param $crudConfig
|
||||||
|
* @return RouteCollection
|
||||||
|
*/
|
||||||
|
protected function loadApiMultiConfig(array $crudConfig): RouteCollection
|
||||||
{
|
{
|
||||||
$localPath = $action['path'].'.{_format}';
|
$collection = new RouteCollection();
|
||||||
$defaults = [
|
$controller ='csapi_'.$crudConfig['name'].'_controller';
|
||||||
'_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;
|
foreach ($crudConfig['actions'] as $name => $action) {
|
||||||
|
// filter only on single actions
|
||||||
|
$singleCollection = $action['single-collection'] ?? $name === '_index' ? 'collection' : NULL;
|
||||||
|
if ('single' === $singleCollection) {
|
||||||
|
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);
|
||||||
|
|
||||||
|
$collection->add('chill_api_single_'.$crudConfig['name'].'_'.$name, $route);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $collection;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
63
src/Bundle/ChillMainBundle/Controller/AddressController.php
Normal file
63
src/Bundle/ChillMainBundle/Controller/AddressController.php
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Chill\MainBundle\Controller;
|
||||||
|
|
||||||
|
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
|
||||||
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||||
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
use Symfony\Component\HttpFoundation\Exception\BadRequestException;
|
||||||
|
use Symfony\Component\Routing\Annotation\Route;
|
||||||
|
use Chill\MainBundle\Entity\Address;
|
||||||
|
use Chill\MainBundle\Entity\AddressReference;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class AddressController
|
||||||
|
*
|
||||||
|
* @package Chill\MainBundle\Controller
|
||||||
|
*/
|
||||||
|
class AddressController extends AbstractController
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get API Data for showing endpoint
|
||||||
|
*
|
||||||
|
* @Route(
|
||||||
|
* "/{_locale}/main/api/1.0/address/{address_id}/show.{_format}",
|
||||||
|
* name="chill_main_address_api_show"
|
||||||
|
* )
|
||||||
|
* @ParamConverter("address", options={"id": "address_id"})
|
||||||
|
*/
|
||||||
|
public function showAddress(Address $address, $_format): Response
|
||||||
|
{
|
||||||
|
// TODO check ACL ?
|
||||||
|
switch ($_format) {
|
||||||
|
case 'json':
|
||||||
|
return $this->json($address);
|
||||||
|
default:
|
||||||
|
throw new BadRequestException('Unsupported format');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get API Data for showing endpoint
|
||||||
|
*
|
||||||
|
* @Route(
|
||||||
|
* "/{_locale}/main/api/1.0/address-reference/{address_reference_id}/show.{_format}",
|
||||||
|
* name="chill_main_address_reference_api_show"
|
||||||
|
* )
|
||||||
|
* @ParamConverter("addressReference", options={"id": "address_reference_id"})
|
||||||
|
*/
|
||||||
|
public function showAddressReference(AddressReference $addressReference, $_format): Response
|
||||||
|
{
|
||||||
|
// TODO check ACL ?
|
||||||
|
switch ($_format) {
|
||||||
|
case 'json':
|
||||||
|
return $this->json($addressReference);
|
||||||
|
default:
|
||||||
|
throw new BadRequestException('Unsupported format');
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@@ -1,27 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Chill\MainBundle\Controller;
|
|
||||||
|
|
||||||
use Chill\MainBundle\CRUD\Controller\ApiController;
|
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Class AddressReferenceAPIController
|
|
||||||
*
|
|
||||||
* @package Chill\MainBundle\Controller
|
|
||||||
* @author Champs Libres
|
|
||||||
*/
|
|
||||||
class AddressReferenceAPIController extends ApiController
|
|
||||||
{
|
|
||||||
|
|
||||||
protected function customizeQuery(string $action, Request $request, $qb): void
|
|
||||||
{
|
|
||||||
if ($request->query->has('postal_code')) {
|
|
||||||
|
|
||||||
$qb->where('e.postcode = :postal_code')
|
|
||||||
->setParameter('postal_code', $request->query->get('postal_code'));
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@@ -1,27 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Chill\MainBundle\Controller;
|
|
||||||
|
|
||||||
use Chill\MainBundle\CRUD\Controller\ApiController;
|
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Class PostalCodeAPIController
|
|
||||||
*
|
|
||||||
* @package Chill\MainBundle\Controller
|
|
||||||
* @author Champs Libres
|
|
||||||
*/
|
|
||||||
class PostalCodeAPIController extends ApiController
|
|
||||||
{
|
|
||||||
|
|
||||||
protected function customizeQuery(string $action, Request $request, $qb): void
|
|
||||||
{
|
|
||||||
if ($request->query->has('country')) {
|
|
||||||
|
|
||||||
$qb->where('e.country = :country')
|
|
||||||
->setParameter('country', $request->query->get('country'));
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@@ -22,7 +22,6 @@
|
|||||||
|
|
||||||
namespace Chill\MainBundle\Controller;
|
namespace Chill\MainBundle\Controller;
|
||||||
|
|
||||||
use Chill\MainBundle\Serializer\Model\Collection;
|
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Chill\MainBundle\Search\UnknowSearchDomainException;
|
use Chill\MainBundle\Search\UnknowSearchDomainException;
|
||||||
@@ -35,7 +34,6 @@ use Symfony\Component\HttpFoundation\JsonResponse;
|
|||||||
use Chill\MainBundle\Search\SearchProvider;
|
use Chill\MainBundle\Search\SearchProvider;
|
||||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||||
use Chill\MainBundle\Pagination\PaginatorFactory;
|
use Chill\MainBundle\Pagination\PaginatorFactory;
|
||||||
use Chill\MainBundle\Search\SearchApi;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class SearchController
|
* Class SearchController
|
||||||
@@ -44,24 +42,32 @@ use Chill\MainBundle\Search\SearchApi;
|
|||||||
*/
|
*/
|
||||||
class SearchController extends AbstractController
|
class SearchController extends AbstractController
|
||||||
{
|
{
|
||||||
protected SearchProvider $searchProvider;
|
/**
|
||||||
|
*
|
||||||
|
* @var SearchProvider
|
||||||
|
*/
|
||||||
|
protected $searchProvider;
|
||||||
|
|
||||||
protected TranslatorInterface $translator;
|
/**
|
||||||
|
*
|
||||||
|
* @var TranslatorInterface
|
||||||
|
*/
|
||||||
|
protected $translator;
|
||||||
|
|
||||||
protected PaginatorFactory $paginatorFactory;
|
/**
|
||||||
|
*
|
||||||
protected SearchApi $searchApi;
|
* @var PaginatorFactory
|
||||||
|
*/
|
||||||
|
protected $paginatorFactory;
|
||||||
|
|
||||||
function __construct(
|
function __construct(
|
||||||
SearchProvider $searchProvider,
|
SearchProvider $searchProvider,
|
||||||
TranslatorInterface $translator,
|
TranslatorInterface $translator,
|
||||||
PaginatorFactory $paginatorFactory,
|
PaginatorFactory $paginatorFactory
|
||||||
SearchApi $searchApi
|
|
||||||
) {
|
) {
|
||||||
$this->searchProvider = $searchProvider;
|
$this->searchProvider = $searchProvider;
|
||||||
$this->translator = $translator;
|
$this->translator = $translator;
|
||||||
$this->paginatorFactory = $paginatorFactory;
|
$this->paginatorFactory = $paginatorFactory;
|
||||||
$this->searchApi = $searchApi;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -146,19 +152,6 @@ class SearchController extends AbstractController
|
|||||||
array('results' => $results, 'pattern' => $pattern)
|
array('results' => $results, 'pattern' => $pattern)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function searchApi(Request $request, $_format): JsonResponse
|
|
||||||
{
|
|
||||||
//TODO this is an incomplete implementation
|
|
||||||
$query = $request->query->get('q', '');
|
|
||||||
|
|
||||||
$results = $this->searchApi->getResults($query, 0, 150);
|
|
||||||
$paginator = $this->paginatorFactory->create(count($results));
|
|
||||||
|
|
||||||
$collection = new Collection($results, $paginator);
|
|
||||||
|
|
||||||
return $this->json($collection);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function advancedSearchListAction(Request $request)
|
public function advancedSearchListAction(Request $request)
|
||||||
{
|
{
|
||||||
|
@@ -1,91 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright (C) 2015 Champs-Libres Coopérative <info@champs-libres.coop>
|
|
||||||
*
|
|
||||||
* 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 <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Chill\MainBundle\Controller;
|
|
||||||
|
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
|
||||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
|
||||||
use Chill\MainBundle\Timeline\TimelineBuilder;
|
|
||||||
use Chill\MainBundle\Pagination\PaginatorFactory;
|
|
||||||
use Chill\PersonBundle\Security\Authorization\PersonVoter;
|
|
||||||
use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
|
|
||||||
use Symfony\Component\Security\Core\Role\Role;
|
|
||||||
use Symfony\Component\Routing\Annotation\Route;
|
|
||||||
use Symfony\Component\Security\Core\Security;
|
|
||||||
|
|
||||||
class TimelineCenterController extends AbstractController
|
|
||||||
{
|
|
||||||
|
|
||||||
protected TimelineBuilder $timelineBuilder;
|
|
||||||
|
|
||||||
protected PaginatorFactory $paginatorFactory;
|
|
||||||
|
|
||||||
private Security $security;
|
|
||||||
|
|
||||||
public function __construct(
|
|
||||||
TimelineBuilder $timelineBuilder,
|
|
||||||
PaginatorFactory $paginatorFactory,
|
|
||||||
Security $security
|
|
||||||
) {
|
|
||||||
$this->timelineBuilder = $timelineBuilder;
|
|
||||||
$this->paginatorFactory = $paginatorFactory;
|
|
||||||
$this->security = $security;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @Route("/{_locale}/center/timeline",
|
|
||||||
* name="chill_center_timeline",
|
|
||||||
* methods={"GET"}
|
|
||||||
* )
|
|
||||||
*/
|
|
||||||
public function centerAction(Request $request)
|
|
||||||
{
|
|
||||||
// collect reachable center for each group
|
|
||||||
$user = $this->security->getUser();
|
|
||||||
$centers = [];
|
|
||||||
foreach ($user->getGroupCenters() as $group) {
|
|
||||||
$centers[] = $group->getCenter();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (0 === count($centers)) {
|
|
||||||
throw $this->createNotFoundException();
|
|
||||||
}
|
|
||||||
|
|
||||||
$nbItems = $this->timelineBuilder->countItems('center',
|
|
||||||
[ 'centers' => $centers ]
|
|
||||||
);
|
|
||||||
|
|
||||||
$paginator = $this->paginatorFactory->create($nbItems);
|
|
||||||
|
|
||||||
return $this->render('@ChillMain/Timeline/index.html.twig', array
|
|
||||||
(
|
|
||||||
'timeline' => $this->timelineBuilder->getTimelineHTML(
|
|
||||||
'center',
|
|
||||||
[ 'centers' => $centers ],
|
|
||||||
$paginator->getCurrentPage()->getFirstItemNumber(),
|
|
||||||
$paginator->getItemsPerPage()
|
|
||||||
),
|
|
||||||
'nb_items' => $nbItems,
|
|
||||||
'paginator' => $paginator
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
@@ -55,11 +55,11 @@ class LoadCenters extends AbstractFixture implements OrderedFixtureInterface
|
|||||||
public function load(ObjectManager $manager)
|
public function load(ObjectManager $manager)
|
||||||
{
|
{
|
||||||
foreach (static::$centers as $new) {
|
foreach (static::$centers as $new) {
|
||||||
$center = new Center();
|
$centerA = new Center();
|
||||||
$center->setName($new['name']);
|
$centerA->setName($new['name']);
|
||||||
|
|
||||||
$manager->persist($center);
|
$manager->persist($centerA);
|
||||||
$this->addReference($new['ref'], $center);
|
$this->addReference($new['ref'], $centerA);
|
||||||
static::$refs[] = $new['ref'];
|
static::$refs[] = $new['ref'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -35,9 +35,6 @@ use Chill\MainBundle\Doctrine\DQL\OverlapsI;
|
|||||||
use Symfony\Component\DependencyInjection\Definition;
|
use Symfony\Component\DependencyInjection\Definition;
|
||||||
use Symfony\Component\DependencyInjection\Reference;
|
use Symfony\Component\DependencyInjection\Reference;
|
||||||
use Chill\MainBundle\Doctrine\DQL\Replace;
|
use Chill\MainBundle\Doctrine\DQL\Replace;
|
||||||
use Chill\MainBundle\Doctrine\Type\NativeDateIntervalType;
|
|
||||||
use Chill\MainBundle\Doctrine\Type\PointType;
|
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class ChillMainExtension
|
* Class ChillMainExtension
|
||||||
@@ -136,7 +133,7 @@ class ChillMainExtension extends Extension implements PrependExtensionInterface,
|
|||||||
$loader->load('services/search.yaml');
|
$loader->load('services/search.yaml');
|
||||||
$loader->load('services/serializer.yaml');
|
$loader->load('services/serializer.yaml');
|
||||||
|
|
||||||
$this->configureCruds($container, $config['cruds'], $config['apis'], $loader);
|
$this->configureCruds($container, $config['cruds'], $config['apis'], $loader);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -169,49 +166,37 @@ class ChillMainExtension extends Extension implements PrependExtensionInterface,
|
|||||||
$container->prependExtensionConfig('twig', $twigConfig);
|
$container->prependExtensionConfig('twig', $twigConfig);
|
||||||
|
|
||||||
//add DQL function to ORM (default entity_manager)
|
//add DQL function to ORM (default entity_manager)
|
||||||
$container
|
$container->prependExtensionConfig('doctrine', array(
|
||||||
->prependExtensionConfig(
|
'orm' => array(
|
||||||
'doctrine',
|
'dql' => array(
|
||||||
[
|
'string_functions' => array(
|
||||||
'orm' => [
|
'unaccent' => Unaccent::class,
|
||||||
'dql' => [
|
'GET_JSON_FIELD_BY_KEY' => GetJsonFieldByKey::class,
|
||||||
'string_functions' => [
|
'AGGREGATE' => JsonAggregate::class,
|
||||||
'unaccent' => Unaccent::class,
|
'REPLACE' => Replace::class,
|
||||||
'GET_JSON_FIELD_BY_KEY' => GetJsonFieldByKey::class,
|
),
|
||||||
'AGGREGATE' => JsonAggregate::class,
|
'numeric_functions' => [
|
||||||
'REPLACE' => Replace::class,
|
'JSONB_EXISTS_IN_ARRAY' => JsonbExistsInArray::class,
|
||||||
],
|
'SIMILARITY' => Similarity::class,
|
||||||
'numeric_functions' => [
|
'OVERLAPSI' => OverlapsI::class
|
||||||
'JSONB_EXISTS_IN_ARRAY' => JsonbExistsInArray::class,
|
]
|
||||||
'SIMILARITY' => Similarity::class,
|
)
|
||||||
'OVERLAPSI' => OverlapsI::class,
|
)
|
||||||
],
|
));
|
||||||
],
|
|
||||||
],
|
|
||||||
],
|
|
||||||
);
|
|
||||||
|
|
||||||
//add dbal types (default entity_manager)
|
//add dbal types (default entity_manager)
|
||||||
$container
|
$container->prependExtensionConfig('doctrine', array(
|
||||||
->prependExtensionConfig(
|
'dbal' => [
|
||||||
'doctrine',
|
'types' => [
|
||||||
[
|
'dateinterval' => [
|
||||||
'dbal' => [
|
'class' => \Chill\MainBundle\Doctrine\Type\NativeDateIntervalType::class
|
||||||
// This is mandatory since we are using postgis as database.
|
],
|
||||||
'mapping_types' => [
|
'point' => [
|
||||||
'geometry' => 'string',
|
'class' => \Chill\MainBundle\Doctrine\Type\PointType::class
|
||||||
],
|
]
|
||||||
'types' => [
|
]
|
||||||
'dateinterval' => [
|
]
|
||||||
'class' => NativeDateIntervalType::class
|
));
|
||||||
],
|
|
||||||
'point' => [
|
|
||||||
'class' => PointType::class
|
|
||||||
]
|
|
||||||
]
|
|
||||||
]
|
|
||||||
]
|
|
||||||
);
|
|
||||||
|
|
||||||
//add current route to chill main
|
//add current route to chill main
|
||||||
$container->prependExtensionConfig('chill_main', array(
|
$container->prependExtensionConfig('chill_main', array(
|
||||||
@@ -227,9 +212,6 @@ class ChillMainExtension extends Extension implements PrependExtensionInterface,
|
|||||||
$container->prependExtensionConfig('monolog', array(
|
$container->prependExtensionConfig('monolog', array(
|
||||||
'channels' => array('chill')
|
'channels' => array('chill')
|
||||||
));
|
));
|
||||||
|
|
||||||
//add crud api
|
|
||||||
$this->prependCruds($container);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -253,99 +235,4 @@ class ChillMainExtension extends Extension implements PrependExtensionInterface,
|
|||||||
|
|
||||||
// Note: the controller are loaded inside compiler pass
|
// Note: the controller are loaded inside compiler pass
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param ContainerBuilder $container
|
|
||||||
*/
|
|
||||||
protected function prependCruds(ContainerBuilder $container)
|
|
||||||
{
|
|
||||||
$container->prependExtensionConfig('chill_main', [
|
|
||||||
'apis' => [
|
|
||||||
[
|
|
||||||
'class' => \Chill\MainBundle\Entity\Address::class,
|
|
||||||
'name' => 'address',
|
|
||||||
'base_path' => '/api/1.0/main/address',
|
|
||||||
'base_role' => 'ROLE_USER',
|
|
||||||
'actions' => [
|
|
||||||
'_index' => [
|
|
||||||
'methods' => [
|
|
||||||
Request::METHOD_GET => true,
|
|
||||||
Request::METHOD_HEAD => true
|
|
||||||
],
|
|
||||||
],
|
|
||||||
'_entity' => [
|
|
||||||
'methods' => [
|
|
||||||
Request::METHOD_GET => true,
|
|
||||||
Request::METHOD_POST => true,
|
|
||||||
Request::METHOD_HEAD => true
|
|
||||||
]
|
|
||||||
],
|
|
||||||
]
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'controller' => \Chill\MainBundle\Controller\AddressReferenceAPIController::class,
|
|
||||||
'class' => \Chill\MainBundle\Entity\AddressReference::class,
|
|
||||||
'name' => 'address_reference',
|
|
||||||
'base_path' => '/api/1.0/main/address-reference',
|
|
||||||
'base_role' => 'ROLE_USER',
|
|
||||||
'actions' => [
|
|
||||||
'_index' => [
|
|
||||||
'methods' => [
|
|
||||||
Request::METHOD_GET => true,
|
|
||||||
Request::METHOD_HEAD => true
|
|
||||||
],
|
|
||||||
],
|
|
||||||
'_entity' => [
|
|
||||||
'methods' => [
|
|
||||||
Request::METHOD_GET => true,
|
|
||||||
Request::METHOD_HEAD => true
|
|
||||||
]
|
|
||||||
],
|
|
||||||
]
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'controller' => \Chill\MainBundle\Controller\PostalCodeAPIController::class,
|
|
||||||
'class' => \Chill\MainBundle\Entity\PostalCode::class,
|
|
||||||
'name' => 'postal_code',
|
|
||||||
'base_path' => '/api/1.0/main/postal-code',
|
|
||||||
'base_role' => 'ROLE_USER',
|
|
||||||
'actions' => [
|
|
||||||
'_index' => [
|
|
||||||
'methods' => [
|
|
||||||
Request::METHOD_GET => true,
|
|
||||||
Request::METHOD_HEAD => true
|
|
||||||
],
|
|
||||||
],
|
|
||||||
'_entity' => [
|
|
||||||
'methods' => [
|
|
||||||
Request::METHOD_GET => true,
|
|
||||||
Request::METHOD_HEAD => true
|
|
||||||
]
|
|
||||||
],
|
|
||||||
]
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'class' => \Chill\MainBundle\Entity\Country::class,
|
|
||||||
'name' => 'country',
|
|
||||||
'base_path' => '/api/1.0/main/country',
|
|
||||||
'base_role' => 'ROLE_USER',
|
|
||||||
'actions' => [
|
|
||||||
'_index' => [
|
|
||||||
'methods' => [
|
|
||||||
Request::METHOD_GET => true,
|
|
||||||
Request::METHOD_HEAD => true
|
|
||||||
],
|
|
||||||
],
|
|
||||||
'_entity' => [
|
|
||||||
'methods' => [
|
|
||||||
Request::METHOD_GET => true,
|
|
||||||
Request::METHOD_HEAD => true
|
|
||||||
]
|
|
||||||
],
|
|
||||||
]
|
|
||||||
]
|
|
||||||
]
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@@ -221,7 +221,6 @@ class Configuration implements ConfigurationInterface
|
|||||||
->booleanNode(Request::METHOD_POST)->defaultFalse()->end()
|
->booleanNode(Request::METHOD_POST)->defaultFalse()->end()
|
||||||
->booleanNode(Request::METHOD_DELETE)->defaultFalse()->end()
|
->booleanNode(Request::METHOD_DELETE)->defaultFalse()->end()
|
||||||
->booleanNode(Request::METHOD_PUT)->defaultFalse()->end()
|
->booleanNode(Request::METHOD_PUT)->defaultFalse()->end()
|
||||||
->booleanNode(Request::METHOD_PATCH)->defaultFalse()->end()
|
|
||||||
->end()
|
->end()
|
||||||
->end()
|
->end()
|
||||||
->arrayNode('roles')
|
->arrayNode('roles')
|
||||||
@@ -233,7 +232,6 @@ class Configuration implements ConfigurationInterface
|
|||||||
->scalarNode(Request::METHOD_POST)->defaultNull()->end()
|
->scalarNode(Request::METHOD_POST)->defaultNull()->end()
|
||||||
->scalarNode(Request::METHOD_DELETE)->defaultNull()->end()
|
->scalarNode(Request::METHOD_DELETE)->defaultNull()->end()
|
||||||
->scalarNode(Request::METHOD_PUT)->defaultNull()->end()
|
->scalarNode(Request::METHOD_PUT)->defaultNull()->end()
|
||||||
->scalarNode(Request::METHOD_PATCH)->defaultNull()->end()
|
|
||||||
->end()
|
->end()
|
||||||
->end()
|
->end()
|
||||||
->end()
|
->end()
|
||||||
|
@@ -1,65 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Chill\MainBundle\Doctrine\Event;
|
|
||||||
|
|
||||||
use Chill\MainBundle\Entity\User;
|
|
||||||
use Doctrine\Common\EventSubscriber;
|
|
||||||
use Doctrine\ORM\Events;
|
|
||||||
use Doctrine\Persistence\Event\LifecycleEventArgs;
|
|
||||||
use Chill\MainBundle\Doctrine\Model\TrackCreationInterface;
|
|
||||||
use Chill\MainBundle\Doctrine\Model\TrackUpdateInterface;
|
|
||||||
use Symfony\Component\Security\Core\Security;
|
|
||||||
|
|
||||||
|
|
||||||
class TrackCreateUpdateSubscriber implements EventSubscriber
|
|
||||||
{
|
|
||||||
private Security $security;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Security $security
|
|
||||||
*/
|
|
||||||
public function __construct(Security $security)
|
|
||||||
{
|
|
||||||
$this->security = $security;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
public function getSubscribedEvents()
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
Events::prePersist,
|
|
||||||
Events::preUpdate
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function prePersist(LifecycleEventArgs $args): void
|
|
||||||
{
|
|
||||||
$object = $args->getObject();
|
|
||||||
|
|
||||||
if ($object instanceof TrackCreationInterface
|
|
||||||
&& $this->security->getUser() instanceof User) {
|
|
||||||
$object->setCreatedBy($this->security->getUser());
|
|
||||||
$object->setCreatedAt(new \DateTimeImmutable('now'));
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->onUpdate($object);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function preUpdate(LifecycleEventArgs $args): void
|
|
||||||
{
|
|
||||||
$object = $args->getObject();
|
|
||||||
|
|
||||||
$this->onUpdate($object);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function onUpdate(object $object): void
|
|
||||||
{
|
|
||||||
if ($object instanceof TrackUpdateInterface
|
|
||||||
&& $this->security->getUser() instanceof User) {
|
|
||||||
$object->setUpdatedBy($this->security->getUser());
|
|
||||||
$object->setUpdatedAt(new \DateTimeImmutable('now'));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -9,11 +9,11 @@ use \JsonSerializable;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
class Point implements JsonSerializable {
|
class Point implements JsonSerializable {
|
||||||
private ?float $lat = null;
|
private float $lat;
|
||||||
private ?float $lon = null;
|
private float $lon;
|
||||||
public static string $SRID = '4326';
|
public static string $SRID = '4326';
|
||||||
|
|
||||||
private function __construct(?float $lon, ?float $lat)
|
private function __construct(float $lon, float $lat)
|
||||||
{
|
{
|
||||||
$this->lat = $lat;
|
$this->lat = $lat;
|
||||||
$this->lon = $lon;
|
$this->lon = $lon;
|
||||||
|
@@ -1,12 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Chill\MainBundle\Doctrine\Model;
|
|
||||||
|
|
||||||
use Chill\MainBundle\Entity\User;
|
|
||||||
|
|
||||||
interface TrackCreationInterface
|
|
||||||
{
|
|
||||||
public function setCreatedBy(User $user): self;
|
|
||||||
|
|
||||||
public function setCreatedAt(\DateTimeInterface $datetime): self;
|
|
||||||
}
|
|
@@ -1,12 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Chill\MainBundle\Doctrine\Model;
|
|
||||||
|
|
||||||
use Chill\MainBundle\Entity\User;
|
|
||||||
|
|
||||||
interface TrackUpdateInterface
|
|
||||||
{
|
|
||||||
public function setUpdatedBy(User $user): self;
|
|
||||||
|
|
||||||
public function setUpdatedAt(\DateTimeInterface $datetime): self;
|
|
||||||
}
|
|
@@ -4,7 +4,6 @@ namespace Chill\MainBundle\Entity;
|
|||||||
|
|
||||||
use Doctrine\ORM\Mapping as ORM;
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
use Symfony\Component\Validator\Context\ExecutionContextInterface;
|
use Symfony\Component\Validator\Context\ExecutionContextInterface;
|
||||||
use Symfony\Component\Serializer\Annotation\Groups;
|
|
||||||
use Chill\MainBundle\Doctrine\Model\Point;
|
use Chill\MainBundle\Doctrine\Model\Point;
|
||||||
use Chill\ThirdPartyBundle\Entity\ThirdParty;
|
use Chill\ThirdPartyBundle\Entity\ThirdParty;
|
||||||
|
|
||||||
@@ -23,7 +22,6 @@ class Address
|
|||||||
* @ORM\Id
|
* @ORM\Id
|
||||||
* @ORM\Column(name="id", type="integer")
|
* @ORM\Column(name="id", type="integer")
|
||||||
* @ORM\GeneratedValue(strategy="AUTO")
|
* @ORM\GeneratedValue(strategy="AUTO")
|
||||||
* @groups({"write"})
|
|
||||||
*/
|
*/
|
||||||
private $id;
|
private $id;
|
||||||
|
|
||||||
@@ -31,7 +29,6 @@ class Address
|
|||||||
* @var string
|
* @var string
|
||||||
*
|
*
|
||||||
* @ORM\Column(type="string", length=255)
|
* @ORM\Column(type="string", length=255)
|
||||||
* @groups({"write"})
|
|
||||||
*/
|
*/
|
||||||
private $street = '';
|
private $street = '';
|
||||||
|
|
||||||
@@ -39,7 +36,6 @@ class Address
|
|||||||
* @var string
|
* @var string
|
||||||
*
|
*
|
||||||
* @ORM\Column(type="string", length=255)
|
* @ORM\Column(type="string", length=255)
|
||||||
* @groups({"write"})
|
|
||||||
*/
|
*/
|
||||||
private $streetNumber = '';
|
private $streetNumber = '';
|
||||||
|
|
||||||
@@ -47,7 +43,6 @@ class Address
|
|||||||
* @var PostalCode
|
* @var PostalCode
|
||||||
*
|
*
|
||||||
* @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\PostalCode")
|
* @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\PostalCode")
|
||||||
* @groups({"write"})
|
|
||||||
*/
|
*/
|
||||||
private $postcode;
|
private $postcode;
|
||||||
|
|
||||||
@@ -55,7 +50,6 @@ class Address
|
|||||||
* @var string|null
|
* @var string|null
|
||||||
*
|
*
|
||||||
* @ORM\Column(type="string", length=16, nullable=true)
|
* @ORM\Column(type="string", length=16, nullable=true)
|
||||||
* @groups({"write"})
|
|
||||||
*/
|
*/
|
||||||
private $floor;
|
private $floor;
|
||||||
|
|
||||||
@@ -63,7 +57,6 @@ class Address
|
|||||||
* @var string|null
|
* @var string|null
|
||||||
*
|
*
|
||||||
* @ORM\Column(type="string", length=16, nullable=true)
|
* @ORM\Column(type="string", length=16, nullable=true)
|
||||||
* @groups({"write"})
|
|
||||||
*/
|
*/
|
||||||
private $corridor;
|
private $corridor;
|
||||||
|
|
||||||
@@ -71,7 +64,6 @@ class Address
|
|||||||
* @var string|null
|
* @var string|null
|
||||||
*
|
*
|
||||||
* @ORM\Column(type="string", length=16, nullable=true)
|
* @ORM\Column(type="string", length=16, nullable=true)
|
||||||
* @groups({"write"})
|
|
||||||
*/
|
*/
|
||||||
private $steps;
|
private $steps;
|
||||||
|
|
||||||
@@ -79,7 +71,6 @@ class Address
|
|||||||
* @var string|null
|
* @var string|null
|
||||||
*
|
*
|
||||||
* @ORM\Column(type="string", length=255, nullable=true)
|
* @ORM\Column(type="string", length=255, nullable=true)
|
||||||
* @groups({"write"})
|
|
||||||
*/
|
*/
|
||||||
private $buildingName;
|
private $buildingName;
|
||||||
|
|
||||||
@@ -87,7 +78,6 @@ class Address
|
|||||||
* @var string|null
|
* @var string|null
|
||||||
*
|
*
|
||||||
* @ORM\Column(type="string", length=16, nullable=true)
|
* @ORM\Column(type="string", length=16, nullable=true)
|
||||||
* @groups({"write"})
|
|
||||||
*/
|
*/
|
||||||
private $flat;
|
private $flat;
|
||||||
|
|
||||||
@@ -95,7 +85,6 @@ class Address
|
|||||||
* @var string|null
|
* @var string|null
|
||||||
*
|
*
|
||||||
* @ORM\Column(type="string", length=255, nullable=true)
|
* @ORM\Column(type="string", length=255, nullable=true)
|
||||||
* @groups({"write"})
|
|
||||||
*/
|
*/
|
||||||
private $distribution;
|
private $distribution;
|
||||||
|
|
||||||
@@ -103,7 +92,6 @@ class Address
|
|||||||
* @var string|null
|
* @var string|null
|
||||||
*
|
*
|
||||||
* @ORM\Column(type="string", length=255, nullable=true)
|
* @ORM\Column(type="string", length=255, nullable=true)
|
||||||
* @groups({"write"})
|
|
||||||
*/
|
*/
|
||||||
private $extra;
|
private $extra;
|
||||||
|
|
||||||
@@ -114,7 +102,6 @@ class Address
|
|||||||
* @var \DateTime
|
* @var \DateTime
|
||||||
*
|
*
|
||||||
* @ORM\Column(type="date")
|
* @ORM\Column(type="date")
|
||||||
* @groups({"write"})
|
|
||||||
*/
|
*/
|
||||||
private $validFrom;
|
private $validFrom;
|
||||||
|
|
||||||
@@ -125,13 +112,11 @@ class Address
|
|||||||
* @var \DateTime|null
|
* @var \DateTime|null
|
||||||
*
|
*
|
||||||
* @ORM\Column(type="date", nullable=true)
|
* @ORM\Column(type="date", nullable=true)
|
||||||
* @groups({"write"})
|
|
||||||
*/
|
*/
|
||||||
private $validTo;
|
private $validTo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* True if the address is a "no address", aka homeless person, ...
|
* True if the address is a "no address", aka homeless person, ...
|
||||||
* @groups({"write"})
|
|
||||||
*
|
*
|
||||||
* @var bool
|
* @var bool
|
||||||
*/
|
*/
|
||||||
@@ -143,7 +128,6 @@ class Address
|
|||||||
* @var Point|null
|
* @var Point|null
|
||||||
*
|
*
|
||||||
* @ORM\Column(type="point", nullable=true)
|
* @ORM\Column(type="point", nullable=true)
|
||||||
* @groups({"write"})
|
|
||||||
*/
|
*/
|
||||||
private $point;
|
private $point;
|
||||||
|
|
||||||
@@ -153,8 +137,7 @@ class Address
|
|||||||
* @var ThirdParty|null
|
* @var ThirdParty|null
|
||||||
*
|
*
|
||||||
* @ORM\ManyToOne(targetEntity="Chill\ThirdPartyBundle\Entity\ThirdParty")
|
* @ORM\ManyToOne(targetEntity="Chill\ThirdPartyBundle\Entity\ThirdParty")
|
||||||
* @groups({"write"})
|
* @ORM\JoinColumn(nullable=true)
|
||||||
* @ORM\JoinColumn(nullable=true, onDelete="SET NULL")
|
|
||||||
*/
|
*/
|
||||||
private $linkedToThirdParty;
|
private $linkedToThirdParty;
|
||||||
|
|
||||||
|
@@ -2,12 +2,12 @@
|
|||||||
|
|
||||||
namespace Chill\MainBundle\Entity;
|
namespace Chill\MainBundle\Entity;
|
||||||
|
|
||||||
|
use Chill\MainBundle\Entity\AddressReferenceRepository;
|
||||||
use Doctrine\ORM\Mapping as ORM;
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
use Chill\MainBundle\Doctrine\Model\Point;
|
use Chill\MainBundle\Doctrine\Model\Point;
|
||||||
use Symfony\Component\Serializer\Annotation\Groups;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\Entity()
|
* @ORM\Entity(repositoryClass=AddressReferenceRepository::class)
|
||||||
* @ORM\Table(name="chill_main_address_reference")
|
* @ORM\Table(name="chill_main_address_reference")
|
||||||
* @ORM\HasLifecycleCallbacks()
|
* @ORM\HasLifecycleCallbacks()
|
||||||
*/
|
*/
|
||||||
@@ -17,25 +17,21 @@ class AddressReference
|
|||||||
* @ORM\Id
|
* @ORM\Id
|
||||||
* @ORM\GeneratedValue
|
* @ORM\GeneratedValue
|
||||||
* @ORM\Column(type="integer")
|
* @ORM\Column(type="integer")
|
||||||
* @groups({"read"})
|
|
||||||
*/
|
*/
|
||||||
private $id;
|
private $id;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\Column(type="string", length=255)
|
* @ORM\Column(type="string", length=255)
|
||||||
* @groups({"read"})
|
|
||||||
*/
|
*/
|
||||||
private $refId;
|
private $refId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\Column(type="string", length=255, nullable=true)
|
* @ORM\Column(type="string", length=255, nullable=true)
|
||||||
* @groups({"read"})
|
|
||||||
*/
|
*/
|
||||||
private $street;
|
private $street;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\Column(type="string", length=255, nullable=true)
|
* @ORM\Column(type="string", length=255, nullable=true)
|
||||||
* @groups({"read"})
|
|
||||||
*/
|
*/
|
||||||
private $streetNumber;
|
private $streetNumber;
|
||||||
|
|
||||||
@@ -43,19 +39,16 @@ class AddressReference
|
|||||||
* @var PostalCode
|
* @var PostalCode
|
||||||
*
|
*
|
||||||
* @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\PostalCode")
|
* @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\PostalCode")
|
||||||
* @groups({"read"})
|
|
||||||
*/
|
*/
|
||||||
private $postcode;
|
private $postcode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\Column(type="string", length=255, nullable=true)
|
* @ORM\Column(type="string", length=255, nullable=true)
|
||||||
* @groups({"read"})
|
|
||||||
*/
|
*/
|
||||||
private $municipalityCode;
|
private $municipalityCode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\Column(type="string", length=255, nullable=true)
|
* @ORM\Column(type="string", length=255, nullable=true)
|
||||||
* @groups({"read"})
|
|
||||||
*/
|
*/
|
||||||
private $source;
|
private $source;
|
||||||
|
|
||||||
@@ -65,7 +58,6 @@ class AddressReference
|
|||||||
* @var Point
|
* @var Point
|
||||||
*
|
*
|
||||||
* @ORM\Column(type="point")
|
* @ORM\Column(type="point")
|
||||||
* @groups({"read"})
|
|
||||||
*/
|
*/
|
||||||
private $point;
|
private $point;
|
||||||
|
|
||||||
|
@@ -3,7 +3,6 @@
|
|||||||
namespace Chill\MainBundle\Entity;
|
namespace Chill\MainBundle\Entity;
|
||||||
|
|
||||||
use Doctrine\ORM\Mapping as ORM;
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
use Symfony\Component\Serializer\Annotation\Groups;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Country
|
* Country
|
||||||
@@ -21,7 +20,6 @@ class Country
|
|||||||
* @ORM\Id
|
* @ORM\Id
|
||||||
* @ORM\Column(name="id", type="integer")
|
* @ORM\Column(name="id", type="integer")
|
||||||
* @ORM\GeneratedValue(strategy="AUTO")
|
* @ORM\GeneratedValue(strategy="AUTO")
|
||||||
* @groups({"read"})
|
|
||||||
*/
|
*/
|
||||||
private $id;
|
private $id;
|
||||||
|
|
||||||
@@ -29,16 +27,13 @@ class Country
|
|||||||
* @var string
|
* @var string
|
||||||
*
|
*
|
||||||
* @ORM\Column(type="json_array")
|
* @ORM\Column(type="json_array")
|
||||||
* @groups({"read"})
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
private $name;
|
private $name;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string
|
* @var string
|
||||||
*
|
*
|
||||||
* @ORM\Column(type="string", length=3)
|
* @ORM\Column(type="string", length=3)
|
||||||
* @groups({"read"})
|
|
||||||
*/
|
*/
|
||||||
private $countryCode;
|
private $countryCode;
|
||||||
|
|
||||||
@@ -46,7 +41,7 @@ class Country
|
|||||||
/**
|
/**
|
||||||
* Get id
|
* Get id
|
||||||
*
|
*
|
||||||
* @return integer
|
* @return integer
|
||||||
*/
|
*/
|
||||||
public function getId()
|
public function getId()
|
||||||
{
|
{
|
||||||
@@ -62,20 +57,20 @@ class Country
|
|||||||
public function setName($name)
|
public function setName($name)
|
||||||
{
|
{
|
||||||
$this->name = $name;
|
$this->name = $name;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get name
|
* Get name
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getName()
|
public function getName()
|
||||||
{
|
{
|
||||||
return $this->name;
|
return $this->name;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
@@ -95,12 +90,12 @@ class Country
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param string $countryCode
|
* @param string $countryCode
|
||||||
*/
|
*/
|
||||||
public function setCountryCode($countryCode)
|
public function setCountryCode($countryCode)
|
||||||
{
|
{
|
||||||
$this->countryCode = $countryCode;
|
$this->countryCode = $countryCode;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -3,7 +3,6 @@
|
|||||||
namespace Chill\MainBundle\Entity;
|
namespace Chill\MainBundle\Entity;
|
||||||
|
|
||||||
use Doctrine\ORM\Mapping as ORM;
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
use Symfony\Component\Serializer\Annotation\Groups;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PostalCode
|
* PostalCode
|
||||||
@@ -26,7 +25,6 @@ class PostalCode
|
|||||||
* @ORM\Id
|
* @ORM\Id
|
||||||
* @ORM\Column(name="id", type="integer")
|
* @ORM\Column(name="id", type="integer")
|
||||||
* @ORM\GeneratedValue(strategy="AUTO")
|
* @ORM\GeneratedValue(strategy="AUTO")
|
||||||
* @groups({"read"})
|
|
||||||
*/
|
*/
|
||||||
private $id;
|
private $id;
|
||||||
|
|
||||||
@@ -34,7 +32,6 @@ class PostalCode
|
|||||||
* @var string
|
* @var string
|
||||||
*
|
*
|
||||||
* @ORM\Column(type="string", length=255, name="label")
|
* @ORM\Column(type="string", length=255, name="label")
|
||||||
* @groups({"read"})
|
|
||||||
*/
|
*/
|
||||||
private $name;
|
private $name;
|
||||||
|
|
||||||
@@ -42,7 +39,6 @@ class PostalCode
|
|||||||
* @var string
|
* @var string
|
||||||
*
|
*
|
||||||
* @ORM\Column(type="string", length=100)
|
* @ORM\Column(type="string", length=100)
|
||||||
* @groups({"read"})
|
|
||||||
*/
|
*/
|
||||||
private $code;
|
private $code;
|
||||||
|
|
||||||
@@ -50,7 +46,6 @@ class PostalCode
|
|||||||
* @var Country
|
* @var Country
|
||||||
*
|
*
|
||||||
* @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\Country")
|
* @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\Country")
|
||||||
* @groups({"read"})
|
|
||||||
*/
|
*/
|
||||||
private $country;
|
private $country;
|
||||||
|
|
||||||
|
@@ -24,16 +24,13 @@ use Doctrine\ORM\Mapping as ORM;
|
|||||||
use Doctrine\Common\Collections\Collection;
|
use Doctrine\Common\Collections\Collection;
|
||||||
use Doctrine\Common\Collections\ArrayCollection;
|
use Doctrine\Common\Collections\ArrayCollection;
|
||||||
use Chill\MainBundle\Entity\RoleScope;
|
use Chill\MainBundle\Entity\RoleScope;
|
||||||
use Symfony\Component\Serializer\Annotation\Groups;
|
|
||||||
use Symfony\Component\Serializer\Annotation\DiscriminatorMap;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\Entity()
|
* @ORM\Entity()
|
||||||
* @ORM\Table(name="scopes")
|
* @ORM\Table(name="scopes")
|
||||||
* @ORM\Cache(usage="NONSTRICT_READ_WRITE", region="acl_cache_region")
|
* @ORM\Cache(usage="NONSTRICT_READ_WRITE", region="acl_cache_region")
|
||||||
* @DiscriminatorMap(typeProperty="type", mapping={
|
*
|
||||||
* "scope"=Scope::class
|
* @author Julien Fastré <julien.fastre@champs-libres.coop>
|
||||||
* })
|
|
||||||
*/
|
*/
|
||||||
class Scope
|
class Scope
|
||||||
{
|
{
|
||||||
@@ -43,7 +40,6 @@ class Scope
|
|||||||
* @ORM\Id
|
* @ORM\Id
|
||||||
* @ORM\Column(name="id", type="integer")
|
* @ORM\Column(name="id", type="integer")
|
||||||
* @ORM\GeneratedValue(strategy="AUTO")
|
* @ORM\GeneratedValue(strategy="AUTO")
|
||||||
* @Groups({"read"})
|
|
||||||
*/
|
*/
|
||||||
private $id;
|
private $id;
|
||||||
|
|
||||||
@@ -53,7 +49,6 @@ class Scope
|
|||||||
* @var array
|
* @var array
|
||||||
*
|
*
|
||||||
* @ORM\Column(type="json_array")
|
* @ORM\Column(type="json_array")
|
||||||
* @Groups({"read"})
|
|
||||||
*/
|
*/
|
||||||
private $name = [];
|
private $name = [];
|
||||||
|
|
||||||
|
@@ -7,7 +7,6 @@ use Doctrine\Common\Collections\Collection;
|
|||||||
use Doctrine\Common\Collections\ArrayCollection;
|
use Doctrine\Common\Collections\ArrayCollection;
|
||||||
use Symfony\Component\Security\Core\User\AdvancedUserInterface;
|
use Symfony\Component\Security\Core\User\AdvancedUserInterface;
|
||||||
use Symfony\Component\Validator\Context\ExecutionContextInterface;
|
use Symfony\Component\Validator\Context\ExecutionContextInterface;
|
||||||
use Symfony\Component\Serializer\Annotation\DiscriminatorMap;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* User
|
* User
|
||||||
@@ -15,9 +14,6 @@ use Symfony\Component\Serializer\Annotation\DiscriminatorMap;
|
|||||||
* @ORM\Entity(repositoryClass="Chill\MainBundle\Repository\UserRepository")
|
* @ORM\Entity(repositoryClass="Chill\MainBundle\Repository\UserRepository")
|
||||||
* @ORM\Table(name="users")
|
* @ORM\Table(name="users")
|
||||||
* @ORM\Cache(usage="NONSTRICT_READ_WRITE", region="acl_cache_region")
|
* @ORM\Cache(usage="NONSTRICT_READ_WRITE", region="acl_cache_region")
|
||||||
* @DiscriminatorMap(typeProperty="type", mapping={
|
|
||||||
* "user"=User::class
|
|
||||||
* })
|
|
||||||
*/
|
*/
|
||||||
class User implements AdvancedUserInterface {
|
class User implements AdvancedUserInterface {
|
||||||
|
|
||||||
|
@@ -23,7 +23,7 @@
|
|||||||
// @import "bootstrap/scss/button-group";
|
// @import "bootstrap/scss/button-group";
|
||||||
// @import "bootstrap/scss/input-group";
|
// @import "bootstrap/scss/input-group";
|
||||||
// @import "bootstrap/scss/custom-forms";
|
// @import "bootstrap/scss/custom-forms";
|
||||||
@import "bootstrap/scss/nav";
|
// @import "bootstrap/scss/nav";
|
||||||
// @import "bootstrap/scss/navbar";
|
// @import "bootstrap/scss/navbar";
|
||||||
// @import "bootstrap/scss/card";
|
// @import "bootstrap/scss/card";
|
||||||
// @import "bootstrap/scss/breadcrumb";
|
// @import "bootstrap/scss/breadcrumb";
|
||||||
|
@@ -9,12 +9,6 @@ div.chill_address {
|
|||||||
margin: 0 0 0 1.5em;
|
margin: 0 0 0 1.5em;
|
||||||
text-indent: -1.5em;
|
text-indent: -1.5em;
|
||||||
}
|
}
|
||||||
|
|
||||||
&.chill_address_address--multiline {
|
|
||||||
p {
|
|
||||||
display: block;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -9,11 +9,6 @@ ul.record_actions li {
|
|||||||
ul.record_actions, ul.record_actions_column {
|
ul.record_actions, ul.record_actions_column {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: flex-end;
|
justify-content: flex-end;
|
||||||
|
|
||||||
&.record_actions--left {
|
|
||||||
justify-content: flex-start;
|
|
||||||
}
|
|
||||||
|
|
||||||
padding: 0.5em 0;
|
padding: 0.5em 0;
|
||||||
flex-wrap: wrap-reverse;
|
flex-wrap: wrap-reverse;
|
||||||
|
|
||||||
|
@@ -1,57 +1,21 @@
|
|||||||
/*
|
/*
|
||||||
* NOTE 2021.04
|
* NOTE 2021.04
|
||||||
* scss/chillmain.scss is the main sass file for the new chill.2
|
* scss/chill.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
|
* scratch will be replaced by bootstrap, please avoid to edit in modules/scratch/_custom.scss
|
||||||
*
|
*
|
||||||
* when possible, try to use bootstrap html class
|
* when possible, try to use bootstrap class naming
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/* [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;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Specific rules
|
|
||||||
*/
|
|
||||||
|
|
||||||
// [scratch] un bouton 'disabled' non clickable
|
|
||||||
.sc-button {
|
|
||||||
&.disabled {
|
|
||||||
cursor: default;
|
|
||||||
&.bt-remove {
|
|
||||||
background-color: #d9d9d9;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// [debug] un affichage discret pour le debug
|
|
||||||
.discret {
|
|
||||||
color: grey;
|
|
||||||
margin-right: 1em;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 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
|
* Header custom for Accompanying Course
|
||||||
*/
|
*/
|
||||||
|
|
||||||
div#header-accompanying_course-name {
|
div#header-accompanying_course-name {
|
||||||
background: none repeat scroll 0 0 #718596;
|
background: none repeat scroll 0 0 #718596;
|
||||||
color: #FFF;
|
color: #FFF;
|
||||||
h1 {
|
padding-top: 1em;
|
||||||
margin: 0.4em 0;
|
padding-bottom: 1em;
|
||||||
}
|
|
||||||
span {
|
span {
|
||||||
a {
|
a {
|
||||||
color: white;
|
color: white;
|
||||||
@@ -61,6 +25,7 @@ div#header-accompanying_course-name {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
div#header-accompanying_course-details {
|
div#header-accompanying_course-details {
|
||||||
background: none repeat scroll 0 0 #718596ab;
|
background: none repeat scroll 0 0 #718596ab;
|
||||||
color: #FFF;
|
color: #FFF;
|
||||||
@@ -68,196 +33,121 @@ div#header-accompanying_course-details {
|
|||||||
padding-bottom: 1em;
|
padding-bottom: 1em;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/* /!\ Contourne le positionnement problématique du div#content_conainter suivant,
|
||||||
* FLEX RESPONSIVE TABLE/BLOCK PRESENTATION
|
* car sa position: relative le place au-dessus du bandeau et les liens sont incliquables */
|
||||||
*/
|
div.subheader {
|
||||||
div.flex-bloc,
|
height: 130px;
|
||||||
div.flex-table {
|
|
||||||
h2, h3, h4, dl, p {
|
|
||||||
margin: 0;
|
|
||||||
}
|
|
||||||
h2, h3, h4 {
|
|
||||||
color: var(--chill-blue);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//// 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;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Bloc appearance
|
* 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.
|
||||||
*/
|
*/
|
||||||
div.flex-bloc {
|
.modal-enter {
|
||||||
box-sizing: border-box;
|
opacity: 0;
|
||||||
display: flex;
|
}
|
||||||
flex-direction: row;
|
.modal-leave-active {
|
||||||
flex-wrap: wrap;
|
opacity: 0;
|
||||||
align-items: stretch;
|
}
|
||||||
align-content: stretch;
|
.modal-enter .modal-container,
|
||||||
|
.modal-leave-active .modal-container {
|
||||||
|
-webkit-transform: scale(1.1);
|
||||||
|
transform: scale(1.1);
|
||||||
|
}
|
||||||
|
|
||||||
div.item-bloc {
|
//// AddPersons modal
|
||||||
flex-grow: 0; flex-shrink: 1; flex-basis: 50%;
|
div.modal-body.up {
|
||||||
|
margin: auto 4em;
|
||||||
margin: 0;
|
div.search {
|
||||||
border: 1px solid #000;
|
position: relative;
|
||||||
padding: 1em;
|
input {
|
||||||
|
padding: 1.2em 1.5em 1.2em 2.5em;
|
||||||
border-top: 0;
|
margin: 1em 0;
|
||||||
&:nth-child(1), &:nth-child(2) {
|
|
||||||
border-top: 1px solid #000;
|
|
||||||
}
|
}
|
||||||
border-left: 0;
|
i {
|
||||||
&:nth-child(odd) {
|
position: absolute;
|
||||||
border-left: 1px solid #000;
|
top: 50%;
|
||||||
|
left: 0.5em;
|
||||||
|
padding: 0.65em 0;
|
||||||
|
opacity: 0.5;
|
||||||
}
|
}
|
||||||
|
|
||||||
//background-color: #e6e6e6;
|
}
|
||||||
|
}
|
||||||
|
div.results {
|
||||||
|
div.count {
|
||||||
|
margin: -0.5em 0 0.7em;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
justify-content: space-between;
|
||||||
|
|
||||||
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; }
|
div.list-item {
|
||||||
@media only screen and (max-width: 935px) { margin: auto -0.5em; }
|
line-height: 26pt;
|
||||||
@media only screen and (max-width: 920px) { margin: auto -0.9em; }
|
padding: 0.3em 0.8em;
|
||||||
@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; }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Address form
|
|
||||||
*/
|
|
||||||
div.address_form {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
div.address_form__header {
|
|
||||||
|
|
||||||
}
|
|
||||||
div.address_form__select {
|
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
justify-content: space-between;
|
&.checked {
|
||||||
|
background-color: #ececec;
|
||||||
div.address_form__select__body {
|
border-bottom: 1px dotted #8b8b8b;
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
flex-grow: 1;
|
|
||||||
}
|
}
|
||||||
|
div.container {
|
||||||
div.address_form__select__map {
|
& > input {
|
||||||
margin: 0px 20px;
|
margin-right: 0.8em;
|
||||||
div#address_map {
|
|
||||||
height:400px;
|
|
||||||
width:400px;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
div.right_actions {
|
||||||
div.address_form__more {
|
margin: 0 0 0 auto;
|
||||||
|
& > * {
|
||||||
|
margin-left: 0.5em;
|
||||||
|
}
|
||||||
|
a.sc-button {
|
||||||
|
border: 1px solid lightgrey;
|
||||||
|
font-size: 70%;
|
||||||
|
padding: 4px;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.discret {
|
||||||
|
color: grey;
|
||||||
|
margin-right: 1em;
|
||||||
|
}
|
||||||
|
@@ -1,60 +0,0 @@
|
|||||||
<template>
|
|
||||||
|
|
||||||
<div v-if="address.address">
|
|
||||||
{{ address.address.street }}, {{ address.address.streetNumber }}
|
|
||||||
</div>
|
|
||||||
<div v-if="address.city">
|
|
||||||
{{ address.city.code }} {{ address.city.name }}
|
|
||||||
</div>
|
|
||||||
<div v-if="address.country">
|
|
||||||
{{ address.country.name }}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<add-address
|
|
||||||
@addNewAddress="addNewAddress">
|
|
||||||
</add-address>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
import { mapState } from 'vuex';
|
|
||||||
|
|
||||||
import AddAddress from '../_components/AddAddress.vue';
|
|
||||||
|
|
||||||
export default {
|
|
||||||
name: 'App',
|
|
||||||
components: {
|
|
||||||
AddAddress
|
|
||||||
},
|
|
||||||
computed: {
|
|
||||||
address() {
|
|
||||||
return this.$store.state.address;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
addNewAddress({ address, modal }) {
|
|
||||||
console.log('@@@ CLICK button addNewAdress', address);
|
|
||||||
|
|
||||||
let newAddress = {
|
|
||||||
'isNoAddress': address.isNoAddress,
|
|
||||||
'street': address.selected.address.street,
|
|
||||||
'streetNumber': address.selected.address.streetNumber,
|
|
||||||
'postcode': {'id': address.selected.city.id },
|
|
||||||
'floor': address.floor,
|
|
||||||
'corridor': address.corridor,
|
|
||||||
'steps': address.steps,
|
|
||||||
'flat': address.flat,
|
|
||||||
'buildingName': address.buildingName,
|
|
||||||
'distribution': address.distribution,
|
|
||||||
'extra': address.extra
|
|
||||||
};
|
|
||||||
|
|
||||||
if (address.selected.address.point !== undefined){
|
|
||||||
newAddress = Object.assign(newAddress, {'point': address.selected.address.point.coordinates});
|
|
||||||
}
|
|
||||||
|
|
||||||
this.$store.dispatch('addAddress', newAddress);
|
|
||||||
modal.showModal = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
</script>
|
|
@@ -1,16 +0,0 @@
|
|||||||
import { createApp } from 'vue'
|
|
||||||
import { _createI18n } from 'ChillMainAssets/vuejs/_js/i18n'
|
|
||||||
import { addressMessages } from './js/i18n'
|
|
||||||
import { store } from './store'
|
|
||||||
|
|
||||||
import App from './App.vue';
|
|
||||||
|
|
||||||
const i18n = _createI18n(addressMessages);
|
|
||||||
|
|
||||||
const app = createApp({
|
|
||||||
template: `<app></app>`,
|
|
||||||
})
|
|
||||||
.use(store)
|
|
||||||
.use(i18n)
|
|
||||||
.component('app', App)
|
|
||||||
.mount('#address');
|
|
@@ -1,23 +0,0 @@
|
|||||||
const addressMessages = {
|
|
||||||
fr: {
|
|
||||||
add_an_address_title: 'Ajouter une adresse',
|
|
||||||
select_an_address_title: 'Sélectionner une adresse',
|
|
||||||
fill_an_address: 'Compléter l\'adresse',
|
|
||||||
select_country: 'Choisir le pays',
|
|
||||||
select_city: 'Choisir une localité',
|
|
||||||
select_address: 'Choisir une adresse',
|
|
||||||
create_address: 'Appuyer sur "Entrée" pour créer une nouvelle adresse',
|
|
||||||
isNoAddress: 'Pas d\'adresse complète',
|
|
||||||
floor: 'Étage',
|
|
||||||
corridor: 'Couloir',
|
|
||||||
steps: 'Escalier',
|
|
||||||
flat: 'Appartement',
|
|
||||||
buildingName: 'Nom du batiment',
|
|
||||||
extra: 'Complément d\'adresse',
|
|
||||||
distribution: 'Service particulier de distribution'
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
export {
|
|
||||||
addressMessages
|
|
||||||
};
|
|
@@ -1,45 +0,0 @@
|
|||||||
import 'es6-promise/auto';
|
|
||||||
import { createStore } from 'vuex';
|
|
||||||
|
|
||||||
import { postAddress } from '../../_api/AddAddress'
|
|
||||||
|
|
||||||
const debug = process.env.NODE_ENV !== 'production';
|
|
||||||
|
|
||||||
const store = createStore({
|
|
||||||
strict: debug,
|
|
||||||
state: {
|
|
||||||
address: {},
|
|
||||||
errorMsg: []
|
|
||||||
},
|
|
||||||
getters: {
|
|
||||||
},
|
|
||||||
mutations: {
|
|
||||||
catchError(state, error) {
|
|
||||||
state.errorMsg.push(error);
|
|
||||||
},
|
|
||||||
addAddress(state, address) {
|
|
||||||
console.log('@M addAddress address', address);
|
|
||||||
state.address = address;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
actions: {
|
|
||||||
addAddress({ commit }, payload) {
|
|
||||||
console.log('@A addAddress payload', payload);
|
|
||||||
//commit('addAddress', payload); // à remplacer par la suite
|
|
||||||
|
|
||||||
//fetch POST qui envoie l'adresse, et récupère la confirmation que c'est ok.
|
|
||||||
//La confirmation est l'adresse elle-même.
|
|
||||||
|
|
||||||
postAddress(payload)
|
|
||||||
.then(address => new Promise((resolve, reject) => {
|
|
||||||
commit('addAddress', address);
|
|
||||||
resolve();
|
|
||||||
}))
|
|
||||||
.catch((error) => {
|
|
||||||
commit('catchError', error);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
export { store };
|
|
@@ -1,75 +0,0 @@
|
|||||||
/*
|
|
||||||
* Endpoint chill_api_single_country__index
|
|
||||||
* method GET, get Country Object
|
|
||||||
* @returns {Promise} a promise containing all Country object
|
|
||||||
*/
|
|
||||||
const fetchCountries = () => {
|
|
||||||
console.log('<<< fetching countries');
|
|
||||||
|
|
||||||
const url = `/api/1.0/main/country.json?item_per_page=1000`;
|
|
||||||
return fetch(url)
|
|
||||||
.then(response => {
|
|
||||||
if (response.ok) { return response.json(); }
|
|
||||||
throw Error('Error with request resource response');
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Endpoint chill_api_single_postal_code__index
|
|
||||||
* method GET, get Country Object
|
|
||||||
* @returns {Promise} a promise containing all Postal Code objects filtered with country
|
|
||||||
*/
|
|
||||||
const fetchCities = (country) => {
|
|
||||||
console.log('<<< fetching cities for', country);
|
|
||||||
const url = `/api/1.0/main/postal-code.json?item_per_page=1000&country=${country.id}`;
|
|
||||||
return fetch(url)
|
|
||||||
.then(response => {
|
|
||||||
if (response.ok) { return response.json(); }
|
|
||||||
throw Error('Error with request resource response');
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Endpoint chill_api_single_address_reference__index
|
|
||||||
* method GET, get AddressReference Object
|
|
||||||
* @returns {Promise} a promise containing all AddressReference objects filtered with postal code
|
|
||||||
*/
|
|
||||||
const fetchReferenceAddresses = (postalCode) => {
|
|
||||||
console.log('<<< fetching references addresses for', postalCode);
|
|
||||||
//TODO deal with huge number of addresses... we should do suggestion...
|
|
||||||
const url = `/api/1.0/main/address-reference.json?item_per_page=1000&postal_code=${postalCode.id}`;
|
|
||||||
return fetch(url)
|
|
||||||
.then(response => {
|
|
||||||
if (response.ok) { return response.json(); }
|
|
||||||
throw Error('Error with request resource response');
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Endpoint chill_api_single_address__entity__create
|
|
||||||
* method POST, post Address Object
|
|
||||||
* @returns {Promise}
|
|
||||||
*/
|
|
||||||
const postAddress = (address) => {
|
|
||||||
console.log(address);
|
|
||||||
const url = `/api/1.0/main/address.json?`;
|
|
||||||
const body = address;
|
|
||||||
|
|
||||||
return fetch(url, {
|
|
||||||
method: 'POST',
|
|
||||||
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 {
|
|
||||||
fetchCountries,
|
|
||||||
fetchCities,
|
|
||||||
fetchReferenceAddresses,
|
|
||||||
postAddress
|
|
||||||
};
|
|
@@ -1,205 +0,0 @@
|
|||||||
<template>
|
|
||||||
<button class="sc-button bt-create centered mt-4" @click="openModal">
|
|
||||||
{{ $t('add_an_address_title') }}
|
|
||||||
</button>
|
|
||||||
|
|
||||||
<teleport to="body">
|
|
||||||
<modal v-if="modal.showModal"
|
|
||||||
v-bind:modalDialogClass="modal.modalDialogClass"
|
|
||||||
@close="modal.showModal = false">
|
|
||||||
|
|
||||||
<template v-slot:header>
|
|
||||||
<h3 class="modal-title">{{ $t('add_an_address_title') }}</h3>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<template v-slot:body>
|
|
||||||
<div class="address_form">
|
|
||||||
|
|
||||||
<div class="address_form__header">
|
|
||||||
<h4>{{ $t('select_an_address_title') }}</h4>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="address_form__select">
|
|
||||||
|
|
||||||
<div class="address_form__select__body">
|
|
||||||
<label for="isNoAddress">
|
|
||||||
<input type="checkbox"
|
|
||||||
name="isNoAddress"
|
|
||||||
v-bind:placeholder="$t('isNoAddress')"
|
|
||||||
v-model="isNoAddress"
|
|
||||||
v-bind:value="value"/>
|
|
||||||
{{ $t('isNoAddress') }}
|
|
||||||
</label>
|
|
||||||
|
|
||||||
<country-selection
|
|
||||||
v-bind:address="address"
|
|
||||||
v-bind:getCities="getCities">
|
|
||||||
</country-selection>
|
|
||||||
|
|
||||||
<city-selection
|
|
||||||
v-bind:address="address"
|
|
||||||
v-bind:getReferenceAddresses="getReferenceAddresses">
|
|
||||||
</city-selection>
|
|
||||||
|
|
||||||
<address-selection
|
|
||||||
v-bind:address="address"
|
|
||||||
v-bind:updateMapCenter="updateMapCenter">
|
|
||||||
</address-selection>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="address_form__select__map">
|
|
||||||
<address-map
|
|
||||||
v-bind:address="address"
|
|
||||||
ref="addressMap">
|
|
||||||
</address-map>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="address_form__more">
|
|
||||||
<address-more
|
|
||||||
v-if="!isNoAddress"
|
|
||||||
v-bind:address="address">
|
|
||||||
</address-more>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<template v-slot:footer>
|
|
||||||
<button class="sc-button green"
|
|
||||||
@click.prevent="$emit('addNewAddress', { address, modal })">
|
|
||||||
<i class="fa fa-plus fa-fw"></i>{{ $t('action.add')}}
|
|
||||||
</button>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
</modal>
|
|
||||||
</teleport>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
import Modal from './Modal';
|
|
||||||
import { fetchCountries, fetchCities, fetchReferenceAddresses } from '../_api/AddAddress'
|
|
||||||
import CountrySelection from './AddAddress/CountrySelection';
|
|
||||||
import CitySelection from './AddAddress/CitySelection';
|
|
||||||
import AddressSelection from './AddAddress/AddressSelection';
|
|
||||||
import AddressMap from './AddAddress/AddressMap';
|
|
||||||
import AddressMore from './AddAddress/AddressMore'
|
|
||||||
|
|
||||||
export default {
|
|
||||||
name: 'AddAddresses',
|
|
||||||
components: {
|
|
||||||
Modal,
|
|
||||||
CountrySelection,
|
|
||||||
CitySelection,
|
|
||||||
AddressSelection,
|
|
||||||
AddressMap,
|
|
||||||
AddressMore
|
|
||||||
},
|
|
||||||
props: [
|
|
||||||
],
|
|
||||||
emits: ['addNewAddress'],
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
modal: {
|
|
||||||
showModal: false,
|
|
||||||
modalDialogClass: "modal-dialog-scrollable modal-xl"
|
|
||||||
},
|
|
||||||
address: {
|
|
||||||
loaded: {
|
|
||||||
countries: [],
|
|
||||||
cities: [],
|
|
||||||
addresses: [],
|
|
||||||
},
|
|
||||||
selected: {
|
|
||||||
country: {},
|
|
||||||
city: {},
|
|
||||||
address: {},
|
|
||||||
},
|
|
||||||
addressMap: {
|
|
||||||
center : [48.8589, 2.3469], // Note: LeafletJs demands [lat, lon] cfr https://macwright.com/lonlat/
|
|
||||||
zoom: 12
|
|
||||||
},
|
|
||||||
isNoAddress: false,
|
|
||||||
floor: null,
|
|
||||||
corridor: null,
|
|
||||||
steps: null,
|
|
||||||
floor: null,
|
|
||||||
flat: null,
|
|
||||||
buildingName: null,
|
|
||||||
extra: null,
|
|
||||||
distribution: null,
|
|
||||||
},
|
|
||||||
errorMsg: {}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
computed: {
|
|
||||||
isNoAddress: {
|
|
||||||
set(value) {
|
|
||||||
console.log('value', value);
|
|
||||||
this.address.isNoAddress = value;
|
|
||||||
},
|
|
||||||
get() {
|
|
||||||
return this.address.isNoAddress;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
mounted() {
|
|
||||||
this.getCountries();
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
openModal() {
|
|
||||||
this.modal.showModal = true;
|
|
||||||
this.resetAll();
|
|
||||||
//this.$nextTick(function() {
|
|
||||||
// this.$refs.search.focus(); // positionner le curseur à l'ouverture de la modale
|
|
||||||
//})
|
|
||||||
},
|
|
||||||
getCountries() {
|
|
||||||
console.log('getCountries');
|
|
||||||
fetchCountries().then(countries => new Promise((resolve, reject) => {
|
|
||||||
this.address.loaded.countries = countries.results;
|
|
||||||
resolve()
|
|
||||||
}))
|
|
||||||
.catch((error) => {
|
|
||||||
this.errorMsg.push(error.message);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
getCities(country) {
|
|
||||||
console.log('getCities for', country.name);
|
|
||||||
fetchCities(country).then(cities => new Promise((resolve, reject) => {
|
|
||||||
this.address.loaded.cities = cities.results;
|
|
||||||
resolve()
|
|
||||||
}))
|
|
||||||
.catch((error) => {
|
|
||||||
this.errorMsg.push(error.message);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
getReferenceAddresses(city) {
|
|
||||||
console.log('getReferenceAddresses for', city.name);
|
|
||||||
fetchReferenceAddresses(city).then(addresses => new Promise((resolve, reject) => {
|
|
||||||
console.log('addresses', addresses);
|
|
||||||
this.address.loaded.addresses = addresses.results;
|
|
||||||
resolve();
|
|
||||||
}))
|
|
||||||
.catch((error) => {
|
|
||||||
this.errorMsg.push(error.message);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
updateMapCenter(point) {
|
|
||||||
console.log('point', point);
|
|
||||||
this.address.addressMap.center[0] = point.coordinates[1]; // TODO use reverse()
|
|
||||||
this.address.addressMap.center[1] = point.coordinates[0];
|
|
||||||
this.$refs.addressMap.update(); // cast child methods
|
|
||||||
},
|
|
||||||
resetAll() {
|
|
||||||
console.log('reset all selected');
|
|
||||||
this.address.loaded.addresses = [];
|
|
||||||
this.address.selected.address = {};
|
|
||||||
this.address.loaded.cities = [];
|
|
||||||
this.address.selected.city = {};
|
|
||||||
this.address.selected.country = {};
|
|
||||||
console.log('cities and addresses', this.address.loaded.cities, this.address.loaded.addresses);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
@@ -1,50 +0,0 @@
|
|||||||
<template>
|
|
||||||
<div class="container">
|
|
||||||
<div id='address_map'></div>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
|
|
||||||
import L from 'leaflet';
|
|
||||||
import markerIconPng from 'leaflet/dist/images/marker-icon.png'
|
|
||||||
import 'leaflet/dist/leaflet.css';
|
|
||||||
|
|
||||||
let map;
|
|
||||||
let marker;
|
|
||||||
|
|
||||||
export default {
|
|
||||||
name: 'AddressMap',
|
|
||||||
props: ['address'],
|
|
||||||
computed: {
|
|
||||||
center() {
|
|
||||||
return this.address.addressMap.center;
|
|
||||||
},
|
|
||||||
},
|
|
||||||
methods:{
|
|
||||||
init() {
|
|
||||||
map = L.map('address_map').setView([48.8589, 2.3469], 12);
|
|
||||||
|
|
||||||
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
|
|
||||||
attribution: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
|
|
||||||
}).addTo(map);
|
|
||||||
|
|
||||||
const markerIcon = L.icon({
|
|
||||||
iconUrl: markerIconPng,
|
|
||||||
iconAnchor: [12, 41],
|
|
||||||
});
|
|
||||||
|
|
||||||
marker = L.marker([48.8589, 2.3469], {icon: markerIcon}).addTo(map);
|
|
||||||
|
|
||||||
},
|
|
||||||
update() {
|
|
||||||
console.log('update map with : ', this.address.addressMap.center)
|
|
||||||
marker.setLatLng(this.address.addressMap.center);
|
|
||||||
map.setView(this.address.addressMap.center, 12);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
mounted(){
|
|
||||||
this.init()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
@@ -1,112 +0,0 @@
|
|||||||
<template>
|
|
||||||
<div>
|
|
||||||
<h4>{{ $t('fill_an_address') }}</h4>
|
|
||||||
<input
|
|
||||||
type="text"
|
|
||||||
name="floor"
|
|
||||||
:placeholder="$t('floor')"
|
|
||||||
v-model="floor"/>
|
|
||||||
<input
|
|
||||||
type="text"
|
|
||||||
name="corridor"
|
|
||||||
:placeholder="$t('corridor')"
|
|
||||||
v-model="corridor"/>
|
|
||||||
<input
|
|
||||||
type="text"
|
|
||||||
name="steps"
|
|
||||||
:placeholder="$t('steps')"
|
|
||||||
v-model="steps"/>
|
|
||||||
<input
|
|
||||||
type="text"
|
|
||||||
name="flat"
|
|
||||||
:placeholder="$t('flat')"
|
|
||||||
v-model="flat"/>
|
|
||||||
<input
|
|
||||||
type="text"
|
|
||||||
name="buildingName"
|
|
||||||
:placeholder="$t('buildingName')"
|
|
||||||
v-model="buildingName"/>
|
|
||||||
<input
|
|
||||||
type="text"
|
|
||||||
name="extra"
|
|
||||||
:placeholder="$t('extra')"
|
|
||||||
v-model="extra"/>
|
|
||||||
<input
|
|
||||||
type="text"
|
|
||||||
name="distribution"
|
|
||||||
:placeholder="$t('distribution')"
|
|
||||||
v-model="distribution"/>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
export default {
|
|
||||||
name: "AddressMore",
|
|
||||||
props: ['address'],
|
|
||||||
computed: {
|
|
||||||
floor: {
|
|
||||||
set(value) {
|
|
||||||
console.log('value', value);
|
|
||||||
this.address.floor = value;
|
|
||||||
},
|
|
||||||
get() {
|
|
||||||
return this.address.floor;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
corridor: {
|
|
||||||
set(value) {
|
|
||||||
console.log('value', value);
|
|
||||||
this.address.corridor = value;
|
|
||||||
},
|
|
||||||
get() {
|
|
||||||
return this.address.corridor;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
steps: {
|
|
||||||
set(value) {
|
|
||||||
console.log('value', value);
|
|
||||||
this.address.steps = value;
|
|
||||||
},
|
|
||||||
get() {
|
|
||||||
return this.address.steps;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
flat: {
|
|
||||||
set(value) {
|
|
||||||
console.log('value', value);
|
|
||||||
this.address.flat = value;
|
|
||||||
},
|
|
||||||
get() {
|
|
||||||
return this.address.flat;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
buildingName: {
|
|
||||||
set(value) {
|
|
||||||
console.log('value', value);
|
|
||||||
this.address.buildingName = value;
|
|
||||||
},
|
|
||||||
get() {
|
|
||||||
return this.address.buildingName;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
extra: {
|
|
||||||
set(value) {
|
|
||||||
console.log('value', value);
|
|
||||||
this.address.extra = value;
|
|
||||||
},
|
|
||||||
get() {
|
|
||||||
return this.address.extra;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
distribution: {
|
|
||||||
set(value) {
|
|
||||||
console.log('value', value);
|
|
||||||
this.address.distribution = value;
|
|
||||||
},
|
|
||||||
get() {
|
|
||||||
return this.address.distribution;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
@@ -1,56 +0,0 @@
|
|||||||
<template>
|
|
||||||
<div class="container">
|
|
||||||
<VueMultiselect
|
|
||||||
v-model="value"
|
|
||||||
@select="selectAddress"
|
|
||||||
name="field"
|
|
||||||
track-by="id"
|
|
||||||
label="value"
|
|
||||||
:custom-label="transName"
|
|
||||||
:taggable="true"
|
|
||||||
:multiple="false"
|
|
||||||
@tag="addAddress"
|
|
||||||
:placeholder="$t('select_address')"
|
|
||||||
:tagPlaceholder="$t('create_address')"
|
|
||||||
:options="addresses">
|
|
||||||
</VueMultiselect>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
import VueMultiselect from 'vue-multiselect';
|
|
||||||
|
|
||||||
export default {
|
|
||||||
name: 'AddressSelection',
|
|
||||||
components: { VueMultiselect },
|
|
||||||
props: ['address', 'updateMapCenter'],
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
value: null
|
|
||||||
}
|
|
||||||
},
|
|
||||||
computed: {
|
|
||||||
addresses() {
|
|
||||||
return this.address.loaded.addresses;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
transName(value) {
|
|
||||||
return value.streetNumber === undefined ? value.street : `${value.street}, ${value.streetNumber}`
|
|
||||||
},
|
|
||||||
selectAddress(value) {
|
|
||||||
this.address.selected.address = value;
|
|
||||||
this.updateMapCenter(value.point);
|
|
||||||
},
|
|
||||||
addAddress (newAddress) {
|
|
||||||
const address = {
|
|
||||||
street: newAddress
|
|
||||||
};
|
|
||||||
this.value = address;
|
|
||||||
this.address.selected.address = address;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style src="vue-multiselect/dist/vue-multiselect.css"></style>
|
|
@@ -1,45 +0,0 @@
|
|||||||
<template>
|
|
||||||
<div class="container">
|
|
||||||
<VueMultiselect
|
|
||||||
v-model="value"
|
|
||||||
@select="selectCity"
|
|
||||||
name="field"
|
|
||||||
track-by="id"
|
|
||||||
label="value"
|
|
||||||
:custom-label="transName"
|
|
||||||
:placeholder="$t('select_city')"
|
|
||||||
:options="cities">
|
|
||||||
</VueMultiselect>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
import VueMultiselect from 'vue-multiselect';
|
|
||||||
|
|
||||||
export default {
|
|
||||||
name: 'CitySelection',
|
|
||||||
components: { VueMultiselect },
|
|
||||||
props: ['address', 'getReferenceAddresses'],
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
value: null
|
|
||||||
}
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
transName(value) {
|
|
||||||
return `${value.code}-${value.name}`
|
|
||||||
},
|
|
||||||
selectCity(value) {
|
|
||||||
this.address.selected.city = value;
|
|
||||||
this.getReferenceAddresses(value);
|
|
||||||
},
|
|
||||||
},
|
|
||||||
computed: {
|
|
||||||
cities() {
|
|
||||||
return this.address.loaded.cities;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style src="vue-multiselect/dist/vue-multiselect.css"></style>
|
|
@@ -1,59 +0,0 @@
|
|||||||
<template>
|
|
||||||
<div class="container">
|
|
||||||
<VueMultiselect
|
|
||||||
v-model="value"
|
|
||||||
name="field"
|
|
||||||
track-by="id"
|
|
||||||
label="name"
|
|
||||||
:custom-label="transName"
|
|
||||||
:placeholder="$t('select_country')"
|
|
||||||
:options="countries"
|
|
||||||
@select="selectCountry">
|
|
||||||
</VueMultiselect>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
import VueMultiselect from 'vue-multiselect';
|
|
||||||
|
|
||||||
export default {
|
|
||||||
name: 'CountrySelection',
|
|
||||||
components: { VueMultiselect },
|
|
||||||
props: ['address', 'getCities'],
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
value: this.address.loaded.countries.filter(c => c.countryCode === 'FR')[0]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
init() {
|
|
||||||
if (this.value !== undefined) {
|
|
||||||
this.getCities(this.value);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
transName ({ name }) {
|
|
||||||
return name.fr //TODO multilang
|
|
||||||
},
|
|
||||||
selectCountry(value) {
|
|
||||||
console.log(value);
|
|
||||||
this.address.selected.country = value;
|
|
||||||
this.getCities(value);
|
|
||||||
},
|
|
||||||
},
|
|
||||||
mounted(){
|
|
||||||
this.init()
|
|
||||||
},
|
|
||||||
computed: {
|
|
||||||
countries() {
|
|
||||||
const countries = this.address.loaded.countries;
|
|
||||||
let orderedCountries = [];
|
|
||||||
orderedCountries.push(...countries.filter(c => c.countryCode === 'FR'))
|
|
||||||
orderedCountries.push(...countries.filter(c => c.countryCode === 'BE'))
|
|
||||||
orderedCountries.push(...countries.filter(c => c.countryCode !== 'FR').filter(c => c.countryCode !== 'BE'))
|
|
||||||
return orderedCountries;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style src="vue-multiselect/dist/vue-multiselect.css"></style>
|
|
@@ -1,40 +1,41 @@
|
|||||||
<template>
|
<template>
|
||||||
<transition name="modal">
|
<transition name="modal">
|
||||||
<div class="modal-mask">
|
<div class="modal-mask">
|
||||||
<!-- :: styles bootstrap :: -->
|
<!-- :: styles bootstrap :: -->
|
||||||
<div class="modal-dialog" :class="modalDialogClass">
|
<div class="modal-dialog" :class="modalDialogClass">
|
||||||
<div class="modal-content">
|
<div class="modal-content">
|
||||||
<div class="modal-header">
|
<div class="modal-header">
|
||||||
<slot name="header"></slot>
|
<slot name="header"></slot>
|
||||||
<button class="close sc-button grey" @click="$emit('close')">
|
<button class="close sc-button grey" @click="$emit('close')">
|
||||||
<i class="fa fa-times" aria-hidden="true"></i></button>
|
<i class="fa fa-times" aria-hidden="true"></i></button>
|
||||||
</div>
|
</div>
|
||||||
<div class="body-head">
|
<div class="modal-body up" style="overflow-y: unset;">
|
||||||
<slot name="body-head"></slot>
|
<slot name="body-fixed"></slot>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
<slot name="body"></slot>
|
<slot name="body"></slot>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
<button class="sc-button cancel" @click="$emit('close')">{{ $t('action.close') }}</button>
|
<button class="sc-button cancel" @click="$emit('close')">{{ $t('action.close') }}</button>
|
||||||
<slot name="footer"></slot>
|
<slot name="footer"></slot>
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<!-- :: end styles bootstrap :: -->
|
|
||||||
</div>
|
</div>
|
||||||
</transition>
|
<!-- :: end styles bootstrap :: -->
|
||||||
|
</div>
|
||||||
|
</transition>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
/*
|
/*
|
||||||
* This Modal component is a mix between Vue3 modal implementation
|
* This Modal component is a mix between :
|
||||||
* [+] with 'v-if:showModal' directive:parameter, html scope is added/removed not just shown/hidden
|
* - Vue3 modal implementation
|
||||||
* [+] with slot we can pass content from parent component
|
* => with 'v-if:showModal' directive:parameter, html scope is added/removed not just shown/hidden
|
||||||
* [+] some classes are passed from parent component
|
* => with slot we can pass content from parent component
|
||||||
* and Bootstrap 4.6 _modal.scss module
|
* => some classes are passed from parent component
|
||||||
* [+] using bootstrap css classes, the modal have a responsive behaviour,
|
* - Bootstrap 4.6 _modal.scss module
|
||||||
* [+] modal design can be configured using css classes (size, scroll)
|
* => using bootstrap css classes, the modal have a responsive behaviour,
|
||||||
|
* => modal design can be configured using css classes (size, scroll)
|
||||||
*/
|
*/
|
||||||
export default {
|
export default {
|
||||||
name: 'Modal',
|
name: 'Modal',
|
||||||
@@ -42,39 +43,3 @@ export default {
|
|||||||
emits: ['close']
|
emits: ['close']
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss">
|
|
||||||
.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);
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
|
@@ -1,153 +0,0 @@
|
|||||||
<template>
|
|
||||||
|
|
||||||
<a class="sc-button" target="_blank"
|
|
||||||
:class="classAction"
|
|
||||||
:title="$t(titleAction)"
|
|
||||||
@click="openModal">
|
|
||||||
{{ buttonText }}
|
|
||||||
</a>
|
|
||||||
|
|
||||||
<teleport to="body">
|
|
||||||
<modal v-if="modal.showModal"
|
|
||||||
:modalDialogClass="modal.modalDialogClass"
|
|
||||||
@close="modal.showModal = false">
|
|
||||||
|
|
||||||
<template v-slot:header>
|
|
||||||
<h3 class="modal-title">{{ $t(titleModal) }}</h3>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<template v-slot:body v-if="type === 'person'">
|
|
||||||
<on-the-fly-person
|
|
||||||
v-bind:id="id"
|
|
||||||
v-bind:type="type"
|
|
||||||
v-bind:action="action"
|
|
||||||
ref="castPerson">
|
|
||||||
</on-the-fly-person>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<template v-slot:body v-else-if="type === 'thirdparty'">
|
|
||||||
<on-the-fly-thirdparty
|
|
||||||
v-bind:id="id"
|
|
||||||
v-bind:type="type"
|
|
||||||
v-bind:action="action"
|
|
||||||
ref="castThirdparty">
|
|
||||||
</on-the-fly-thirdparty>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<template v-slot:body v-else>
|
|
||||||
<on-the-fly-create
|
|
||||||
v-bind:action="action"
|
|
||||||
ref="castNew">
|
|
||||||
</on-the-fly-create>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<template v-slot:footer>
|
|
||||||
<button v-if="action === 'show'"
|
|
||||||
@click="changeActionTo('edit')"
|
|
||||||
class="sc-button bt-update"> <!-- @click.prevent="$emit('..', ..)" -->
|
|
||||||
</button>
|
|
||||||
<button v-else
|
|
||||||
class="sc-button bt-save"
|
|
||||||
@click="saveAction"
|
|
||||||
> <!--
|
|
||||||
-->
|
|
||||||
{{ $t('action.save')}}
|
|
||||||
</button>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
</modal>
|
|
||||||
</teleport>
|
|
||||||
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
import Modal from 'ChillMainAssets/vuejs/_components/Modal.vue';
|
|
||||||
import OnTheFlyPerson from 'ChillPersonAssets/vuejs/_components/OnTheFly/Person.vue';
|
|
||||||
import OnTheFlyThirdparty from './OnTheFly/ThirdParty.vue';
|
|
||||||
import OnTheFlyCreate from './OnTheFly/Create.vue';
|
|
||||||
|
|
||||||
export default {
|
|
||||||
name: 'OnTheFly',
|
|
||||||
components: {
|
|
||||||
Modal,
|
|
||||||
OnTheFlyPerson,
|
|
||||||
OnTheFlyThirdparty,
|
|
||||||
OnTheFlyCreate
|
|
||||||
},
|
|
||||||
props: ['type', 'id', 'action', 'buttonText'],
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
modal: {
|
|
||||||
showModal: false,
|
|
||||||
modalDialogClass: "modal-dialog-scrollable modal-xl"
|
|
||||||
},
|
|
||||||
action: this.action
|
|
||||||
}
|
|
||||||
},
|
|
||||||
computed: {
|
|
||||||
action() {
|
|
||||||
return this.$data.action;
|
|
||||||
},
|
|
||||||
classAction() {
|
|
||||||
switch (this.action) {
|
|
||||||
case 'show':
|
|
||||||
return 'bt-show';
|
|
||||||
case 'edit':
|
|
||||||
return 'bt-update';
|
|
||||||
case 'create':
|
|
||||||
return 'bt-create';
|
|
||||||
}
|
|
||||||
},
|
|
||||||
titleAction() {
|
|
||||||
switch (this.action) {
|
|
||||||
case 'show':
|
|
||||||
return 'action.show';
|
|
||||||
case 'edit':
|
|
||||||
return 'action.edit';
|
|
||||||
case 'create':
|
|
||||||
return 'action.create';
|
|
||||||
}
|
|
||||||
},
|
|
||||||
titleModal() {
|
|
||||||
switch (this.action) {
|
|
||||||
case 'show':
|
|
||||||
return 'onthefly.show.' + this.type;
|
|
||||||
case 'edit':
|
|
||||||
return 'onthefly.edit.' + this.type;
|
|
||||||
case 'create':
|
|
||||||
return 'onthefly.create.title';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
openModal() {
|
|
||||||
this.modal.showModal = true;
|
|
||||||
this.$nextTick(function() {
|
|
||||||
//this.$refs.search.focus();
|
|
||||||
})
|
|
||||||
},
|
|
||||||
changeActionTo(action) {
|
|
||||||
// [BUG] clic first on show item button; in modal clic edit button; close modal; clic again on show item button
|
|
||||||
this.$data.action = action;
|
|
||||||
},
|
|
||||||
saveAction() {
|
|
||||||
console.log('saveAction');
|
|
||||||
if (this.type === 'person') {
|
|
||||||
this.$refs.castPerson.postData();
|
|
||||||
} else if (this.type === 'thirdparty') {
|
|
||||||
this.$refs.castThirdparty.postData();
|
|
||||||
} else {
|
|
||||||
// saveAction() ==cast=to==> child.castByType() ==cast=to==> grand-child.postData()
|
|
||||||
this.$refs.castNew.castByType();
|
|
||||||
}
|
|
||||||
this.modal.showModal = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style lang="css" scoped>
|
|
||||||
a {
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
</style>
|
|
@@ -1,84 +0,0 @@
|
|||||||
<template>
|
|
||||||
<ul class="nav nav-tabs">
|
|
||||||
<li class="nav-item">
|
|
||||||
<a class="nav-link" :class="{ active: isActive('person') }">
|
|
||||||
<label for="person">
|
|
||||||
<input type="radio" name="person" v-model="radioType" value="person">
|
|
||||||
{{ $t('onthefly.create.person') }}
|
|
||||||
</label>
|
|
||||||
</a>
|
|
||||||
</li>
|
|
||||||
<li class="nav-item">
|
|
||||||
<a class="nav-link" :class="{ active: isActive('thirdparty') }">
|
|
||||||
<label for="thirdparty">
|
|
||||||
<input type="radio" name="thirdparty" v-model="radioType" value="thirdparty">
|
|
||||||
{{ $t('onthefly.create.thirdparty') }}
|
|
||||||
</label>
|
|
||||||
</a>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
<div class="my-4">
|
|
||||||
<on-the-fly-person
|
|
||||||
v-if="type === 'person'"
|
|
||||||
v-bind:action="action"
|
|
||||||
ref="castPerson">
|
|
||||||
</on-the-fly-person>
|
|
||||||
|
|
||||||
<on-the-fly-thirdparty
|
|
||||||
v-if="type === 'thirdparty'"
|
|
||||||
v-bind:action="action"
|
|
||||||
ref="castThirdparty">
|
|
||||||
</on-the-fly-thirdparty>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
import OnTheFlyPerson from 'ChillPersonAssets/vuejs/_components/OnTheFly/Person.vue';
|
|
||||||
import OnTheFlyThirdparty from './ThirdParty.vue'; // TODO move in ChillThirdpartyAssets
|
|
||||||
|
|
||||||
export default {
|
|
||||||
name: "OnTheFlyCreate",
|
|
||||||
props: ['action'],
|
|
||||||
components: {
|
|
||||||
OnTheFlyPerson,
|
|
||||||
OnTheFlyThirdparty
|
|
||||||
},
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
type: 'person' //by default
|
|
||||||
}
|
|
||||||
},
|
|
||||||
computed: {
|
|
||||||
radioType: {
|
|
||||||
set(type) {
|
|
||||||
this.type = type;
|
|
||||||
},
|
|
||||||
get() {
|
|
||||||
return this.type;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
isActive(tab) {
|
|
||||||
return (this.type === tab) ? true : false;
|
|
||||||
},
|
|
||||||
castByType() {
|
|
||||||
console.log('saveActionByType');
|
|
||||||
if (this.type === 'person') {
|
|
||||||
this.$refs.castPerson.postData();
|
|
||||||
} else if (this.type === 'thirdparty') {
|
|
||||||
this.$refs.castThirdparty.postData();
|
|
||||||
} else {
|
|
||||||
throw Error('Invalid type of entity');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style lang="css" scoped>
|
|
||||||
label {
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
</style>
|
|
@@ -1,23 +0,0 @@
|
|||||||
<template>
|
|
||||||
<div v-if="action === 'show'">
|
|
||||||
show
|
|
||||||
thirdparty
|
|
||||||
{{ id }}
|
|
||||||
</div>
|
|
||||||
<div v-else-if="action === 'edit' || action === 'create'">
|
|
||||||
{{ action }}
|
|
||||||
thirdparty
|
|
||||||
{{ id }}
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
export default {
|
|
||||||
name: "OnTheFlyThirdParty",
|
|
||||||
props: ['id', 'type', 'action']
|
|
||||||
}
|
|
||||||
// TODO move in ChillThirdpartyAssets
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style lang="css" scoped>
|
|
||||||
</style>
|
|
@@ -7,15 +7,11 @@ const datetimeFormats = {
|
|||||||
month: "numeric",
|
month: "numeric",
|
||||||
day: "numeric"
|
day: "numeric"
|
||||||
},
|
},
|
||||||
text: {
|
|
||||||
year: "numeric",
|
|
||||||
month: "long",
|
|
||||||
day: "numeric",
|
|
||||||
},
|
|
||||||
long: {
|
long: {
|
||||||
year: "numeric",
|
year: "numeric",
|
||||||
month: "numeric",
|
month: "short",
|
||||||
day: "numeric",
|
day: "numeric",
|
||||||
|
weekday: "short",
|
||||||
hour: "numeric",
|
hour: "numeric",
|
||||||
minute: "numeric",
|
minute: "numeric",
|
||||||
hour12: false
|
hour12: false
|
||||||
@@ -37,32 +33,12 @@ const messages = {
|
|||||||
ok: "OK",
|
ok: "OK",
|
||||||
cancel: "Annuler",
|
cancel: "Annuler",
|
||||||
close: "Fermer",
|
close: "Fermer",
|
||||||
|
next: "Suivant",
|
||||||
|
previous: "Précédent",
|
||||||
back: "Retour",
|
back: "Retour",
|
||||||
check_all: "cocher tout",
|
check_all: "cocher tout",
|
||||||
reset: "réinitialiser"
|
reset: "réinitialiser"
|
||||||
},
|
},
|
||||||
nav: {
|
|
||||||
next: "Suivant",
|
|
||||||
previous: "Précédent",
|
|
||||||
top: "Haut",
|
|
||||||
bottom: "Bas",
|
|
||||||
},
|
|
||||||
onthefly: {
|
|
||||||
show: {
|
|
||||||
person: "Détails de l'usager",
|
|
||||||
thirdparty: "Détails du tiers"
|
|
||||||
},
|
|
||||||
edit: {
|
|
||||||
person: "Modifier un usager",
|
|
||||||
thirdparty: "Modifier un tiers"
|
|
||||||
},
|
|
||||||
create: {
|
|
||||||
button: "Créer \"{q}\"",
|
|
||||||
title: "Créer à la volée…",
|
|
||||||
person: "un nouvel usager",
|
|
||||||
thirdparty: "un nouveau tiers"
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -1,16 +0,0 @@
|
|||||||
<div class="chill_address">
|
|
||||||
{% if options['has_no_address'] == true and address.isNoAddress == true %}
|
|
||||||
<div class="chill_address_is_noaddress">{{ 'address.consider homeless'|trans }}</div>
|
|
||||||
{% endif %}
|
|
||||||
<div class="chill_address_address {% if options['multiline'] %}chill_address_address--multiline{% endif %}">
|
|
||||||
{% if address.street is not empty %}<p class="street street1">{{ address.street }}</p>{% endif %}
|
|
||||||
{% if address.streetNumber is not empty %}<p class="street street2">{{ address.streetNumber }}</p>{% endif %}
|
|
||||||
{% if address.postCode is not empty %}
|
|
||||||
<p class="postalCode"><span class="code">{{ address.postCode.code }}</span> <span class="name">{{ address.postCode.name }}</span></p>
|
|
||||||
<p class="country">{{ address.postCode.country.name|localize_translatable_string }}</p>
|
|
||||||
{% endif %}
|
|
||||||
</div>
|
|
||||||
{%- if options['with_valid_from'] == true -%}
|
|
||||||
<span class="address_since">{{ 'Since %date%'|trans( { '%date%' : address.validFrom|format_date('long') } ) }}</span>
|
|
||||||
{%- endif -%}
|
|
||||||
</div>
|
|
@@ -1,12 +1,11 @@
|
|||||||
{%- macro _render(address, options) -%}
|
{%- macro _render(address, options) -%}
|
||||||
{%- set options = { 'with_valid_from' : true }|merge(options|default({})) -%}
|
{%- set options = { 'with_valid_from' : true }|merge(options|default({})) -%}
|
||||||
{%- set options = { 'has_no_address' : false }|merge(options|default({})) -%}
|
{%- set options = { 'has_no_address' : false }|merge(options|default({})) -%}
|
||||||
{%- set options = { 'with_icon' : false }|merge(options|default({})) -%}
|
|
||||||
<div class="chill_address">
|
<div class="chill_address">
|
||||||
{% if options['has_no_address'] == true and address.isNoAddress == true %}
|
{% if options['has_no_address'] == true and address.isNoAddress == true %}
|
||||||
<div class="chill_address_is_noaddress">{{ 'address.consider homeless'|trans }}</div>
|
<div class="chill_address_is_noaddress">{{ 'address.consider homeless'|trans }}</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<div class="chill_address_address">{% if options['with_icon'] == true %}<i class="fa fa-fw fa-map-marker"></i>{% endif %}
|
<div class="chill_address_address">
|
||||||
{% if address.street is not empty %}<p class="street street1">{{ address.street }}</p>{% endif %}
|
{% if address.street is not empty %}<p class="street street1">{{ address.street }}</p>{% endif %}
|
||||||
{% if address.streetNumber is not empty %}<p class="street street2">{{ address.streetNumber }}</p>{% endif %}
|
{% if address.streetNumber is not empty %}<p class="street street2">{{ address.streetNumber }}</p>{% endif %}
|
||||||
{% if address.postCode is not empty %}
|
{% if address.postCode is not empty %}
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
<footer class="footer">
|
<footer class="footer">
|
||||||
<p>{{ 'This program is free software: you can redistribute it and/or modify it under the terms of the <strong>GNU Affero General Public License</strong>'|trans|raw }}
|
<p>{{ 'This program is free software: you can redistribute it and/or modify it under the terms of the <strong>GNU Affero General Public License</strong>'|trans|raw }}
|
||||||
<br/> <a name="bottom" href="https://{{ app.request.locale }}.wikibooks.org/wiki/Chill" target="_blank">{{ 'User manual'|trans }}</a></p>
|
<br/> <a href="https://{{ app.request.locale }}.wikibooks.org/wiki/Chill" target="_blank">{{ 'User manual'|trans }}</a></p>
|
||||||
</footer>
|
</footer>
|
@@ -1 +1 @@
|
|||||||
<img name="top" class="logo" src="{{ asset('build/images/logo-chill-sans-slogan_white.png') }}">
|
<img class="logo" src="{{ asset('build/images/logo-chill-sans-slogan_white.png') }}">
|
@@ -1,7 +0,0 @@
|
|||||||
<div class="timeline">
|
|
||||||
{% for result in results %}
|
|
||||||
<div class="timeline-item {% if loop.index0 is even %}even{% else %}odd{% endif %}">
|
|
||||||
{% include result.template with result.template_data %}
|
|
||||||
</div>
|
|
||||||
{% endfor %}
|
|
||||||
</div>
|
|
@@ -1,15 +1,7 @@
|
|||||||
{% extends "@ChillMain/layout.html.twig" %}
|
<div class="timeline">
|
||||||
|
{% for result in results %}
|
||||||
{% block content %}
|
<div class="timeline-item {% if loop.index0 is even %}even{% else %}odd{% endif %}">
|
||||||
<div id="container content">
|
{% include result.template with result.template_data %}
|
||||||
<div class="grid-8 centered">
|
</div>
|
||||||
<h1>{{ 'Global timeline'|trans }}</h1>
|
{% endfor %}
|
||||||
|
</div>
|
||||||
{{ timeline|raw }}
|
|
||||||
|
|
||||||
{% if nb_items > paginator.getItemsPerPage %}
|
|
||||||
{{ chill_pagination(paginator) }}
|
|
||||||
{% endif %}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{% endblock content %}
|
|
||||||
|
@@ -68,14 +68,6 @@ class SectionMenuBuilder implements LocalMenuBuilderInterface
|
|||||||
'icons' => ['home'],
|
'icons' => ['home'],
|
||||||
'order' => 0
|
'order' => 0
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$menu->addChild($this->translator->trans('Global timeline'), [
|
|
||||||
'route' => 'chill_center_timeline',
|
|
||||||
])
|
|
||||||
->setExtras([
|
|
||||||
'order' => 10
|
|
||||||
]
|
|
||||||
);
|
|
||||||
|
|
||||||
if ($this->authorizationChecker->isGranted(ChillExportVoter::EXPORT)) {
|
if ($this->authorizationChecker->isGranted(ChillExportVoter::EXPORT)) {
|
||||||
$menu->addChild($this->translator->trans('Export Menu'), [
|
$menu->addChild($this->translator->trans('Export Menu'), [
|
||||||
|
@@ -1,36 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Chill\MainBundle\Search\Model;
|
|
||||||
|
|
||||||
class Result
|
|
||||||
{
|
|
||||||
private float $relevance;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* mixed an arbitrary result
|
|
||||||
*/
|
|
||||||
private $result;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param float $relevance
|
|
||||||
* @param $result
|
|
||||||
*/
|
|
||||||
public function __construct(float $relevance, $result)
|
|
||||||
{
|
|
||||||
$this->relevance = $relevance;
|
|
||||||
$this->result = $result;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getRelevance(): float
|
|
||||||
{
|
|
||||||
return $this->relevance;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getResult()
|
|
||||||
{
|
|
||||||
return $this->result;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@@ -1,89 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Chill\MainBundle\Search;
|
|
||||||
|
|
||||||
use Chill\PersonBundle\Entity\Person;
|
|
||||||
use Chill\ThirdPartyBundle\Entity\ThirdParty;
|
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
|
||||||
use Chill\MainBundle\Search\SearchProvider;
|
|
||||||
use Symfony\Component\VarDumper\Resources\functions\dump;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ***Warning*** This is an incomplete implementation ***Warning***
|
|
||||||
*/
|
|
||||||
class SearchApi
|
|
||||||
{
|
|
||||||
private EntityManagerInterface $em;
|
|
||||||
private SearchProvider $search;
|
|
||||||
|
|
||||||
public function __construct(EntityManagerInterface $em, SearchProvider $search)
|
|
||||||
{
|
|
||||||
$this->em = $em;
|
|
||||||
$this->search = $search;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return Model/Result[]
|
|
||||||
*/
|
|
||||||
public function getResults(string $query, int $offset, int $maxResult): array
|
|
||||||
{
|
|
||||||
// **warning again**: this is an incomplete implementation
|
|
||||||
$results = [];
|
|
||||||
|
|
||||||
foreach ($this->getPersons($query) as $p) {
|
|
||||||
$results[] = new Model\Result((float)\rand(0, 100) / 100, $p);
|
|
||||||
}
|
|
||||||
foreach ($this->getThirdParties($query) as $t) {
|
|
||||||
$results[] = new Model\Result((float)\rand(0, 100) / 100, $t);
|
|
||||||
}
|
|
||||||
|
|
||||||
\usort($results, function(Model\Result $a, Model\Result $b) {
|
|
||||||
return ($a->getRelevance() <=> $b->getRelevance()) * -1;
|
|
||||||
});
|
|
||||||
|
|
||||||
return $results;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function countResults(string $query): int
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
private function getThirdParties(string $query)
|
|
||||||
{
|
|
||||||
$thirdPartiesIds = $this->em->createQuery('SELECT t.id FROM '.ThirdParty::class.' t')
|
|
||||||
->getScalarResult();
|
|
||||||
$nbResults = rand(0, 15);
|
|
||||||
|
|
||||||
if ($nbResults === 1) {
|
|
||||||
$nbResults++;
|
|
||||||
} elseif ($nbResults === 0) {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
$ids = \array_map(function ($e) use ($thirdPartiesIds) { return $thirdPartiesIds[$e]['id'];},
|
|
||||||
\array_rand($thirdPartiesIds, $nbResults));
|
|
||||||
|
|
||||||
$a = $this->em->getRepository(ThirdParty::class)
|
|
||||||
->findById($ids);
|
|
||||||
return $a;
|
|
||||||
}
|
|
||||||
|
|
||||||
private function getPersons(string $query)
|
|
||||||
{
|
|
||||||
$params = [
|
|
||||||
SearchInterface::SEARCH_PREVIEW_OPTION => false
|
|
||||||
];
|
|
||||||
$search = $this->search->getResultByName($query, 'person_regular', 0, 50, $params, 'json');
|
|
||||||
$ids = \array_map(function($r) { return $r['id']; }, $search['results']);
|
|
||||||
|
|
||||||
|
|
||||||
if (count($ids) === 0) {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->em->getRepository(Person::class)
|
|
||||||
->findById($ids)
|
|
||||||
;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@@ -110,6 +110,8 @@ class AuthorizationHelper
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$role = ($attribute instanceof Role) ? $attribute : new Role($attribute);
|
||||||
|
|
||||||
foreach ($user->getGroupCenters() as $groupCenter){
|
foreach ($user->getGroupCenters() as $groupCenter){
|
||||||
//filter on center
|
//filter on center
|
||||||
if ($groupCenter->getCenter()->getId() === $entity->getCenter()->getId()) {
|
if ($groupCenter->getCenter()->getId() === $entity->getCenter()->getId()) {
|
||||||
@@ -117,7 +119,8 @@ class AuthorizationHelper
|
|||||||
//iterate on roleScopes
|
//iterate on roleScopes
|
||||||
foreach($permissionGroup->getRoleScopes() as $roleScope) {
|
foreach($permissionGroup->getRoleScopes() as $roleScope) {
|
||||||
//check that the role allow to reach the required role
|
//check that the role allow to reach the required role
|
||||||
if ($this->isRoleReached($attribute, $roleScope->getRole())) {
|
if ($this->isRoleReached($role,
|
||||||
|
new Role($roleScope->getRole()))){
|
||||||
//if yes, we have a right on something...
|
//if yes, we have a right on something...
|
||||||
// perform check on scope if necessary
|
// perform check on scope if necessary
|
||||||
if ($entity instanceof HasScopeInterface) {
|
if ($entity instanceof HasScopeInterface) {
|
||||||
@@ -146,15 +149,12 @@ class AuthorizationHelper
|
|||||||
* and optionnaly Scope
|
* and optionnaly Scope
|
||||||
*
|
*
|
||||||
* @param User $user
|
* @param User $user
|
||||||
* @param string|Role $role
|
* @param Role $role
|
||||||
* @param null|Scope $scope
|
* @param null|Scope $scope
|
||||||
* @return Center[]
|
* @return Center[]
|
||||||
*/
|
*/
|
||||||
public function getReachableCenters(User $user, $role, Scope $scope = null)
|
public function getReachableCenters(User $user, Role $role, Scope $scope = null)
|
||||||
{
|
{
|
||||||
if ($role instanceof Role) {
|
|
||||||
$role = $role->getRole();
|
|
||||||
}
|
|
||||||
$centers = array();
|
$centers = array();
|
||||||
|
|
||||||
foreach ($user->getGroupCenters() as $groupCenter){
|
foreach ($user->getGroupCenters() as $groupCenter){
|
||||||
@@ -162,7 +162,8 @@ class AuthorizationHelper
|
|||||||
//iterate on roleScopes
|
//iterate on roleScopes
|
||||||
foreach($permissionGroup->getRoleScopes() as $roleScope) {
|
foreach($permissionGroup->getRoleScopes() as $roleScope) {
|
||||||
//check that the role is in the reachable roles
|
//check that the role is in the reachable roles
|
||||||
if ($this->isRoleReached($role, $roleScope->getRole())) {
|
if ($this->isRoleReached($role,
|
||||||
|
new Role($roleScope->getRole()))) {
|
||||||
if ($scope === null) {
|
if ($scope === null) {
|
||||||
$centers[] = $groupCenter->getCenter();
|
$centers[] = $groupCenter->getCenter();
|
||||||
break 1;
|
break 1;
|
||||||
@@ -179,30 +180,6 @@ class AuthorizationHelper
|
|||||||
|
|
||||||
return $centers;
|
return $centers;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Filter an array of centers, return only center which are reachable
|
|
||||||
*
|
|
||||||
* @param User $user The user
|
|
||||||
* @param array $centers a list of centers which are going to be filtered
|
|
||||||
* @param string|Center $role
|
|
||||||
*/
|
|
||||||
public function filterReachableCenters(User $user, array $centers, $role): array
|
|
||||||
{
|
|
||||||
$results = [];
|
|
||||||
|
|
||||||
if ($role instanceof Role) {
|
|
||||||
$role = $role->getRole();
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($centers as $center) {
|
|
||||||
if ($this->userCanReachCenter($user, $center, $role)) {
|
|
||||||
$results[] = $center;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $results;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return all reachable scope for a given user, center and role
|
* Return all reachable scope for a given user, center and role
|
||||||
@@ -214,12 +191,8 @@ class AuthorizationHelper
|
|||||||
* @param Center $center
|
* @param Center $center
|
||||||
* @return Scope[]
|
* @return Scope[]
|
||||||
*/
|
*/
|
||||||
public function getReachableScopes(User $user, $role, Center $center)
|
public function getReachableScopes(User $user, Role $role, Center $center)
|
||||||
{
|
{
|
||||||
if ($role instanceof Role) {
|
|
||||||
$role = $role->getRole();
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->getReachableCircles($user, $role, $center);
|
return $this->getReachableCircles($user, $role, $center);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -227,15 +200,12 @@ class AuthorizationHelper
|
|||||||
* Return all reachable circle for a given user, center and role
|
* Return all reachable circle for a given user, center and role
|
||||||
*
|
*
|
||||||
* @param User $user
|
* @param User $user
|
||||||
* @param string|Role $role
|
* @param Role $role
|
||||||
* @param Center $center
|
* @param Center $center
|
||||||
* @return Scope[]
|
* @return Scope[]
|
||||||
*/
|
*/
|
||||||
public function getReachableCircles(User $user, $role, Center $center)
|
public function getReachableCircles(User $user, Role $role, Center $center)
|
||||||
{
|
{
|
||||||
if ($role instanceof Role) {
|
|
||||||
$role = $role->getRole();
|
|
||||||
}
|
|
||||||
$scopes = array();
|
$scopes = array();
|
||||||
|
|
||||||
foreach ($user->getGroupCenters() as $groupCenter){
|
foreach ($user->getGroupCenters() as $groupCenter){
|
||||||
@@ -245,7 +215,9 @@ class AuthorizationHelper
|
|||||||
//iterate on roleScopes
|
//iterate on roleScopes
|
||||||
foreach($permissionGroup->getRoleScopes() as $roleScope) {
|
foreach($permissionGroup->getRoleScopes() as $roleScope) {
|
||||||
//check that the role is in the reachable roles
|
//check that the role is in the reachable roles
|
||||||
if ($this->isRoleReached($role, $roleScope->getRole())) {
|
if ($this->isRoleReached($role,
|
||||||
|
new Role($roleScope->getRole()))) {
|
||||||
|
|
||||||
$scopes[] = $roleScope->getScope();
|
$scopes[] = $roleScope->getScope();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -297,10 +269,10 @@ class AuthorizationHelper
|
|||||||
* @param Role $parentRole The role which should give access to $childRole
|
* @param Role $parentRole The role which should give access to $childRole
|
||||||
* @return boolean true if the child role is granted by parent role
|
* @return boolean true if the child role is granted by parent role
|
||||||
*/
|
*/
|
||||||
protected function isRoleReached($childRole, $parentRole)
|
protected function isRoleReached(Role $childRole, Role $parentRole)
|
||||||
{
|
{
|
||||||
$reachableRoles = $this->roleHierarchy
|
$reachableRoles = $this->roleHierarchy
|
||||||
->getReachableRoleNames([$parentRole]);
|
->getReachableRoles([$parentRole]);
|
||||||
|
|
||||||
return in_array($childRole, $reachableRoles);
|
return in_array($childRole, $reachableRoles);
|
||||||
}
|
}
|
||||||
|
@@ -1,29 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Chill\MainBundle\Serializer\Normalizer;
|
|
||||||
|
|
||||||
use Chill\MainBundle\Entity\Address;
|
|
||||||
use Symfony\Component\Serializer\Normalizer\NormalizerAwareInterface;
|
|
||||||
use Symfony\Component\Serializer\Normalizer\NormalizerAwareTrait;
|
|
||||||
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
|
|
||||||
|
|
||||||
class AddressNormalizer implements NormalizerAwareInterface, NormalizerInterface
|
|
||||||
{
|
|
||||||
use NormalizerAwareTrait;
|
|
||||||
|
|
||||||
public function normalize($address, string $format = null, array $context = [])
|
|
||||||
{
|
|
||||||
$data['address_id'] = $address->getId();
|
|
||||||
$data['text'] = $address->getStreet().', '.$address->getBuildingName();
|
|
||||||
$data['postcode']['name'] = $address->getPostCode()->getName();
|
|
||||||
|
|
||||||
return $data;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function supportsNormalization($data, string $format = null)
|
|
||||||
{
|
|
||||||
return $data instanceof Address;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@@ -20,32 +20,19 @@
|
|||||||
namespace Chill\MainBundle\Serializer\Normalizer;
|
namespace Chill\MainBundle\Serializer\Normalizer;
|
||||||
|
|
||||||
use Chill\MainBundle\Entity\Center;
|
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\Normalizer\NormalizerInterface;
|
||||||
use Symfony\Component\Serializer\Exception\InvalidArgumentException;
|
|
||||||
use Symfony\Component\Serializer\Exception\UnexpectedValueException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
class CenterNormalizer implements NormalizerInterface, DenormalizerInterface
|
class CenterNormalizer implements NormalizerInterface
|
||||||
{
|
{
|
||||||
private CenterRepository $repository;
|
|
||||||
|
|
||||||
|
|
||||||
public function __construct(CenterRepository $repository)
|
|
||||||
{
|
|
||||||
$this->repository = $repository;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function normalize($center, string $format = null, array $context = array())
|
public function normalize($center, string $format = null, array $context = array())
|
||||||
{
|
{
|
||||||
/** @var Center $center */
|
/** @var Center $center */
|
||||||
return [
|
return [
|
||||||
'id' => $center->getId(),
|
'id' => $center->getId(),
|
||||||
'type' => 'center',
|
|
||||||
'name' => $center->getName()
|
'name' => $center->getName()
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
@@ -54,30 +41,4 @@ class CenterNormalizer implements NormalizerInterface, DenormalizerInterface
|
|||||||
{
|
{
|
||||||
return $data instanceof Center;
|
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@@ -20,16 +20,15 @@
|
|||||||
namespace Chill\MainBundle\Serializer\Normalizer;
|
namespace Chill\MainBundle\Serializer\Normalizer;
|
||||||
|
|
||||||
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
|
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
|
||||||
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
|
|
||||||
use Symfony\Component\Serializer\Normalizer\AbstractNormalizer;
|
|
||||||
|
|
||||||
class DateNormalizer implements NormalizerInterface, DenormalizerInterface
|
class DateNormalizer implements NormalizerInterface
|
||||||
{
|
{
|
||||||
public function normalize($date, string $format = null, array $context = array())
|
public function normalize($date, string $format = null, array $context = array())
|
||||||
{
|
{
|
||||||
/** @var \DateTimeInterface $date */
|
/** @var \DateTimeInterface $date */
|
||||||
return [
|
return [
|
||||||
'datetime' => $date->format(\DateTimeInterface::ISO8601)
|
'datetime' => $date->format(\DateTimeInterface::ISO8601),
|
||||||
|
'u' => $date->getTimestamp()
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -37,24 +36,4 @@ class DateNormalizer implements NormalizerInterface, DenormalizerInterface
|
|||||||
{
|
{
|
||||||
return $data instanceof \DateTimeInterface;
|
return $data instanceof \DateTimeInterface;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function denormalize($data, string $type, string $format = null, array $context = [])
|
|
||||||
{
|
|
||||||
switch ($type) {
|
|
||||||
case \DateTime::class:
|
|
||||||
return \DateTime::createFromFormat(\DateTimeInterface::ISO8601, $data['datetime']);
|
|
||||||
case \DateTimeInterface::class:
|
|
||||||
case \DateTimeImmutable::class:
|
|
||||||
default:
|
|
||||||
return \DateTimeImmutable::createFromFormat(\DateTimeInterface::ISO8601, $data['datetime']);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function supportsDenormalization($data, string $type, string $format = null): bool
|
|
||||||
{
|
|
||||||
return $type === \DateTimeInterface::class ||
|
|
||||||
$type === \DateTime::class ||
|
|
||||||
$type === \DateTimeImmutable::class ||
|
|
||||||
(\is_array($data) && array_key_exists('datetime', $data));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@@ -1,71 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Chill\MainBundle\Serializer\Normalizer;
|
|
||||||
|
|
||||||
use Symfony\Component\Serializer\Normalizer\ContextAwareDenormalizerInterface;
|
|
||||||
use Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactoryInterface;
|
|
||||||
use Symfony\Component\Serializer\Normalizer\DenormalizerAwareInterface;
|
|
||||||
use Symfony\Component\Serializer\Normalizer\DenormalizerAwareTrait;
|
|
||||||
use Symfony\Component\Serializer\Exception\RuntimeException;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Denormalize an object given a list of supported class
|
|
||||||
*/
|
|
||||||
class DiscriminatedObjectDenormalizer implements ContextAwareDenormalizerInterface, DenormalizerAwareInterface
|
|
||||||
{
|
|
||||||
use DenormalizerAwareTrait;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The type to set for enabling this type
|
|
||||||
*/
|
|
||||||
public const TYPE = '@multi';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Should be present in context and contains an array of
|
|
||||||
* allowed types.
|
|
||||||
*/
|
|
||||||
public const ALLOWED_TYPES = 'denormalize_multi.allowed_types';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
public function denormalize($data, string $type, string $format = null, array $context = [])
|
|
||||||
{
|
|
||||||
foreach ($context[self::ALLOWED_TYPES] as $localType) {
|
|
||||||
if ($this->denormalizer->supportsDenormalization($data, $localType, $format)) {
|
|
||||||
try {
|
|
||||||
return $this->denormalizer->denormalize($data, $localType, $format, $context); } catch (RuntimeException $e) {
|
|
||||||
$lastException = $e;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
throw new RuntimeException(sprintf("Could not find any denormalizer for those ".
|
|
||||||
"ALLOWED_TYPES: %s", \implode(", ", $context[self::ALLOWED_TYPES])));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
public function supportsDenormalization($data, string $type, string $format = null, array $context = [])
|
|
||||||
{
|
|
||||||
if (self::TYPE !== $type) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (0 === count($context[self::ALLOWED_TYPES] ?? [])) {
|
|
||||||
throw new \LogicException("The context should contains a list of
|
|
||||||
allowed types");
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($context[self::ALLOWED_TYPES] as $localType) {
|
|
||||||
if ($this->denormalizer->supportsDenormalization($data, $localType, $format)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@@ -1,71 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Chill\MainBundle\Serializer\Normalizer;
|
|
||||||
|
|
||||||
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
|
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
|
||||||
use Symfony\Component\Serializer\Normalizer\AbstractNormalizer;
|
|
||||||
use Doctrine\ORM\Mapping\ClassMetadata;
|
|
||||||
use Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactoryInterface;
|
|
||||||
use Symfony\Component\Serializer\Mapping\ClassMetadataInterface as SerializerMetadata;
|
|
||||||
|
|
||||||
|
|
||||||
class DoctrineExistingEntityNormalizer implements DenormalizerInterface
|
|
||||||
{
|
|
||||||
private EntityManagerInterface $em;
|
|
||||||
|
|
||||||
private ClassMetadataFactoryInterface $serializerMetadataFactory;
|
|
||||||
|
|
||||||
|
|
||||||
public function __construct(EntityManagerInterface $em, ClassMetadataFactoryInterface $serializerMetadataFactory)
|
|
||||||
{
|
|
||||||
$this->em = $em;
|
|
||||||
$this->serializerMetadataFactory = $serializerMetadataFactory;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function denormalize($data, string $type, string $format = null, array $context = [])
|
|
||||||
{
|
|
||||||
if (\array_key_exists(AbstractNormalizer::OBJECT_TO_POPULATE, $context)) {
|
|
||||||
return $context[AbstractNormalizer::OBJECT_TO_POPULATE];
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->em->getRepository($type)
|
|
||||||
->find($data['id']);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function supportsDenormalization($data, string $type, string $format = null)
|
|
||||||
{
|
|
||||||
if (FALSE === \is_array($data)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (FALSE === \array_key_exists('id', $data)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (FALSE === $this->em->getClassMetadata($type) instanceof ClassMetadata) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// does have serializer metadata, and class discriminator ?
|
|
||||||
if ($this->serializerMetadataFactory->hasMetadataFor($type)) {
|
|
||||||
|
|
||||||
$classDiscriminator = $this->serializerMetadataFactory
|
|
||||||
->getMetadataFor($type)->getClassDiscriminatorMapping();
|
|
||||||
|
|
||||||
if ($classDiscriminator) {
|
|
||||||
$typeProperty = $classDiscriminator->getTypeProperty();
|
|
||||||
|
|
||||||
// check that only 2 keys
|
|
||||||
// that the second key is property
|
|
||||||
// and that the type match the class for given type property
|
|
||||||
return count($data) === 2
|
|
||||||
&& \array_key_exists($typeProperty, $data)
|
|
||||||
&& $type === $classDiscriminator->getClassForType($data[$typeProperty]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// we do not have any class discriminator. Check that the id is the only one key
|
|
||||||
return count($data) === 1;
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,34 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Chill\MainBundle\Serializer\Normalizer;
|
|
||||||
|
|
||||||
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
|
|
||||||
use Symfony\Component\Serializer\Exception\InvalidArgumentException;
|
|
||||||
|
|
||||||
use Chill\MainBundle\Doctrine\Model\Point;
|
|
||||||
|
|
||||||
|
|
||||||
class PointNormalizer implements DenormalizerInterface
|
|
||||||
{
|
|
||||||
|
|
||||||
public function supportsDenormalization($data, string $type, string $format = null) : bool
|
|
||||||
{
|
|
||||||
return $type === Point::class;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function denormalize($data, string $type, string $format = null, array $context = [])
|
|
||||||
{
|
|
||||||
|
|
||||||
if (!is_array($data)) {
|
|
||||||
throw new InvalidArgumentException('point data is not an array. It should be an array of 2 coordinates.');
|
|
||||||
} else {
|
|
||||||
if (count($data) !== 2) {
|
|
||||||
throw new InvalidArgumentException('point data is not an array of 2 elements. It should be an array of 2 coordinates.');
|
|
||||||
} else {
|
|
||||||
return Point::fromLonLat($data[0], $data[1]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@@ -24,7 +24,7 @@ use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @internal we keep this normalizer, because the property 'text' may be replace by a rendering in the future
|
*
|
||||||
*/
|
*/
|
||||||
class UserNormalizer implements NormalizerInterface
|
class UserNormalizer implements NormalizerInterface
|
||||||
{
|
{
|
||||||
@@ -32,10 +32,8 @@ class UserNormalizer implements NormalizerInterface
|
|||||||
{
|
{
|
||||||
/** @var User $user */
|
/** @var User $user */
|
||||||
return [
|
return [
|
||||||
'type' => 'user',
|
|
||||||
'id' => $user->getId(),
|
'id' => $user->getId(),
|
||||||
'username' => $user->getUsername(),
|
'username' => $user->getUsername()
|
||||||
'text' => $user->getUsername()
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,67 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Chill\MainBundle\Templating\Entity;
|
|
||||||
|
|
||||||
use Symfony\Component\Templating\EngineInterface;
|
|
||||||
use Chill\MainBundle\Entity\Address;
|
|
||||||
|
|
||||||
class AddressRender implements ChillEntityRenderInterface
|
|
||||||
{
|
|
||||||
private EngineInterface $templating;
|
|
||||||
|
|
||||||
public const DEFAULT_OPTIONS = [
|
|
||||||
'with_valid_from' => 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
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
}
|
|
@@ -172,7 +172,6 @@ abstract class AbstractExportTest extends WebTestCase
|
|||||||
*/
|
*/
|
||||||
public function testInitiateQuery($modifiers, $acl, $data)
|
public function testInitiateQuery($modifiers, $acl, $data)
|
||||||
{
|
{
|
||||||
var_dump($data);
|
|
||||||
$query = $this->getExport()->initiateQuery($modifiers, $acl, $data);
|
$query = $this->getExport()->initiateQuery($modifiers, $acl, $data);
|
||||||
|
|
||||||
$this->assertTrue($query instanceof QueryBuilder || $query instanceof NativeQuery,
|
$this->assertTrue($query instanceof QueryBuilder || $query instanceof NativeQuery,
|
||||||
|
@@ -1,51 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Chill\MainBundle\Tests\Serializer\Normalizer;
|
|
||||||
|
|
||||||
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
|
|
||||||
use Chill\MainBundle\Serializer\Normalizer\DoctrineExistingEntityNormalizer;
|
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
|
||||||
use Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactoryInterface;
|
|
||||||
use Chill\MainBundle\Entity\User;
|
|
||||||
|
|
||||||
|
|
||||||
class DoctrineExistingEntityNormalizerTest extends KernelTestCase
|
|
||||||
{
|
|
||||||
protected DoctrineExistingEntityNormalizer $normalizer;
|
|
||||||
|
|
||||||
protected function setUp()
|
|
||||||
{
|
|
||||||
self::bootKernel();
|
|
||||||
$em = self::$container->get(EntityManagerInterface::class);
|
|
||||||
$serializerFactory = self::$container->get(ClassMetadataFactoryInterface::class);
|
|
||||||
|
|
||||||
$this->normalizer = new DoctrineExistingEntityNormalizer($em, $serializerFactory);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @dataProvider dataProviderUserId
|
|
||||||
*/
|
|
||||||
public function testGetMappedClass($userId)
|
|
||||||
{
|
|
||||||
$data = [ 'type' => 'user', 'id' => $userId];
|
|
||||||
$supports = $this->normalizer->supportsDenormalization($data, User::class);
|
|
||||||
|
|
||||||
$this->assertTrue($supports);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function dataProviderUserId()
|
|
||||||
{
|
|
||||||
self::bootKernel();
|
|
||||||
|
|
||||||
$userIds = self::$container->get(EntityManagerInterface::class)
|
|
||||||
->getRepository(User::class)
|
|
||||||
->createQueryBuilder('u')
|
|
||||||
->select('u.id')
|
|
||||||
->setMaxResults(1)
|
|
||||||
->getQuery()
|
|
||||||
->getResult()
|
|
||||||
;
|
|
||||||
|
|
||||||
yield [ $userIds[0]['id'] ];
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,55 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Chill\MainBundle\Tests\Templating\Entity;
|
|
||||||
|
|
||||||
use Chill\MainBundle\Entity\Country;
|
|
||||||
use Chill\MainBundle\Entity\PostalCode;
|
|
||||||
use Chill\MainBundle\Templating\Entity\AddressRender;
|
|
||||||
use Chill\MainBundle\Entity\Address;
|
|
||||||
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
|
|
||||||
use Symfony\Component\Templating\EngineInterface;
|
|
||||||
|
|
||||||
class AddressRenderTest extends KernelTestCase
|
|
||||||
{
|
|
||||||
|
|
||||||
protected function setUp()
|
|
||||||
{
|
|
||||||
self::bootKernel();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @dataProvider addressDataProvider
|
|
||||||
*/
|
|
||||||
public function testRenderString(Address $addr, string $expectedString): void
|
|
||||||
{
|
|
||||||
$engine = self::$container->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"];
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@@ -23,11 +23,11 @@ use Doctrine\ORM\Query\ResultSetMapping;
|
|||||||
use Doctrine\DBAL\Types\Type;
|
use Doctrine\DBAL\Types\Type;
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
|
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
|
||||||
use Doctrine\ORM\Query;
|
|
||||||
use Doctrine\ORM\NativeQuery;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Build timeline
|
* Build timeline
|
||||||
|
*
|
||||||
|
* @author Julien Fastré <julien.fastre@champs-libres.coop>
|
||||||
*/
|
*/
|
||||||
class TimelineBuilder implements ContainerAwareInterface
|
class TimelineBuilder implements ContainerAwareInterface
|
||||||
{
|
{
|
||||||
@@ -78,14 +78,14 @@ class TimelineBuilder implements ContainerAwareInterface
|
|||||||
*/
|
*/
|
||||||
public function getTimelineHTML($context, array $args, $firstItem = 0, $number = 20)
|
public function getTimelineHTML($context, array $args, $firstItem = 0, $number = 20)
|
||||||
{
|
{
|
||||||
list($union, $parameters) = $this->buildUnionQuery($context, $args);
|
$union = $this->buildUnionQuery($context, $args);
|
||||||
|
|
||||||
//add ORDER BY clause and LIMIT
|
//add ORDER BY clause and LIMIT
|
||||||
$query = $union . sprintf(' ORDER BY date DESC LIMIT %d OFFSET %d',
|
$query = $union . sprintf(' ORDER BY date DESC LIMIT %d OFFSET %d',
|
||||||
$number, $firstItem);
|
$number, $firstItem);
|
||||||
|
|
||||||
// run query and handle results
|
// run query and handle results
|
||||||
$fetched = $this->runUnionQuery($query, $parameters);
|
$fetched = $this->runUnionQuery($query);
|
||||||
$entitiesByKey = $this->getEntities($fetched, $context);
|
$entitiesByKey = $this->getEntities($fetched, $context);
|
||||||
|
|
||||||
return $this->render($fetched, $entitiesByKey, $context, $args);
|
return $this->render($fetched, $entitiesByKey, $context, $args);
|
||||||
@@ -100,18 +100,16 @@ class TimelineBuilder implements ContainerAwareInterface
|
|||||||
*/
|
*/
|
||||||
public function countItems($context, array $args)
|
public function countItems($context, array $args)
|
||||||
{
|
{
|
||||||
|
$union = $this->buildUnionQuery($context, $args);
|
||||||
|
|
||||||
|
// embed the union query inside a count query
|
||||||
|
$count = sprintf('SELECT COUNT(sq.id) AS total FROM (%s) as sq', $union);
|
||||||
|
|
||||||
$rsm = (new ResultSetMapping())
|
$rsm = (new ResultSetMapping())
|
||||||
->addScalarResult('total', 'total', Type::INTEGER);
|
->addScalarResult('total', 'total', Type::INTEGER);
|
||||||
|
|
||||||
list($select, $parameters) = $this->buildUnionQuery($context, $args);
|
|
||||||
|
|
||||||
// embed the union query inside a count query
|
|
||||||
$countQuery = sprintf('SELECT COUNT(sq.id) AS total FROM (%s) as sq', $select);
|
|
||||||
|
|
||||||
$nq = $this->em->createNativeQuery($countQuery, $rsm);
|
|
||||||
$nq->setParameters($parameters);
|
|
||||||
|
|
||||||
return $nq->getSingleScalarResult();
|
return $this->em->createNativeQuery($count, $rsm)
|
||||||
|
->getSingleScalarResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -156,59 +154,40 @@ class TimelineBuilder implements ContainerAwareInterface
|
|||||||
*
|
*
|
||||||
* @uses self::buildSelectQuery to build individual SELECT queries
|
* @uses self::buildSelectQuery to build individual SELECT queries
|
||||||
*
|
*
|
||||||
|
* @param string $context
|
||||||
|
* @param mixed $args
|
||||||
|
* @param int $page
|
||||||
|
* @param int $number
|
||||||
|
* @return string
|
||||||
* @throws \LogicException if no builder have been defined for this context
|
* @throws \LogicException if no builder have been defined for this context
|
||||||
* @return array, where first element is the query, the second one an array with the parameters
|
|
||||||
*/
|
*/
|
||||||
private function buildUnionQuery(string $context, array $args): array
|
private function buildUnionQuery($context, array $args)
|
||||||
{
|
{
|
||||||
//append SELECT queries with UNION keyword between them
|
//append SELECT queries with UNION keyword between them
|
||||||
$union = '';
|
$union = '';
|
||||||
$parameters = [];
|
|
||||||
|
|
||||||
foreach($this->getProvidersByContext($context) as $provider) {
|
foreach($this->getProvidersByContext($context) as $provider) {
|
||||||
$data = $provider->fetchQuery($context, $args);
|
$select = $this->buildSelectQuery($provider, $context, $args);
|
||||||
list($select, $selectParameters) = $this->buildSelectQuery($data);
|
$append = ($union === '') ? $select : ' UNION '.$select;
|
||||||
$append = empty($union) ? $select : ' UNION '.$select;
|
|
||||||
$union .= $append;
|
$union .= $append;
|
||||||
$parameters = array_merge($parameters, $selectParameters);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return [$union, $parameters];
|
return $union;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Hack to replace the arbitrary "AS" statement in DQL
|
|
||||||
* into proper SQL query
|
|
||||||
* TODO remove
|
|
||||||
private function replaceASInDQL(string $dql): string
|
|
||||||
{
|
|
||||||
$pattern = '/^(SELECT\s+[a-zA-Z0-9\_\.\']{1,}\s+)(AS [a-z0-9\_]{1,})(\s{0,},\s{0,}[a-zA-Z0-9\_\.\']{1,}\s+)(AS [a-z0-9\_]{1,})(\s{0,},\s{0,}[a-zA-Z0-9\_\.\']{1,}\s+)(AS [a-z0-9\_]{1,})(\s+FROM.*)/';
|
|
||||||
$replacements = '${1} AS id ${3} AS type ${5} AS date ${7}';
|
|
||||||
|
|
||||||
$s = \preg_replace($pattern, $replacements, $dql, 1);
|
|
||||||
|
|
||||||
if (NULL === $s) {
|
|
||||||
throw new \RuntimeException('Could not replace the "AS" statement produced by '.
|
|
||||||
'DQL with normal SQL AS: '.$dql);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $s;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* return the SQL SELECT query as a string,
|
* return the SQL SELECT query as a string,
|
||||||
*
|
*
|
||||||
* @return array: first parameter is the sql string, second an array with parameters
|
* @uses TimelineProfiderInterface::fetchQuery use the fetchQuery function
|
||||||
|
* @param \Chill\MainBundle\Timeline\TimelineProviderInterface $provider
|
||||||
|
* @param string $context
|
||||||
|
* @param mixed[] $args
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
private function buildSelectQuery($data): array
|
private function buildSelectQuery(TimelineProviderInterface $provider, $context, array $args)
|
||||||
{
|
{
|
||||||
return [$data->buildSql(), $data->getParameters()];
|
$data = $provider->fetchQuery($context, $args);
|
||||||
|
|
||||||
// dead code
|
return sprintf(
|
||||||
$parameters = [];
|
|
||||||
|
|
||||||
$sql = sprintf(
|
|
||||||
'SELECT %s AS id, '
|
'SELECT %s AS id, '
|
||||||
. '%s AS "date", '
|
. '%s AS "date", '
|
||||||
. "'%s' AS type "
|
. "'%s' AS type "
|
||||||
@@ -218,19 +197,16 @@ class TimelineBuilder implements ContainerAwareInterface
|
|||||||
$data['date'],
|
$data['date'],
|
||||||
$data['type'],
|
$data['type'],
|
||||||
$data['FROM'],
|
$data['FROM'],
|
||||||
is_string($data['WHERE']) ? $data['WHERE'] : $data['WHERE'][0]
|
$data['WHERE']);
|
||||||
);
|
|
||||||
|
|
||||||
return [$sql, $data['WHERE'][1]];
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* run the UNION query and return result as an array
|
* run the UNION query and return result as an array
|
||||||
*
|
*
|
||||||
* @return array an array with the results
|
* @param string $query
|
||||||
|
* @return array
|
||||||
*/
|
*/
|
||||||
private function runUnionQuery(string $query, array $parameters): array
|
private function runUnionQuery($query)
|
||||||
{
|
{
|
||||||
$resultSetMapping = (new ResultSetMapping())
|
$resultSetMapping = (new ResultSetMapping())
|
||||||
->addScalarResult('id', 'id')
|
->addScalarResult('id', 'id')
|
||||||
@@ -238,8 +214,7 @@ class TimelineBuilder implements ContainerAwareInterface
|
|||||||
->addScalarResult('date', 'date');
|
->addScalarResult('date', 'date');
|
||||||
|
|
||||||
return $this->em->createNativeQuery($query, $resultSetMapping)
|
return $this->em->createNativeQuery($query, $resultSetMapping)
|
||||||
->setParameters($parameters)
|
->getArrayResult();
|
||||||
->getArrayResult();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -299,7 +274,7 @@ class TimelineBuilder implements ContainerAwareInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
return $this->container->get('templating')
|
return $this->container->get('templating')
|
||||||
->render('@ChillMain/Timeline/chain_timelines.html.twig', array(
|
->render('@ChillMain/Timeline/index.html.twig', array(
|
||||||
'results' => $timelineEntries
|
'results' => $timelineEntries
|
||||||
));
|
));
|
||||||
|
|
||||||
|
@@ -1,155 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Chill\MainBundle\Timeline;
|
|
||||||
|
|
||||||
|
|
||||||
class TimelineSingleQuery
|
|
||||||
{
|
|
||||||
private ?string $id;
|
|
||||||
|
|
||||||
private ?string $date;
|
|
||||||
|
|
||||||
private ?string $key;
|
|
||||||
|
|
||||||
private ?string $from;
|
|
||||||
|
|
||||||
private ?string $where;
|
|
||||||
|
|
||||||
private array $parameters = [];
|
|
||||||
|
|
||||||
private bool $distinct = false;
|
|
||||||
|
|
||||||
public function __construct(
|
|
||||||
string $id = null,
|
|
||||||
string $date = null,
|
|
||||||
string $key = null,
|
|
||||||
string $from = null,
|
|
||||||
string $where = null,
|
|
||||||
array $parameters = []
|
|
||||||
) {
|
|
||||||
$this->id = $id;
|
|
||||||
$this->date = $date;
|
|
||||||
$this->key = $key;
|
|
||||||
$this->from = $from;
|
|
||||||
$this->where = $where;
|
|
||||||
$this->parameters = $parameters;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function fromArray(array $a)
|
|
||||||
{
|
|
||||||
return new TimelineSingleQuery(
|
|
||||||
$a['id'] ?? null,
|
|
||||||
$a['date'] ?? null,
|
|
||||||
$a['type'] ?? $a['key'] ?? null,
|
|
||||||
$a['FROM'] ?? $a['from'] ?? null,
|
|
||||||
$a['WHERE'] ?? $a['where'] ?? null,
|
|
||||||
$a['parameters'] ?? null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getId(): string
|
|
||||||
{
|
|
||||||
return $this->id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setId(string $id): self
|
|
||||||
{
|
|
||||||
$this->id = $id;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getDate(): string
|
|
||||||
{
|
|
||||||
return $this->date;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setDate(string $date): self
|
|
||||||
{
|
|
||||||
$this->date = $date;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getKey(): string
|
|
||||||
{
|
|
||||||
return $this->key;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setKey(string $key): self
|
|
||||||
{
|
|
||||||
$this->key = $key;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getFrom(): string
|
|
||||||
{
|
|
||||||
return $this->from;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setFrom(string $from): self
|
|
||||||
{
|
|
||||||
$this->from = $from;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getWhere(): string
|
|
||||||
{
|
|
||||||
return $this->where;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setWhere(string $where): self
|
|
||||||
{
|
|
||||||
$this->where = $where;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getParameters(): array
|
|
||||||
{
|
|
||||||
return $this->parameters;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setParameters(array $parameters): self
|
|
||||||
{
|
|
||||||
$this->parameters = $parameters;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setDistinct(bool $distinct): self
|
|
||||||
{
|
|
||||||
$this->distinct = $distinct;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function isDistinct(): bool
|
|
||||||
{
|
|
||||||
return $this->distinct;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function buildSql(): string
|
|
||||||
{
|
|
||||||
$parameters = [];
|
|
||||||
|
|
||||||
$sql = \strtr(
|
|
||||||
'SELECT {distinct} {id} AS id, '
|
|
||||||
. '{date} AS "date", '
|
|
||||||
. "'{key}' AS type "
|
|
||||||
. 'FROM {from} '
|
|
||||||
. 'WHERE {where}',
|
|
||||||
[
|
|
||||||
'{distinct}' => $this->distinct ? 'DISTINCT' : '',
|
|
||||||
'{id}' => $this->getId(),
|
|
||||||
'{date}' => $this->getDate(),
|
|
||||||
'{key}' => $this->getKey(),
|
|
||||||
'{from}' => $this->getFrom(),
|
|
||||||
'{where}' => $this->getWhere(),
|
|
||||||
]
|
|
||||||
);
|
|
||||||
|
|
||||||
return $sql;
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,58 +0,0 @@
|
|||||||
---
|
|
||||||
openapi: "3.0.0"
|
|
||||||
info:
|
|
||||||
version: "1.0.0"
|
|
||||||
title: "Chill api"
|
|
||||||
description: "Api documentation for chill. Currently, work in progress"
|
|
||||||
servers:
|
|
||||||
- url: "/api"
|
|
||||||
description: "Your current dev server"
|
|
||||||
|
|
||||||
components:
|
|
||||||
schemas:
|
|
||||||
Center:
|
|
||||||
type: object
|
|
||||||
properties:
|
|
||||||
id:
|
|
||||||
type: integer
|
|
||||||
name:
|
|
||||||
type: string
|
|
||||||
|
|
||||||
paths:
|
|
||||||
/1.0/search.json:
|
|
||||||
get:
|
|
||||||
summary: perform a search across multiple entities
|
|
||||||
tags:
|
|
||||||
- search
|
|
||||||
- person
|
|
||||||
- thirdparty
|
|
||||||
description: >
|
|
||||||
**Warning**: This is currently a stub (not really implemented
|
|
||||||
|
|
||||||
The search is performed across multiple entities. The entities must be listed into
|
|
||||||
`type` parameters.
|
|
||||||
|
|
||||||
The results are ordered by relevance, from the most to the lowest relevant.
|
|
||||||
|
|
||||||
parameters:
|
|
||||||
- name: q
|
|
||||||
in: query
|
|
||||||
required: true
|
|
||||||
description: the pattern to search
|
|
||||||
schema:
|
|
||||||
type: string
|
|
||||||
- name: type[]
|
|
||||||
in: query
|
|
||||||
required: true
|
|
||||||
description: the type entities amongst the search is performed
|
|
||||||
schema:
|
|
||||||
type: array
|
|
||||||
items:
|
|
||||||
type: string
|
|
||||||
enum:
|
|
||||||
- person
|
|
||||||
- thirdparty
|
|
||||||
responses:
|
|
||||||
200:
|
|
||||||
description: "OK"
|
|
||||||
|
|
@@ -62,7 +62,5 @@ module.exports = function(encore, entries)
|
|||||||
buildCKEditor(encore);
|
buildCKEditor(encore);
|
||||||
encore.addEntry('ckeditor5', __dirname + '/Resources/public/modules/ckeditor5/index.js');
|
encore.addEntry('ckeditor5', __dirname + '/Resources/public/modules/ckeditor5/index.js');
|
||||||
|
|
||||||
// Address
|
|
||||||
encore.addEntry('address', __dirname + '/Resources/public/vuejs/Address/index.js');
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@@ -3,8 +3,8 @@
|
|||||||
"license": "AGPL-3.0",
|
"license": "AGPL-3.0",
|
||||||
"type": "symfony-bundle",
|
"type": "symfony-bundle",
|
||||||
"description": "The main bundle for the Chill App",
|
"description": "The main bundle for the Chill App",
|
||||||
"keywords": ["chill", "social work", "software for social service"],
|
"keywords" : ["chill", "social work", "software for social service"],
|
||||||
"homepage": "http://chill.social",
|
"homepage" : "http://chill.social",
|
||||||
"support": {
|
"support": {
|
||||||
"email": "dev@lists.chill.social",
|
"email": "dev@lists.chill.social",
|
||||||
"issues": "https://git.framasoft.org/Chill-project/Chill-Main/issues",
|
"issues": "https://git.framasoft.org/Chill-project/Chill-Main/issues",
|
||||||
@@ -12,16 +12,12 @@
|
|||||||
"docs": "http://docs.chill.social"
|
"docs": "http://docs.chill.social"
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-4": {
|
"psr-4": { "Chill\\MainBundle\\": "" }
|
||||||
"Chill\\MainBundle\\": ""
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
"autoload-dev": {
|
"autoload-dev": {
|
||||||
"classmap": [
|
"classmap": [ "Resources/test/Fixtures/App/app/AppKernel.php" ]
|
||||||
"Resources/test/Fixtures/App/app/AppKernel.php"
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
"authors": [
|
"authors" : [
|
||||||
{
|
{
|
||||||
"name": "Champs-Libres",
|
"name": "Champs-Libres",
|
||||||
"email": "info@champs-libres.coop",
|
"email": "info@champs-libres.coop",
|
||||||
@@ -32,6 +28,8 @@
|
|||||||
"league/csv": "^9.6",
|
"league/csv": "^9.6",
|
||||||
"phpoffice/phpspreadsheet": "~1.2"
|
"phpoffice/phpspreadsheet": "~1.2"
|
||||||
},
|
},
|
||||||
|
"require-dev": {
|
||||||
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"post-install-cmd": [
|
"post-install-cmd": [
|
||||||
"ComposerBundleMigration\\Composer\\Migrations::synchronizeMigrations",
|
"ComposerBundleMigration\\Composer\\Migrations::synchronizeMigrations",
|
||||||
|
@@ -1,7 +1,3 @@
|
|||||||
chill_main_controllers:
|
|
||||||
resource: '../Controller/'
|
|
||||||
type: annotation
|
|
||||||
|
|
||||||
chill_main_admin_permissionsgroup:
|
chill_main_admin_permissionsgroup:
|
||||||
resource: "@ChillMainBundle/config/routes/permissionsgroup.yaml"
|
resource: "@ChillMainBundle/config/routes/permissionsgroup.yaml"
|
||||||
prefix: "{_locale}/admin/permissionsgroup"
|
prefix: "{_locale}/admin/permissionsgroup"
|
||||||
@@ -73,13 +69,6 @@ chill_main_search:
|
|||||||
requirements:
|
requirements:
|
||||||
_format: html|json
|
_format: html|json
|
||||||
|
|
||||||
chill_main_search_global:
|
|
||||||
path: '/api/1.0/search.{_format}'
|
|
||||||
controller: Chill\MainBundle\Controller\SearchController::searchApi
|
|
||||||
format: 'json'
|
|
||||||
requirements:
|
|
||||||
_format: 'json'
|
|
||||||
|
|
||||||
chill_main_advanced_search:
|
chill_main_advanced_search:
|
||||||
path: /{_locale}/search/advanced/{name}
|
path: /{_locale}/search/advanced/{name}
|
||||||
controller: Chill\MainBundle\Controller\SearchController::advancedSearchAction
|
controller: Chill\MainBundle\Controller\SearchController::advancedSearchAction
|
||||||
|
@@ -3,18 +3,6 @@ parameters:
|
|||||||
|
|
||||||
services:
|
services:
|
||||||
|
|
||||||
Chill\MainBundle\Serializer\Normalizer\:
|
|
||||||
resource: '../Serializer/Normalizer'
|
|
||||||
autowire: true
|
|
||||||
tags:
|
|
||||||
- { name: 'serializer.normalizer', priority: 64 }
|
|
||||||
|
|
||||||
Chill\MainBundle\Doctrine\Event\:
|
|
||||||
resource: '../Doctrine/Event/'
|
|
||||||
autowire: true
|
|
||||||
tags:
|
|
||||||
- { name: 'doctrine.event_subscriber' }
|
|
||||||
|
|
||||||
chill.main.helper.translatable_string:
|
chill.main.helper.translatable_string:
|
||||||
class: Chill\MainBundle\Templating\TranslatableStringHelper
|
class: Chill\MainBundle\Templating\TranslatableStringHelper
|
||||||
arguments:
|
arguments:
|
||||||
@@ -31,14 +19,14 @@ services:
|
|||||||
- [ setContainer, ["@service_container"]]
|
- [ setContainer, ["@service_container"]]
|
||||||
tags:
|
tags:
|
||||||
- { name: twig.extension }
|
- { name: twig.extension }
|
||||||
|
|
||||||
chill.main.twig.widget:
|
chill.main.twig.widget:
|
||||||
class: Chill\MainBundle\Templating\Widget\WidgetRenderingTwig
|
class: Chill\MainBundle\Templating\Widget\WidgetRenderingTwig
|
||||||
arguments:
|
arguments:
|
||||||
- "@event_dispatcher"
|
- "@event_dispatcher"
|
||||||
tags:
|
tags:
|
||||||
- { name: twig.extension }
|
- { name: twig.extension }
|
||||||
|
|
||||||
chill.main.twig.csv_cell:
|
chill.main.twig.csv_cell:
|
||||||
class: Chill\MainBundle\Templating\CSVCellTwig
|
class: Chill\MainBundle\Templating\CSVCellTwig
|
||||||
tags:
|
tags:
|
||||||
@@ -65,4 +53,3 @@ services:
|
|||||||
- "@security.authorization_checker"
|
- "@security.authorization_checker"
|
||||||
- "@chill.main.security.authorization.helper"
|
- "@chill.main.security.authorization.helper"
|
||||||
- "@security.token_storage"
|
- "@security.token_storage"
|
||||||
|
|
||||||
|
@@ -7,7 +7,7 @@ services:
|
|||||||
$validator: '@Symfony\Component\Validator\Validator\ValidatorInterface'
|
$validator: '@Symfony\Component\Validator\Validator\ValidatorInterface'
|
||||||
tags:
|
tags:
|
||||||
- { name: console.command }
|
- { name: console.command }
|
||||||
|
|
||||||
Chill\MainBundle\Command\ChillUserSendRenewPasswordCodeCommand:
|
Chill\MainBundle\Command\ChillUserSendRenewPasswordCodeCommand:
|
||||||
arguments:
|
arguments:
|
||||||
$logger: '@Psr\Log\LoggerInterface'
|
$logger: '@Psr\Log\LoggerInterface'
|
||||||
|
@@ -16,7 +16,6 @@ services:
|
|||||||
$searchProvider: '@chill_main.search_provider'
|
$searchProvider: '@chill_main.search_provider'
|
||||||
$translator: '@Symfony\Contracts\Translation\TranslatorInterface'
|
$translator: '@Symfony\Contracts\Translation\TranslatorInterface'
|
||||||
$paginatorFactory: '@Chill\MainBundle\Pagination\PaginatorFactory'
|
$paginatorFactory: '@Chill\MainBundle\Pagination\PaginatorFactory'
|
||||||
$searchApi: '@Chill\MainBundle\Search\SearchApi'
|
|
||||||
tags: ['controller.service_arguments']
|
tags: ['controller.service_arguments']
|
||||||
|
|
||||||
Chill\MainBundle\Controller\PermissionsGroupController:
|
Chill\MainBundle\Controller\PermissionsGroupController:
|
||||||
|
@@ -1,10 +1,3 @@
|
|||||||
services:
|
services:
|
||||||
chill_main.search_provider:
|
chill_main.search_provider:
|
||||||
class: Chill\MainBundle\Search\SearchProvider
|
class: Chill\MainBundle\Search\SearchProvider
|
||||||
|
|
||||||
Chill\MainBundle\Search\SearchProvider: '@chill_main.search_provider'
|
|
||||||
|
|
||||||
Chill\MainBundle\Search\SearchApi:
|
|
||||||
arguments:
|
|
||||||
$em: '@Doctrine\ORM\EntityManagerInterface'
|
|
||||||
$search: '@Chill\MainBundle\Search\SearchProvider'
|
|
@@ -1,11 +1,17 @@
|
|||||||
---
|
---
|
||||||
services:
|
services:
|
||||||
|
Chill\MainBundle\Serializer\Normalizer\CenterNormalizer:
|
||||||
# note: the autowiring for serializers and normalizers is declared
|
|
||||||
# into ../services.yaml
|
|
||||||
|
|
||||||
Chill\MainBundle\Serializer\Normalizer\DoctrineExistingEntityNormalizer:
|
|
||||||
autowire: true
|
|
||||||
tags:
|
tags:
|
||||||
- { name: 'serializer.normalizer', priority: 8 }
|
- { name: 'serializer.normalizer', priority: 64 }
|
||||||
|
|
||||||
|
Chill\MainBundle\Serializer\Normalizer\DateNormalizer:
|
||||||
|
tags:
|
||||||
|
- { name: 'serializer.normalizer', priority: 64 }
|
||||||
|
|
||||||
|
Chill\MainBundle\Serializer\Normalizer\UserNormalizer:
|
||||||
|
tags:
|
||||||
|
- { name: 'serializer.normalizer', priority: 64 }
|
||||||
|
|
||||||
|
Chill\MainBundle\Serializer\Normalizer\CollectionNormalizer:
|
||||||
|
tags:
|
||||||
|
- { name: 'serializer.normalizer', priority: 64 }
|
||||||
|
@@ -41,10 +41,3 @@ services:
|
|||||||
Chill\MainBundle\Templating\ChillMarkdownRenderExtension:
|
Chill\MainBundle\Templating\ChillMarkdownRenderExtension:
|
||||||
tags:
|
tags:
|
||||||
- { name: twig.extension }
|
- { name: twig.extension }
|
||||||
|
|
||||||
Chill\MainBundle\Templating\Entity\AddressRender:
|
|
||||||
arguments:
|
|
||||||
- '@Symfony\Component\Templating\EngineInterface'
|
|
||||||
tags:
|
|
||||||
- { name: 'chill.render_entity' }
|
|
||||||
|
|
||||||
|
@@ -4,7 +4,4 @@ services:
|
|||||||
arguments:
|
arguments:
|
||||||
- "@doctrine.orm.entity_manager"
|
- "@doctrine.orm.entity_manager"
|
||||||
calls:
|
calls:
|
||||||
- [ setContainer, ["@service_container"]]
|
- [ setContainer, ["@service_container"]]
|
||||||
# alias:
|
|
||||||
Chill\MainBundle\Timeline\TimelineBuilder: '@chill_main.timeline_builder'
|
|
||||||
|
|
@@ -1,31 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace Chill\Migrations\Main;
|
|
||||||
|
|
||||||
use Doctrine\DBAL\Schema\Schema;
|
|
||||||
use Doctrine\Migrations\AbstractMigration;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Specify ON DELETE behaviour to handle deletion of parents in associated tables
|
|
||||||
*/
|
|
||||||
final class Version20210525144016 extends AbstractMigration
|
|
||||||
{
|
|
||||||
public function getDescription(): string
|
|
||||||
{
|
|
||||||
return 'Specify ON DELETE behaviour to handle deletion of parents in associated tables';
|
|
||||||
}
|
|
||||||
|
|
||||||
public function up(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) 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');
|
|
||||||
}
|
|
||||||
}
|
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user