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