mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-13 13:54:23 +00:00
add form edit metadata in summary page
This commit is contained in:
parent
04ccca092b
commit
99337c4aa6
@ -51,10 +51,18 @@ class HouseholdController extends AbstractController
|
|||||||
// initialize members collection, which will avoid
|
// initialize members collection, which will avoid
|
||||||
// some queries
|
// some queries
|
||||||
$household->getMembers()->initialize();
|
$household->getMembers()->initialize();
|
||||||
|
|
||||||
|
if ($request->query->has('edit')) {
|
||||||
|
$form = $this->createMetadataForm($household);
|
||||||
|
} else {
|
||||||
|
$form = null;
|
||||||
|
}
|
||||||
|
|
||||||
return $this->render('@ChillPerson/Household/summary.html.twig',
|
return $this->render('@ChillPerson/Household/summary.html.twig',
|
||||||
[
|
[
|
||||||
'household' => $household,
|
'household' => $household,
|
||||||
'positions' => $positions
|
'positions' => $positions,
|
||||||
|
'form' => NULL !== $form ? $form->createView() : null,
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -149,7 +157,7 @@ class HouseholdController extends AbstractController
|
|||||||
|
|
||||||
$this->addFlash('success', $this->translator->trans('household.data_saved'));
|
$this->addFlash('success', $this->translator->trans('household.data_saved'));
|
||||||
|
|
||||||
return $this->redirectToRoute('chill_person_household_members', [
|
return $this->redirectToRoute('chill_person_household_summary', [
|
||||||
'household_id' => $household->getId()
|
'household_id' => $household->getId()
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,60 @@
|
|||||||
|
|
||||||
<h2>{{ 'household.Household members'|trans }}</h2>
|
<h2>{{ 'household.Household members'|trans }}</h2>
|
||||||
|
|
||||||
|
{% if form is not null %}
|
||||||
|
{{ form_start(form) }}
|
||||||
|
|
||||||
|
{{ form_row(form.commentMembers) }}
|
||||||
|
|
||||||
|
<div id="waitingForBirthContainer">
|
||||||
|
{{ form_row(form.waitingForBirth) }}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="waitingForBirthDateContainer">
|
||||||
|
{{ form_row(form.waitingForBirthDate) }}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<ul class="record_actions">
|
||||||
|
<li>
|
||||||
|
<button type="submit" class="sc-button bt-save">
|
||||||
|
{{ 'Save'|trans }}
|
||||||
|
</button>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
{{ form_end(form) }}
|
||||||
|
{% else %}
|
||||||
|
|
||||||
|
{% if not household.commentMembers.isEmpty() %}
|
||||||
|
{{ household.commentMembers|chill_entity_render_box }}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% if household.waitingForBirth %}
|
||||||
|
{% if household.waitingForBirthDate is not null %}
|
||||||
|
{{ 'household.Expecting for birth on date'|trans({ 'date': household.waitingForBirthDate|format_date('long') }) }}
|
||||||
|
{% else %}
|
||||||
|
{{ 'household.Expecting for birth'|trans }}
|
||||||
|
{% endif %}
|
||||||
|
{% else %}
|
||||||
|
<p class="chill-no-data-statement">
|
||||||
|
{{ 'household.Any expecting birth'|trans }}
|
||||||
|
</p>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
<ul class="record_actions">
|
||||||
|
<li>
|
||||||
|
<a
|
||||||
|
href="{{ chill_path_add_return_path('chill_person_household_summary', { 'household_id': household.id, 'edit': 1 }) }}"
|
||||||
|
class="sc-button bt-edit"
|
||||||
|
>
|
||||||
|
{{ 'household.Comment and expecting birth'|trans }}
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
|
||||||
{% for p in positions %}
|
{% for p in positions %}
|
||||||
<h3>{{ p.label|localize_translatable_string }}</h3>
|
<h3>{{ p.label|localize_translatable_string }}</h3>
|
||||||
|
|
||||||
@ -176,3 +230,8 @@
|
|||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block js %}
|
||||||
|
{{ encore_entry_script_tags('household_edit_metadata') }}
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
@ -33,6 +33,35 @@ class HouseholdControllerTest extends WebTestCase
|
|||||||
$this->assertResponseIsSuccessful();
|
$this->assertResponseIsSuccessful();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dataProvider generateValidHouseholdIds
|
||||||
|
*/
|
||||||
|
public function testEditMetadata($householdId)
|
||||||
|
{
|
||||||
|
|
||||||
|
$crawler = $this->client->request(
|
||||||
|
Request::METHOD_GET,
|
||||||
|
"/fr/person/household/{$householdId}/summary",
|
||||||
|
[
|
||||||
|
'edit' => true
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->assertResponseIsSuccessful();
|
||||||
|
|
||||||
|
$form = $crawler->selectButton('Enregistrer')
|
||||||
|
->form();
|
||||||
|
|
||||||
|
$form['household[commentMembers][comment]'] = "This is a text **generated** by automatic tests";
|
||||||
|
$form['household[waitingForBirth]']->tick();
|
||||||
|
$form['household[waitingForBirthDate]'] = (new \DateTime('today'))
|
||||||
|
->add(new \DateInterval('P1M'))->format('Y-m-d');
|
||||||
|
|
||||||
|
$this->client->submit($form);
|
||||||
|
|
||||||
|
$this->assertResponseRedirects("/fr/person/household/{$householdId}/summary");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dataProvider generateValidHouseholdIds
|
* @dataProvider generateValidHouseholdIds
|
||||||
*/
|
*/
|
||||||
@ -44,6 +73,7 @@ class HouseholdControllerTest extends WebTestCase
|
|||||||
);
|
);
|
||||||
|
|
||||||
$this->assertResponseIsSuccessful();
|
$this->assertResponseIsSuccessful();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user