diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 86e65c390..295eb3e0e 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -5,11 +5,13 @@ image: registry.gitlab.com/chill-projet/chill-app/php-base-image:7.4 cache: paths: - tests/app/vendor/ + - .composer before_script: # add extensions to postgres - 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 + - mkdir -p $COMPOSER_HOME - curl -sS https://getcomposer.org/installer | php - php -d memory_limit=2G composer.phar install - php tests/app/bin/console doctrine:migrations:migrate -n @@ -34,6 +36,10 @@ variables: REDIS_HOST: redis REDIS_PORT: 6379 REDIS_URL: redis://redis:6379 + # change vendor dir to make the app install into tests/apps + COMPOSER_VENDOR_DIR: tests/app/vendor + # cache some composer data + COMPOSER_HOME: .composer # Run our tests diff --git a/src/Bundle/ChillMainBundle/DataFixtures/ORM/LoadAbstractNotificationsTrait.php b/src/Bundle/ChillMainBundle/DataFixtures/ORM/LoadAbstractNotificationsTrait.php index 071f67497..629b6657e 100644 --- a/src/Bundle/ChillMainBundle/DataFixtures/ORM/LoadAbstractNotificationsTrait.php +++ b/src/Bundle/ChillMainBundle/DataFixtures/ORM/LoadAbstractNotificationsTrait.php @@ -15,6 +15,7 @@ trait LoadAbstractNotificationsTrait { public function load(ObjectManager $manager) { + return; foreach ($this->notifs as $notif) { $entityId = $this->getReference($notif['entityRef'])->getId(); diff --git a/src/Bundle/ChillMainBundle/Resources/public/chill/scss/buttons.scss b/src/Bundle/ChillMainBundle/Resources/public/chill/scss/buttons.scss index c2995e57d..fde222a23 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/chill/scss/buttons.scss +++ b/src/Bundle/ChillMainBundle/Resources/public/chill/scss/buttons.scss @@ -111,3 +111,8 @@ $chill-theme-buttons: ( } } } + +// fix min-width on small pictos buttons +.btn-sm, .btn-group-sm > .btn { + min-width: 36px; +} diff --git a/src/Bundle/ChillMainBundle/Resources/public/chill/scss/flex_table.scss b/src/Bundle/ChillMainBundle/Resources/public/chill/scss/flex_table.scss index c942bb709..259a23055 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/chill/scss/flex_table.scss +++ b/src/Bundle/ChillMainBundle/Resources/public/chill/scss/flex_table.scss @@ -51,6 +51,7 @@ div.flex-bloc { flex-grow: 0; flex-shrink: 1; flex-basis: auto; flex-direction: column; margin: 0; + hyphens: auto; div.item-row { flex-grow: 1; flex-shrink: 1; flex-basis: auto; diff --git a/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadAccompanyingPeriod.php b/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadAccompanyingPeriod.php deleted file mode 100644 index a30943bcb..000000000 --- a/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadAccompanyingPeriod.php +++ /dev/null @@ -1,88 +0,0 @@ -, - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -namespace Chill\PersonBundle\DataFixtures\ORM; - -use Doctrine\Common\DataFixtures\AbstractFixture; -use Doctrine\Common\DataFixtures\OrderedFixtureInterface; -use Doctrine\Persistence\ObjectManager; -use Symfony\Component\DependencyInjection\ContainerAwareInterface; - -use Chill\PersonBundle\Entity\AccompanyingPeriod; -use Chill\PersonBundle\Entity\Person; - -/** - * Description of LoadAccompanyingPeriod - * - * @author Champs-Libres Coop - */ -class LoadAccompanyingPeriod extends AbstractFixture implements OrderedFixtureInterface, ContainerAwareInterface -{ - use \Symfony\Component\DependencyInjection\ContainerAwareTrait; - - - public const ACCOMPANYING_PERIOD = 'parcours 1'; - - public function getOrder() - { - return 10004; - } - - public static $references = array(); - - public function load(ObjectManager $manager) - { - - $centerA = $this->getReference('centerA'); - $centerAId = $centerA->getId(); - - $personIds = $this->container->get('doctrine.orm.entity_manager') - ->createQueryBuilder() - ->select('p.id') - ->from('ChillPersonBundle:Person', 'p') - ->where('p.center = :centerAId') - ->orderBy('p.id', 'ASC') - ->setParameter('centerAId', $centerAId) - ->getQuery() - ->getScalarResult(); - - $openingDate = new \DateTime('2020-04-01'); - - $person1 = $manager->getRepository(Person::class)->find($personIds[0]); - $person2 = $manager->getRepository(Person::class)->find($personIds[1]); - - $socialScope = $this->getReference('scope_social'); - - $a = new AccompanyingPeriod($openingDate); - $a->addPerson($person1); - $a->addPerson($person2); - $a->addScope($socialScope); - $a->setStep(AccompanyingPeriod::STEP_CONFIRMED); - - $manager->persist($a); - - $this->addReference(self::ACCOMPANYING_PERIOD, $a); - echo "Adding one AccompanyingPeriod\n"; - - $manager->flush(); - } -} diff --git a/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadAccompanyingPeriodNotifications.php b/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadAccompanyingPeriodNotifications.php index d1c6f4da7..e96bf44e6 100644 --- a/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadAccompanyingPeriodNotifications.php +++ b/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadAccompanyingPeriodNotifications.php @@ -6,7 +6,6 @@ use Doctrine\Common\DataFixtures\AbstractFixture; use Doctrine\Common\DataFixtures\DependentFixtureInterface; use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\MainBundle\DataFixtures\ORM\LoadAbstractNotificationsTrait; -use Chill\PersonBundle\DataFixtures\ORM\LoadAccompanyingPeriod; /** * Load notififications into database @@ -19,7 +18,7 @@ class LoadAccompanyingPeriodNotifications extends AbstractFixture implements Dep [ 'message' => 'Hello !', 'entityClass' => AccompanyingPeriod::class, - 'entityRef' => LoadAccompanyingPeriod::ACCOMPANYING_PERIOD, + 'entityRef' => null, 'sender' => 'center a_social', 'addressees' => [ 'center a_social', @@ -30,10 +29,15 @@ class LoadAccompanyingPeriodNotifications extends AbstractFixture implements Dep ] ]; + protected function getEntityRef() + { + return null; + } + public function getDependencies() { return [ - LoadAccompanyingPeriod::class, + LoadPeople::class, ]; } } diff --git a/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadHousehold.php b/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadHousehold.php index 812f2bb07..24a5bbb7f 100644 --- a/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadHousehold.php +++ b/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadHousehold.php @@ -33,7 +33,7 @@ class LoadHousehold extends Fixture implements DependentFixtureInterface public function load(ObjectManager $manager) { - // generate two times the participation. This will lead to + // generate two times the participation. This will lead to // some movement in participation (same people in two differents // households) @@ -110,7 +110,7 @@ class LoadHousehold extends Fixture implements DependentFixtureInterface $i = 0; while ($i < $nb) { $address = $this->createAddress(); - $address->setValidFrom(\DateTime::createFromImmutable($date)); + $address->setValidFrom(\DateTime::createFromImmutable($date)); if (\random_int(0, 20) < 1) { $date = $date->add(new \DateInterval('P'.\random_int(8, 52).'W')); @@ -157,6 +157,7 @@ class LoadHousehold extends Fixture implements DependentFixtureInterface ->setParameter('center', 'Center A') ->getScalarResult() ; + \shuffle($this->personIds); } diff --git a/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadPeople.php b/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadPeople.php index 474cd1216..d6bdce233 100644 --- a/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadPeople.php +++ b/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadPeople.php @@ -21,9 +21,15 @@ namespace Chill\PersonBundle\DataFixtures\ORM; +use Chill\MainBundle\Entity\Center; +use Chill\MainBundle\Entity\Country; use Chill\MainBundle\Entity\PostalCode; +use Chill\MainBundle\Repository\CenterRepository; +use Chill\MainBundle\Repository\CountryRepository; use Chill\PersonBundle\Entity\AccompanyingPeriod; +use Chill\PersonBundle\Entity\MaritalStatus; use Chill\PersonBundle\Entity\SocialWork\SocialIssue; +use Chill\PersonBundle\Repository\MaritalStatusRepository; use Chill\ThirdPartyBundle\Entity\ThirdParty; use Doctrine\Common\DataFixtures\AbstractFixture; use Doctrine\Common\DataFixtures\OrderedFixtureInterface; @@ -31,6 +37,7 @@ use Doctrine\Persistence\ObjectManager; use Chill\PersonBundle\Entity\Person; use Faker\Factory; use Faker\Generator; +use Nelmio\Alice\Faker\GeneratorFactory; use Nelmio\Alice\Loader\NativeLoader; use Nelmio\Alice\ObjectSet; use Symfony\Component\DependencyInjection\ContainerAwareInterface; @@ -44,8 +51,6 @@ use Chill\PersonBundle\Repository\SocialWork\SocialIssueRepository; /** * Load people into database * - * @author Julien Fastré - * @author Marc Ducobu */ class LoadPeople extends AbstractFixture implements OrderedFixtureInterface, ContainerAwareInterface { @@ -57,35 +62,50 @@ class LoadPeople extends AbstractFixture implements OrderedFixtureInterface, Con protected SocialIssueRepository $socialIssueRepository; - protected array $cacheSocialIssues = array(); + protected CountryRepository $countryRepository; - public function __construct(Registry $workflowRegistry, SocialIssueRepository $socialIssueRepository) - { + protected NativeLoader $loader; + + /** + * @var array|SocialIssue[] + */ + protected array $cacheSocialIssues = []; + + /** + * @var array|Country[] + */ + protected array $cacheCountries = []; + + /** + * @var array|Center[] + */ + protected array $cacheCenters = []; + + protected CenterRepository $centerRepository; + + /** + * @var array|MaritalStatus[] + */ + protected array $cacheMaritalStatuses = []; + + protected MaritalStatusRepository $maritalStatusRepository; + + public function __construct( + Registry $workflowRegistry, + SocialIssueRepository $socialIssueRepository, + CenterRepository $centerRepository, + CountryRepository $countryRepository, + MaritalStatusRepository $maritalStatusRepository + ) { $this->faker = Factory::create('fr_FR'); + $this->faker->addProvider($this); $this->workflowRegistry = $workflowRegistry; $this->socialIssueRepository = $socialIssueRepository; - } + $this->centerRepository = $centerRepository; + $this->countryRepository = $countryRepository; + $this->maritalStatusRepository = $maritalStatusRepository; + $this->loader = new NativeLoader($this->faker); - public function prepare() - { - //prepare days, month, years - $y = 1950; - do { - $this->years[] = $y; - $y = $y +1; - } while ($y >= 1990); - - $m = 1; - do { - $this->month[] = $m; - $m = $m +1; - } while ($m >= 12); - - $d = 1; - do { - $this->day[] = $d; - $d = $d + 1; - } while ($d <= 28); } public function getOrder() @@ -95,8 +115,8 @@ class LoadPeople extends AbstractFixture implements OrderedFixtureInterface, Con public function load(ObjectManager $manager) { - $this->loadRandPeople($manager); $this->loadExpectedPeople($manager); + $this->loadRandPeople($manager); $manager->flush(); } @@ -105,117 +125,102 @@ class LoadPeople extends AbstractFixture implements OrderedFixtureInterface, Con { echo "loading expected people...\n"; - foreach ($this->peoples as $person) { - $this->addAPerson($this->fillWithDefault($person), $manager); + + foreach ($this->peoples as $personDef) { + $person = $this->createExpectedPerson($personDef); + $this->addAPerson($person, $manager); } } - public function loadRandPeople(ObjectManager $manager) + protected function loadRandPeople(ObjectManager $manager) { echo "loading rand people...\n"; + $persons = $this->createRandPerson()->getObjects(); - $this->prepare(); - - $chooseLastNameOrTri = array('tri', 'tri', 'name', 'tri'); - - $i = 0; - - do { - $i++; - - $sex = $this->genders[array_rand($this->genders)]; - - if ($chooseLastNameOrTri[array_rand($chooseLastNameOrTri)] === 'tri' ) { - $length = rand(2, 3); - $lastName = ''; - for ($j = 0; $j <= $length; $j++) { - $lastName .= $this->lastNamesTrigrams[array_rand($this->lastNamesTrigrams)]; - } - $lastName = ucfirst($lastName); - } else { - $lastName = $this->lastNames[array_rand($this->lastNames)]; - } - - if ($sex === Person::MALE_GENDER) { - $firstName = $this->firstNamesMale[array_rand($this->firstNamesMale)]; - } else { - $firstName = $this->firstNamesFemale[array_rand($this->firstNamesFemale)]; - } - - // add an address on 80% of the created people - if (rand(0,100) < 80) { - $address = $this->getRandomAddress(); - // on 30% of those person, add multiple addresses - if (rand(0,10) < 4) { - $address = array( - $address, - $this->getRandomAddress() - ); - } - } else { - $address = null; - } - - $person = array( - 'FirstName' => $firstName, - 'LastName' => $lastName, - 'Gender' => $sex, - 'Nationality' => (rand(0,100) > 50) ? NULL: 'BE', - 'center' => (rand(0,1) == 0) ? 'centerA': 'centerB', - 'Address' => $address, - 'maritalStatus' => $this->maritalStatusRef[array_rand($this->maritalStatusRef)] - ); - - $this->addAPerson($this->fillWithDefault($person), $manager); - - } while ($i <= 100); + foreach ($persons as $person) { + $this->addAPerson($person, $manager); + } } - /** - * fill a person array with default value - * - * @param string[] $specific - */ - private function fillWithDefault(array $specific) + private function createRandPerson(): ObjectSet { - return array_merge(array( - 'Birthdate' => "1960-10-12", - 'PlaceOfBirth' => "Ottignies Louvain-La-Neuve", - 'Gender' => Person::MALE_GENDER, - 'Email' => "roger@yopmail.com", - 'CountryOfBirth' => 'BE', - 'Nationality' => 'BE', - 'CFData' => array(), - 'Address' => null - ), $specific); + return $this->loader->loadData([ + Person::class => [ + 'persons{1..300}' => [ + 'firstName' => '', + 'lastName' => '', + 'gender' => '', + 'nationality' => '', + 'center' => '', + 'maritalStatus' => '', + 'birthdate' => '', + 'placeOfBirth' => '', + 'email' => '', + 'countryOfBirth' => '', + ] + ] + ]); } - private function getRandomSocialIssue(): SocialIssue + private function createExpectedPerson($default): Person { - if (0 === count($this->cacheSocialIssues)) { - $this->cacheSocialIssues = $this->socialIssueRepository->findAll(); + $person = $this->loader->loadData([ + Person::class => [ + "person" => [ + 'firstName' => $default['firstName'] ?? '', + 'lastName' => $default['lastName'] ?? '', + 'gender' => '', + 'nationality' => '', + 'center' => '', + 'maritalStatus' => '', + 'birthdate' => '', + 'placeOfBirth' => '', + 'email' => '', + 'countryOfBirth' => '', + ], + ] + ])->getObjects()['person']; + + // force some values + foreach ($default as $key => $value) { + switch ($key) { + case 'birthdate': + $person->setBirthdate(new \DateTime($value)); + break; + case 'center': + $person->setCenter($this->centerRepository + ->findOneBy(['name' => $value])); + break; + case 'countryOfBirth': + case 'nationality': + $country = $this->countryRepository + ->findOneBy(['countryCode' => $value]); + $person->{'set'.\ucfirst($key)}($country); + break; + case 'maritalStatus': + $person->setMaritalStatus($this->maritalStatusRepository + ->find($value)); + break; + } } - return $this->cacheSocialIssues[\array_rand($this->cacheSocialIssues)]; + return $person; } /** * create a new person from array data * - * @param array $person - * @param ObjectManager $manager * @throws \Exception */ - private function addAPerson(array $person, ObjectManager $manager) + private function addAPerson(Person $person, ObjectManager $manager) { - $p = new Person(); $accompanyingPeriod = new AccompanyingPeriod( (new \DateTime()) ->sub( new \DateInterval('P' . \random_int(0, 180) . 'D') ) ); - $p->addAccompanyingPeriod($accompanyingPeriod); + $person->addAccompanyingPeriod($accompanyingPeriod); $accompanyingPeriod->addSocialIssue($this->getRandomSocialIssue()); if (\random_int(0, 10) > 3) { @@ -225,53 +230,13 @@ class LoadPeople extends AbstractFixture implements OrderedFixtureInterface, Con $workflow->apply($accompanyingPeriod, 'confirm'); } - foreach ($person as $key => $value) { - switch ($key) { - case 'CountryOfBirth': - case 'Nationality': - $value = $this->getCountry($value); - break; - case 'Birthdate': - $value = new \DateTime($value); - break; - case 'center': - case 'maritalStatus': - $value = $this->getReference($value); - break; - case 'accompanyingPeriods': - $this->addAccompanyingPeriods($p, $value, $manager); - break; - } - - //try to add the data using the setSomething function, - // if not possible, fallback to addSomething function - if (method_exists($p, 'set'.$key)) { - call_user_func(array($p, 'set'.$key), $value); - } elseif (method_exists($p, 'add'.$key)) { - // if we have a "addSomething", we may have multiple items to add - // so, we set the value in an array if it is not an array, and - // will call the function addSomething multiple times - if (!is_array($value)) { - $value = array($value); - } - - foreach($value as $v) { - if ($v !== NULL) { - call_user_func(array($p, 'add'.$key), $v); - } - } - - } - } - - $manager->persist($p); - echo "add person'".$p->__toString()."'\n"; + $manager->persist($person); + echo "add person'".$person->__toString()."'\n"; } private function createAddress(): Address { - $loader = new NativeLoader(); - $objectSet = $loader->loadData([ + $objectSet = $this->loader->loadData([ Address::class => [ 'address' => [ 'street' => '', @@ -285,6 +250,17 @@ class LoadPeople extends AbstractFixture implements OrderedFixtureInterface, Con return $objectSet->getObjects()['address']; } + + + private function getRandomSocialIssue(): SocialIssue + { + if (0 === count($this->cacheSocialIssues)) { + $this->cacheSocialIssues = $this->socialIssueRepository->findAll(); + } + + return $this->cacheSocialIssues[\array_rand($this->cacheSocialIssues)]; + } + private function getPostalCode(): PostalCode { $ref = LoadPostalCodes::$refs[\array_rand(LoadPostalCodes::$refs)]; @@ -306,7 +282,6 @@ class LoadPeople extends AbstractFixture implements OrderedFixtureInterface, Con return Point::fromLonLat($lon, $lat); } - /** * Create a random address * @@ -329,53 +304,77 @@ class LoadPeople extends AbstractFixture implements OrderedFixtureInterface, Con ; } - private function getCountry($countryCode) + /** + * @internal This method is public and called by faker as a custom generator + * @return Center + */ + public function getRandomCenter(): Center { - if ($countryCode === NULL) { - return NULL; + if (0 === count($this->cacheCenters)) { + $this->cacheCenters = $this->centerRepository->findAll(); } - return $this->container->get('doctrine.orm.entity_manager') - ->getRepository('ChillMainBundle:Country') - ->findOneByCountryCode($countryCode); + + return $this->cacheCenters[\array_rand($this->cacheCenters)]; } - private $maritalStatusRef = ['ms_single', 'ms_married', 'ms_widow', 'ms_separat', - 'ms_divorce', 'ms_legalco', 'ms_unknown']; + /** + * @internal This method is public and called by faker as a custom generator + * @param int $nullPercentage + * @return Country|null + * @throws \Exception + */ + public function getRandomCountry(int $nullPercentage = 20): ?Country + { + if (0 === count($this->cacheCountries)) { + $this->cacheCountries = $this->countryRepository->findAll(); + } - private $firstNamesMale = array("Jean", "Mohamed", "Alfred", "Robert", "Justin", "Brian", - "Compère", "Jean-de-Dieu", "Charles", "Pierre", "Luc", "Mathieu", "Alain", "Etienne", "Eric", - "Corentin", "Gaston", "Spirou", "Fantasio", "Mahmadou", "Mohamidou", "Vursuv", "Youssef" ); + if ($nullPercentage < \random_int(0, 100)) { + return NULL; + } - private $firstNamesFemale = array("Svedana", "Sevlatina", "Irène", "Marcelle", - "Corentine", "Alfonsine", "Caroline", "Solange", "Gostine", "Fatoumata", "Nicole", - "Groseille", "Chana", "Oxana", "Ivana", "Julie", "Tina", "Adèle" ); + return $this->cacheCountries [\array_rand($this->cacheCountries)]; + } - private $lastNames = array("Diallo", "Bah", "Gaillot", "Martin"); + /** + * @internal This method is public and called by faker as a custom generator + * @return string + */ + public function getRandomGender(): string + { + return $this->genders[array_rand($this->genders)]; + } - private $lastNamesTrigrams = array("fas", "tré", "hu", 'blart', 'van', 'der', 'lin', 'den', - 'ta', 'mi', 'net', 'gna', 'bol', 'sac', 'ré', 'jo', 'du', 'pont', 'cas', 'tor', 'rob', 'al', - 'ma', 'gone', 'car',"fu", "ka", "lot", "no", "va", "du", "bu", "su", "jau", "tte", 'sir', - "lo", 'to', "cho", "car", 'mo','zu', 'qi', 'mu'); + /** + * @internal This method is public and called by faker as a custom generator + * @param int $nullPercentage + * @return MaritalStatus|null + * @throws \Exception + */ + public function getRandomMaritalStatus(int $nullPercentage = 50): ?MaritalStatus + { + if (0 === count($this->cacheMaritalStatuses)) { + $this->cacheMaritalStatuses = $this->maritalStatusRepository->findAll(); + } - private $genders = array(Person::MALE_GENDER, Person::FEMALE_GENDER); + if ($nullPercentage < \random_int(0, 100)) { + return NULL; + } - private $years = array(); + return $this->cacheMaritalStatuses[array_rand($this->cacheMaritalStatuses)]; + } - private $month = array(); - - private $day = array(); + private $genders = array(Person::MALE_GENDER, Person::FEMALE_GENDER, Person::BOTH_GENDER); private $peoples = array( array( - 'LastName' => "Depardieu", - 'FirstName' => "Gérard", - 'Birthdate' => "1948-12-27", - 'PlaceOfBirth' => "Châteauroux", - 'Gender' => Person::MALE_GENDER, - 'CountryOfBirth' => 'FR', - 'Nationality' => 'RU', - 'center' => 'centerA', - 'maritalStatus' => 'ms_divorce', + 'lastName' => "Depardieu", + 'firstName' => "Gérard", + 'birthdate' => "1948-12-27", + 'placeOfBirth' => "Châteauroux", + 'nationality' => 'RU', + 'gender' => Person::MALE_GENDER, + 'center' => 'Center A', 'accompanyingPeriods' => [ [ 'from' => '2015-02-01', @@ -394,67 +393,123 @@ class LoadPeople extends AbstractFixture implements OrderedFixtureInterface, Con ), array( //to have a person with same firstname as Gérard Depardieu - 'LastName' => "Depardieu", - 'FirstName' => "Jean", - 'Birthdate' => "1960-10-12", - 'CountryOfBirth' => 'FR', - 'Nationality' => 'FR', - 'center' => 'centerA', + 'lastName' => "Depardieu", + 'firstName' => "Jean", + 'birthdate' => "1960-10-12", + 'countryOfBirth' => 'FR', + 'nationality' => 'FR', + 'center' => 'Center A', 'maritalStatus' => 'ms_divorce' ), array( //to have a person with same birthdate of Gérard Depardieu - 'LastName' => 'Van Snick', - 'FirstName' => 'Bart', - 'Birthdate' => '1948-12-27', - 'center' => 'centerA', + 'lastName' => 'Van Snick', + 'firstName' => 'Bart', + 'birthdate' => '1948-12-27', + 'center' => 'Center A', 'maritalStatus' => 'ms_legalco' ), array( //to have a woman with Depardieu as FirstName - 'LastName' => 'Depardieu', - 'FirstName' => 'Charline', - 'Gender' => Person::FEMALE_GENDER, - 'center' => 'centerA', + 'lastName' => 'Depardieu', + 'firstName' => 'Charline', + 'gender' => Person::FEMALE_GENDER, + 'center' => 'Center A', 'maritalStatus' => 'ms_legalco' ), array( //to have a special character in lastName - 'LastName' => 'Manço', - 'FirstName' => 'Étienne', - 'center' => 'centerA', + 'lastName' => 'Manço', + 'firstName' => 'Étienne', + 'center' => 'Center A', 'maritalStatus' => 'ms_unknown' ), array( //to have true duplicate person - 'LastName' => "Depardieu", - 'FirstName' => "Jean", - 'Birthdate' => "1960-10-12", - 'CountryOfBirth' => 'FR', - 'Nationality' => 'FR', - 'center' => 'centerA', + 'lastName' => "Depardieu", + 'firstName' => "Jean", + 'birthdate' => "1960-10-12", + 'countryOfBirth' => 'FR', + 'nationality' => 'FR', + 'center' => 'Center A', 'maritalStatus' => 'ms_divorce' ), array( //to have false duplicate person - 'LastName' => "Depardieu", - 'FirstName' => "Jeanne", - 'Birthdate' => "1966-11-13", - 'CountryOfBirth' => 'FR', - 'Nationality' => 'FR', - 'center' => 'centerA', + 'lastName' => "Depardieu", + 'firstName' => "Jeanne", + 'birthdate' => "1966-11-13", + 'countryOfBirth' => 'FR', + 'nationality' => 'FR', + 'center' => 'Center A', 'maritalStatus' => 'ms_legalco' ), + [ + 'lastName' => 'Diallo', + 'firstName' => "Fatoumata Binta" + ], + [ + 'lastName' => 'Diallo', + 'firstName' => 'Abdoulaye', + ], + [ + 'lastName' => 'Diallo', + 'firstName' => 'Diakite', + ], + [ + 'lastName' => 'Diallo', + 'firstName' => 'Mohamed', + ], + [ + 'lastName' => 'Diallo', + 'firstName' => 'Fatou', + ], + [ + 'lastName' => 'Diallo', + 'firstName' => 'Fanta', + ], + [ + 'lastName' => 'Bah', + 'firstName' => "Fatoumata Binta" + ], + [ + 'lastName' => 'Bah', + 'firstName' => 'Abdoulaye', + ], + [ + 'lastName' => 'Bah', + 'firstName' => 'Diakite', + ], + [ + 'lastName' => 'Bah', + 'firstName' => 'Mohamed', + ], + [ + 'lastName' => 'Bah', + 'firstName' => 'Fatou', + ], + [ + 'lastName' => 'Bah', + 'firstName' => 'Fanta', + ], + [ + 'lastName' => 'Bah', + 'firstName' => 'Gaston', + ], + [ + 'lastName' => 'Gaillot', + 'firstName' => 'Adèle', + ], ); - +/* private function addAccompanyingPeriods(Person $person, array $periods, ObjectManager $manager) { foreach ($periods as $period) { echo "adding new past Accompanying Period..\n"; - /** @var AccompanyingPeriod $accompanyingPeriod */ + /** @var AccompanyingPeriod $accompanyingPeriod $accompanyingPeriod = new AccompanyingPeriod(new \DateTime($period['from'])); $accompanyingPeriod ->setClosingDate(new \DateTime($period['to'])) @@ -464,4 +519,5 @@ class LoadPeople extends AbstractFixture implements OrderedFixtureInterface, Con $person->addAccompanyingPeriod($accompanyingPeriod); } } + */ } diff --git a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWorkEvaluationDocument.php b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWorkEvaluationDocument.php index 2c7ca1099..f61955e1d 100644 --- a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWorkEvaluationDocument.php +++ b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWorkEvaluationDocument.php @@ -167,7 +167,7 @@ class AccompanyingPeriodWorkEvaluationDocument implements \Chill\MainBundle\Doct /** * @return DateTimeImmutable|null */ - public function getUpdatedAt(): ?DateTimeInterface + public function getUpdatedAt(): ?\DateTimeInterface { return $this->updatedAt; } diff --git a/src/Bundle/ChillPersonBundle/Repository/MaritalStatusRepository.php b/src/Bundle/ChillPersonBundle/Repository/MaritalStatusRepository.php new file mode 100644 index 000000000..1a69d1319 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Repository/MaritalStatusRepository.php @@ -0,0 +1,43 @@ +repository = $entityManager->getRepository(MaritalStatus::class); + } + public function find($id): ?MaritalStatus + { + return $this->repository->find($id); + } + + public function findAll(): array + { + return $this->repository->findAll(); + } + + public function findBy(array $criteria, ?array $orderBy = null, $limit = null, $offset = null): array + { + return $this->repository->findBy($criteria, $orderBy, $limit, $offset); + } + + public function findOneBy(array $criteria): ?MaritalStatus + { + return $this->findOneBy($criteria); + } + + public function getClassName(): string + { + return MaritalStatus::class; + } +} diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/App.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/App.vue index c2d7d3946..e8d7dd192 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/App.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/App.vue @@ -6,15 +6,21 @@

{{ $t('course.title.active') }}

+ - +
+

+ {{ error.sta }} {{ error.txt }}
+ {{ $t(error.msg) }} +

+
@@ -89,6 +96,16 @@ export default { } table { } + + &.errors { + //display: flex; + //position: sticky; + //bottom: 0.3em; + //z-index: 1000; + margin: 1em 0; + padding: 1em; + border-radius: 0; + } } } diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/api.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/api.js index 676bbf7b7..52e253ac1 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/api.js +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/api.js @@ -9,7 +9,7 @@ const getAccompanyingCourse = (id) => { return fetch(url) .then(response => { if (response.ok) { return response.json(); } - throw Error('Error with request resource response'); + throw { msg: 'Error while retriving AccompanyingPeriod Course.', sta: response.status, txt: response.statusText, err: new Error(), body: response.body }; }); }; @@ -32,7 +32,8 @@ const patchAccompanyingCourse = (id, body) => { }) .then(response => { if (response.ok) { return response.json(); } - throw Error('Error with request resource response'); + console.log(response); + throw { msg: 'Error while updating AccompanyingPeriod Course.', sta: response.status, txt: response.statusText, err: new Error(), body: response.body }; }); }; @@ -47,7 +48,7 @@ const confirmAccompanyingCourse = (id) => { }) .then(response => { if (response.ok) { return response.json(); } - throw Error('Error with request resource response'); + throw { msg: 'Error while confirming AccompanyingPeriod Course.', sta: response.status, txt: response.statusText, err: new Error(), body: response.body }; }); }; @@ -59,7 +60,7 @@ const getSocialIssues = () => { return fetch(url) .then(response => { if (response.ok) { return response.json(); } - throw Error('Error with request resource response'); + throw { msg: 'Error while retriving Social Issues.', sta: response.status, txt: response.statusText, err: new Error(), body: response.body }; }); }; @@ -83,7 +84,7 @@ const postParticipation = (id, payload, method) => { }) .then(response => { if (response.ok) { return response.json(); } - throw Error('Error with request resource response'); + throw { msg: 'Error while sending AccompanyingPeriod Course participation.', sta: response.status, txt: response.statusText, err: new Error(), body: response.body }; }); }; @@ -109,7 +110,7 @@ const postRequestor = (id, payload, method) => { }) .then(response => { if (response.ok) { return response.json(); } - throw Error('Error with request resource response'); + throw { msg: 'Error while sending AccompanyingPeriod Course requestor', sta: response.status, txt: response.statusText, err: new Error(), body: response.body }; }); }; @@ -142,7 +143,7 @@ const postResource = (id, payload, method) => { }) .then(response => { if (response.ok) { return response.json(); } - throw Error('Error with request resource response'); + throw { msg: 'Error while sending AccompanyingPeriod Course resource.', sta: response.status, txt: response.statusText, err: new Error(), body: response.body }; }); }; @@ -161,7 +162,7 @@ const postSocialIssue = (id, body, method) => { }) .then(response => { if (response.ok) { return response.json(); } - throw Error('Error with request resource response'); + throw { msg: 'Error while updating SocialIssue.', sta: response.status, txt: response.statusText, err: new Error(), body: response.body }; }); }; @@ -170,7 +171,7 @@ const getUsers = () => { return fetch(url) .then(response => { if (response.ok) { return response.json(); } - throw Error('Error with request resource response'); + throw { msg: 'Error while retriving users.', sta: response.status, txt: response.statusText, err: new Error(), body: response.body }; }); }; @@ -179,7 +180,7 @@ const whoami = () => { return fetch(url) .then(response => { if (response.ok) { return response.json(); } - throw Error('Error with request resource response'); + throw { msg: 'Error while getting whoami.', sta: response.status, txt: response.statusText, err: new Error(), body: response.body }; }); }; @@ -188,7 +189,7 @@ const getListOrigins = () => { return fetch(url) .then(response => { if (response.ok) { return response.json(); } - throw Error('Error with request resource response'); + throw { msg: 'Error while retriving origin\'s list.', sta: response.status, txt: response.statusText, err: new Error(), body: response.body }; }); } diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/ButtonLocation.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/ButtonLocation.vue index c2f50c489..08b608d89 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/ButtonLocation.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/ButtonLocation.vue @@ -60,7 +60,7 @@ export default { personId: this.person.id }; this.$store.dispatch('updateLocation', payload); - window.location.assign('#section-50'); + window.location.assign('#section-20'); this.modal.showModal = false; } } diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Comment.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Comment.vue index b42fe8453..b64d46103 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Comment.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Comment.vue @@ -27,17 +27,19 @@ ]) }} - +
+ +
diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Confirm.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Confirm.vue index 13752f383..44479831c 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Confirm.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Confirm.vue @@ -3,24 +3,43 @@

{{ $t('confirm.title') }}

-
-

- {{ $t('confirm.text_draft') }} - {{ $t('course.step.draft') }} -

-

- {{ $t('confirm.text_active') }} - {{ $t('course.step.active') }} -

+

+ +
+
+ {{ $t('confirm.alert_validation') }} +
    +
  • + {{ $t(notValidMessages[k].msg) }} + + + +
  • +
+
+
    +
  • + +
  • +
+
+ +
+

+
    +
  • + +
  • +
+
-
    -
  • - -
  • -
@@ -43,6 +62,7 @@ - - diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/CourseLocation.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/CourseLocation.vue index b9a4e111d..3c4d79521 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/CourseLocation.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/CourseLocation.vue @@ -1,28 +1,36 @@ @@ -96,6 +104,9 @@ export default { isPersonLocation() { return this.accompanyingCourse.locationStatus === 'person'; }, + hasNoLocation() { + return this.accompanyingCourse.locationStatus === 'none'; + }, isContextEdit() { return this.context.edit; } diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/OriginDemand.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/OriginDemand.vue index 1804529ba..af0fcf2b7 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/OriginDemand.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/OriginDemand.vue @@ -1,8 +1,8 @@ diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Requestor.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Requestor.vue index e682542aa..703b105d8 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Requestor.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Requestor.vue @@ -1,12 +1,12 @@