Merge pull request #3753 from alchemy-fr/PHRAS-3399-feedback-right_issue

PHRAS-3399 merge Prod - feedback - right issue
This commit is contained in:
Nicolas Maillat
2021-03-19 11:23:26 +01:00
committed by GitHub
2 changed files with 27 additions and 12 deletions

View File

@@ -302,9 +302,12 @@ class PushController extends Controller
// we always add the author of the validation request (current user) to the participants
//
$found = false;
foreach ($participants as $participant) {
if ($participant['usr_id'] === $this->getAuthenticatedUser()->getId()) {
foreach ($participants as $key => $participant) {
if ($Validation->isInitiator($this->getAuthenticatedUser()) && $participant['usr_id'] == $this->getAuthenticatedUser()->getId()) {
// the initiator always can see others
$participants[$key]['see_others'] = 1;
$found = true;
break;
}
}
@@ -353,9 +356,14 @@ class PushController extends Controller
}
// end of sanity check
// if participant already exists, skip insertion
// if participant already exists, just update right
try {
$Validation->getParticipant($participantUser);
$validationParticipant = $Validation->getParticipant($participantUser);
$validationParticipant->setCanAgree($participant['agree']);
$validationParticipant->setCanSeeOthers($participant['see_others']);
$manager->persist($validationParticipant);
$manager->flush();
continue;
}
catch (NotFoundHttpException $e) {
@@ -460,10 +468,17 @@ class PushController extends Controller
$this->app->trans('Unknown user %usr_id%', ['%usr_id%' => $userIdToRemove])
);
}
$validationParticipant = $Validation->getParticipant($participantUser);
$Validation->removeParticipant($validationParticipant);
$manager->remove($validationParticipant);
// if initiator is removed from the user selection,
// do not remove it to the participant list, just set can_agree to false for it
if ($Validation->isInitiator($participantUser)) {
$validationParticipant->setCanAgree(false);
$manager->persist($validationParticipant);
} else {
$Validation->removeParticipant($validationParticipant);
$manager->remove($validationParticipant);
}
}
}

View File

@@ -245,7 +245,7 @@
<input type="checkbox" value="1" name="force_authentication" style="display:none;"/>
<div class="PNB10 badges">
{% if context == 'Feedback' %}
{% for participant in participants | sort | reverse if participant.getCanAgree() %}
{% for participant in participants | sort | reverse %}
{% set userId = participant.getUser().getId() %}
<div class="badge {{ 'badge_' ~ userId }} %>">
<a href="#" class="deleter">
@@ -273,19 +273,19 @@
</td>
</tr>
<tr class="toggles">
<td class="toggle status_on toggle_agree">
<td class="toggle toggle_agree {{ participant.getCanAgree() ? 'status_on' : 'status_off' }} ">
<img title="{% trans %}User contribute to the feedback{% endtrans %}" class="toggle_off"
src="/assets/common/images/icons/grey-pen.png"/>
<img title="{% trans %}User contribute to the feedback{% endtrans %}" class="toggle_on"
src="/assets/common/images/icons/dark-green-pen.png"/>
<input type="hidden" name="participants[{{ userId }}][agree]" value="1" />
<input type="hidden" name="participants[{{ userId }}][agree]" value="{{ participant.getCanAgree() ? '1' : '0' }}" />
</td>
<td class="toggle status_off toggle_see_others" style="text-align: center;">
<td class="toggle {{ participant.getCanSeeOthers() ? 'status_on' : 'status_off' }} toggle_see_others" style="text-align: center;">
<img title="{% trans %}User can see others choices{% endtrans %}" class="toggle_off"
src="/assets/common/images/icons/grey-user.png"/>
<img title="{% trans %}User can see others choices{% endtrans %}" class="toggle_on"
src="/assets/common/images/icons/dark-green-user.png"/>
<input type="hidden" name="participants[{{ userId }}][see_others]" value="0" />
<input type="hidden" name="participants[{{ userId }}][see_others]" value="{{ participant.getCanSeeOthers() ? '1' : '0' }}" />
</td>
<td class="toggle status_off toggle_HD" style="text-align: right;">
<img title="{% trans %}User can download HD{% endtrans %}" class="toggle_off"