On permet d'éditer son vote à la volée.
Dans le cas d'un vote ou l'utilisateur ne peut modifier que son propre vote, après qu'il ait ajouté (ou édité) son vote, on affiche le crayon qui permet d'éditer son vote. Fix #116
This commit is contained in:
parent
8f2c9f07d4
commit
3f774d5445
|
@ -39,6 +39,7 @@ $poll_id = null;
|
|||
$poll = null;
|
||||
$message = null;
|
||||
$editingVoteId = 0;
|
||||
$editedVoteUniqueId = null;
|
||||
|
||||
/* Services */
|
||||
/*----------*/
|
||||
|
@ -133,8 +134,8 @@ if (!empty($_POST['save'])) { // Save edition of an old vote
|
|||
$result = $pollService->updateVote($poll_id, $editedVote, $name, $choices);
|
||||
if ($result) {
|
||||
if ($poll->editable == Editable::EDITABLE_BY_OWN) {
|
||||
$editedVoteUniqId = filter_input(INPUT_POST, 'edited_vote', FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => POLL_REGEX]]);
|
||||
$urlEditVote = Utils::getUrlSondage($poll_id, false, $editedVoteUniqId);
|
||||
$editedVoteUniqueId = filter_input(INPUT_POST, 'edited_vote', FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => POLL_REGEX]]);
|
||||
$urlEditVote = Utils::getUrlSondage($poll_id, false, $editedVoteUniqueId);
|
||||
$message = new Message('success', __('studs', 'Your vote has been registered successfully, but be careful: regarding this poll options, you need to keep this personal link to edit your own vote:'), $urlEditVote);
|
||||
} else {
|
||||
$message = new Message('success', __('studs', 'Update vote succeeded'));
|
||||
|
@ -161,6 +162,7 @@ if (!empty($_POST['save'])) { // Save edition of an old vote
|
|||
if ($result) {
|
||||
if ($poll->editable == Editable::EDITABLE_BY_OWN) {
|
||||
$urlEditVote = Utils::getUrlSondage($poll_id, false, $result->uniqId);
|
||||
$editedVoteUniqueId = $result->uniqId;
|
||||
$message = new Message('success', __('studs', 'Your vote has been registered successfully, but be careful: regarding this poll options, you need to keep this personal link to edit your own vote:'), $urlEditVote);
|
||||
} else {
|
||||
$message = new Message('success', __('studs', 'Adding the vote succeeded'));
|
||||
|
@ -216,5 +218,6 @@ $smarty->assign('editingVoteId', $editingVoteId);
|
|||
$smarty->assign('message', $message);
|
||||
$smarty->assign('admin', false);
|
||||
$smarty->assign('hidden', $poll->hidden);
|
||||
$smarty->assign('editedVoteUniqueId', $editedVoteUniqueId);
|
||||
|
||||
$smarty->display('studs.tpl');
|
||||
|
|
|
@ -94,7 +94,14 @@
|
|||
|
||||
{/foreach}
|
||||
|
||||
{if $active && !$expired && ($poll->editable == constant('Framadate\Editable::EDITABLE_BY_ALL') or $admin)}
|
||||
{if $active && !$expired &&
|
||||
(
|
||||
$poll->editable == constant('Framadate\Editable::EDITABLE_BY_ALL')
|
||||
or ($poll->editable == constant('Framadate\Editable::EDITABLE_BY_OWN') && $editedVoteUniqueId == $vote->uniqId)
|
||||
or $admin
|
||||
)
|
||||
}
|
||||
|
||||
<td class="hidden-print">
|
||||
<a href="{if $admin}{poll_url id=$poll->admin_id vote_id=$vote->uniqId admin=true}{else}{poll_url id=$poll->id vote_id=$vote->uniqId}{/if}" class="btn btn-default btn-sm" title="{__('Poll results', 'Edit the line:')|html} {$vote->name|html}">
|
||||
<i class="glyphicon glyphicon-pencil"></i><span class="sr-only">{__('Generic', 'Edit')}</span>
|
||||
|
|
Loading…
Reference in New Issue