Merge branch 'master' into issue321_layout_improvements_actionForm

This commit is contained in:
2021-12-20 12:56:41 +01:00
16 changed files with 231 additions and 77 deletions

View File

@@ -57,7 +57,7 @@ class HouseholdMenuBuilder implements LocalMenuBuilderInterface
'routeParameters' => [
'household_id' => $household->getId(),
], ])
->setExtras(['order' => 40]);
->setExtras(['order' => 15]);
}
public static function getMenuIds(): array

View File

@@ -3,44 +3,54 @@
*/
const parametersToString = ({ query, options }) => {
let types ='';
options.type.forEach(function(type) {
options.type.forEach(function(type) {
types += '&type[]=' + type;
});
});
return 'q=' + query + types;
};
/*
/*
* Endpoint chill_person_search
* method GET, get a list of persons
*
*
* @query string - the query to search for
* @deprecated
*/
const searchPersons = ({ query, options }) => {
const searchPersons = ({ query, options }, signal) => {
console.err('deprecated');
let queryStr = parametersToString({ query, options });
let url = `/fr/search.json?name=person_regular&${queryStr}`;
return fetch(url)
let fetchOpts = {
method: 'GET',
headers: {
'Content-Type': 'application/json;charset=utf-8'
},
signal,
};
return fetch(url, fetchOpts)
.then(response => {
if (response.ok) { return response.json(); }
throw Error('Error with request resource response');
throw Error('Error with request resource response');
});
};
/*
/*
* Endpoint v.2 chill_main_search_global
* method GET, get a list of persons and thirdparty
*
* NOTE: this is a temporary WIP endpoint, return inconsistent random results
* @query string - the query to search for
*
* @param query string - the query to search for
*
*/
const searchPersons_2 = ({ query, options }) => {
const searchEntities = ({ query, options }, signal) => {
let queryStr = parametersToString({ query, options });
let url = `/api/1.0/search.json?${queryStr}`;
return fetch(url)
.then(response => {
if (response.ok) { return response.json(); }
throw Error('Error with request resource response');
throw Error('Error with request resource response');
});
};
export { searchPersons, searchPersons_2 };
export { searchPersons, searchEntities };

View File

@@ -90,7 +90,7 @@
import Modal from 'ChillMainAssets/vuejs/_components/Modal';
import OnTheFly from 'ChillMainAssets/vuejs/OnTheFly/components/OnTheFly.vue';
import PersonSuggestion from './AddPersons/PersonSuggestion';
import { searchPersons, searchPersons_2 } from 'ChillPersonAssets/vuejs/_api/AddPersons';
import { searchEntities } from 'ChillPersonAssets/vuejs/_api/AddPersons';
import { postPerson } from "ChillPersonAssets/vuejs/_api/OnTheFly";
import { postThirdparty } from "ChillThirdPartyAssets/vuejs/_api/OnTheFly";
@@ -115,6 +115,8 @@ export default {
},
search: {
query: "",
previousQuery: "",
currentSearchQueryController: null,
suggested: [],
selected: [],
priorSuggestion: {}
@@ -189,16 +191,24 @@ export default {
},
setQuery(query) {
this.search.query = query;
if (query.length >= 3) {
searchPersons_2({ query, options: this.options })
.then(suggested => new Promise((resolve, reject) => {
//console.log('suggested', suggested);
this.loadSuggestions(suggested.results);
resolve();
}));
} else {
this.loadSuggestions([]);
}
setTimeout(function() {
if (query === "") {
this.loadSuggestions([]);
return;
}
if (query === this.search.query) {
if (this.currentSearchQueryController !== undefined) {
this.currentSearchQueryController.abort()
}
this.currentSearchQueryController = new AbortController();
searchEntities({ query, options: this.options }, this.currentSearchQueryController)
.then(suggested => new Promise((resolve, reject) => {
this.loadSuggestions(suggested.results);
resolve();
}));
}
}.bind(this), query.length > 3 ? 300 : 700);
},
loadSuggestions(suggested) {
this.search.suggested = suggested;

View File

@@ -74,7 +74,7 @@ class PersonDocGenNormalizer implements
$data = [
'type' => 'person',
'isNull' => false,
'civility' => $this->normalizer->normalize($person->getCivility(), $format, array_merge($context, ['docgen:expect' => Civility::class])),
'civility' => $this->normalizer->normalize($person->getCivility(), $format, array_merge($context, ['docgen:expects' => Civility::class])),
'firstname' => $person->getFirstName(),
'lastname' => $person->getLastName(),
'altNames' => implode(
@@ -87,6 +87,7 @@ class PersonDocGenNormalizer implements
)
),
'text' => $this->personRender->renderString($person, []),
'age' => (int) $person->getAge(),
'birthdate' => $this->normalizer->normalize($person->getBirthdate(), $format, $dateContext),
'deathdate' => $this->normalizer->normalize($person->getDeathdate(), $format, $dateContext),
'gender' => $this->translator->trans($person->getGender()),

View File

@@ -15,6 +15,7 @@ use Chill\DocGeneratorBundle\Context\DocGeneratorContextWithAdminFormInterface;
use Chill\DocGeneratorBundle\Context\DocGeneratorContextWithPublicFormInterface;
use Chill\DocGeneratorBundle\Context\Exception\UnexpectedTypeException;
use Chill\DocGeneratorBundle\Entity\DocGeneratorTemplate;
use Chill\DocGeneratorBundle\Service\Context\BaseContextData;
use Chill\DocStoreBundle\Entity\AccompanyingCourseDocument;
use Chill\DocStoreBundle\Entity\StoredObject;
use Chill\DocStoreBundle\Repository\DocumentCategoryRepository;
@@ -38,6 +39,8 @@ class AccompanyingPeriodContext implements
DocGeneratorContextWithAdminFormInterface,
DocGeneratorContextWithPublicFormInterface
{
private BaseContextData $baseContextData;
private DocumentCategoryRepository $documentCategoryRepository;
private EntityManagerInterface $em;
@@ -56,7 +59,8 @@ class AccompanyingPeriodContext implements
TranslatableStringHelperInterface $translatableStringHelper,
EntityManagerInterface $em,
PersonRender $personRender,
TranslatorInterface $translator
TranslatorInterface $translator,
BaseContextData $baseContextData
) {
$this->documentCategoryRepository = $documentCategoryRepository;
$this->normalizer = $normalizer;
@@ -64,12 +68,11 @@ class AccompanyingPeriodContext implements
$this->em = $em;
$this->personRender = $personRender;
$this->translator = $translator;
$this->baseContextData = $baseContextData;
}
public function adminFormReverseTransform(array $data): array
{
dump($data);
if (array_key_exists('category', $data)) {
$data['category'] = [
'idInsideBundle' => $data['category']->getIdInsideBundle(),
@@ -171,6 +174,7 @@ class AccompanyingPeriodContext implements
$options = $template->getOptions();
$data = [];
$data = array_merge($data, $this->baseContextData->getData());
$data['course'] = $this->normalizer->normalize($entity, 'docgen', ['docgen:expects' => AccompanyingPeriod::class, 'groups' => 'docgen:read']);
foreach (['mainPerson', 'person1', 'person2'] as $k) {

View File

@@ -56,6 +56,7 @@ final class PersonDocGenNormalizerTest extends KernelTestCase
'placeOfBirth' => '',
'memo' => '',
'numberOfChildren' => '',
'age' => '@ignored',
];
private NormalizerInterface $normalizer;