mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-12 13:24:25 +00:00
dispatch action change value of hidden fields, persisted when submited
This commit is contained in:
parent
6f1209eaf5
commit
b705c5910f
@ -112,41 +112,45 @@ class ActivityType extends AbstractType
|
||||
}
|
||||
|
||||
if ($activityType->isVisible('socialIssues') && $accompanyingPeriod) {
|
||||
$builder->add('socialIssues',
|
||||
/*
|
||||
HiddenType::class
|
||||
*/
|
||||
EntityType::class, [
|
||||
'label' => $activityType->getLabel('socialIssues'),
|
||||
'required' => $activityType->isRequired('socialIssues'),
|
||||
'class' => SocialIssue::class,
|
||||
'choice_label' => function (SocialIssue $socialIssue) {
|
||||
return $this->socialIssueRender->renderString($socialIssue, []);
|
||||
},
|
||||
'multiple' => true,
|
||||
'choices' => $accompanyingPeriod->getRecursiveSocialIssues(),
|
||||
'expanded' => true,
|
||||
]
|
||||
);
|
||||
$builder->add('socialIssues', HiddenType::class);
|
||||
$builder->get('socialIssues')
|
||||
->addModelTransformer(new CallbackTransformer(
|
||||
function (iterable $socialIssuesAsIterable): string {
|
||||
$socialIssueIds = [];
|
||||
foreach ($socialIssuesAsIterable as $value) {
|
||||
$socialIssueIds[] = $value->getId();
|
||||
}
|
||||
return implode(',', $socialIssueIds);
|
||||
},
|
||||
function (?string $socialIssuesAsString): array {
|
||||
return array_map(
|
||||
fn(string $id): ?SocialIssue => $this->om->getRepository(SocialIssue::class)->findOneBy(['id' => (int) $id]),
|
||||
explode(',', $socialIssuesAsString)
|
||||
);
|
||||
}
|
||||
))
|
||||
;
|
||||
}
|
||||
|
||||
if ($activityType->isVisible('socialActions') && $accompanyingPeriod) {
|
||||
$builder->add('socialActions',
|
||||
/*
|
||||
HiddenType::class
|
||||
*/
|
||||
EntityType::class, [
|
||||
'label' => $activityType->getLabel('socialActions'),
|
||||
'required' => $activityType->isRequired('socialActions'),
|
||||
'class' => SocialAction::class,
|
||||
'choice_label' => function (SocialAction $socialAction) {
|
||||
return $this->socialActionRender->renderString($socialAction, []);
|
||||
},
|
||||
'multiple' => true,
|
||||
'choices' => $accompanyingPeriod->getRecursiveSocialActions(),
|
||||
'expanded' => true,
|
||||
]
|
||||
);
|
||||
$builder->add('socialActions', HiddenType::class);
|
||||
$builder->get('socialActions')
|
||||
->addModelTransformer(new CallbackTransformer(
|
||||
function (iterable $socialActionsAsIterable): string {
|
||||
$socialActionIds = [];
|
||||
foreach ($socialActionsAsIterable as $value) {
|
||||
$socialActionIds[] = $value->getId();
|
||||
}
|
||||
return implode(',', $socialActionIds);
|
||||
},
|
||||
function (?string $socialActionsAsString): array {
|
||||
return array_map(
|
||||
fn(string $id): ?SocialAction => $this->om->getRepository(SocialAction::class)->findOneBy(['id' => (int) $id]),
|
||||
explode(',', $socialActionsAsString)
|
||||
);
|
||||
}
|
||||
))
|
||||
;
|
||||
}
|
||||
|
||||
if ($activityType->isVisible('date')) {
|
||||
|
@ -69,6 +69,7 @@
|
||||
{{ $t('activity.select_first_a_social_issue') }}
|
||||
</span>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
@ -111,12 +111,24 @@ const store = createStore({
|
||||
},
|
||||
actions: {
|
||||
addIssueSelected({ commit }, issue) {
|
||||
let aSocialIssues = document.getElementById("chill_activitybundle_activity_socialIssues");
|
||||
aSocialIssues.value = addIdToValue(aSocialIssues.value, issue.id);
|
||||
commit('addIssueSelected', issue);
|
||||
},
|
||||
updateIssuesSelected({ commit }, payload) {
|
||||
let aSocialIssues = document.getElementById("chill_activitybundle_activity_socialIssues");
|
||||
aSocialIssues.value = '';
|
||||
payload.forEach(item => {
|
||||
aSocialIssues.value = addIdToValue(aSocialIssues.value, item.id);
|
||||
});
|
||||
commit('updateIssuesSelected', payload);
|
||||
},
|
||||
updateActionsSelected({ commit }, payload) {
|
||||
let aSocialActions = document.getElementById("chill_activitybundle_activity_socialActions");
|
||||
aSocialActions.value = '';
|
||||
payload.forEach(item => {
|
||||
aSocialActions.value = addIdToValue(aSocialActions.value, item.id);
|
||||
});
|
||||
commit('updateActionsSelected', payload);
|
||||
},
|
||||
addPersonsInvolved({ commit }, payload) {
|
||||
|
@ -23,7 +23,6 @@
|
||||
{{ form_row(edit_form.scope) }}
|
||||
{% endif %}
|
||||
|
||||
<!--
|
||||
{%- if edit_form.socialIssues is defined -%}
|
||||
{{ form_row(edit_form.socialIssues) }}
|
||||
{% endif %}
|
||||
@ -31,7 +30,7 @@
|
||||
{%- if edit_form.socialActions is defined -%}
|
||||
{{ form_row(edit_form.socialActions) }}
|
||||
{% endif %}
|
||||
-->
|
||||
|
||||
<div id="social-issues-acc"></div>
|
||||
|
||||
{%- if edit_form.reasons is defined -%}
|
||||
|
Loading…
x
Reference in New Issue
Block a user