Merge branch 'feature/rework_poll_creation_1st_page' into 'release'

Rework on 1st page of poll creation



See merge request !142
This commit is contained in:
Antonin 2016-08-04 22:07:52 +02:00
commit c50ca48efd
10 changed files with 196 additions and 161 deletions

View File

@ -52,6 +52,12 @@ class Form
*/
public $hidden;
/**
* If true, the author want to customize the URL
* @var boolean
*/
public $use_customized_url;
/**
* If true, a password will be needed to access the poll
* @var boolean
@ -99,4 +105,4 @@ class Form
usort($this->choices, array('Framadate\Choice', 'compare'));
}
}
}

View File

@ -56,8 +56,8 @@ if (isset($_GET['type']) && $_GET['type'] == 'date' ||
$goToStep2 = filter_input(INPUT_POST, GO_TO_STEP_2, FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => '/^(date|classic)$/']]);
if ($goToStep2) {
$title = $inputService->filterTitle($_POST['title']);
$customizeId = isset($_POST['customize_id']) ? $inputService->filterBoolean($_POST['customize_id']) : false;
$id = $customizeId == true ? $inputService->filterId($_POST['id']) : null;
$use_customized_url = isset($_POST['use_customized_url']) ? $inputService->filterBoolean($_POST['use_customized_url']) : false;
$customized_url = $use_customized_url == true ? $inputService->filterId($_POST['customized_url']) : null;
$name = $inputService->filterName($_POST['name']);
$mail = $config['use_smtp'] == true ? $inputService->filterMail($_POST['mail']) : null;
$description = $inputService->filterDescription($_POST['description']);
@ -77,10 +77,11 @@ if ($goToStep2) {
$error_on_description = false;
$error_on_password = false;
$error_on_password_repeat = false;
$error_on_id = false;
$error_on_customized_url = false;
$_SESSION['form']->title = $title;
$_SESSION['form']->id = $id;
$_SESSION['form']->id = $customized_url;
$_SESSION['form']->use_customized_url = $use_customized_url;
$_SESSION['form']->admin_name = $name;
$_SESSION['form']->admin_mail = $mail;
$_SESSION['form']->description = $description;
@ -102,12 +103,12 @@ if ($goToStep2) {
$error_on_title = true;
}
if ($customizeId) {
if ($id === false) {
$error_on_id = true;
} else if ($pollRepository->existsById($id)) {
$error_on_id = true;
$error_on_id_msg = __('Error', 'Poll id already used');
if ($use_customized_url) {
if ($customized_url === false) {
$error_on_customized_url = true;
} else if ($pollRepository->existsById($customized_url)) {
$error_on_customized_url = true;
$error_on_customized_url_msg = __('Error', 'Poll id already used');
}
}
@ -134,7 +135,7 @@ if ($goToStep2) {
}
}
if ($title && $name && $email_OK && !$error_on_title && !$error_on_id && !$error_on_description && !$error_on_name
if ($title && $name && $email_OK && !$error_on_title && !$error_on_customized_url && !$error_on_description && !$error_on_name
&& !$error_on_password && !$error_on_password_repeat
) {
@ -172,7 +173,7 @@ $errors = array(
'aria' => '',
'class' => ''
),
'id' => array(
'customized_url' => array(
'msg' => '',
'aria' => '',
'class' => ''
@ -215,10 +216,10 @@ if (!empty($_POST[GO_TO_STEP_2])) {
$errors['title']['msg'] = __('Error', 'Something is wrong with the format');
}
if ($error_on_id) {
$errors['id']['aria'] = 'aria-describeby="poll_comment_error" ';
$errors['id']['class'] = ' has-error';
$errors['id']['msg'] = isset($error_on_id_msg) ? $error_on_id_msg : __('Error', 'Something is wrong with the format');
if ($error_on_customized_url) {
$errors['customized_url']['aria'] = 'aria-describeby="customized_url" ';
$errors['customized_url']['class'] = ' has-error';
$errors['customized_url']['msg'] = isset($error_on_customized_url_msg) ? $error_on_customized_url_msg : __('Error', 'Something is wrong with the format');
}
if ($error_on_description) {
@ -269,7 +270,8 @@ $smarty->assign('goToStep2', GO_TO_STEP_2);
$smarty->assign('poll_type', $poll_type);
$smarty->assign('poll_title', Utils::fromPostOrDefault('title', $_SESSION['form']->title));
$smarty->assign('poll_id', Utils::fromPostOrDefault('id', $_SESSION['form']->id));
$smarty->assign('customized_url', Utils::fromPostOrDefault('customized_url', $_SESSION['form']->id));
$smarty->assign('use_customized_url', Utils::fromPostOrDefault('use_customized_url', $_SESSION['form']->use_customized_url));
$smarty->assign('poll_description', Utils::fromPostOrDefault('description', $_SESSION['form']->description));
$smarty->assign('poll_name', Utils::fromPostOrDefault('name', $_SESSION['form']->admin_name));
$smarty->assign('poll_mail', Utils::fromPostOrDefault('mail', $_SESSION['form']->admin_mail));

View File

@ -34,27 +34,13 @@ $(document).ready(function () {
});
/**
* Enable/Disable custom id options
* Enable/Disable custom url options
*/
var $pollId = $("#poll_id");
var $customizeId = $("#customize_id");
// Init checkbox + input
if (($pollId.val() || $pollId.attr('value') || "").length > 0) {
$customizeId.attr('checked', 'checked');
$pollId.removeAttr("disabled");
}
// Listen for checkbox changes
$customizeId.change(function () {
$("#use_customized_url").change(function () {
if ($(this).prop("checked")) {
$pollId
.removeAttr("disabled")
.val($pollId.attr("tmp") || $pollId.attr('value'));
$("#customized_url_options").removeClass("hidden");
} else {
$pollId
.attr("disabled", "disabled")
.attr("tmp", $pollId.val())
.val("");
$("#customized_url_options").addClass("hidden");
}
});
@ -90,4 +76,4 @@ $(document).ready(function () {
document.getElementById("cookie-warning").setAttribute("style", "");
}
});
});

View File

@ -241,7 +241,9 @@
"Use a password to restrict access": "Verwende ein Passwort um den Zugriff zu beschänken",
"The results are publicly visible": "Die Ergebnisse sind öffentlich Einsehbar",
"Poll password": "Password",
"Confirm password": "Passwort bestätigen",
"Password choice": "DE_Choix",
"Password confirmation": "DE_Confirmation",
"Permissions": "DE_Permissions",
"Go to step 2": "Weiter zum 2. Schritt"
},
"Step 2": {

View File

@ -229,7 +229,7 @@
"You are in the poll creation section.": "You are in the poll creation section.",
"Required fields cannot be left blank.": "Required fields cannot be left blank.",
"Poll title": "Poll title",
"Poll id": "Identifier",
"Poll id": "Poll link",
"Poll id rules": "The identifier can contain letters, numbers and dashes \"-\".",
"Poll id warning": "By defining an identifier that can facilitate access to the poll for unwanted people. It is recommended to protect it with a password.",
"Votes cannot be modified": "Votes cannot be modified",
@ -241,7 +241,9 @@
"Use a password to restrict access": "Use a password to restrict access",
"The results are publicly visible": "The results are publicly visible",
"Poll password": "Password",
"Confirm password": "Confirmer votre mot de passe",
"Password choice": "Choice",
"Password confirmation": "Confirmation",
"Permissions": "Permissions",
"Go to step 2": "Go to step 2"
},
"Step 2": {
@ -420,4 +422,4 @@
"Check again": "Check again",
"Continue the installation": "Continue the installation"
}
}
}

View File

@ -241,7 +241,9 @@
"Use a password to restrict access": "ES_Utiliser un mot de passe pour restreindre l'accès au sondage",
"The results are publicly visible": "ES_Les résultats sont visibles sans mot de passe",
"Poll password": "ES_Mot de passe",
"Confirm password": "ES_Confirmer votre mot de passe",
"Password choice": "ES_Choix",
"Password confirmation": "ES_Confirmation",
"Permissions": "ES_Permissions",
"Go to step 2": "Ir al paso número 2"
},
"Step 2": {

View File

@ -229,19 +229,22 @@
"You are in the poll creation section.": "Vous avez choisi de créer un nouveau sondage.",
"Required fields cannot be left blank.": "Merci de remplir les champs obligatoires, marqués d'une *.",
"Poll title": "Titre du sondage",
"Poll id": "Identifiant",
"Poll id rules": "L'identifiant peut contenir des lettres, des chiffres et des tirets \"-\".",
"Poll id warning": "En définissant un identifiant cela peut faciliter l'accès à ce sondage pour des personnes non désirées. Il est recommandé de le protéger par mot de passe.",
"Poll id": "Lien du sondage",
"Customize the URL": "Personnaliser le lien",
"Poll id rules": "(peut contenir des lettres, des chiffres et des tirets)",
"Poll id warning": "La modification du lien du sondage peut faciliter l'accès à ce sondage pour des personnes non désirées. Il est recommandé de le protéger par mot de passe.",
"Votes cannot be modified": "Aucun vote ne peut être modifié",
"All voters can modify any vote": "Tous les sondés peuvent modifier tous les votes",
"Voters can modify their vote themselves": "Chaque sondé peut modifier son propre vote",
"To receive an email for each new vote": "Recevoir un courriel à chaque participation d'un sondé",
"To receive an email for each new vote": "Recevoir un courriel à chaque participation",
"To receive an email for each new comment": "Recevoir un courriel à chaque commentaire",
"Only the poll maker can see the poll's results": "Seul le créateur du sondage peut voir les résultats",
"Use a password to restrict access": "Utiliser un mot de passe pour restreindre l'accès au sondage",
"Use a password to restrict access": "Restreindre l'accès au sondage par mot de passe",
"The results are publicly visible": "Les résultats sont visibles sans mot de passe",
"Poll password": "Mot de passe",
"Confirm password": "Confirmer votre mot de passe ",
"Password choice": "Choix",
"Password confirmation": "Confirmation",
"Permissions": "Permissions",
"Go to step 2": "Aller à l'étape 2"
},
"Step 2": {
@ -419,4 +422,4 @@
"Check again": "Vérifier à nouveau",
"Continue the installation": "Continuer l'installation"
}
}
}

View File

@ -241,7 +241,9 @@
"Use a password to restrict access": "Utilizzare una passwor per limitare l'accesso al sondaggio",
"The results are publicly visible": "I risultati sono visibili senza password",
"Poll password": "Password",
"Confirm password": "Conferma della password",
"Password choice": "IT_Choix",
"Password confirmation": "Conferma della password",
"Permissions": "IT_Permissions",
"Go to step 2": "Andare al punto 2"
},
"Step 2": {

View File

@ -241,7 +241,9 @@
"Use a password to restrict access": "OC_Utiliser un mot de passe pour restreindre l'accès au sondage",
"The results are publicly visible": "OC_Les résultats sont visibles sans mot de passe",
"Poll password": "OC_Mot de passe",
"Confirm password": "OC_Confirmer votre mot de passe ",
"Password choice": "OC_Choix",
"Password confirmation": "OC_Confirmation",
"Permissions": "OC_Permissions",
"Go to step 2": "Anar a l'etapa 2"
},
"Step 2": {
@ -419,4 +421,4 @@
"Check again": "OC_Vérifier à nouveau",
"Continue the installation": "OC_Continuer l'installation"
}
}
}

View File

@ -17,63 +17,6 @@
</p>
</div>
<div class="form-group {$errors['title']['class']}">
<label for="poll_title" class="col-sm-4 control-label">{__('Step 1', 'Poll title')} *</label>
<div class="col-sm-8">
<input id="poll_title" type="text" name="title" class="form-control" {$errors['title']['aria']}
value="{$poll_title|html}"/>
</div>
</div>
{if !empty($errors['title']['msg'])}
<div class="alert alert-danger">
<p id="poll_title_error">
{$errors['title']['msg']}
</p>
</div>
{/if}
<div class="form-group {$errors['id']['class']}">
<label for="poll_id" class="col-sm-4 control-label">{__('Step 1', 'Poll id')}</label>
<div class="col-sm-8">
<div class="input-group">
<span class="input-group-addon">
<input id="customize_id" name="customize_id" type="checkbox"/>
</span>
<input id="poll_id" type="text" name="id" class="form-control" {$errors['id']['aria']}
value="{$poll_id|html}" aria-describedBy="pollIdDesc" disabled="disabled" maxlength="64"
pattern="[A-Za-z0-9-]+"/>
</div>
<span id="pollIdDesc" class="help-block">{__('Step 1', 'Poll id rules')}</span>
<span class="help-block text-warning">{__('Step 1', 'Poll id warning')}</span>
</div>
</div>
{if !empty($errors['id']['msg'])}
<div class="alert alert-danger">
<p id="poll_title_error">
{$errors['id']['msg']}
</p>
</div>
{/if}
<div class="form-group {$errors['description']['class']}">
<label for="poll_comments" class="col-sm-4 control-label">{__('Generic', 'Description')}</label>
<div class="col-sm-8">
<textarea id="poll_comments" name="description"
class="form-control" {$errors['description']['aria']}
rows="5">{$poll_description|html}</textarea>
</div>
</div>
{if !empty($errors['description']['msg'])}
<div class="alert alert-danger">
<p id="poll_title_error">
{$errors['description']['msg']}
</p>
</div>
{/if}
<div class="form-group {$errors['name']['class']}">
<label for="yourname" class="col-sm-4 control-label">{__('Generic', 'Your name')} *</label>
@ -118,8 +61,143 @@
{/if}
<div class="form-group {$errors['title']['class']}">
<label for="poll_title" class="col-sm-4 control-label">{__('Step 1', 'Poll title')} *</label>
<div class="col-sm-8">
<input id="poll_title" type="text" name="title" class="form-control" {$errors['title']['aria']}
value="{$poll_title|html}"/>
</div>
</div>
{if !empty($errors['title']['msg'])}
<div class="alert alert-danger">
<p id="poll_title_error">
{$errors['title']['msg']}
</p>
</div>
{/if}
<div class="form-group {$errors['description']['class']}">
<label for="poll_comments" class="col-sm-4 control-label">{__('Generic', 'Description')}</label>
<div class="col-sm-8">
<textarea id="poll_comments" name="description"
class="form-control" {$errors['description']['aria']}
rows="5">{$poll_description|html}</textarea>
</div>
</div>
{if !empty($errors['description']['msg'])}
<div class="alert alert-danger">
<p id="poll_title_error">
{$errors['description']['msg']}
</p>
</div>
{/if}
{* Poll identifier *}
<div class="form-group {$errors['customized_url']['class']}">
<label for="poll_id" class="col-sm-4 control-label">
{__('Step 1', 'Poll id')}<br/>
</label>
<div class="col-sm-8">
<div class="checkbox">
<label>
<input id="use_customized_url" name="use_customized_url" type="checkbox" {if $use_customized_url}checked{/if}/>
{__('Step 1', 'Customize the URL')}
</label>
</div>
</div>
</div>
<div id="customized_url_options" {if !$use_customized_url}class="hidden"{/if}>
<div class="form-group {$errors['customized_url']['class']}">
<label for="customized_url" class="col-sm-4 control-label">
<span id="pollUrlDesc" class="small">{__('Step 1', 'Poll id rules')}</span>
</label>
<div class="col-sm-8">
<div class="input-group">
<span class="input-group-addon">
{$SERVER_URL}
</span>
<input id="customized_url" type="text" name="customized_url" class="form-control" {$errors['customized_url']['aria']}
value="{$customized_url|html}" aria-describedBy="pollUrlDesc" maxlength="64"
pattern="[A-Za-z0-9-]+"/>
</div>
<span class="help-block text-warning">{__('Step 1', 'Poll id warning')}</span>
</div>
</div>
{if !empty($errors['customized_url']['msg'])}
<div class="alert alert-danger">
<p id="poll_customized_url_error">
{$errors['customized_url']['msg']}
</p>
</div>
{/if}
</div>
{* Password *}
<div class="form-group">
<div class="col-sm-offset-4 col-sm-8">
<label for="poll_id" class="col-sm-4 control-label">
{__('Step 1', 'Poll password')}
</label>
<div class="col-sm-8">
<div class="checkbox">
<label>
<input type="checkbox" name="use_password" {if $poll_use_password}checked{/if}
id="use_password">
{__('Step 1', "Use a password to restrict access")}
</label>
</div>
</div>
<div id="password_options"{if !$poll_use_password} class="hidden"{/if}>
<div class="col-sm-offset-4 col-sm-8">
<div class="input-group">
<input id="poll_password" type="password" name="password" class="form-control" {$errors['password']['aria']}/>
<label for="poll_password" class="input-group-addon">{__('Step 1', 'Password choice')}</label>
</div>
</div>
{if !empty($errors['password']['msg'])}
<div class="alert alert-danger">
<p id="poll_password_error">
{$errors['password']['msg']}
</p>
</div>
{/if}
<div class="col-sm-offset-4 col-sm-8">
<div class="input-group">
<input id="poll_password_repeat" type="password" name="password_repeat" class="form-control" {$errors['password_repeat']['aria']}/>
<label for="poll_password_repeat" class="input-group-addon">{__('Step 1', 'Password confirmation')}</label>
</div>
</div>
{if !empty($errors['password_repeat']['msg'])}
<div class="alert alert-danger">
<p id="poll_password_repeat_error">
{$errors['password_repeat']['msg']}
</p>
</div>
{/if}
<div class="col-sm-offset-4 col-sm-8">
<div class="checkbox">
<label>
<input type="checkbox" name="results_publicly_visible"
{if $poll_results_publicly_visible}checked{/if} id="results_publicly_visible"/>
{__('Step 1', "The results are publicly visible")}
</label>
</div>
</div>
</div>
</div>
<div class="form-group">
<label for="poll_id" class="col-sm-4 control-label">
{__('Step 1', 'Permissions')}
</label>
<div class="col-sm-8">
<div class="radio">
<label>
<input type="radio" name="editable" id="editableByAll" {if $poll_editable==constant("Framadate\Editable::EDITABLE_BY_ALL")}checked{/if} value="{constant("Framadate\Editable::EDITABLE_BY_ALL")}">
@ -180,56 +258,6 @@
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-4 col-sm-8">
<div class="checkbox">
<label>
<input type="checkbox" name="use_password" {if $poll_use_password}checked{/if}
id="use_password">
{__('Step 1', "Use a password to restrict access")}
</label>
</div>
</div>
<div id="password_options"{if !$poll_use_password} class="hidden"{/if}>
<label for="poll_password" class="col-sm-4 control-label">{__('Step 1', 'Poll password')}</label>
<div class="col-sm-8">
<input id="poll_password" type="password" name="password" class="form-control" {$errors['password']['aria']}/>
</div>
{if !empty($errors['password']['msg'])}
<div class="alert alert-danger">
<p id="poll_password_error">
{$errors['password']['msg']}
</p>
</div>
{/if}
<label for="poll_password_repeat" class="col-sm-4 control-label">{__('Step 1', 'Confirm password')}</label>
<div class="col-sm-8">
<input id="poll_password_repeat" type="password" name="password_repeat" class="form-control" {$errors['password_repeat']['aria']}/>
</div>
{if !empty($errors['password_repeat']['msg'])}
<div class="alert alert-danger">
<p id="poll_password_repeat_error">
{$errors['password_repeat']['msg']}
</p>
</div>
{/if}
<div class="col-sm-offset-4 col-sm-8">
<div class="checkbox">
<label>
<input type="checkbox" name="results_publicly_visible"
{if $poll_results_publicly_visible}checked{/if} id="results_publicly_visible"/>
{__('Step 1', "The results are publicly visible")}
</label>
</div>
</div>
</div>
</div>
<p class="text-right">
<input type="hidden" name="type" value="$poll_type"/>
<button name="{$goToStep2}" value="{$poll_type}" type="submit"
@ -249,4 +277,4 @@
<div id="cookie-warning" class="alert alert-danger" style="display:none">
{__('Step 1', 'Cookies are disabled on your browser. Theirs activation is required to create a poll.')}
</div>
{/block}
{/block}