mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-20 14:43:49 +00:00
Merge remote-tracking branch 'origin/master' into issue294_suggestPersonInActivity
This commit is contained in:
@@ -298,16 +298,19 @@ final class ActivityController extends AbstractController
|
||||
|
||||
$activity_array = $this->serializer->normalize($entity, 'json', ['groups' => 'read']);
|
||||
|
||||
$defaultLocationId = $this->getUser()->getCurrentLocation()->getId();
|
||||
|
||||
return $this->render($view, [
|
||||
'person' => $person,
|
||||
'accompanyingCourse' => $accompanyingPeriod,
|
||||
'entity' => $entity,
|
||||
'form' => $form->createView(),
|
||||
'activity_json' => $activity_array
|
||||
'activity_json' => $activity_array,
|
||||
'default_location_id' => $defaultLocationId
|
||||
]);
|
||||
}
|
||||
|
||||
public function showAction(Request $request, $id): Response
|
||||
public function showAction(Request $request, int $id): Response
|
||||
{
|
||||
$view = null;
|
||||
|
||||
@@ -361,7 +364,7 @@ final class ActivityController extends AbstractController
|
||||
/**
|
||||
* Displays a form to edit an existing Activity entity.
|
||||
*/
|
||||
public function editAction($id, Request $request): Response
|
||||
public function editAction(int $id, Request $request): Response
|
||||
{
|
||||
$view = null;
|
||||
|
||||
|
@@ -36,6 +36,8 @@ use Chill\MainBundle\DataFixtures\ORM\LoadScopes;
|
||||
|
||||
class LoadActivity extends AbstractFixture implements OrderedFixtureInterface
|
||||
{
|
||||
use \Symfony\Component\DependencyInjection\ContainerAwareTrait;
|
||||
|
||||
/**
|
||||
* @var \Faker\Generator
|
||||
*/
|
||||
@@ -80,15 +82,10 @@ class LoadActivity extends AbstractFixture implements OrderedFixtureInterface
|
||||
*
|
||||
* @return \Chill\ActivityBundle\Entity\ActivityReason
|
||||
*/
|
||||
private function getRandomActivityReason(array $excludingIds)
|
||||
private function getRandomActivityReason()
|
||||
{
|
||||
$reasonRef = LoadActivityReason::$references[array_rand(LoadActivityReason::$references)];
|
||||
|
||||
if (in_array($this->getReference($reasonRef)->getId(), $excludingIds, true)) {
|
||||
// we have a reason which should be excluded. Find another...
|
||||
return $this->getRandomActivityReason($excludingIds);
|
||||
}
|
||||
|
||||
return $this->getReference($reasonRef);
|
||||
}
|
||||
|
||||
@@ -103,7 +100,7 @@ class LoadActivity extends AbstractFixture implements OrderedFixtureInterface
|
||||
return $this->getReference($userRef);
|
||||
}
|
||||
|
||||
public function newRandomActivity($person)
|
||||
public function newRandomActivity($person): ?Activity
|
||||
{
|
||||
$activity = (new Activity())
|
||||
->setUser($this->getRandomUser())
|
||||
@@ -116,11 +113,13 @@ class LoadActivity extends AbstractFixture implements OrderedFixtureInterface
|
||||
|
||||
// ->setAttendee($this->faker->boolean())
|
||||
|
||||
$usedId = array();
|
||||
for ($i = 0; $i < rand(0, 4); $i++) {
|
||||
$reason = $this->getRandomActivityReason($usedId);
|
||||
$usedId[] = $reason->getId();
|
||||
$activity->addReason($reason);
|
||||
$reason = $this->getRandomActivityReason();
|
||||
if (null !== $reason) {
|
||||
$activity->addReason($reason);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
return $activity;
|
||||
@@ -137,7 +136,9 @@ class LoadActivity extends AbstractFixture implements OrderedFixtureInterface
|
||||
|
||||
for ($i = 0; $i < $activityNbr; $i ++) {
|
||||
$activity = $this->newRandomActivity($person);
|
||||
$manager->persist($activity);
|
||||
if (null !== $activity) {
|
||||
$manager->persist($activity);
|
||||
}
|
||||
}
|
||||
}
|
||||
$manager->flush();
|
||||
|
@@ -10,9 +10,12 @@
|
||||
</persons-bloc>
|
||||
</div>
|
||||
<div v-if="getContext === 'accompanyingCourse' && suggestedEntities.length > 0">
|
||||
<ul>
|
||||
<ul class="list-unstyled">
|
||||
<li v-for="p in suggestedEntities" @click="addSuggestedEntity(p)">
|
||||
{{ p.text }}
|
||||
<span class="badge bg-primary" style="cursor: pointer;">
|
||||
<i class="fa fa-plus fa-fw text-success"></i>
|
||||
{{ p.text }}
|
||||
</span>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
@@ -4,7 +4,7 @@
|
||||
<span class="chill_denomination">
|
||||
{{ textCutted }}
|
||||
</span>
|
||||
<a class="fa fa-fw fa-times"
|
||||
<a class="fa fa-fw fa-times text-danger text-decoration-none"
|
||||
@click.prevent="$emit('remove', person)">
|
||||
</a>
|
||||
</span>
|
||||
|
@@ -55,16 +55,17 @@ export default {
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.getLocationsList();
|
||||
getLocations().then(response => new Promise(resolve => {
|
||||
console.log('getLocations', response);
|
||||
this.locations = response.results;
|
||||
if (window.default_location_id) {
|
||||
let location = this.locations.filter(l => l.id === window.default_location_id);
|
||||
this.$store.dispatch('updateLocation', location);
|
||||
}
|
||||
resolve();
|
||||
}))
|
||||
},
|
||||
methods: {
|
||||
getLocationsList() {
|
||||
getLocations().then(response => new Promise(resolve => {
|
||||
console.log('getLocations', response);
|
||||
this.locations = response.results;
|
||||
resolve();
|
||||
}))
|
||||
},
|
||||
customLabel(value) {
|
||||
return `${value.locationType.title.fr} ${value.name ? value.name : ''}`;
|
||||
}
|
||||
|
@@ -55,6 +55,9 @@ const store = createStore({
|
||||
.filter((p) => !existingPersonIds.includes(p.id));
|
||||
},
|
||||
suggestedRequestor(state) {
|
||||
if (state.activity.accompanyingPeriod.requestor === null) {
|
||||
return [];
|
||||
}
|
||||
const existingPersonIds = state.activity.persons.map((p) => p.id);
|
||||
const existingThirdPartyIds = state.activity.thirdParties.map(
|
||||
(p) => p.id
|
||||
@@ -74,7 +77,7 @@ const store = createStore({
|
||||
return state.activity.activityType.usersVisible === 0
|
||||
? []
|
||||
: [state.activity.accompanyingPeriod.user].filter(
|
||||
(u) => !existingUserIds.includes(u.id)
|
||||
(u) => u !== null && !existingUserIds.includes(u.id)
|
||||
);
|
||||
},
|
||||
suggestedResources(state) {
|
||||
|
@@ -27,14 +27,16 @@
|
||||
{{ activity.type.name | localize_translatable_string }}
|
||||
|
||||
<ul class="small_in_title">
|
||||
{% if activity.location and t.locationVisible %}
|
||||
<li>
|
||||
<abbr title="{{ 'location'|trans }}">{{ 'location'|trans ~ ': ' }}</abbr>
|
||||
{# TODO {% if activity.location %}{{ activity.location }}{% endif %} #}
|
||||
Domicile de l'usager
|
||||
<span class="item-key">{{ 'location'|trans ~ ': ' }}</span>
|
||||
<span>{{ activity.location.locationType.title|localize_translatable_string }}</span>
|
||||
{{ activity.location.name }}
|
||||
</li>
|
||||
{% endif %}
|
||||
{% if activity.user and t.userVisible %}
|
||||
<li>
|
||||
<abbr title="{{ 'Referrer'|trans }}">{{ 'Referrer'|trans ~ ': ' }}</abbr>
|
||||
<span class="item-key">{{ 'Referrer'|trans ~ ': ' }}</span>
|
||||
{{ activity.user.usernameCanonical }}
|
||||
</li>
|
||||
{% endif %}
|
||||
|
@@ -22,6 +22,7 @@
|
||||
'{{ "You are going to leave a page with unsubmitted data. Are you sure you want to leave ?"|trans }}');
|
||||
});
|
||||
window.activity = {{ activity_json|json_encode|raw }};
|
||||
window.default_location_id = {{ default_location_id }};
|
||||
</script>
|
||||
{{ encore_entry_script_tags('vue_activity') }}
|
||||
{% endblock %}
|
||||
|
@@ -55,7 +55,7 @@
|
||||
{% endif %}
|
||||
|
||||
<h2 class="chill-red">{{ 'Concerned groups'|trans }}</h2>
|
||||
{% include 'ChillActivityBundle:Activity:concernedGroups.html.twig' with {'context': context, 'with_display': 'bloc' } %}
|
||||
{% include 'ChillActivityBundle:Activity:concernedGroups.html.twig' with {'context': context, 'with_display': 'bloc', 'badge_person': 'true' } %}
|
||||
|
||||
<h2 class="chill-red">{{ 'Activity data'|trans }}</h2>
|
||||
|
||||
|
@@ -1,4 +1,2 @@
|
||||
|
||||
{{ dump(notification) }}
|
||||
|
||||
<a href="{{ path('chill_activity_activity_show', {'id': notification.relatedEntityId }) }}">Go to Activity</a>
|
||||
|
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\Migrations\Activity;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
final class Version20211119173555 extends AbstractMigration
|
||||
{
|
||||
public function getDescription(): string
|
||||
{
|
||||
return 'remove comment on deprecated json_array type';
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
$columns = [
|
||||
'activitytype.name',
|
||||
'activitytypecategory.name'
|
||||
];
|
||||
|
||||
foreach ($columns as $col) {
|
||||
$this->addSql("COMMENT ON COLUMN $col IS NULL");
|
||||
}
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$this->throwIrreversibleMigrationException();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user