mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-27 09:05:01 +00:00
Compare commits
2 Commits
use-sympli
...
issue_59_p
Author | SHA1 | Date | |
---|---|---|---|
|
5af36d18eb | ||
|
016baf1ac9 |
@@ -11,10 +11,9 @@ 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.
|
||||||
@@ -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
|
||||||
|
169
composer.json
169
composer.json
@@ -1,110 +1,89 @@
|
|||||||
{
|
{
|
||||||
"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",
|
||||||
|
"nelmio/alice": "^3.8"
|
||||||
},
|
},
|
||||||
"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
|
|
||||||
}
|
}
|
||||||
|
@@ -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() ]
|
);
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//....
|
//....
|
||||||
|
@@ -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);
|
|
||||||
};
|
|
@@ -20,18 +20,9 @@
|
|||||||
</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>
|
<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
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -57,10 +56,6 @@ class TimelineActivityProvider implements TimelineProviderInterface
|
|||||||
*/
|
*/
|
||||||
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 array(
|
||||||
|
|
||||||
return TimelineSingleQuery::fromArray([
|
|
||||||
'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 = [];
|
|
||||||
|
|
||||||
// first parameter: activity.person_id
|
if (count($reachableCenters) === 0) {
|
||||||
$parameters[] = $person->getId();
|
return 'FALSE = TRUE';
|
||||||
|
|
||||||
// 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 '
|
||||||
@@ -173,7 +164,7 @@ class TimelineActivityProvider implements TimelineProviderInterface
|
|||||||
*/
|
*/
|
||||||
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,4 +1,3 @@
|
|||||||
---
|
|
||||||
services:
|
services:
|
||||||
chill_activity.repository.activity_type:
|
chill_activity.repository.activity_type:
|
||||||
class: Doctrine\ORM\EntityRepository
|
class: Doctrine\ORM\EntityRepository
|
||||||
@@ -17,16 +16,3 @@ services:
|
|||||||
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;
|
||||||
}
|
}
|
||||||
|
@@ -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
|
||||||
|
@@ -40,20 +40,6 @@ class AbstractCRUDController extends AbstractController
|
|||||||
return $e;
|
return $e;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Create an entity.
|
|
||||||
*
|
|
||||||
* @param string $action
|
|
||||||
* @param Request $request
|
|
||||||
* @return object
|
|
||||||
*/
|
|
||||||
protected function createEntity(string $action, Request $request): object
|
|
||||||
{
|
|
||||||
$type = $this->getEntityClass();
|
|
||||||
|
|
||||||
return new $type;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Count the number of entities
|
* Count the number of entities
|
||||||
*
|
*
|
||||||
|
@@ -85,75 +85,11 @@ class ApiController extends AbstractCRUDController
|
|||||||
case Request::METHOD_PUT:
|
case Request::METHOD_PUT:
|
||||||
case Request::METHOD_PATCH:
|
case Request::METHOD_PATCH:
|
||||||
return $this->entityPut('_entity', $request, $id, $_format);
|
return $this->entityPut('_entity', $request, $id, $_format);
|
||||||
case Request::METHOD_POST:
|
|
||||||
return $this->entityPostAction('_entity', $request, $id, $_format);
|
|
||||||
default:
|
|
||||||
throw new \Symfony\Component\HttpFoundation\Exception\BadRequestException("This method is not implemented");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public function entityPost(Request $request, $_format): Response
|
|
||||||
{
|
|
||||||
switch($request->getMethod()) {
|
|
||||||
case Request::METHOD_POST:
|
|
||||||
return $this->entityPostAction('_entity', $request, $_format);
|
|
||||||
default:
|
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");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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
|
public function entityPut($action, Request $request, $id, string $_format): Response
|
||||||
{
|
{
|
||||||
$entity = $this->getEntity($action, $id, $request, $_format);
|
$entity = $this->getEntity($action, $id, $request, $_format);
|
||||||
@@ -471,7 +407,6 @@ class ApiController extends AbstractCRUDController
|
|||||||
return [ 'groups' => [ 'read' ]];
|
return [ 'groups' => [ 'read' ]];
|
||||||
case Request::METHOD_PUT:
|
case Request::METHOD_PUT:
|
||||||
case Request::METHOD_PATCH:
|
case Request::METHOD_PATCH:
|
||||||
case Request::METHOD_POST:
|
|
||||||
return [ 'groups' => [ 'write' ]];
|
return [ 'groups' => [ 'write' ]];
|
||||||
default:
|
default:
|
||||||
throw new \LogicException("get context for serialization is not implemented for this method");
|
throw new \LogicException("get context for serialization is not implemented for this method");
|
||||||
|
@@ -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'));
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@@ -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
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
@@ -35,8 +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;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -169,49 +167,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(
|
||||||
@@ -284,7 +270,6 @@ class ChillMainExtension extends Extension implements PrependExtensionInterface,
|
|||||||
]
|
]
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'controller' => \Chill\MainBundle\Controller\AddressReferenceAPIController::class,
|
|
||||||
'class' => \Chill\MainBundle\Entity\AddressReference::class,
|
'class' => \Chill\MainBundle\Entity\AddressReference::class,
|
||||||
'name' => 'address_reference',
|
'name' => 'address_reference',
|
||||||
'base_path' => '/api/1.0/main/address-reference',
|
'base_path' => '/api/1.0/main/address-reference',
|
||||||
@@ -305,7 +290,6 @@ class ChillMainExtension extends Extension implements PrependExtensionInterface,
|
|||||||
]
|
]
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'controller' => \Chill\MainBundle\Controller\PostalCodeAPIController::class,
|
|
||||||
'class' => \Chill\MainBundle\Entity\PostalCode::class,
|
'class' => \Chill\MainBundle\Entity\PostalCode::class,
|
||||||
'name' => 'postal_code',
|
'name' => 'postal_code',
|
||||||
'base_path' => '/api/1.0/main/postal-code',
|
'base_path' => '/api/1.0/main/postal-code',
|
||||||
|
@@ -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;
|
||||||
|
@@ -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;
|
||||||
|
|
||||||
|
@@ -4,7 +4,6 @@ namespace Chill\MainBundle\Entity;
|
|||||||
|
|
||||||
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()
|
||||||
@@ -17,25 +16,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 +38,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 +57,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,8 +27,6 @@ class Country
|
|||||||
* @var string
|
* @var string
|
||||||
*
|
*
|
||||||
* @ORM\Column(type="json_array")
|
* @ORM\Column(type="json_array")
|
||||||
* @groups({"read"})
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
private $name;
|
private $name;
|
||||||
|
|
||||||
@@ -38,7 +34,6 @@ class Country
|
|||||||
* @var string
|
* @var string
|
||||||
*
|
*
|
||||||
* @ORM\Column(type="string", length=3)
|
* @ORM\Column(type="string", length=3)
|
||||||
* @groups({"read"})
|
|
||||||
*/
|
*/
|
||||||
private $countryCode;
|
private $countryCode;
|
||||||
|
|
||||||
|
@@ -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;
|
||||||
|
|
||||||
|
@@ -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";
|
||||||
|
@@ -10,11 +10,5 @@ div.chill_address {
|
|||||||
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,48 +1,12 @@
|
|||||||
/*
|
/*
|
||||||
* 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
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -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,31 @@ 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 {
|
|
||||||
|
//// SCRATCH BUTTONS
|
||||||
|
.sc-button {
|
||||||
|
&.disabled {
|
||||||
|
cursor: default;
|
||||||
|
&.bt-remove {
|
||||||
|
background-color: #d9d9d9;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//// à ranger
|
||||||
|
.discret {
|
||||||
|
color: grey;
|
||||||
|
margin-right: 1em;
|
||||||
|
}
|
||||||
|
|
||||||
|
table {
|
||||||
|
ul.record_actions {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
}
|
padding: 0.5em;
|
||||||
h2, h3, h4 {
|
|
||||||
color: var(--chill-blue);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Bloc appearance
|
|
||||||
*/
|
|
||||||
div.flex-bloc {
|
|
||||||
box-sizing: border-box;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: row;
|
|
||||||
flex-wrap: wrap;
|
|
||||||
align-items: stretch;
|
|
||||||
align-content: stretch;
|
|
||||||
|
|
||||||
div.item-bloc {
|
|
||||||
flex-grow: 0; flex-shrink: 1; flex-basis: 50%;
|
|
||||||
|
|
||||||
margin: 0;
|
|
||||||
border: 1px solid #000;
|
|
||||||
padding: 1em;
|
|
||||||
|
|
||||||
border-top: 0;
|
|
||||||
&:nth-child(1), &:nth-child(2) {
|
|
||||||
border-top: 1px solid #000;
|
|
||||||
}
|
|
||||||
border-left: 0;
|
|
||||||
&:nth-child(odd) {
|
|
||||||
border-left: 1px solid #000;
|
|
||||||
}
|
|
||||||
|
|
||||||
//background-color: #e6e6e6;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
|
|
||||||
div.item-row {
|
|
||||||
flex-grow: 1; flex-shrink: 1; flex-basis: auto;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
|
|
||||||
div.item-col {
|
|
||||||
&:first-child {
|
|
||||||
flex-grow: 0; flex-shrink: 0; flex-basis: auto;
|
|
||||||
}
|
|
||||||
&:last-child {
|
|
||||||
flex-grow: 1; flex-shrink: 1; flex-basis: auto;
|
|
||||||
display: flex;
|
|
||||||
|
|
||||||
.list-content { // ul, dl, or div
|
|
||||||
}
|
|
||||||
ul.record_actions {
|
|
||||||
margin: 0;
|
|
||||||
align-self: flex-end;
|
|
||||||
flex-grow: 1; flex-shrink: 0; flex-basis: auto;
|
|
||||||
li {
|
|
||||||
margin-right: 5px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@media only screen and (max-width: 945px) { margin: auto -0.2em; }
|
|
||||||
@media only screen and (max-width: 935px) { margin: auto -0.5em; }
|
|
||||||
@media only screen and (max-width: 920px) { margin: auto -0.9em; }
|
|
||||||
@media only screen and (max-width: 900px) {
|
|
||||||
flex-direction: column;
|
|
||||||
margin: auto 0;
|
|
||||||
div.item-bloc {
|
|
||||||
border-left: 1px solid #000;
|
|
||||||
&:nth-child(2) {
|
|
||||||
border-top: 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Table appearance
|
|
||||||
*/
|
|
||||||
div.flex-table {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
align-items: stretch;
|
|
||||||
align-content: stretch;
|
|
||||||
|
|
||||||
div.item-bloc {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
padding: 1em;
|
|
||||||
border: 1px solid #000;
|
|
||||||
border-top: 0;
|
|
||||||
&:first-child {
|
|
||||||
border-top: 1px solid #000;
|
|
||||||
}
|
|
||||||
&:nth-child(even) {
|
|
||||||
background-color: #e6e6e6;
|
|
||||||
}
|
|
||||||
|
|
||||||
div.item-row {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: row;
|
|
||||||
&:not(:first-child) {
|
|
||||||
margin-top: 0.5em;
|
|
||||||
border-top: 1px dotted #0000004f;
|
|
||||||
padding-top: 0.5em;
|
|
||||||
flex-direction: column;
|
|
||||||
}
|
|
||||||
|
|
||||||
div.item-col {
|
|
||||||
&:first-child {
|
|
||||||
flex-grow: 0; flex-shrink: 0; flex-basis: 33%;
|
|
||||||
}
|
|
||||||
&:last-child {
|
|
||||||
flex-grow: 1; flex-shrink: 1; flex-basis: auto;
|
|
||||||
display: flex;
|
|
||||||
justify-content: flex-end;
|
|
||||||
|
|
||||||
.list-content { // ul, dl, or div
|
|
||||||
}
|
|
||||||
ul.record_actions {
|
|
||||||
margin: 0;
|
|
||||||
align-self: flex-start;
|
|
||||||
flex-grow: 1; flex-shrink: 0; flex-basis: auto;
|
|
||||||
li {
|
|
||||||
margin-right: 5px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@media only screen and (max-width: 900px) {
|
|
||||||
flex-direction: column;
|
|
||||||
div.item-col {
|
|
||||||
&:last-child {
|
|
||||||
ul.record_actions {
|
|
||||||
align-self: flex-end;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// neutralize
|
|
||||||
div.chill_address div.chill_address_address p { text-indent: 0; }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Address form
|
|
||||||
*/
|
|
||||||
div.address_form {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
div.address_form__header {
|
|
||||||
|
|
||||||
}
|
|
||||||
div.address_form__select {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: row;
|
|
||||||
justify-content: space-between;
|
|
||||||
|
|
||||||
div.address_form__select__body {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
flex-grow: 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
div.address_form__select__map {
|
|
||||||
margin: 0px 20px;
|
|
||||||
div#address_map {
|
|
||||||
height:400px;
|
|
||||||
width:400px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
div.address_form__more {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@@ -33,26 +33,7 @@ export default {
|
|||||||
methods: {
|
methods: {
|
||||||
addNewAddress({ address, modal }) {
|
addNewAddress({ address, modal }) {
|
||||||
console.log('@@@ CLICK button addNewAdress', address);
|
console.log('@@@ CLICK button addNewAdress', address);
|
||||||
|
this.$store.dispatch('addAddress', address.selected);
|
||||||
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;
|
modal.showModal = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,13 +1,12 @@
|
|||||||
const addressMessages = {
|
const addressMessages = {
|
||||||
fr: {
|
fr: {
|
||||||
add_an_address_title: 'Ajouter une adresse',
|
add_an_address: 'Ajouter une adresse',
|
||||||
select_an_address_title: 'Sélectionner une adresse',
|
select_an_address: 'Sélectionner une adresse',
|
||||||
fill_an_address: 'Compléter l\'adresse',
|
fill_an_address: 'Compléter l\'adresse',
|
||||||
select_country: 'Choisir le pays',
|
select_country: 'Choisir le pays',
|
||||||
select_city: 'Choisir une localité',
|
select_city: 'Choisir une localité',
|
||||||
select_address: 'Choisir une adresse',
|
select_address: 'Choisir une adresse',
|
||||||
create_address: 'Appuyer sur "Entrée" pour créer une nouvelle adresse',
|
isNoAddress: 'L\'adresse n\'est pas celle d\'un domicile fixe ?',
|
||||||
isNoAddress: 'Pas d\'adresse complète',
|
|
||||||
floor: 'Étage',
|
floor: 'Étage',
|
||||||
corridor: 'Couloir',
|
corridor: 'Couloir',
|
||||||
steps: 'Escalier',
|
steps: 'Escalier',
|
||||||
|
@@ -1,7 +1,8 @@
|
|||||||
import 'es6-promise/auto';
|
import 'es6-promise/auto';
|
||||||
import { createStore } from 'vuex';
|
import { createStore } from 'vuex';
|
||||||
|
|
||||||
import { postAddress } from '../../_api/AddAddress'
|
// le fetch POST serait rangé dans la logique du composant qui appelle AddAddress
|
||||||
|
//import { postAddress } from '... api'
|
||||||
|
|
||||||
const debug = process.env.NODE_ENV !== 'production';
|
const debug = process.env.NODE_ENV !== 'production';
|
||||||
|
|
||||||
@@ -9,14 +10,11 @@ const store = createStore({
|
|||||||
strict: debug,
|
strict: debug,
|
||||||
state: {
|
state: {
|
||||||
address: {},
|
address: {},
|
||||||
errorMsg: []
|
errorMsg: {}
|
||||||
},
|
},
|
||||||
getters: {
|
getters: {
|
||||||
},
|
},
|
||||||
mutations: {
|
mutations: {
|
||||||
catchError(state, error) {
|
|
||||||
state.errorMsg.push(error);
|
|
||||||
},
|
|
||||||
addAddress(state, address) {
|
addAddress(state, address) {
|
||||||
console.log('@M addAddress address', address);
|
console.log('@M addAddress address', address);
|
||||||
state.address = address;
|
state.address = address;
|
||||||
@@ -25,19 +23,19 @@ const store = createStore({
|
|||||||
actions: {
|
actions: {
|
||||||
addAddress({ commit }, payload) {
|
addAddress({ commit }, payload) {
|
||||||
console.log('@A addAddress payload', payload);
|
console.log('@A addAddress payload', payload);
|
||||||
//commit('addAddress', payload); // à remplacer par la suite
|
commit('addAddress', payload); // à remplacer par
|
||||||
|
|
||||||
//fetch POST qui envoie l'adresse, et récupère la confirmation que c'est ok.
|
// fetch POST qui envoie l'adresse, et récupère la confirmation que c'est ok.
|
||||||
//La confirmation est l'adresse elle-même.
|
// La confirmation est l'adresse elle-même.
|
||||||
|
//
|
||||||
postAddress(payload)
|
// postAddress(payload)
|
||||||
.then(address => new Promise((resolve, reject) => {
|
// .fetch(address => new Promise((resolve, reject) => {
|
||||||
commit('addAddress', address);
|
// commit('addAddress', address);
|
||||||
resolve();
|
// resolve();
|
||||||
}))
|
// }))
|
||||||
.catch((error) => {
|
// .catch((error) => {
|
||||||
commit('catchError', error);
|
// state.errorMsg.push(error.message);
|
||||||
});
|
// });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@@ -1,43 +1,37 @@
|
|||||||
/*
|
/*
|
||||||
* Endpoint chill_api_single_country__index
|
* Endpoint countries GET
|
||||||
* method GET, get Country Object
|
* TODO
|
||||||
* @returns {Promise} a promise containing all Country object
|
|
||||||
*/
|
*/
|
||||||
const fetchCountries = () => {
|
const fetchCountries = () => {
|
||||||
console.log('<<< fetching countries');
|
console.log('<<< fetching countries');
|
||||||
|
return [
|
||||||
const url = `/api/1.0/main/country.json?item_per_page=1000`;
|
{id: 1, name: 'France', countryCode: 'FR'},
|
||||||
return fetch(url)
|
{id: 2, name: 'Belgium', countryCode: 'BE'}
|
||||||
.then(response => {
|
];
|
||||||
if (response.ok) { return response.json(); }
|
|
||||||
throw Error('Error with request resource response');
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Endpoint chill_api_single_postal_code__index
|
* Endpoint cities GET
|
||||||
* method GET, get Country Object
|
* TODO
|
||||||
* @returns {Promise} a promise containing all Postal Code objects filtered with country
|
|
||||||
*/
|
*/
|
||||||
const fetchCities = (country) => {
|
const fetchCities = (country) => {
|
||||||
console.log('<<< fetching cities for', country);
|
console.log('<<< fetching cities for', country);
|
||||||
const url = `/api/1.0/main/postal-code.json?item_per_page=1000&country=${country.id}`;
|
return [
|
||||||
return fetch(url)
|
{id: 1, name: 'Bruxelles', code: '1000', country: 'BE'},
|
||||||
.then(response => {
|
{id: 2, name: 'Aisne', code: '85045', country: 'FR'},
|
||||||
if (response.ok) { return response.json(); }
|
{id: 3, name: 'Saint-Gervais', code: '85230', country: 'FR'}
|
||||||
throw Error('Error with request resource response');
|
];
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Endpoint chill_api_single_address_reference__index
|
* Endpoint chill_main_address_reference_api_show
|
||||||
* method GET, get AddressReference Object
|
* method GET, get AddressReference Object
|
||||||
* @returns {Promise} a promise containing all AddressReference objects filtered with postal code
|
* @returns {Promise} a promise containing all AddressReference object
|
||||||
*/
|
*/
|
||||||
const fetchReferenceAddresses = (postalCode) => {
|
const fetchReferenceAddresses = (city) => {
|
||||||
console.log('<<< fetching references addresses for', postalCode);
|
console.log('<<< fetching references addresses for', city); // city n'est pas utilisé pour le moment
|
||||||
//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}`;
|
const url = `/api/1.0/main/address-reference.json`;
|
||||||
return fetch(url)
|
return fetch(url)
|
||||||
.then(response => {
|
.then(response => {
|
||||||
if (response.ok) { return response.json(); }
|
if (response.ok) { return response.json(); }
|
||||||
@@ -45,31 +39,8 @@ const fetchReferenceAddresses = (postalCode) => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
|
||||||
* 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 {
|
export {
|
||||||
fetchCountries,
|
fetchCountries,
|
||||||
fetchCities,
|
fetchCities,
|
||||||
fetchReferenceAddresses,
|
fetchReferenceAddresses
|
||||||
postAddress
|
|
||||||
};
|
};
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<button class="sc-button bt-create centered mt-4" @click="openModal">
|
<button class="sc-button bt-create centered mt-4" @click="openModal">
|
||||||
{{ $t('add_an_address_title') }}
|
{{ $t('add_an_address') }}
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
<teleport to="body">
|
<teleport to="body">
|
||||||
@@ -9,60 +9,72 @@
|
|||||||
@close="modal.showModal = false">
|
@close="modal.showModal = false">
|
||||||
|
|
||||||
<template v-slot:header>
|
<template v-slot:header>
|
||||||
<h3 class="modal-title">{{ $t('add_an_address_title') }}</h3>
|
<h3 class="modal-title">{{ $t('add_an_address') }}</h3>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<template v-slot:body>
|
<template v-slot:body>
|
||||||
<div class="address_form">
|
|
||||||
|
|
||||||
<div class="address_form__header">
|
<h4>{{ $t('select_an_address') }}</h4>
|
||||||
<h4>{{ $t('select_an_address_title') }}</h4>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="address_form__select">
|
<label for="isNoAddress">
|
||||||
|
<input type="checkbox"
|
||||||
|
name="isNoAddress"
|
||||||
|
v-bind:placeholder="$t('isNoAddress')"
|
||||||
|
v-model="isNoAddress"
|
||||||
|
v-bind:value="value"/>
|
||||||
|
{{ $t('isNoAddress') }}
|
||||||
|
</label>
|
||||||
|
|
||||||
<div class="address_form__select__body">
|
<country-selection
|
||||||
<label for="isNoAddress">
|
v-bind:address="address"
|
||||||
<input type="checkbox"
|
v-bind:getCities="getCities">
|
||||||
name="isNoAddress"
|
</country-selection>
|
||||||
v-bind:placeholder="$t('isNoAddress')"
|
|
||||||
v-model="isNoAddress"
|
|
||||||
v-bind:value="value"/>
|
|
||||||
{{ $t('isNoAddress') }}
|
|
||||||
</label>
|
|
||||||
|
|
||||||
<country-selection
|
<city-selection
|
||||||
v-bind:address="address"
|
v-bind:address="address"
|
||||||
v-bind:getCities="getCities">
|
v-bind:getReferenceAddresses="getReferenceAddresses">
|
||||||
</country-selection>
|
</city-selection>
|
||||||
|
|
||||||
<city-selection
|
<address-selection
|
||||||
v-bind:address="address"
|
v-bind:address="address"
|
||||||
v-bind:getReferenceAddresses="getReferenceAddresses">
|
v-bind:updateMapCenter="updateMapCenter">
|
||||||
</city-selection>
|
</address-selection>
|
||||||
|
|
||||||
<address-selection
|
<address-map
|
||||||
v-bind:address="address"
|
v-bind:address="address"
|
||||||
v-bind:updateMapCenter="updateMapCenter">
|
ref="addressMap">
|
||||||
</address-selection>
|
</address-map>
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="address_form__select__map">
|
<address-more
|
||||||
<address-map
|
v-if="!isNoAddress"
|
||||||
v-bind:address="address"
|
v-bind:address="address">
|
||||||
ref="addressMap">
|
</address-more>
|
||||||
</address-map>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="address_form__more">
|
<!--
|
||||||
<address-more
|
<div class="address_form__fields__isNoAddress"></div>
|
||||||
v-if="!isNoAddress"
|
<div class="address_form__select">
|
||||||
v-bind:address="address">
|
<div class="address_form__select__header"></div>
|
||||||
</address-more>
|
<div class="address_form__select__left"></div>
|
||||||
</div>
|
<div class="address_form__map"></div>
|
||||||
|
</div>
|
||||||
|
<div class="address_form__fields">
|
||||||
|
<div class="address_form__fields__header"></div>
|
||||||
|
<div class="address_form__fields__left"></div>
|
||||||
|
<div class="address_form__fields__right"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
à discuter,
|
||||||
|
mais je pense qu'il est préférable de profiter de l'imbriquation des classes css
|
||||||
|
|
||||||
|
div.address_form {
|
||||||
|
div.select {
|
||||||
|
div.header {}
|
||||||
|
div.left {}
|
||||||
|
div.map {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
-->
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<template v-slot:footer>
|
<template v-slot:footer>
|
||||||
@@ -143,40 +155,42 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
|
||||||
this.getCountries();
|
|
||||||
},
|
|
||||||
methods: {
|
methods: {
|
||||||
openModal() {
|
openModal() {
|
||||||
this.modal.showModal = true;
|
this.modal.showModal = true;
|
||||||
this.resetAll();
|
this.resetAll();
|
||||||
|
this.getCountries();
|
||||||
|
|
||||||
//this.$nextTick(function() {
|
//this.$nextTick(function() {
|
||||||
// this.$refs.search.focus(); // positionner le curseur à l'ouverture de la modale
|
// this.$refs.search.focus(); // positionner le curseur à l'ouverture de la modale
|
||||||
//})
|
//})
|
||||||
},
|
},
|
||||||
getCountries() {
|
getCountries() {
|
||||||
console.log('getCountries');
|
console.log('getCountries');
|
||||||
fetchCountries().then(countries => new Promise((resolve, reject) => {
|
this.address.loaded.countries = fetchCountries(); // à remplacer par
|
||||||
this.address.loaded.countries = countries.results;
|
// fetchCountries().then(countries => new Promise((resolve, reject) => {
|
||||||
resolve()
|
// this.address.loaded.countries = countries;
|
||||||
}))
|
// resolve()
|
||||||
.catch((error) => {
|
// }))
|
||||||
this.errorMsg.push(error.message);
|
// .catch((error) => {
|
||||||
});
|
// this.errorMsg.push(error.message);
|
||||||
|
// });
|
||||||
},
|
},
|
||||||
getCities(country) {
|
getCities(country) {
|
||||||
console.log('getCities for', country.name);
|
console.log('getCities for', country.name);
|
||||||
fetchCities(country).then(cities => new Promise((resolve, reject) => {
|
this.address.loaded.cities = fetchCities(); // à remplacer par
|
||||||
this.address.loaded.cities = cities.results;
|
// fetchCities(country).then(cities => new Promise((resolve, reject) => {
|
||||||
resolve()
|
// this.address.loaded.cities = cities;
|
||||||
}))
|
// resolve()
|
||||||
.catch((error) => {
|
// }))
|
||||||
this.errorMsg.push(error.message);
|
// .catch((error) => {
|
||||||
});
|
// this.errorMsg.push(error.message);
|
||||||
|
// });
|
||||||
},
|
},
|
||||||
getReferenceAddresses(city) {
|
getReferenceAddresses(city) {
|
||||||
console.log('getReferenceAddresses for', city.name);
|
console.log('getReferenceAddresses for', city.name);
|
||||||
fetchReferenceAddresses(city).then(addresses => new Promise((resolve, reject) => {
|
fetchReferenceAddresses(city) // il me semble que le paramètre city va limiter le poids des adresses de références reçues
|
||||||
|
.then(addresses => new Promise((resolve, reject) => {
|
||||||
console.log('addresses', addresses);
|
console.log('addresses', addresses);
|
||||||
this.address.loaded.addresses = addresses.results;
|
this.address.loaded.addresses = addresses.results;
|
||||||
resolve();
|
resolve();
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div id='address_map'></div>
|
<div id='address_map' style='height:400px; width:400px;'></div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -11,7 +11,6 @@ import markerIconPng from 'leaflet/dist/images/marker-icon.png'
|
|||||||
import 'leaflet/dist/leaflet.css';
|
import 'leaflet/dist/leaflet.css';
|
||||||
|
|
||||||
let map;
|
let map;
|
||||||
let marker;
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'AddressMap',
|
name: 'AddressMap',
|
||||||
@@ -31,15 +30,13 @@ export default {
|
|||||||
|
|
||||||
const markerIcon = L.icon({
|
const markerIcon = L.icon({
|
||||||
iconUrl: markerIconPng,
|
iconUrl: markerIconPng,
|
||||||
iconAnchor: [12, 41],
|
|
||||||
});
|
});
|
||||||
|
|
||||||
marker = L.marker([48.8589, 2.3469], {icon: markerIcon}).addTo(map);
|
L.marker([48.8589, 2.3469], {icon: markerIcon}).addTo(map);
|
||||||
|
|
||||||
},
|
},
|
||||||
update() {
|
update() {
|
||||||
console.log('update map with : ', this.address.addressMap.center)
|
console.log('update map with : ', this.address.addressMap.center)
|
||||||
marker.setLatLng(this.address.addressMap.center);
|
|
||||||
map.setView(this.address.addressMap.center, 12);
|
map.setView(this.address.addressMap.center, 12);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@@ -1,56 +1,38 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<VueMultiselect
|
<select
|
||||||
v-model="value"
|
v-model="selected">
|
||||||
@select="selectAddress"
|
<option :value="{}" disabled selected>{{ $t('select_address') }}</option>
|
||||||
name="field"
|
<option
|
||||||
track-by="id"
|
v-for="item in this.addresses"
|
||||||
label="value"
|
v-bind:item="item"
|
||||||
:custom-label="transName"
|
v-bind:key="item.id"
|
||||||
:taggable="true"
|
v-bind:value="item">
|
||||||
:multiple="false"
|
{{ item.street }}, {{ item.streetNumber }}
|
||||||
@tag="addAddress"
|
</option>
|
||||||
:placeholder="$t('select_address')"
|
</select>
|
||||||
:tagPlaceholder="$t('create_address')"
|
|
||||||
:options="addresses">
|
|
||||||
</VueMultiselect>
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import VueMultiselect from 'vue-multiselect';
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'AddressSelection',
|
name: 'AddressSelection',
|
||||||
components: { VueMultiselect },
|
|
||||||
props: ['address', 'updateMapCenter'],
|
props: ['address', 'updateMapCenter'],
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
value: null
|
|
||||||
}
|
|
||||||
},
|
|
||||||
computed: {
|
computed: {
|
||||||
addresses() {
|
addresses() {
|
||||||
return this.address.loaded.addresses;
|
return this.address.loaded.addresses;
|
||||||
}
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
transName(value) {
|
|
||||||
return value.streetNumber === undefined ? value.street : `${value.street}, ${value.streetNumber}`
|
|
||||||
},
|
},
|
||||||
selectAddress(value) {
|
selected: {
|
||||||
this.address.selected.address = value;
|
set(value) {
|
||||||
this.updateMapCenter(value.point);
|
console.log('selected value', value);
|
||||||
|
this.address.selected.address = value;
|
||||||
|
this.updateMapCenter(value.point);
|
||||||
|
},
|
||||||
|
get() {
|
||||||
|
return this.address.selected.address;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
addAddress (newAddress) {
|
|
||||||
const address = {
|
|
||||||
street: newAddress
|
|
||||||
};
|
|
||||||
this.value = address;
|
|
||||||
this.address.selected.address = address;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style src="vue-multiselect/dist/vue-multiselect.css"></style>
|
|
||||||
|
@@ -1,45 +1,38 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<VueMultiselect
|
<select
|
||||||
v-model="value"
|
v-model="selected">
|
||||||
@select="selectCity"
|
<option :value="{}" disabled selected>{{ $t('select_city') }}</option>
|
||||||
name="field"
|
<option
|
||||||
track-by="id"
|
v-for="item in this.cities"
|
||||||
label="value"
|
v-bind:item="item"
|
||||||
:custom-label="transName"
|
v-bind:key="item.id"
|
||||||
:placeholder="$t('select_city')"
|
v-bind:value="item">
|
||||||
:options="cities">
|
{{ item.code }}-{{ item.name }}
|
||||||
</VueMultiselect>
|
</option>
|
||||||
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import VueMultiselect from 'vue-multiselect';
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'CitySelection',
|
name: 'CitySelection',
|
||||||
components: { VueMultiselect },
|
|
||||||
props: ['address', 'getReferenceAddresses'],
|
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: {
|
computed: {
|
||||||
cities() {
|
cities() {
|
||||||
return this.address.loaded.cities;
|
return this.address.loaded.cities;
|
||||||
}
|
},
|
||||||
|
selected: {
|
||||||
|
set(value) {
|
||||||
|
console.log('selected value', value.name);
|
||||||
|
this.address.selected.city = value;
|
||||||
|
this.getReferenceAddresses(value);
|
||||||
|
},
|
||||||
|
get() {
|
||||||
|
return this.address.selected.city;
|
||||||
|
}
|
||||||
|
},
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style src="vue-multiselect/dist/vue-multiselect.css"></style>
|
|
||||||
|
@@ -1,59 +1,38 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<VueMultiselect
|
<select
|
||||||
v-model="value"
|
v-model="selected">
|
||||||
name="field"
|
<option :value="{}" disabled selected>{{ $t('select_country') }}</option>
|
||||||
track-by="id"
|
<option
|
||||||
label="name"
|
v-for="item in this.countries"
|
||||||
:custom-label="transName"
|
v-bind:item="item"
|
||||||
:placeholder="$t('select_country')"
|
v-bind:key="item.id"
|
||||||
:options="countries"
|
v-bind:value="item">
|
||||||
@select="selectCountry">
|
{{ item.name }}
|
||||||
</VueMultiselect>
|
</option>
|
||||||
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import VueMultiselect from 'vue-multiselect';
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'CountrySelection',
|
name: 'CountrySelection',
|
||||||
components: { VueMultiselect },
|
|
||||||
props: ['address', 'getCities'],
|
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: {
|
computed: {
|
||||||
countries() {
|
countries() {
|
||||||
const countries = this.address.loaded.countries;
|
return this.address.loaded.countries;
|
||||||
let orderedCountries = [];
|
},
|
||||||
orderedCountries.push(...countries.filter(c => c.countryCode === 'FR'))
|
selected: {
|
||||||
orderedCountries.push(...countries.filter(c => c.countryCode === 'BE'))
|
set(value) {
|
||||||
orderedCountries.push(...countries.filter(c => c.countryCode !== 'FR').filter(c => c.countryCode !== 'BE'))
|
console.log('selected value', value.name);
|
||||||
return orderedCountries;
|
this.address.selected.country = value;
|
||||||
|
this.getCities(value);
|
||||||
|
},
|
||||||
|
get() {
|
||||||
|
return this.address.selected.country;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style src="vue-multiselect/dist/vue-multiselect.css"></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>
|
|
@@ -37,32 +37,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,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 %}
|
|
||||||
|
@@ -69,14 +69,6 @@ class SectionMenuBuilder implements LocalMenuBuilderInterface
|
|||||||
'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'), [
|
||||||
'route' => 'chill_main_export_index'
|
'route' => 'chill_main_export_index'
|
||||||
|
@@ -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;
|
||||||
@@ -180,30 +181,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);
|
||||||
}
|
}
|
||||||
|
@@ -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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@@ -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]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@@ -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
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
}
|
|
@@ -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);
|
return $this->em->createNativeQuery($count, $rsm)
|
||||||
|
->getSingleScalarResult();
|
||||||
// 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();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
@@ -9,14 +9,15 @@ servers:
|
|||||||
description: "Your current dev server"
|
description: "Your current dev server"
|
||||||
|
|
||||||
components:
|
components:
|
||||||
schemas:
|
parameters:
|
||||||
Center:
|
_format:
|
||||||
type: object
|
name: _format
|
||||||
properties:
|
in: path
|
||||||
id:
|
required: true
|
||||||
type: integer
|
schema:
|
||||||
name:
|
type: string
|
||||||
type: string
|
enum:
|
||||||
|
- json
|
||||||
|
|
||||||
paths:
|
paths:
|
||||||
/1.0/search.json:
|
/1.0/search.json:
|
||||||
|
@@ -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"
|
||||||
|
@@ -65,4 +65,3 @@ services:
|
|||||||
- "@security.authorization_checker"
|
- "@security.authorization_checker"
|
||||||
- "@chill.main.security.authorization.helper"
|
- "@chill.main.security.authorization.helper"
|
||||||
- "@security.token_storage"
|
- "@security.token_storage"
|
||||||
|
|
||||||
|
@@ -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' }
|
|
||||||
|
|
||||||
|
@@ -5,6 +5,3 @@ services:
|
|||||||
- "@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');
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,29 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace Chill\Migrations\Main;
|
|
||||||
|
|
||||||
use Doctrine\DBAL\Schema\Schema;
|
|
||||||
use Doctrine\Migrations\AbstractMigration;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add extension btree_gist
|
|
||||||
*/
|
|
||||||
final class Version20210528090000 extends AbstractMigration
|
|
||||||
{
|
|
||||||
public function getDescription(): string
|
|
||||||
{
|
|
||||||
return 'add extension btree_gist';
|
|
||||||
}
|
|
||||||
|
|
||||||
public function up(Schema $schema): void
|
|
||||||
{
|
|
||||||
$this->addSql('CREATE EXTENSION IF NOT EXISTS btree_gist');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function down(Schema $schema): void
|
|
||||||
{
|
|
||||||
$this->addSql('DROP EXTENSION btree_gist');
|
|
||||||
}
|
|
||||||
}
|
|
@@ -46,11 +46,6 @@ Back to the list: Retour à la liste
|
|||||||
#interval
|
#interval
|
||||||
Years: Années
|
Years: Années
|
||||||
|
|
||||||
# misc date
|
|
||||||
Since %date%: Depuis le %date%
|
|
||||||
since %date%: depuis le %date%
|
|
||||||
Until %date%: Jusqu'au %date%
|
|
||||||
until %date%: jusqu'au %date%
|
|
||||||
#elements used in software
|
#elements used in software
|
||||||
centers: centres
|
centers: centres
|
||||||
Centers: Centres
|
Centers: Centres
|
||||||
@@ -83,9 +78,6 @@ Results %start%-%end% of %total%: Résultats %start%-%end% sur %total%
|
|||||||
See all results: Voir tous les résultats
|
See all results: Voir tous les résultats
|
||||||
Advanced search: Recherche avancée
|
Advanced search: Recherche avancée
|
||||||
|
|
||||||
# timeline
|
|
||||||
Global timeline: Historique global
|
|
||||||
|
|
||||||
#admin
|
#admin
|
||||||
Create: Créer
|
Create: Créer
|
||||||
show: voir
|
show: voir
|
||||||
|
@@ -75,10 +75,10 @@ $workflow = $this->registry->get($accompanyingPeriod);
|
|||||||
|
|
||||||
switch ($request->getMethod()) {
|
switch ($request->getMethod()) {
|
||||||
case Request::METHOD_POST:
|
case Request::METHOD_POST:
|
||||||
$participation = $accompanyingPeriod->createParticipationFor($person);
|
$participation = $accompanyingPeriod->addPerson($person);
|
||||||
break;
|
break;
|
||||||
case Request::METHOD_DELETE:
|
case Request::METHOD_DELETE:
|
||||||
$participation = $accompanyingPeriod->closeParticipationFor($person);
|
$participation = $accompanyingPeriod->removePerson($person);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new BadRequestException("This method is not supported");
|
throw new BadRequestException("This method is not supported");
|
||||||
|
@@ -72,7 +72,7 @@ class AccompanyingCourseController extends Controller
|
|||||||
$em->persist($period);
|
$em->persist($period);
|
||||||
$em->flush();
|
$em->flush();
|
||||||
|
|
||||||
return $this->redirectToRoute('chill_person_accompanying_course_edit', [
|
return $this->redirectToRoute('chill_person_accompanying_course_show', [
|
||||||
'accompanying_period_id' => $period->getId()
|
'accompanying_period_id' => $period->getId()
|
||||||
]);
|
]);
|
||||||
|
|
||||||
@@ -92,16 +92,17 @@ class AccompanyingCourseController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Edit page of Accompanying Course section
|
* Show page of Accompanying Course section
|
||||||
*
|
*
|
||||||
* the page edit all blocks managed by vuejs component
|
* the page show all blocks except one active edit block, managed by vuejs component
|
||||||
|
* that's why title of page is 'edit accompanying course'
|
||||||
*
|
*
|
||||||
* @Route("/{_locale}/parcours/{accompanying_period_id}/edit", name="chill_person_accompanying_course_edit")
|
* @Route("/{_locale}/parcours/{accompanying_period_id}/show", name="chill_person_accompanying_course_show")
|
||||||
* @ParamConverter("accompanyingCourse", options={"id": "accompanying_period_id"})
|
* @ParamConverter("accompanyingCourse", options={"id": "accompanying_period_id"})
|
||||||
*/
|
*/
|
||||||
public function editAction(AccompanyingPeriod $accompanyingCourse): Response
|
public function showAction(AccompanyingPeriod $accompanyingCourse): Response
|
||||||
{
|
{
|
||||||
return $this->render('@ChillPerson/AccompanyingCourse/edit.html.twig', [
|
return $this->render('@ChillPerson/AccompanyingCourse/show.html.twig', [
|
||||||
'accompanyingCourse' => $accompanyingCourse
|
'accompanyingCourse' => $accompanyingCourse
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
@@ -390,13 +390,13 @@ class AccompanyingPeriodController extends AbstractController
|
|||||||
/** @var Person $person */
|
/** @var Person $person */
|
||||||
$person = $this->_getPerson($person_id);
|
$person = $this->_getPerson($person_id);
|
||||||
|
|
||||||
|
$criteria = Criteria::create();
|
||||||
|
$criteria->where($criteria->expr()->eq('id', $period_id));
|
||||||
|
|
||||||
/* @var $period AccompanyingPeriod */
|
/* @var $period AccompanyingPeriod */
|
||||||
$period = \array_filter(
|
$period = $person->getAccompanyingPeriods()
|
||||||
$person->getAccompanyingPeriods(),
|
->matching($criteria)
|
||||||
function (AccompanyingPeriod $p) use ($period_id) {
|
->first();
|
||||||
return $p->getId() === ($period_id);
|
|
||||||
}
|
|
||||||
)[0] ?? NULL;
|
|
||||||
|
|
||||||
if ($period === NULL) {
|
if ($period === NULL) {
|
||||||
throw $this->createNotFoundException('period not found');
|
throw $this->createNotFoundException('period not found');
|
||||||
|
@@ -0,0 +1,30 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2015-2021 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\PersonBundle\Controller;
|
||||||
|
|
||||||
|
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
||||||
|
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||||
|
|
||||||
|
|
||||||
|
class ApiPersonController extends Controller
|
||||||
|
{
|
||||||
|
public function viewAction($id, $_format)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@@ -1,88 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Chill\PersonBundle\Controller;
|
|
||||||
|
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
|
||||||
use Symfony\Component\Routing\Annotation\Route;
|
|
||||||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
|
|
||||||
use Chill\PersonBundle\Entity\Household\Household;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @Route("/{_locale}/person/household")
|
|
||||||
*/
|
|
||||||
class HouseholdController extends AbstractController
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @Route(
|
|
||||||
* "/{household_id}/summary",
|
|
||||||
* name="chill_person_household_summary",
|
|
||||||
* methods={"GET", "HEAD"}
|
|
||||||
* )
|
|
||||||
* @ParamConverter("household", options={"id" = "household_id"})
|
|
||||||
*/
|
|
||||||
public function summary(Request $request, Household $household)
|
|
||||||
{
|
|
||||||
// TODO ACL
|
|
||||||
return $this->render('@ChillPerson/Household/summary.html.twig',
|
|
||||||
[
|
|
||||||
'household' => $household
|
|
||||||
]
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @Route(
|
|
||||||
* "/{household_id}/members",
|
|
||||||
* name="chill_person_household_members",
|
|
||||||
* methods={"GET", "HEAD"}
|
|
||||||
* )
|
|
||||||
* @ParamConverter("household", options={"id" = "household_id"})
|
|
||||||
*/
|
|
||||||
public function members(Request $request, Household $household)
|
|
||||||
{
|
|
||||||
// TODO ACL
|
|
||||||
return $this->render('@ChillPerson/Household/members.html.twig',
|
|
||||||
[
|
|
||||||
'household' => $household
|
|
||||||
]
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @Route(
|
|
||||||
* "/{household_id}/addresses",
|
|
||||||
* name="chill_person_household_addresses",
|
|
||||||
* methods={"GET", "HEAD"}
|
|
||||||
* )
|
|
||||||
* @ParamConverter("household", options={"id" = "household_id"})
|
|
||||||
*/
|
|
||||||
public function addresses(Request $request, Household $household)
|
|
||||||
{
|
|
||||||
// TODO ACL
|
|
||||||
return $this->render('@ChillPerson/Household/addresses.html.twig',
|
|
||||||
[
|
|
||||||
'household' => $household
|
|
||||||
]
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @Route(
|
|
||||||
* "/{household_id}/address/move",
|
|
||||||
* name="chill_person_household_address_move",
|
|
||||||
* methods={"GET", "HEAD", "POST"}
|
|
||||||
* )
|
|
||||||
* @ParamConverter("household", options={"id" = "household_id"})
|
|
||||||
*/
|
|
||||||
public function addressMove(Request $request, Household $household)
|
|
||||||
{
|
|
||||||
// TODO ACL
|
|
||||||
return $this->render('@ChillPerson/Household/address_move.html.twig',
|
|
||||||
[
|
|
||||||
'household' => $household
|
|
||||||
]
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,47 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Chill\PersonBundle\Controller;
|
|
||||||
|
|
||||||
use Symfony\Component\HttpFoundation\Exception\BadRequestException;
|
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
|
||||||
use Symfony\Component\Serializer\Exception;
|
|
||||||
use Symfony\Component\Routing\Annotation\Route;
|
|
||||||
use Chill\MainBundle\CRUD\Controller\ApiController;
|
|
||||||
use Chill\PersonBundle\Household\MembersEditor;
|
|
||||||
use Symfony\Component\Serializer\Normalizer\AbstractNormalizer;
|
|
||||||
|
|
||||||
class HouseholdMemberController extends ApiController
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @Route(
|
|
||||||
* "/api/1.0/person/household/members/move.{_format}",
|
|
||||||
* name="chill_person_household_members_move"
|
|
||||||
* )
|
|
||||||
*/
|
|
||||||
public function move(Request $request, $_format): Response
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
$editor = $this->getSerializer()
|
|
||||||
->deserialize($request->getContent(), MembersEditor::class,
|
|
||||||
$_format, ['groups' => [ "read" ]]);
|
|
||||||
} catch (Exception\InvalidArgumentException | Exception\UnexpectedValueException $e) {
|
|
||||||
throw new BadRequestException("Deserialization error: {$e->getMessage()}", 45896, $e);
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO ACL
|
|
||||||
//
|
|
||||||
// TODO validation
|
|
||||||
//
|
|
||||||
$em = $this->getDoctrine()->getManager();
|
|
||||||
|
|
||||||
foreach ($editor->getPersistable() as $el) {
|
|
||||||
$em->persist($el);
|
|
||||||
}
|
|
||||||
$em->flush();
|
|
||||||
|
|
||||||
return $this->json($editor->getHousehold(), Response::HTTP_OK, [], [
|
|
||||||
"groups" => ["read"],
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,50 +0,0 @@
|
|||||||
<?php
|
|
||||||
/*
|
|
||||||
* Copyright (C) 2015-2021 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\PersonBundle\Controller;
|
|
||||||
|
|
||||||
use Chill\PersonBundle\Security\Authorization\PersonVoter;
|
|
||||||
use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
|
|
||||||
use Symfony\Component\Security\Core\Role\Role;
|
|
||||||
use Chill\MainBundle\CRUD\Controller\ApiController;
|
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
|
||||||
|
|
||||||
|
|
||||||
class PersonApiController extends ApiController
|
|
||||||
{
|
|
||||||
private AuthorizationHelper $authorizationHelper;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param AuthorizationHelper $authorizationHelper
|
|
||||||
*/
|
|
||||||
public function __construct(AuthorizationHelper $authorizationHelper)
|
|
||||||
{
|
|
||||||
$this->authorizationHelper = $authorizationHelper;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function createEntity(string $action, Request $request): object
|
|
||||||
{
|
|
||||||
$person = parent::createEntity($action, $request);
|
|
||||||
|
|
||||||
// TODO temporary hack to allow creation of person with fake center
|
|
||||||
$centers = $this->authorizationHelper->getReachableCenters($this->getUser(),
|
|
||||||
new Role(PersonVoter::CREATE));
|
|
||||||
$person->setCenter($centers[0]);
|
|
||||||
|
|
||||||
return $person;
|
|
||||||
}
|
|
||||||
}
|
|
@@ -27,17 +27,32 @@ use Symfony\Component\HttpFoundation\Request;
|
|||||||
use Chill\MainBundle\Timeline\TimelineBuilder;
|
use Chill\MainBundle\Timeline\TimelineBuilder;
|
||||||
use Chill\MainBundle\Pagination\PaginatorFactory;
|
use Chill\MainBundle\Pagination\PaginatorFactory;
|
||||||
use Chill\PersonBundle\Security\Authorization\PersonVoter;
|
use Chill\PersonBundle\Security\Authorization\PersonVoter;
|
||||||
use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
|
|
||||||
use Symfony\Component\Security\Core\Role\Role;
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class TimelinePersonController
|
||||||
|
*
|
||||||
|
* @package Chill\PersonBundle\Controller
|
||||||
|
* @author Julien Fastré <julien.fastre@champs-libres.coop>
|
||||||
|
*/
|
||||||
class TimelinePersonController extends AbstractController
|
class TimelinePersonController extends AbstractController
|
||||||
{
|
{
|
||||||
|
|
||||||
protected EventDispatcherInterface $eventDispatcher;
|
/**
|
||||||
|
* @var EventDispatcherInterface
|
||||||
|
*/
|
||||||
|
protected $eventDispatcher;
|
||||||
|
|
||||||
protected TimelineBuilder $timelineBuilder;
|
/**
|
||||||
|
*
|
||||||
|
* @var TimelineBuilder
|
||||||
|
*/
|
||||||
|
protected $timelineBuilder;
|
||||||
|
|
||||||
protected PaginatorFactory $paginatorFactory;
|
/**
|
||||||
|
*
|
||||||
|
* @var PaginatorFactory
|
||||||
|
*/
|
||||||
|
protected $paginatorFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TimelinePersonController constructor.
|
* TimelinePersonController constructor.
|
||||||
@@ -47,13 +62,11 @@ class TimelinePersonController extends AbstractController
|
|||||||
public function __construct(
|
public function __construct(
|
||||||
EventDispatcherInterface $eventDispatcher,
|
EventDispatcherInterface $eventDispatcher,
|
||||||
TimelineBuilder $timelineBuilder,
|
TimelineBuilder $timelineBuilder,
|
||||||
PaginatorFactory $paginatorFactory,
|
PaginatorFactory $paginatorFactory
|
||||||
AuthorizationHelper $authorizationHelper
|
|
||||||
) {
|
) {
|
||||||
$this->eventDispatcher = $eventDispatcher;
|
$this->eventDispatcher = $eventDispatcher;
|
||||||
$this->timelineBuilder = $timelineBuilder;
|
$this->timelineBuilder = $timelineBuilder;
|
||||||
$this->paginatorFactory = $paginatorFactory;
|
$this->paginatorFactory = $paginatorFactory;
|
||||||
$this->authorizationHelper = $authorizationHelper;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -1,126 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Chill\PersonBundle\DataFixtures\ORM;
|
|
||||||
|
|
||||||
use Chill\PersonBundle\Entity\Person;
|
|
||||||
use Chill\PersonBundle\Entity\Household\Household;
|
|
||||||
use Chill\PersonBundle\Household\MembersEditorFactory;
|
|
||||||
use Doctrine\Bundle\FixturesBundle\Fixture;
|
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
|
||||||
use Doctrine\Persistence\ObjectManager;
|
|
||||||
use Doctrine\Common\DataFixtures\DependentFixtureInterface;
|
|
||||||
|
|
||||||
class LoadHousehold extends Fixture implements DependentFixtureInterface
|
|
||||||
{
|
|
||||||
private MembersEditorFactory $editorFactory;
|
|
||||||
|
|
||||||
private EntityManagerInterface $em;
|
|
||||||
|
|
||||||
private CONST NUMBER_OF_HOUSEHOLD = 10;
|
|
||||||
|
|
||||||
public function __construct(MembersEditorFactory $editorFactory, EntityManagerInterface $em)
|
|
||||||
{
|
|
||||||
$this->editorFactory = $editorFactory;
|
|
||||||
$this->em = $em;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function load(ObjectManager $manager)
|
|
||||||
{
|
|
||||||
// generate two times the participation. This will lead to
|
|
||||||
// some movement in participation (same people in two differents
|
|
||||||
// households)
|
|
||||||
|
|
||||||
$this->preparePersonIds();
|
|
||||||
|
|
||||||
$this->generateHousehold(
|
|
||||||
$manager,
|
|
||||||
\DateTimeImmutable::createFromFormat('Y-m-d', '2010-01-01')
|
|
||||||
);
|
|
||||||
|
|
||||||
$this->preparePersonIds();
|
|
||||||
|
|
||||||
$this->generateHousehold(
|
|
||||||
$manager,
|
|
||||||
\DateTimeImmutable::createFromFormat('Y-m-d', '2015-01-01')
|
|
||||||
);
|
|
||||||
|
|
||||||
$manager->flush();
|
|
||||||
}
|
|
||||||
|
|
||||||
private function generateHousehold(ObjectManager $manager, \DateTimeImmutable $startDate)
|
|
||||||
{
|
|
||||||
for ($i=0; $i < self::NUMBER_OF_HOUSEHOLD; $i++) {
|
|
||||||
$household = new Household();
|
|
||||||
$manager->persist($household);
|
|
||||||
|
|
||||||
$movement = $this->editorFactory->createEditor($household);
|
|
||||||
|
|
||||||
// load adults
|
|
||||||
$k = 0;
|
|
||||||
foreach ($this->getRandomPersons(1, 3) as $person) {
|
|
||||||
$date = $startDate->add(new \DateInterval('P'.\random_int(1, 200).'W'));
|
|
||||||
$position = $this->getReference(LoadHouseholdPosition::ADULT);
|
|
||||||
|
|
||||||
$movement->addMovement($date, $person, $position, $k === 0, "self generated");
|
|
||||||
$k++;
|
|
||||||
}
|
|
||||||
|
|
||||||
// load children
|
|
||||||
foreach ($this->getRandomPersons(0, 3) as $person) {
|
|
||||||
$date = $startDate->add(new \DateInterval('P'.\random_int(1, 200).'W'));
|
|
||||||
$position = $this->getReference(LoadHouseholdPosition::CHILD);
|
|
||||||
|
|
||||||
$movement->addMovement($date, $person, $position, $k === 0, "self generated");
|
|
||||||
$k++;
|
|
||||||
}
|
|
||||||
|
|
||||||
// load children out
|
|
||||||
foreach ($this->getRandomPersons(0, 2) as $person) {
|
|
||||||
$date = $startDate->add(new \DateInterval('P'.\random_int(1, 200).'W'));
|
|
||||||
$position = $this->getReference(LoadHouseholdPosition::CHILD_OUT);
|
|
||||||
|
|
||||||
$movement->addMovement($date, $person, $position, $k === 0, "self generated");
|
|
||||||
$k++;
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($movement->getPersistable() as $obj) {
|
|
||||||
$manager->persist($obj);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private function preparePersonIds()
|
|
||||||
{
|
|
||||||
$this->personIds = $this->em
|
|
||||||
->createQuery('SELECT p.id FROM '.Person::class.' p '.
|
|
||||||
'JOIN p.center c '.
|
|
||||||
'WHERE c.name = :center '
|
|
||||||
)
|
|
||||||
->setParameter('center', 'Center A')
|
|
||||||
->getScalarResult()
|
|
||||||
;
|
|
||||||
\shuffle($this->personIds);
|
|
||||||
}
|
|
||||||
|
|
||||||
private function getRandomPersons(int $min, int $max)
|
|
||||||
{
|
|
||||||
$nb = \random_int($min, $max);
|
|
||||||
|
|
||||||
for ($i=0; $i < $nb; $i++) {
|
|
||||||
$personId = \array_pop($this->personIds)['id'];
|
|
||||||
$persons[] = $this->em->getRepository(Person::class)
|
|
||||||
->find($personId)
|
|
||||||
;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $persons ?? [];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getDependencies()
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
LoadPeople::class,
|
|
||||||
LoadHouseholdPosition::class
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,38 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Chill\PersonBundle\DataFixtures\ORM;
|
|
||||||
|
|
||||||
use Chill\PersonBundle\Entity\Household\Position;
|
|
||||||
use Doctrine\Bundle\FixturesBundle\Fixture;
|
|
||||||
use Doctrine\Persistence\ObjectManager;
|
|
||||||
|
|
||||||
class LoadHouseholdPosition extends Fixture
|
|
||||||
{
|
|
||||||
const POSITIONS_DATA = [
|
|
||||||
["Adulte", true, true, 1.0, self::ADULT ],
|
|
||||||
["Enfants", true, false, 2.0, self::CHILD ],
|
|
||||||
["Enfants hors ménage", false, false, 3.0, self::CHILD_OUT ]
|
|
||||||
];
|
|
||||||
|
|
||||||
const ADULT = "position_adulte";
|
|
||||||
const CHILD = "position_enfant";
|
|
||||||
const CHILD_OUT = "position_enfant_hors";
|
|
||||||
|
|
||||||
public function load(ObjectManager $manager)
|
|
||||||
{
|
|
||||||
foreach (self::POSITIONS_DATA as list($name, $share, $allowHolder,
|
|
||||||
$ordering, $ref)) {
|
|
||||||
$position = (new Position())
|
|
||||||
->setLabel([ "fr" => $name ])
|
|
||||||
->setAllowHolder($allowHolder)
|
|
||||||
->setShareHousehold($share)
|
|
||||||
->setOrdering($ordering)
|
|
||||||
;
|
|
||||||
|
|
||||||
$manager->persist($position);
|
|
||||||
$this->addReference($ref, $position);
|
|
||||||
}
|
|
||||||
|
|
||||||
$manager->flush();
|
|
||||||
}
|
|
||||||
}
|
|
@@ -72,8 +72,8 @@ class ChillPersonExtension extends Extension implements PrependExtensionInterfac
|
|||||||
$loader->load('services/command.yaml');
|
$loader->load('services/command.yaml');
|
||||||
$loader->load('services/actions.yaml');
|
$loader->load('services/actions.yaml');
|
||||||
$loader->load('services/form.yaml');
|
$loader->load('services/form.yaml');
|
||||||
|
$loader->load('services/templating.yaml');
|
||||||
$loader->load('services/alt_names.yaml');
|
$loader->load('services/alt_names.yaml');
|
||||||
$loader->load('services/household.yaml');
|
|
||||||
// We can get rid of this file when the service 'chill.person.repository.person' is no more used.
|
// We can get rid of this file when the service 'chill.person.repository.person' is no more used.
|
||||||
// We should use the PersonRepository service instead of a custom service name.
|
// We should use the PersonRepository service instead of a custom service name.
|
||||||
$loader->load('services/repository.yaml');
|
$loader->load('services/repository.yaml');
|
||||||
@@ -476,6 +476,7 @@ class ChillPersonExtension extends Extension implements PrependExtensionInterfac
|
|||||||
'class' => \Chill\PersonBundle\Entity\SocialWork\SocialIssue::class,
|
'class' => \Chill\PersonBundle\Entity\SocialWork\SocialIssue::class,
|
||||||
'name' => 'social_work_social_issue',
|
'name' => 'social_work_social_issue',
|
||||||
'base_path' => '/api/1.0/person/social-work/social-issue',
|
'base_path' => '/api/1.0/person/social-work/social-issue',
|
||||||
|
// 'controller' => \Chill\PersonBundle\Controller\OpeningApiController::class,
|
||||||
'base_role' => 'ROLE_USER',
|
'base_role' => 'ROLE_USER',
|
||||||
'actions' => [
|
'actions' => [
|
||||||
'_index' => [
|
'_index' => [
|
||||||
@@ -492,28 +493,6 @@ class ChillPersonExtension extends Extension implements PrependExtensionInterfac
|
|||||||
],
|
],
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
[
|
|
||||||
'class' => \Chill\PersonBundle\Entity\Person::class,
|
|
||||||
'name' => 'person',
|
|
||||||
'base_path' => '/api/1.0/person/person',
|
|
||||||
'base_role' => \Chill\PersonBundle\Security\Authorization\PersonVoter::SEE,
|
|
||||||
'controller' => \Chill\PersonBundle\Controller\PersonApiController::class,
|
|
||||||
'actions' => [
|
|
||||||
'_entity' => [
|
|
||||||
'methods' => [
|
|
||||||
Request::METHOD_GET => true,
|
|
||||||
Request::METHOD_HEAD => true,
|
|
||||||
Request::METHOD_POST=> true,
|
|
||||||
],
|
|
||||||
'roles' => [
|
|
||||||
Request::METHOD_GET => \Chill\PersonBundle\Security\Authorization\PersonVoter::SEE,
|
|
||||||
Request::METHOD_HEAD => \Chill\PersonBundle\Security\Authorization\PersonVoter::SEE,
|
|
||||||
Request::METHOD_POST => \Chill\PersonBundle\Security\Authorization\PersonVoter::CREATE,
|
|
||||||
|
|
||||||
]
|
|
||||||
],
|
|
||||||
]
|
|
||||||
],
|
|
||||||
]
|
]
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
@@ -369,9 +369,13 @@ class AccompanyingPeriod implements TrackCreationInterface, TrackUpdateInterface
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setRemark(string $remark = null): self
|
public function setRemark(string $remark): self
|
||||||
{
|
{
|
||||||
$this->remark = (string) $remark;
|
if ($remark === null) {
|
||||||
|
$remark = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->remark = $remark;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
@@ -443,13 +447,12 @@ class AccompanyingPeriod implements TrackCreationInterface, TrackUpdateInterface
|
|||||||
*/
|
*/
|
||||||
public function getParticipationsContainsPerson(Person $person): Collection
|
public function getParticipationsContainsPerson(Person $person): Collection
|
||||||
{
|
{
|
||||||
return $this
|
return $this->getParticipations($person)->filter(
|
||||||
->getParticipations()
|
function(AccompanyingPeriodParticipation $participation) use ($person) {
|
||||||
->filter(
|
if ($person === $participation->getPerson()) {
|
||||||
static function(AccompanyingPeriodParticipation $participation) use ($person): bool {
|
return $participation;
|
||||||
return $person === $participation->getPerson();
|
|
||||||
}
|
}
|
||||||
);
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -459,13 +462,12 @@ class AccompanyingPeriod implements TrackCreationInterface, TrackUpdateInterface
|
|||||||
*/
|
*/
|
||||||
public function getOpenParticipationContainsPerson(Person $person): ?AccompanyingPeriodParticipation
|
public function getOpenParticipationContainsPerson(Person $person): ?AccompanyingPeriodParticipation
|
||||||
{
|
{
|
||||||
$collection = $this
|
$collection = $this->getParticipationsContainsPerson($person)->filter(
|
||||||
->getParticipationsContainsPerson($person)
|
function(AccompanyingPeriodParticipation $participation) use ($person) {
|
||||||
->filter(
|
if (NULL === $participation->getEndDate()) {
|
||||||
static function(AccompanyingPeriodParticipation $participation): bool {
|
return $participation;
|
||||||
return null === $participation->getEndDate();
|
|
||||||
}
|
}
|
||||||
);
|
});
|
||||||
|
|
||||||
return $collection->count() > 0 ? $collection->first() : NULL;
|
return $collection->count() > 0 ? $collection->first() : NULL;
|
||||||
}
|
}
|
||||||
@@ -481,9 +483,9 @@ class AccompanyingPeriod implements TrackCreationInterface, TrackUpdateInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Open a new participation for a person
|
* Add Person
|
||||||
*/
|
*/
|
||||||
public function createParticipationFor(Person $person): AccompanyingPeriodParticipation
|
public function addPerson(Person $person = null): AccompanyingPeriodParticipation
|
||||||
{
|
{
|
||||||
$participation = new AccompanyingPeriodParticipation($this, $person);
|
$participation = new AccompanyingPeriodParticipation($this, $person);
|
||||||
$this->participations[] = $participation;
|
$this->participations[] = $participation;
|
||||||
@@ -491,24 +493,10 @@ class AccompanyingPeriod implements TrackCreationInterface, TrackUpdateInterface
|
|||||||
return $participation;
|
return $participation;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function addPerson(Person $person = null): self
|
|
||||||
{
|
|
||||||
if (NULL !== $person) {
|
|
||||||
$this->createParticipationFor($person);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Close a participation for a person
|
* Remove Person
|
||||||
*
|
|
||||||
* Search for the person's participation and set the end date at
|
|
||||||
* 'now'.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
*/
|
||||||
public function closeParticipationFor($person): ?AccompanyingPeriodParticipation
|
public function removePerson(Person $person): ?AccompanyingPeriodParticipation
|
||||||
{
|
{
|
||||||
$participation = $this->getOpenParticipationContainsPerson($person);
|
$participation = $this->getOpenParticipationContainsPerson($person);
|
||||||
|
|
||||||
@@ -520,17 +508,6 @@ class AccompanyingPeriod implements TrackCreationInterface, TrackUpdateInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Remove Person
|
|
||||||
*/
|
|
||||||
public function removePerson(Person $person): self
|
|
||||||
{
|
|
||||||
$this->closeParticipationFor($person);
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public function getClosingMotive(): ?ClosingMotive
|
public function getClosingMotive(): ?ClosingMotive
|
||||||
{
|
{
|
||||||
return $this->closingMotive;
|
return $this->closingMotive;
|
||||||
@@ -555,16 +532,15 @@ class AccompanyingPeriod implements TrackCreationInterface, TrackUpdateInterface
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$participation = $this->getOpenParticipationContainsPerson($person);
|
$participation = $this->getParticipationsContainsPerson($person);
|
||||||
|
if (!null === $participation)
|
||||||
if (null === $participation)
|
|
||||||
{
|
{
|
||||||
return false;
|
$person = $participation->getPerson();
|
||||||
|
$periods = $person->getAccompanyingPeriodsOrdered();
|
||||||
|
return end($periods) === $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
$periods = $participation->getPerson()->getAccompanyingPeriodsOrdered();
|
return false;
|
||||||
|
|
||||||
return end($periods) === $this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -824,18 +800,14 @@ class AccompanyingPeriod implements TrackCreationInterface, TrackUpdateInterface
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a list of all persons which are participating to this course
|
* Get a list of all persons which are participating to this course
|
||||||
*
|
|
||||||
* @psalm-return Collection<int, Person>
|
|
||||||
*/
|
*/
|
||||||
public function getPersons(): Collection
|
public function getPersons(): Collection
|
||||||
{
|
{
|
||||||
return $this
|
return $this->participations->map(
|
||||||
->participations
|
function(AccompanyingPeriodParticipation $participation) {
|
||||||
->map(
|
return $participation->getPerson();
|
||||||
static function(AccompanyingPeriodParticipation $participation): Person {
|
}
|
||||||
return $participation->getPerson();
|
);
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setCreatedAt(\DateTimeInterface $datetime): self
|
public function setCreatedAt(\DateTimeInterface $datetime): self
|
||||||
|
@@ -51,7 +51,7 @@ class Comment implements TrackCreationInterface, TrackUpdateInterface
|
|||||||
* @ORM\ManyToOne(
|
* @ORM\ManyToOne(
|
||||||
* targetEntity="Chill\PersonBundle\Entity\AccompanyingPeriod",
|
* targetEntity="Chill\PersonBundle\Entity\AccompanyingPeriod",
|
||||||
* inversedBy="comments")
|
* inversedBy="comments")
|
||||||
* @ORM\JoinColumn(nullable=false, onDelete="CASCADE")
|
* @ORM\JoinColumn(nullable=false)
|
||||||
*/
|
*/
|
||||||
private $accompanyingPeriod;
|
private $accompanyingPeriod;
|
||||||
|
|
||||||
|
@@ -32,7 +32,7 @@ use Symfony\Component\Serializer\Annotation\DiscriminatorMap;
|
|||||||
use Symfony\Component\Serializer\Annotation\Groups;
|
use Symfony\Component\Serializer\Annotation\Groups;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\Entity
|
* @ORM\Entity(repositoryClass=ResourceRepository::class)
|
||||||
* @ORM\Table(name="chill_person_accompanying_period_resource")
|
* @ORM\Table(name="chill_person_accompanying_period_resource")
|
||||||
* @DiscriminatorMap(typeProperty="type", mapping={
|
* @DiscriminatorMap(typeProperty="type", mapping={
|
||||||
* "accompanying_period_resource"=Resource::class
|
* "accompanying_period_resource"=Resource::class
|
||||||
|
@@ -2,21 +2,12 @@
|
|||||||
|
|
||||||
namespace Chill\PersonBundle\Entity\Household;
|
namespace Chill\PersonBundle\Entity\Household;
|
||||||
|
|
||||||
use Doctrine\Common\Collections\ArrayCollection;
|
|
||||||
use Doctrine\ORM\Mapping as ORM;
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
use Doctrine\Common\Collections\Collection;
|
use Doctrine\Common\Collections\Collection;
|
||||||
use Symfony\Component\Serializer\Annotation as Serializer;
|
|
||||||
use Chill\MainBundle\Entity\Address;
|
use Chill\MainBundle\Entity\Address;
|
||||||
use Chill\PersonBundle\Entity\Household\HouseholdMember;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\Entity
|
* @ORM\Entity
|
||||||
* @ORM\Table(
|
|
||||||
* name="chill_person_household"
|
|
||||||
* )
|
|
||||||
* @Serializer\DiscriminatorMap(typeProperty="type", mapping={
|
|
||||||
* "household"=Household::class
|
|
||||||
* })
|
|
||||||
*/
|
*/
|
||||||
class Household
|
class Household
|
||||||
{
|
{
|
||||||
@@ -24,12 +15,17 @@ class Household
|
|||||||
* @ORM\Id
|
* @ORM\Id
|
||||||
* @ORM\GeneratedValue
|
* @ORM\GeneratedValue
|
||||||
* @ORM\Column(type="integer")
|
* @ORM\Column(type="integer")
|
||||||
* @Serializer\Groups({"read"})
|
|
||||||
*/
|
*/
|
||||||
private ?int $id = null;
|
private $id;
|
||||||
|
|
||||||
|
public function getId(): ?int
|
||||||
|
{
|
||||||
|
return $this->id;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Addresses
|
* Addresses
|
||||||
|
* @var Collection
|
||||||
*
|
*
|
||||||
* @ORM\ManyToMany(
|
* @ORM\ManyToMany(
|
||||||
* targetEntity="Chill\MainBundle\Entity\Address",
|
* targetEntity="Chill\MainBundle\Entity\Address",
|
||||||
@@ -37,27 +33,8 @@ class Household
|
|||||||
* @ORM\JoinTable(name="chill_person_household_to_addresses")
|
* @ORM\JoinTable(name="chill_person_household_to_addresses")
|
||||||
* @ORM\OrderBy({"validFrom" = "DESC"})
|
* @ORM\OrderBy({"validFrom" = "DESC"})
|
||||||
*/
|
*/
|
||||||
private Collection $addresses;
|
private $addresses;
|
||||||
|
|
||||||
/**
|
|
||||||
* @ORM\OneToMany(
|
|
||||||
* targetEntity=HouseholdMember::class,
|
|
||||||
* mappedBy="household"
|
|
||||||
* )
|
|
||||||
* @Serializer\Groups({"read"})
|
|
||||||
*/
|
|
||||||
private Collection $members;
|
|
||||||
|
|
||||||
public function __construct()
|
|
||||||
{
|
|
||||||
$this->addresses = new ArrayCollection();
|
|
||||||
$this->members = new ArrayCollection();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getId(): ?int
|
|
||||||
{
|
|
||||||
return $this->id;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Address $address
|
* @param Address $address
|
||||||
@@ -89,34 +66,4 @@ class Household
|
|||||||
return $this->addresses;
|
return $this->addresses;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return Collection|HouseholdMember[]
|
|
||||||
*/
|
|
||||||
public function getMembers(): Collection
|
|
||||||
{
|
|
||||||
return $this->members;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function addMember(HouseholdMember $member): self
|
|
||||||
{
|
|
||||||
if (!$this->members->contains($member)) {
|
|
||||||
$this->members[] = $member;
|
|
||||||
$member->setHousehold($this);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function removeMember(HouseholdMember $member): self
|
|
||||||
{
|
|
||||||
if ($this->members->removeElement($member)) {
|
|
||||||
// set the owning side to null (unless already changed)
|
|
||||||
if ($member->getHousehold() === $this) {
|
|
||||||
$member->setHousehold(null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -1,197 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Chill\PersonBundle\Entity\Household;
|
|
||||||
|
|
||||||
use Doctrine\ORM\Mapping as ORM;
|
|
||||||
use Chill\PersonBundle\Entity\Person;
|
|
||||||
use Chill\PersonBundle\Entity\Household\Household;
|
|
||||||
use Chill\PersonBundle\Entity\Household\Position;
|
|
||||||
use Symfony\Component\Serializer\Annotation as Serializer;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @ORM\Entity
|
|
||||||
* @ORM\Table(
|
|
||||||
* name="chill_person_household_members"
|
|
||||||
* )
|
|
||||||
*/
|
|
||||||
class HouseholdMember
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @ORM\Id
|
|
||||||
* @ORM\GeneratedValue
|
|
||||||
* @ORM\Column(type="integer")
|
|
||||||
* @Serializer\Groups({"read"})
|
|
||||||
*/
|
|
||||||
private $id;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @ORM\ManyToOne(targetEntity=Position::class)
|
|
||||||
* @Serializer\Groups({"read"})
|
|
||||||
*/
|
|
||||||
private ?Position $position = null;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @ORM\Column(type="date_immutable", nullable=true, options={"default": null})
|
|
||||||
* @Serializer\Groups({"read"})
|
|
||||||
*/
|
|
||||||
private ?\DateTimeImmutable $startDate = null;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @ORM\Column(type="date_immutable", nullable= true, options={"default": null})
|
|
||||||
* @Serializer\Groups({"read"})
|
|
||||||
*/
|
|
||||||
private ?\DateTimeImmutable $endDate = null;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @ORM\Column(type="string", length=255, nullable=true)
|
|
||||||
* @Serializer\Groups({"read"})
|
|
||||||
*/
|
|
||||||
private ?string $comment = NULL;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @ORM\Column(type="boolean")
|
|
||||||
*/
|
|
||||||
private bool $sharedHousehold = false;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @ORM\Column(type="boolean", options={"default": false})
|
|
||||||
* @Serializer\Groups({"read"})
|
|
||||||
*/
|
|
||||||
private bool $holder = false;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @var Person
|
|
||||||
* @ORM\ManyToOne(
|
|
||||||
* targetEntity="\Chill\PersonBundle\Entity\Person"
|
|
||||||
* )
|
|
||||||
* @Serializer\Groups({"read"})
|
|
||||||
*/
|
|
||||||
private ?Person $person = null;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @var Household
|
|
||||||
* @ORM\ManyToOne(
|
|
||||||
* targetEntity="\Chill\PersonBundle\Entity\Household\Household"
|
|
||||||
* )
|
|
||||||
*/
|
|
||||||
private ?Household $household = null;
|
|
||||||
|
|
||||||
|
|
||||||
public function getId(): ?int
|
|
||||||
{
|
|
||||||
return $this->id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getPosition(): ?Position
|
|
||||||
{
|
|
||||||
return $this->position;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setPosition(Position $position): self
|
|
||||||
{
|
|
||||||
if ($this->position instanceof Position) {
|
|
||||||
throw new \LogicException("The position is already set. You cannot change ".
|
|
||||||
"a position of a membership");
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->position = $position;
|
|
||||||
$this->sharedHousehold = $position->getShareHousehold();
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getStartDate(): ?\DateTimeImmutable
|
|
||||||
{
|
|
||||||
return $this->startDate;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setStartDate(\DateTimeImmutable $startDate): self
|
|
||||||
{
|
|
||||||
$this->startDate = $startDate;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getEndDate(): ?\DateTimeImmutable
|
|
||||||
{
|
|
||||||
return $this->endDate;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setEndDate(\DateTimeImmutable $endDate): self
|
|
||||||
{
|
|
||||||
$this->endDate = $endDate;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getComment(): ?string
|
|
||||||
{
|
|
||||||
return $this->comment;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setComment(?string $comment): self
|
|
||||||
{
|
|
||||||
$this->comment = $comment;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @Serializer\Groups({"read"})
|
|
||||||
*/
|
|
||||||
public function getShareHousehold(): ?bool
|
|
||||||
{
|
|
||||||
return $this->sharedHousehold;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public function getPerson(): ?Person
|
|
||||||
{
|
|
||||||
return $this->person;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setPerson(?Person $person): self
|
|
||||||
{
|
|
||||||
if ($this->person instanceof Person) {
|
|
||||||
throw new \LogicException("You cannot change person ".
|
|
||||||
"on a membership");
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->person = $person;
|
|
||||||
$this->person->addHouseholdParticipation($this);
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getHousehold(): ?Household
|
|
||||||
{
|
|
||||||
return $this->household;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setHousehold(?Household $household): self
|
|
||||||
{
|
|
||||||
if ($this->household instanceof Household) {
|
|
||||||
throw new \LogicException("You cannot change household ".
|
|
||||||
"on a membership");
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->household = $household;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setHolder(bool $holder): self
|
|
||||||
{
|
|
||||||
$this->holder = $holder;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function isHolder(): bool
|
|
||||||
{
|
|
||||||
return $this->holder;
|
|
||||||
}
|
|
||||||
}
|
|
@@ -0,0 +1,152 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Chill\PersonBundle\Entity\Household;
|
||||||
|
|
||||||
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
|
use Chill\PersonBundle\Entity\Person;
|
||||||
|
use Chill\PersonBundle\Entity\Household\Household;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ORM\Entity
|
||||||
|
*/
|
||||||
|
class HouseholdMembers
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @ORM\Id
|
||||||
|
* @ORM\GeneratedValue
|
||||||
|
* @ORM\Column(type="integer")
|
||||||
|
*/
|
||||||
|
private $id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ORM\Column(type="string", length=255, nullable=true)
|
||||||
|
*/
|
||||||
|
private $position;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ORM\Column(type="date")
|
||||||
|
*/
|
||||||
|
private $startDate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ORM\Column(type="date")
|
||||||
|
*/
|
||||||
|
private $endDate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ORM\Column(type="string", length=255, nullable=true)
|
||||||
|
*/
|
||||||
|
private $comment;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ORM\Column(type="boolean")
|
||||||
|
*/
|
||||||
|
private $sharedHousehold;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @var Person
|
||||||
|
* @ORM\ManyToOne(
|
||||||
|
* targetEntity="\Chill\PersonBundle\Entity\Person"
|
||||||
|
* )
|
||||||
|
*/
|
||||||
|
private $person;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @var Household
|
||||||
|
* @ORM\ManyToOne(
|
||||||
|
* targetEntity="\Chill\PersonBundle\Entity\Household\Household"
|
||||||
|
* )
|
||||||
|
*/
|
||||||
|
private $household;
|
||||||
|
|
||||||
|
public function getId(): ?int
|
||||||
|
{
|
||||||
|
return $this->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getPosition(): ?string
|
||||||
|
{
|
||||||
|
return $this->position;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setPosition(?string $position): self
|
||||||
|
{
|
||||||
|
$this->position = $position;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getStartDate(): ?\DateTimeInterface
|
||||||
|
{
|
||||||
|
return $this->startDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setStartDate(\DateTimeInterface $startDate): self
|
||||||
|
{
|
||||||
|
$this->startDate = $startDate;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getEndDate(): ?\DateTimeInterface
|
||||||
|
{
|
||||||
|
return $this->endDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setEndDate(\DateTimeInterface $endDate): self
|
||||||
|
{
|
||||||
|
$this->endDate = $endDate;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getComment(): ?string
|
||||||
|
{
|
||||||
|
return $this->comment;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setComment(?string $comment): self
|
||||||
|
{
|
||||||
|
$this->comment = $comment;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getSharedHousehold(): ?bool
|
||||||
|
{
|
||||||
|
return $this->sharedHousehold;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setSharedHousehold(bool $sharedHousehold): self
|
||||||
|
{
|
||||||
|
$this->sharedHousehold = $sharedHousehold;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getPerson(): ?Person
|
||||||
|
{
|
||||||
|
return $this->person;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setPerson(?Person $person): self
|
||||||
|
{
|
||||||
|
$this->person = $person;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getHousehold(): ?Household
|
||||||
|
{
|
||||||
|
return $this->household;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setHousehold(?Household $household): self
|
||||||
|
{
|
||||||
|
$this->household = $household;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
}
|
@@ -1,98 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Chill\PersonBundle\Entity\Household;
|
|
||||||
|
|
||||||
use Chill\PersonBundle\Repository\Household\PositionRepository;
|
|
||||||
use Doctrine\ORM\Mapping as ORM;
|
|
||||||
use Symfony\Component\Serializer\Annotation as Serializer;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @ORM\Entity(repositoryClass=PositionRepository::class)
|
|
||||||
* @ORM\Table(name="chill_person_household_position")
|
|
||||||
* @Serializer\DiscriminatorMap(typeProperty="type", mapping={
|
|
||||||
* "household_position"=Position::class
|
|
||||||
* })
|
|
||||||
*/
|
|
||||||
class Position
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @ORM\Id
|
|
||||||
* @ORM\GeneratedValue
|
|
||||||
* @ORM\Column(type="integer")
|
|
||||||
* @Serializer\Groups({ "read" })
|
|
||||||
*/
|
|
||||||
private $id;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @ORM\Column(type="json")
|
|
||||||
*/
|
|
||||||
private $label = [];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @ORM\Column(type="boolean")
|
|
||||||
*/
|
|
||||||
private $shareHouseHold;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @ORM\Column(type="boolean")
|
|
||||||
*/
|
|
||||||
private $allowHolder;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @ORM\Column(type="float")
|
|
||||||
*/
|
|
||||||
private $ordering;
|
|
||||||
|
|
||||||
public function getId(): ?int
|
|
||||||
{
|
|
||||||
return $this->id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getLabel(): ?array
|
|
||||||
{
|
|
||||||
return $this->label;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setLabel(array $label): self
|
|
||||||
{
|
|
||||||
$this->label = $label;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getShareHousehold(): ?bool
|
|
||||||
{
|
|
||||||
return $this->shareHouseHold;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setShareHousehold(bool $shareHouseHold): self
|
|
||||||
{
|
|
||||||
$this->shareHouseHold = $shareHouseHold;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getAllowHolder(): ?bool
|
|
||||||
{
|
|
||||||
return $this->allowHolder;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setAllowHolder(bool $allowHolder): self
|
|
||||||
{
|
|
||||||
$this->allowHolder = $allowHolder;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getOrdering(): ?float
|
|
||||||
{
|
|
||||||
return $this->ordering;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setOrdering(float $ordering): self
|
|
||||||
{
|
|
||||||
$this->ordering = $ordering;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
}
|
|
@@ -26,7 +26,6 @@ use ArrayIterator;
|
|||||||
use Chill\MainBundle\Entity\Center;
|
use Chill\MainBundle\Entity\Center;
|
||||||
use Chill\MainBundle\Entity\Country;
|
use Chill\MainBundle\Entity\Country;
|
||||||
use Chill\PersonBundle\Entity\MaritalStatus;
|
use Chill\PersonBundle\Entity\MaritalStatus;
|
||||||
use Chill\PersonBundle\Entity\Household\HouseholdMember;
|
|
||||||
use Chill\MainBundle\Entity\HasCenterInterface;
|
use Chill\MainBundle\Entity\HasCenterInterface;
|
||||||
use Chill\MainBundle\Entity\Address;
|
use Chill\MainBundle\Entity\Address;
|
||||||
use DateTime;
|
use DateTime;
|
||||||
@@ -273,14 +272,6 @@ class Person implements HasCenterInterface
|
|||||||
*/
|
*/
|
||||||
private $fullnameCanonical;
|
private $fullnameCanonical;
|
||||||
|
|
||||||
/**
|
|
||||||
* @ORM\OneToMany(
|
|
||||||
* targetEntity=HouseholdMember::class,
|
|
||||||
* mappedBy="person"
|
|
||||||
* )
|
|
||||||
*/
|
|
||||||
private Collection $householdParticipations;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Person constructor.
|
* Person constructor.
|
||||||
*
|
*
|
||||||
@@ -293,7 +284,6 @@ class Person implements HasCenterInterface
|
|||||||
$this->addresses = new ArrayCollection();
|
$this->addresses = new ArrayCollection();
|
||||||
$this->altNames = new ArrayCollection();
|
$this->altNames = new ArrayCollection();
|
||||||
$this->otherPhoneNumbers = new ArrayCollection();
|
$this->otherPhoneNumbers = new ArrayCollection();
|
||||||
$this->householdParticipations = new ArrayCollection();
|
|
||||||
|
|
||||||
if ($opening === null) {
|
if ($opening === null) {
|
||||||
$opening = new \DateTime();
|
$opening = new \DateTime();
|
||||||
@@ -431,31 +421,6 @@ class Person implements HasCenterInterface
|
|||||||
return $this->accompanyingPeriodParticipations;
|
return $this->accompanyingPeriodParticipations;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Return a collection of participation, where the participation
|
|
||||||
* is still opened, not a draft, and the period is still opened
|
|
||||||
*/
|
|
||||||
public function getOpenedParticipations(): Collection
|
|
||||||
{
|
|
||||||
// create a criteria for filtering easily
|
|
||||||
$criteria = Criteria::create();
|
|
||||||
$criteria
|
|
||||||
->andWhere(Criteria::expr()->eq('endDate', NULL))
|
|
||||||
->orWhere(Criteria::expr()->gt('endDate', new \DateTime('now')))
|
|
||||||
;
|
|
||||||
|
|
||||||
return $this->getAccompanyingPeriodParticipations()
|
|
||||||
->matching($criteria)
|
|
||||||
->filter(function (AccompanyingPeriodParticipation $app) {
|
|
||||||
$period = $app->getAccompanyingPeriod();
|
|
||||||
return (
|
|
||||||
NULL === $period->getClosingDate()
|
|
||||||
|| new \DateTime('now') < $period->getClosingDate()
|
|
||||||
)
|
|
||||||
&& AccompanyingPeriod::STEP_DRAFT !== $period->getStep();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the accompanying periods of a give person with the chronological order.
|
* Get the accompanying periods of a give person with the chronological order.
|
||||||
*/
|
*/
|
||||||
@@ -1190,16 +1155,4 @@ class Person implements HasCenterInterface
|
|||||||
$this->fullnameCanonical = $fullnameCanonical;
|
$this->fullnameCanonical = $fullnameCanonical;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function addHouseholdParticipation(HouseholdMember $member): self
|
|
||||||
{
|
|
||||||
$this->householdParticipations[] = $member;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getHouseholdParticipations(): Collection
|
|
||||||
{
|
|
||||||
return $this->householdParticipations;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@@ -21,19 +21,31 @@ namespace Chill\PersonBundle\Form\ChoiceLoader;
|
|||||||
|
|
||||||
use Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface;
|
use Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface;
|
||||||
use Symfony\Component\Form\ChoiceList\ChoiceListInterface;
|
use Symfony\Component\Form\ChoiceList\ChoiceListInterface;
|
||||||
|
use Doctrine\ORM\EntityRepository;
|
||||||
use Chill\PersonBundle\Entity\Person;
|
use Chill\PersonBundle\Entity\Person;
|
||||||
use Chill\PersonBundle\Repository\PersonRepository;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allow to load a list of person
|
* Class PersonChoiceLoader
|
||||||
|
*
|
||||||
|
* @package Chill\PersonBundle\Form\ChoiceLoader
|
||||||
|
* @author Julien Fastré <julien.fastre@champs-libres.coop>
|
||||||
*/
|
*/
|
||||||
class PersonChoiceLoader implements ChoiceLoaderInterface
|
class PersonChoiceLoader implements ChoiceLoaderInterface
|
||||||
{
|
{
|
||||||
protected PersonRepository $personRepository;
|
/**
|
||||||
|
* @var EntityRepository
|
||||||
|
*/
|
||||||
|
protected $personRepository;
|
||||||
|
|
||||||
protected array $lazyLoadedPersons = [];
|
/**
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $lazyLoadedPersons = [];
|
||||||
|
|
||||||
protected array $centers = [];
|
/**
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $centers = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PersonChoiceLoader constructor.
|
* PersonChoiceLoader constructor.
|
||||||
@@ -42,7 +54,7 @@ class PersonChoiceLoader implements ChoiceLoaderInterface
|
|||||||
* @param array|null $centers
|
* @param array|null $centers
|
||||||
*/
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
PersonRepository $personRepository,
|
EntityRepository $personRepository,
|
||||||
array $centers = null
|
array $centers = null
|
||||||
) {
|
) {
|
||||||
$this->personRepository = $personRepository;
|
$this->personRepository = $personRepository;
|
||||||
|
@@ -1,79 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Chill\PersonBundle\Household;
|
|
||||||
|
|
||||||
use Symfony\Component\Validator\ConstraintViolationListInterface;
|
|
||||||
use Chill\PersonBundle\Entity\Household\HouseholdMember;
|
|
||||||
use Chill\PersonBundle\Entity\Household\Position;
|
|
||||||
use Chill\PersonBundle\Entity\Household\Household;
|
|
||||||
use Chill\PersonBundle\Entity\Person;
|
|
||||||
use Symfony\Component\Validator\Validator\ValidatorInterface;
|
|
||||||
|
|
||||||
|
|
||||||
class MembersEditor
|
|
||||||
{
|
|
||||||
private ValidatorInterface $validator;
|
|
||||||
private Household $household;
|
|
||||||
|
|
||||||
private array $persistables = [];
|
|
||||||
private array $membershipsAffected = [];
|
|
||||||
|
|
||||||
public function __construct(ValidatorInterface $validator, Household $household)
|
|
||||||
{
|
|
||||||
$this->validation = $validator;
|
|
||||||
$this->household = $household;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function addMovement(\DateTimeImmutable $date, Person $person, Position $position, ?bool $holder = false, ?string $comment = null): self
|
|
||||||
{
|
|
||||||
if (NULL === $this->household) {
|
|
||||||
throw new \LogicException("You must define a household first");
|
|
||||||
}
|
|
||||||
|
|
||||||
$membership = (new HouseholdMember())
|
|
||||||
->setStartDate($date)
|
|
||||||
->setPerson($person)
|
|
||||||
->setPosition($position)
|
|
||||||
->setHolder($holder)
|
|
||||||
->setHousehold($this->household)
|
|
||||||
->setComment($comment)
|
|
||||||
;
|
|
||||||
|
|
||||||
if ($position->getShareHousehold()) {
|
|
||||||
foreach ($person->getHouseholdParticipations() as $participation) {
|
|
||||||
if (FALSE === $participation->getShareHousehold()) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($participation === $membership) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($participation->getEndDate() === NULL || $participation->getEndDate() > $date) {
|
|
||||||
$participation->setEndDate($date);
|
|
||||||
$this->membershipsAffected[] = $participation;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->membershipsAffected[] = $membership;
|
|
||||||
$this->persistables[] = $membership;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function validate(): ConstraintViolationListInterface
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getPersistable(): array
|
|
||||||
{
|
|
||||||
return $this->persistables;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getHousehold(): Household
|
|
||||||
{
|
|
||||||
return $this->household;
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,21 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Chill\PersonBundle\Household;
|
|
||||||
|
|
||||||
use Chill\PersonBundle\Household\MembersEditor;
|
|
||||||
use Chill\PersonBundle\Entity\Household\Household;
|
|
||||||
use Symfony\Component\Validator\Validator\ValidatorInterface;
|
|
||||||
|
|
||||||
|
|
||||||
class MembersEditorFactory
|
|
||||||
{
|
|
||||||
public function __construct(ValidatorInterface $validator)
|
|
||||||
{
|
|
||||||
$this->validator = $validator;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function createEditor(Household $household): MembersEditor
|
|
||||||
{
|
|
||||||
return new MembersEditor($this->validator, $household);
|
|
||||||
}
|
|
||||||
}
|
|
@@ -43,7 +43,7 @@ class AccompanyingCourseMenuBuilder implements LocalMenuBuilderInterface
|
|||||||
->setExtras(['order' => 10]);
|
->setExtras(['order' => 10]);
|
||||||
|
|
||||||
$menu->addChild($this->translator->trans('Edit Accompanying Course'), [
|
$menu->addChild($this->translator->trans('Edit Accompanying Course'), [
|
||||||
'route' => 'chill_person_accompanying_course_edit',
|
'route' => 'chill_person_accompanying_course_show',
|
||||||
'routeParameters' => [
|
'routeParameters' => [
|
||||||
'accompanying_period_id' => $period->getId()
|
'accompanying_period_id' => $period->getId()
|
||||||
]])
|
]])
|
||||||
|
@@ -1,56 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Chill\PersonBundle\Menu;
|
|
||||||
|
|
||||||
use Chill\MainBundle\Routing\LocalMenuBuilderInterface;
|
|
||||||
use Chill\PersonBundle\Entity\Household\Household;
|
|
||||||
use Knp\Menu\MenuItem;
|
|
||||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
|
||||||
|
|
||||||
class HouseholdMenuBuilder implements LocalMenuBuilderInterface
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var TranslatorInterface
|
|
||||||
*/
|
|
||||||
protected $translator;
|
|
||||||
|
|
||||||
public function __construct(TranslatorInterface $translator)
|
|
||||||
{
|
|
||||||
$this->translator = $translator;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function getMenuIds(): array
|
|
||||||
{
|
|
||||||
return [ 'household' ];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function buildMenu($menuId, MenuItem $menu, array $parameters): void
|
|
||||||
{
|
|
||||||
$household = $parameters['household'];
|
|
||||||
|
|
||||||
$menu->addChild($this->translator->trans('Summary'), [
|
|
||||||
'route' => 'chill_person_household_summary',
|
|
||||||
'routeParameters' => [
|
|
||||||
'household_id' => $household->getId()
|
|
||||||
]])
|
|
||||||
->setExtras(['order' => 10]);
|
|
||||||
|
|
||||||
$menu->addChild($this->translator->trans('Members'), [
|
|
||||||
'route' => 'chill_person_household_members',
|
|
||||||
'routeParameters' => [
|
|
||||||
'household_id' => $household->getId()
|
|
||||||
]])
|
|
||||||
->setExtras(['order' => 20]);
|
|
||||||
|
|
||||||
$menu->addChild($this->translator->trans('Addresses'), [
|
|
||||||
'route' => 'chill_person_household_addresses',
|
|
||||||
'routeParameters' => [
|
|
||||||
'household_id' => $household->getId()
|
|
||||||
]])
|
|
||||||
->setExtras(['order' => 30]);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@@ -27,27 +27,31 @@ use Doctrine\ORM\EntityManagerInterface;
|
|||||||
use Doctrine\ORM\EntityRepository;
|
use Doctrine\ORM\EntityRepository;
|
||||||
use Doctrine\ORM\Query\ResultSetMappingBuilder;
|
use Doctrine\ORM\Query\ResultSetMappingBuilder;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class ClosingMotiveRepository
|
||||||
|
* Entity repository for closing motives
|
||||||
|
*
|
||||||
|
* @package Chill\PersonBundle\Repository
|
||||||
|
*/
|
||||||
final class ClosingMotiveRepository
|
final class ClosingMotiveRepository
|
||||||
{
|
{
|
||||||
private EntityRepository $repository;
|
private EntityRepository $repository;
|
||||||
|
|
||||||
private EntityManagerInterface $entityManager;
|
|
||||||
|
|
||||||
public function __construct(EntityManagerInterface $entityManager)
|
public function __construct(EntityManagerInterface $entityManager)
|
||||||
{
|
{
|
||||||
$this->entityManager = $entityManager;
|
|
||||||
$this->repository = $entityManager->getRepository(ClosingMotive::class);
|
$this->repository = $entityManager->getRepository(ClosingMotive::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @param bool $onlyLeaf
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function getActiveClosingMotive(bool $onlyLeaf = true)
|
public function getActiveClosingMotive(bool $onlyLeaf = true)
|
||||||
{
|
{
|
||||||
$rsm = new ResultSetMappingBuilder($this->entityManager);
|
$rsm = new ResultSetMappingBuilder($this->repository->getEntityManager());
|
||||||
$rsm->addRootEntityFromClassMetadata($this->repository->getClassName(), 'cm');
|
$rsm->addRootEntityFromClassMetadata($this->repository->getClassName(), 'cm');
|
||||||
|
|
||||||
$sql = "SELECT " . (string) $rsm . "
|
$sql = "SELECT ".(string) $rsm."
|
||||||
FROM chill_person_accompanying_period_closingmotive AS cm
|
FROM chill_person_accompanying_period_closingmotive AS cm
|
||||||
WHERE
|
WHERE
|
||||||
active IS TRUE ";
|
active IS TRUE ";
|
||||||
@@ -61,7 +65,8 @@ final class ClosingMotiveRepository
|
|||||||
$sql .= " ORDER BY cm.ordering ASC";
|
$sql .= " ORDER BY cm.ordering ASC";
|
||||||
|
|
||||||
return $this
|
return $this
|
||||||
->entityManager
|
->repository
|
||||||
|
->getEntityManager()
|
||||||
->createNativeQuery($sql, $rsm)
|
->createNativeQuery($sql, $rsm)
|
||||||
->getResult();
|
->getResult();
|
||||||
}
|
}
|
||||||
|
@@ -26,6 +26,12 @@ use Chill\PersonBundle\Entity\AccompanyingPeriod\Comment;
|
|||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
use Doctrine\ORM\EntityRepository;
|
use Doctrine\ORM\EntityRepository;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @method Comment|null find($id, $lockMode = null, $lockVersion = null)
|
||||||
|
* @method Comment|null findOneBy(array $criteria, array $orderBy = null)
|
||||||
|
* @method Comment[] findAll()
|
||||||
|
* @method Comment[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
||||||
|
*/
|
||||||
final class CommentRepository
|
final class CommentRepository
|
||||||
{
|
{
|
||||||
private EntityRepository $repository;
|
private EntityRepository $repository;
|
||||||
|
@@ -26,6 +26,12 @@ use Chill\PersonBundle\Entity\AccompanyingPeriod\Origin;
|
|||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
use Doctrine\ORM\EntityRepository;
|
use Doctrine\ORM\EntityRepository;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @method Origin|null find($id, $lockMode = null, $lockVersion = null)
|
||||||
|
* @method Origin|null findOneBy(array $criteria, array $orderBy = null)
|
||||||
|
* @method Origin[] findAll()
|
||||||
|
* @method Origin[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
||||||
|
*/
|
||||||
final class OriginRepository
|
final class OriginRepository
|
||||||
{
|
{
|
||||||
private EntityRepository $repository;
|
private EntityRepository $repository;
|
||||||
|
@@ -24,19 +24,21 @@ namespace Chill\PersonBundle\Repository\AccompanyingPeriod;
|
|||||||
|
|
||||||
use Chill\PersonBundle\Entity\AccompanyingPeriod\Resource;
|
use Chill\PersonBundle\Entity\AccompanyingPeriod\Resource;
|
||||||
use Doctrine\ORM\EntityRepository;
|
use Doctrine\ORM\EntityRepository;
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||||
|
use Doctrine\Persistence\ManagerRegistry;
|
||||||
|
|
||||||
final class ResourceRepository
|
/**
|
||||||
|
* @method Resource|null find($id, $lockMode = null, $lockVersion = null)
|
||||||
|
* @method Resource|null findOneBy(array $criteria, array $orderBy = null)
|
||||||
|
* @method Resource[] findAll()
|
||||||
|
* @method Resource[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
||||||
|
*/
|
||||||
|
final class ResourceRepository extends ServiceEntityRepository
|
||||||
{
|
{
|
||||||
private EntityRepository $repository;
|
private EntityRepository $repository;
|
||||||
|
|
||||||
public function __construct(EntityManagerInterface $entityManager)
|
public function __construct(ManagerRegistry $registry)
|
||||||
{
|
{
|
||||||
$this->repository = $entityManager->getRepository(Resource::class);
|
parent::__construct($registry, Resource::class);
|
||||||
}
|
|
||||||
|
|
||||||
public function find($id, $lockMode = null, $lockVersion = null): ?Resource
|
|
||||||
{
|
|
||||||
return $this->repository->find($id, $lockMode, $lockVersion);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user