Added simple javascript check for the name.
- The goal here is to prevent the losing of the choices by having a bad name. - This is a POC, there is probably some cleaning before merge
This commit is contained in:
parent
3044de5ae3
commit
b66a47ef67
@ -373,5 +373,7 @@ $smarty->assign('comments', $comments);
|
||||
$smarty->assign('editingVoteId', $editingVoteId);
|
||||
$smarty->assign('message', $message);
|
||||
$smarty->assign('admin', true);
|
||||
$smarty->assign('parameter_name_regex', NAME_REGEX);
|
||||
$smarty->assign('parameter_name_error', _('Name is incorrect.'));
|
||||
|
||||
$smarty->display('studs.tpl');
|
21
js/app/studs.js
Normal file
21
js/app/studs.js
Normal file
@ -0,0 +1,21 @@
|
||||
$(document).ready(function() {
|
||||
|
||||
$("#poll_form").submit(function( event ) {
|
||||
var name = $("#name").val();
|
||||
var regexContent = $("#parameter_name_regex").text().split("/");
|
||||
var regex = new RegExp(regexContent[1], regexContent[2]);
|
||||
if (name.length == 0 || !regex.test(name)) {
|
||||
event.preventDefault();
|
||||
var errorMessage = $("#parameter_name_error").text();
|
||||
var addedDiv = "<div class='alert alert-dismissible alert-danger' role='alert'>";
|
||||
addedDiv += errorMessage;
|
||||
addedDiv += "<button type='button' class='close' data-dismiss='alert' aria-label='Close'><span aria-hidden='true'>×</span></button></div>";
|
||||
$("#message-container").empty();
|
||||
$("#message-container").append(addedDiv);
|
||||
$('html, body').animate({
|
||||
scrollTop: $("#message-container").offset().top
|
||||
}, 750);
|
||||
}
|
||||
});
|
||||
|
||||
});
|
@ -202,5 +202,7 @@ $smarty->assign('comments', $comments);
|
||||
$smarty->assign('editingVoteId', $editingVoteId);
|
||||
$smarty->assign('message', $message);
|
||||
$smarty->assign('admin', false);
|
||||
$smarty->assign('parameter_name_regex', NAME_REGEX);
|
||||
$smarty->assign('parameter_name_error', _('Name is incorrect.'));
|
||||
|
||||
$smarty->display('studs.tpl');
|
||||
|
@ -24,6 +24,8 @@
|
||||
<script src="{'nav/nav.js'|resource}" id="nav_js" type="text/javascript" charset="utf-8"></script><!-- /Framanav -->
|
||||
{/if}
|
||||
|
||||
{block name="header"}{/block}
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<div class="container ombre">
|
@ -5,7 +5,7 @@
|
||||
<h3>{__('Poll results\\Votes of the poll')}</h3>
|
||||
|
||||
<div id="tableContainer" class="tableContainer">
|
||||
<form action="" method="POST">
|
||||
<form action="" method="POST" id="poll_form">
|
||||
<table class="results">
|
||||
<caption class="sr-only">{__('Poll results\\Votes of the poll')} {$poll->title|html}</caption>
|
||||
<thead>
|
||||
|
@ -5,7 +5,7 @@
|
||||
<h3>{__('Poll results\\Votes of the poll')}</h3>
|
||||
|
||||
<div id="tableContainer" class="tableContainer">
|
||||
<form action="" method="POST">
|
||||
<form action="" method="POST" id="poll_form">
|
||||
<table class="results">
|
||||
<caption class="sr-only">{__('Poll results\\Votes of the poll')} {$poll->title|html}</caption>
|
||||
<thead>
|
||||
|
@ -1,10 +1,16 @@
|
||||
{extends file='page.tpl'}
|
||||
|
||||
{block name="header"}
|
||||
<script src="{"js/app/studs.js"|resource}" type="text/javascript"></script>
|
||||
{/block}
|
||||
|
||||
{block name=main}
|
||||
|
||||
{if !empty($message)}
|
||||
<div class="alert alert-dismissible alert-{$message->type|html}" role="alert">{$message->message|html}<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button></div>
|
||||
{/if}
|
||||
<div id="message-container">
|
||||
{if !empty($message)}
|
||||
<div class="alert alert-dismissible alert-{$message->type|html}" role="alert">{$message->message|html}<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button></div>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
{* Global informations about the current poll *}
|
||||
|
||||
@ -37,6 +43,12 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="hidden">
|
||||
<p id="parameter_name_regex">{$parameter_name_regex}</p>
|
||||
<p id="parameter_name_error">{$parameter_name_error}</p>
|
||||
</div>
|
||||
|
||||
|
||||
{* Vote table *}
|
||||
|
||||
{if $poll->format === 'D'}
|
||||
|
Loading…
Reference in New Issue
Block a user