Compare commits

...

13 Commits

Author SHA1 Message Date
b19a1ba53b Update bootstrap to version 5.3.0 2023-11-29 10:22:43 +01:00
3d4c439be4 Merge branch 'fix-list-person-custom-field' into 'master'
Fix "PersonList" with custom fields

See merge request Chill-Projet/chill-bundles!622
2023-11-28 11:03:26 +00:00
4727a57825 Export: ListPerson: avoid json_decoding the string '_header' 2023-11-27 21:02:39 +01:00
5f441eb5ac Fix path to csv template 2023-11-27 21:01:01 +01:00
2e4e5ee79a Release v2.14.0 2023-11-24 12:39:13 +01:00
1467c708f2 Merge branch '222-fix-custom-fields' into 'master'
Fix errors in custom field rendering and administration

See merge request Chill-Projet/chill-bundles!620
2023-11-24 11:38:07 +00:00
170bb9586d Fix errors in custom field rendering and administration 2023-11-24 12:30:18 +01:00
c704ffa379 Merge branch '161-fix-ordering-filter-social-action-type' into 'master'
Export: Fix vue app in "filter action by type, goals and result"

Closes #219, #141, and #161

See merge request Chill-Projet/chill-bundles!616
2023-11-23 15:50:57 +00:00
947b7b90e2 Fix SocialWorkTypeFilter: allow null value in date, and avoid vuejs module ExportFormActionGoal to override the export form content 2023-11-23 16:02:55 +01:00
992f7761bb Fix cs 2023-11-21 15:17:02 +01:00
eb01c7c203 Export: on filter "action by type goals, and results", restore the fields when editing a saved export 2023-11-16 14:22:52 +01:00
53b4747697 fixup! Export: in filter "Filter accompanying period work (social action) by type, goal and result", order the items alphabetically or with the defined order 2023-11-16 11:55:15 +01:00
89e19502d3 Export: in filter "Filter accompanying period work (social action) by type, goal and result", order the items alphabetically or with the defined order 2023-11-16 11:53:57 +01:00
23 changed files with 148 additions and 75 deletions

View File

@@ -0,0 +1,5 @@
kind: Fixed
body: 'Export: fix list person with custom fields'
time: 2023-11-27T21:01:38.260730706+01:00
custom:
Issue: ""

8
.changes/v2.14.0.md Normal file
View File

@@ -0,0 +1,8 @@
## v2.14.0 - 2023-11-24
### Feature
* ([#161](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/161)) Export: in filter "Filter accompanying period work (social action) by type, goal and result", order the items alphabetically or with the defined order
### Fixed
* ([#141](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/141)) Export: on filter "action by type goals, and results", restore the fields when editing a saved export
* ([#219](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/219)) Export: fix the list of accompanying period work, when the "calc date" is null
* ([#222](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/222)) Fix rendering of custom fields
* Fix various errors in custom fields administration

View File

@@ -6,6 +6,15 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html),
and is generated by [Changie](https://github.com/miniscruff/changie).
## v2.14.0 - 2023-11-24
### Feature
* ([#161](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/161)) Export: in filter "Filter accompanying period work (social action) by type, goal and result", order the items alphabetically or with the defined order
### Fixed
* ([#141](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/141)) Export: on filter "action by type goals, and results", restore the fields when editing a saved export
* ([#219](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/219)) Export: fix the list of accompanying period work, when the "calc date" is null
* ([#222](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/222)) Fix rendering of custom fields
* Fix various errors in custom fields administration
## v2.13.0 - 2023-11-21
### Feature
* ([#173](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/173)) Allow user to add a phonenumber to their profile which will be included in automatically generated documents

View File

@@ -15,7 +15,7 @@
"@symfony/webpack-encore": "^4.1.0",
"@tsconfig/node14": "^1.0.1",
"bindings": "^1.5.0",
"bootstrap": "^5.0.1",
"bootstrap": "^5.3.0",
"chokidar": "^3.5.1",
"fork-awesome": "^1.1.7",
"jquery": "^3.6.0",

View File

@@ -30,7 +30,7 @@ class CustomFieldController extends AbstractController
/**
* Creates a new CustomField entity.
*
* @Route("/{_locale}/admin/customfield/new", name="customfield_new")
* @Route("/{_locale}/admin/customfield/new", name="customfield_create")
*/
public function createAction(Request $request)
{

View File

@@ -232,7 +232,7 @@ class CustomFieldsGroupController extends AbstractController
/**
* Finds and displays a CustomFieldsGroup entity.
*
* @Route("/{_locale}/admin/customfieldsgroup/{id}/show", name="customfieldsgroup/show")
* @Route("/{_locale}/admin/customfieldsgroup/{id}/show", name="customfieldsgroup_show")
*/
public function showAction(mixed $id)
{
@@ -256,7 +256,7 @@ class CustomFieldsGroupController extends AbstractController
/**
* Edits an existing CustomFieldsGroup entity.
*
* @Route("/{_locale}/admin/customfieldsgroup/{id}/update", name="customfieldsgroup/update")
* @Route("/{_locale}/admin/customfieldsgroup/{id}/update", name="customfieldsgroup_update")
*/
public function updateAction(Request $request, mixed $id)
{
@@ -383,7 +383,7 @@ class CustomFieldsGroupController extends AbstractController
$em = $this->getDoctrine()->getManager();
$customFieldsGroupIds = $em->createQuery('SELECT g.id FROM '
.'ChillCustomFieldsBundle:CustomFieldsDefaultGroup d '
.CustomFieldsDefaultGroup::class.' d '
.'JOIN d.customFieldsGroup g')
->getResult(Query::HYDRATE_SCALAR);

View File

@@ -280,7 +280,7 @@ class CustomFieldChoice extends AbstractCustomField
$template = '@ChillCustomFields/CustomFieldsRendering/choice.html.twig';
if ('csv' === $documentType) {
$template = 'ChillCustomFieldsBundle:CustomFieldsRendering:choice.csv.twig';
$template = '@ChillCustomFields/CustomFieldsRendering/choice.csv.twig';
}
return $this->templating

View File

@@ -68,7 +68,7 @@ class CustomFieldDate extends AbstractCustomField
{
$validatorFunction = static function ($value, ExecutionContextInterface $context) {
try {
$date = new \DateTime($value);
$date = new \DateTime((string) $value);
} catch (\Exception) {
$context->buildViolation('The expression "%expression%" is invalid', [
'%expression%' => $value,
@@ -125,7 +125,7 @@ class CustomFieldDate extends AbstractCustomField
return $date->format('Y-m-d');
default:
$template = 'ChillCustomFieldsBundle:CustomFieldsRendering:date.'
$template = '@ChillCustomFields/CustomFieldsRendering/date.'
.$documentType.'.twig';
return $this->templating

View File

@@ -96,7 +96,7 @@ class CustomFieldLongChoice extends AbstractCustomField
public function render($value, CustomField $customField, $documentType = 'html')
{
$option = $this->deserialize($value, $customField);
$template = 'ChillCustomFieldsBundle:CustomFieldsRendering:choice_long.'
$template = '@ChillCustomFields/CustomFieldsRendering/choice_long.'
.$documentType.'.twig';
return $this->templating

View File

@@ -95,7 +95,7 @@ class CustomFieldNumber extends AbstractCustomField
public function render($value, CustomField $customField, $documentType = 'html')
{
$template = 'ChillCustomFieldsBundle:CustomFieldsRendering:number.'
$template = '@ChillCustomFields/CustomFieldsRendering/number.'
.$documentType.'.twig';
$options = $customField->getOptions();

View File

@@ -89,7 +89,7 @@ class CustomFieldText extends AbstractCustomField
$template = '@ChillCustomFields/CustomFieldsRendering/text.html.twig';
if ('csv' === $documentType) {
$template = 'ChillCustomFieldsBundle:CustomFieldsRendering:text.csv.twig';
$template = '@ChillCustomFields/CustomFieldsRendering/text.csv.twig';
}
return $this->templating

View File

@@ -11,6 +11,7 @@ declare(strict_types=1);
namespace Chill\CustomFieldsBundle\Form;
use Chill\CustomFieldsBundle\Entity\CustomFieldsGroup;
use Chill\CustomFieldsBundle\Form\DataTransformer\CustomFieldsGroupToIdTransformer;
use Chill\CustomFieldsBundle\Service\CustomFieldProvider;
use Chill\MainBundle\Form\Type\TranslatableStringFormType;
@@ -45,7 +46,7 @@ class CustomFieldType extends AbstractType
if ('entity' === $options['group_widget']) {
$builder->add('customFieldsGroup', EntityType::class, [
'class' => 'ChillCustomFieldsBundle:CustomFieldsGroup',
'class' => CustomFieldsGroup::class,
'choice_label' => fn ($g) => $this->translatableStringHelper->localize($g->getName()),
]);
} elseif ('hidden' === $options['group_widget']) {

View File

@@ -1,4 +1,8 @@
services:
_defaults:
autowire: true
autoconfigure: true
Chill\CustomFieldsBundle\Controller\:
resource: '../../Controller'
tags: ['controller.service_arguments']

View File

@@ -11,6 +11,7 @@
// 3. Include remainder of required Bootstrap stylesheets
@import "bootstrap/scss/variables";
@import "bootstrap/scss/variables-dark";
// 4. Include any default map overrides here
@import "custom/_maps";

View File

@@ -70,7 +70,7 @@ class ChildrenNumberAggregator implements AggregatorInterface
public function getLabels($key, array $values, $data)
{
return static function (int|string|null $value): string {
return static function (null|int|string $value): string {
if ('_header' === $value) {
return 'Number of children';
}

View File

@@ -206,6 +206,7 @@ class ListAccompanyingPeriodWorkAssociatePersonOnAccompanyingPeriod implements L
public function initiateQuery(array $requiredModifiers, array $acl, array $data = [])
{
$centers = array_map(static fn ($el) => $el['center'], $acl);
$calcDate = $data['calc_date'] ?? new RollingDate(RollingDate::T_TODAY);
$qb = $this->entityManager->createQueryBuilder();
@@ -220,7 +221,7 @@ class ListAccompanyingPeriodWorkAssociatePersonOnAccompanyingPeriod implements L
->andWhere('acppart.startDate != acppart.endDate OR acppart.endDate IS NULL')
// get participants at the given date
->andWhere('acppart.startDate <= :calc_date AND (acppart.endDate > :calc_date OR acppart.endDate IS NULL)')
->setParameter('calc_date', $this->rollingDateConverter->convert($data['calc_date']));
->setParameter('calc_date', $this->rollingDateConverter->convert($calcDate));
if ($this->filterStatsByCenters) {
$qb
@@ -236,7 +237,7 @@ class ListAccompanyingPeriodWorkAssociatePersonOnAccompanyingPeriod implements L
AccompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb);
$this->addSelectClauses($qb, $this->rollingDateConverter->convert($data['calc_date']));
$this->addSelectClauses($qb, $this->rollingDateConverter->convert($calcDate));
return $qb;
}

View File

@@ -206,6 +206,7 @@ class ListAccompanyingPeriodWorkAssociatePersonOnWork implements ListInterface,
public function initiateQuery(array $requiredModifiers, array $acl, array $data = [])
{
$centers = array_map(static fn ($el) => $el['center'], $acl);
$calcDate = $data['calc_date'] ?? new RollingDate(RollingDate::T_TODAY);
$qb = $this->entityManager->createQueryBuilder();
@@ -231,7 +232,7 @@ class ListAccompanyingPeriodWorkAssociatePersonOnWork implements ListInterface,
AccompanyingCourseExportHelper::addClosingMotiveExclusionClause($qb);
$this->addSelectClauses($qb, $this->rollingDateConverter->convert($data['calc_date']));
$this->addSelectClauses($qb, $this->rollingDateConverter->convert($calcDate));
return $qb;
}

View File

@@ -332,13 +332,18 @@ class ListPerson implements ExportElementValidatedInterface, ListInterface, Grou
if (null === $value) {
return '';
}
$decoded = json_decode((string) $value, true, 512, JSON_THROW_ON_ERROR);
if ('_header' === $value) {
$label = $cfType->getChoices($cf)[$slugChoice];
return $this->translatableStringHelper->localize($cf->getName())
.' | '.$label;
.' | '.$label;
}
try {
$decoded = json_decode((string) $value, true, 512, JSON_THROW_ON_ERROR);
} catch (\JsonException $e) {
throw new \RuntimeException(sprintf('unable to decode json: %s, %s', json_last_error(), json_last_error_msg()), $e->getCode(), $e);
}
if ('_other' === $slugChoice && $cfType->isChecked($cf, $slugChoice, $decoded)) {

View File

@@ -144,6 +144,9 @@ class SocialWorkTypeFilter implements FilterInterface
$ids = [];
foreach ($asIterable as $value) {
if (null === $value) {
continue;
}
$ids[] = $value->getId();
}

View File

@@ -1,5 +1,4 @@
<template>
<teleport to="#export_filters_social_work_type_filter_form">
<fieldset class="mb-3" id="actionType">
<div class="row">
@@ -14,7 +13,7 @@
:multiple="true"
:close-on-select="false"
:placeholder="$t('action.placeholder')"
label="text"
:custom-label="formatSocialAction"
track-by="id"
:searchable="true"
></VueMultiselect>
@@ -68,8 +67,6 @@
</div>
</div>
</fieldset>
</teleport>
</template>
<script>
@@ -150,72 +147,118 @@ export default {
}
},
},
mounted() {
this.getSocialActionsList();
async mounted() {
await this.getSocialActionsList();
this.actions.hiddenField.value = '';
this.goals.hiddenField.value = '';
this.results.hiddenField.value = '';
if ('' !== this.actions.hiddenField.value) {
const actionIds = this.actions.hiddenField.value.split(',');
for (const aid of actionIds) {
let action = this.actions.options.find(a => Number.parseInt(aid) === a.id);
if (undefined !== action) {
this.action.push(action);
await this.selectAction(action);
}
}
}
//console.log(this.actions.hiddenField, this.goals.hiddenField, this.results.hiddenField);
if ('' !== this.goals.hiddenField.value) {
const goalsIds = this.goals.hiddenField.value.split(',').map(s => Number.parseInt(s));
for (const gid of goalsIds) {
let goal = this.goals.options.find(g => gid === g.id);
if (undefined !== goal) {
this.goal.push(goal);
await this.selectGoal(goal);
}
}
}
if ('' !== this.results.hiddenField.value) {
const resultsIds = this.results.hiddenField.value.split(',').map(s => Number.parseInt(s));
for (const rid of resultsIds) {
let result = this.results.options.find(r => rid === r.id);
if (undefined !== result) {
this.result.push(result);
}
}
}
},
methods: {
async getSocialActionsList() {
this.actions.options = await getSocialActions();
let actions = await getSocialActions();
this.actions.options = actions.toSorted(function (a, b) {
if (a.issue.ordering === b.issue.ordering) {
if (a.ordering === b.ordering) {
return 0;
}
if (a.ordering < b.ordering) {
return -1;
}
return 1;
}
if (a.issue.ordering < b.issue.ordering) {
return -1;
}
return 1;
})
return Promise.resolve();
},
formatSocialAction({text, issue}) {
return text + ' (' + issue.text + ')';
},
/**
* Select/unselect in Action Multiselect
* @param value
*/
selectAction(value) {
async selectAction(value) {
//console.log('----'); console.log('select action', value.id);
let children = this.getChildrensFromParent(value);
this.addSelectedElement('actions', children);
let parentAndChildren = [...[value], ...children];
const promises = [];
parentAndChildren.forEach(elem => {
getGoalByAction(elem.id).then(response => new Promise((resolve, reject) => {
this.addElementInData('goals', response.results);
resolve();
})).catch;
getResultByAction(elem.id).then(response => new Promise((resolve, reject) => {
this.addElementInData('results', response.results);
resolve();
})).catch;
promises.push(getGoalByAction(elem.id).then(goals => {
this.addElementInData('goals', goals);
return Promise.resolve();
}));
promises.push(getResultByAction(elem.id).then(results => {
this.addElementInData('results', results);
return Promise.resolve();
}));
});
await Promise.all(promises);
return Promise.resolve();
},
unselectAction(value) {
//console.log('----'); console.log('unselect action', value.id);
getGoalByAction(value.id).then(response => new Promise((resolve, reject) => {
[ this.goals.options, this.goals.value ] = this.removeElementInData('goals', response.results);
resolve();
})).catch;
getResultByAction(value.id).then(response => new Promise((resolve, reject) => {
[ this.results.options, this.results.value ] = this.removeElementInData('results', response.results);
resolve();
})).catch;
getGoalByAction(value.id).then(goals => {
[this.results.options, this.results.value ] = this.removeElementInData('goals', goals);
});
getResultByAction(value.id).then(results => {
[this.results.options, this.results.value ] = this.removeElementInData('results', results);
});
},
/**
* Select/unselect in Goal Multiselect
* @param value
*/
selectGoal(value) {
//console.log('----'); console.log('select goal', value.id);
getResultByGoal(value.id).then(response => new Promise((resolve, reject) => {
this.addElementInData('results', response.results);
resolve();
})).catch;
async selectGoal(value) {
return getResultByGoal(value.id).then(results => {
this.addElementInData('results', results);
})
},
unselectGoal(value) {
//console.log('----'); console.log('unselect goal', value.id);
getResultByGoal(value.id).then(response => new Promise((resolve, reject) => {
[ this.results.options, this.results.value ] = this.removeElementInData('results', response.results);
resolve();
})).catch;
getResultByGoal(value.id).then(results => {
[ this.results.options, this.results.value ] = this.removeElementInData('results', results);
}).catch;
},
/**
@@ -263,6 +306,7 @@ export default {
if (dump.length > 0) {
//console.log('push ' + dump.length + ' elems in', target, dump);
}
data.options.sort();
},
/**

View File

@@ -8,29 +8,17 @@ const getSocialActions = () => fetchResults(
const getGoalByAction = (id) => {
let url = `/api/1.0/person/social-work/goal/by-social-action/${id}.json`;
return fetch(url)
.then(response => {
if (response.ok) { return response.json(); }
throw Error('Error with request resource response');
});
return fetchResults(url);
};
const getResultByAction = (id) => {
let url = `/api/1.0/person/social-work/result/by-social-action/${id}.json`;
return fetch(url)
.then(response => {
if (response.ok) { return response.json(); }
throw Error('Error with request resource response');
});
return fetchResults(url);
};
const getResultByGoal = (id) => {
let url = `/api/1.0/person/social-work/result/by-goal/${id}.json`;
return fetch(url)
.then(response => {
if (response.ok) { return response.json(); }
throw Error('Error with request resource response');
});
return fetchResults(url);
};
export {
@@ -38,4 +26,4 @@ export {
getGoalByAction,
getResultByAction,
getResultByGoal,
}
}

View File

@@ -4,11 +4,13 @@ import App from './App.vue';
if (null !== document.getElementById('export_filters_social_work_type_filter_enabled')) {
const i18n = _createI18n({});
const form = document.getElementById('export_filters_social_work_type_filter_form');
const after = form.appendChild(document.createElement('div'));
const app = createApp({
template: `<app></app>`,
})
.use(i18n)
.component('app', App)
.mount('#export_export');
.mount(after);
}

View File

@@ -35,6 +35,7 @@ class SocialIssueNormalizer implements ContextAwareNormalizerInterface, Normaliz
'children_ids' => $socialIssue->getChildren()->map(static fn (SocialIssue $si) => $si->getId()),
'title' => $socialIssue->getTitle(),
'text' => $this->render->renderString($socialIssue, []),
'ordering' => $socialIssue->getOrdering(),
];
case 'docgen':