Merge branch 'feature/allow-to-remove-date-in-wizard' into 'develop'
Allow to remove date in the poll creation wizard CF MR !140 To be cherry-picked in `release`. See merge request !146
This commit is contained in:
parent
1d5af5de3b
commit
f3ce74d997
@ -120,6 +120,17 @@ switch ($step) {
|
|||||||
// Clear previous choices
|
// Clear previous choices
|
||||||
$_SESSION['form']->clearChoices();
|
$_SESSION['form']->clearChoices();
|
||||||
|
|
||||||
|
// Reorder moments to deal with suppressed dates
|
||||||
|
$moments = array();
|
||||||
|
$i = 0;
|
||||||
|
while(count($moments) < count($_POST['days'])) {
|
||||||
|
if (!empty($_POST['horaires' . $i])) {
|
||||||
|
$moments[] = $_POST['horaires' . $i];
|
||||||
|
}
|
||||||
|
$i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
for ($i = 0; $i < count($_POST['days']); $i++) {
|
for ($i = 0; $i < count($_POST['days']); $i++) {
|
||||||
$day = $_POST['days'][$i];
|
$day = $_POST['days'][$i];
|
||||||
|
|
||||||
@ -130,7 +141,7 @@ switch ($step) {
|
|||||||
$choice = new Choice($time);
|
$choice = new Choice($time);
|
||||||
$_SESSION['form']->addChoice($choice);
|
$_SESSION['form']->addChoice($choice);
|
||||||
|
|
||||||
$schedules = $inputService->filterArray($_POST['horaires' . $i], FILTER_DEFAULT);
|
$schedules = $inputService->filterArray($moments[$i], FILTER_DEFAULT);
|
||||||
for ($j = 0; $j < count($schedules); $j++) {
|
for ($j = 0; $j < count($schedules); $j++) {
|
||||||
if (!empty($schedules[$j])) {
|
if (!empty($schedules[$j])) {
|
||||||
$choice->addSlot(strip_tags($schedules[$j]));
|
$choice->addSlot(strip_tags($schedules[$j]));
|
||||||
@ -138,6 +149,7 @@ switch ($step) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
$_SESSION['form']->sortChoices();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Display step 3
|
// Display step 3
|
||||||
|
@ -475,6 +475,15 @@ table.results > tbody > tr:hover > td .glyphicon {
|
|||||||
border:none;
|
border:none;
|
||||||
background:transparent;
|
background:transparent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#selected-days legend .input-group-addon:last-of-type {
|
||||||
|
padding-top: 0;
|
||||||
|
padding-bottom: 0;
|
||||||
|
}
|
||||||
|
#selected-days legend {
|
||||||
|
height: 33px;
|
||||||
|
}
|
||||||
|
|
||||||
/* create_classic_poll.php */
|
/* create_classic_poll.php */
|
||||||
.md-a-img {
|
.md-a-img {
|
||||||
text-decoration:none !important;
|
text-decoration:none !important;
|
||||||
|
@ -73,29 +73,43 @@ $(document).ready(function () {
|
|||||||
.replace('%Y', ("0000" + date.getFullYear()).slice(-4));
|
.replace('%Y', ("0000" + date.getFullYear()).slice(-4));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function getLastDayNumber(last_day) {
|
||||||
|
if (last_day == null)
|
||||||
|
last_day = $selected_days.find('fieldset').filter(':last');
|
||||||
|
return parseInt(/^d([0-9]+)-h[0-9]+$/.exec($(last_day).find('.hours').filter(':first').attr('id'))[1])
|
||||||
|
}
|
||||||
|
|
||||||
function newDateFields(dateStr) {
|
function newDateFields(dateStr) {
|
||||||
var nb_days = $selected_days.find('fieldset').length;
|
var last_day = $selected_days.find('fieldset').filter(':last');
|
||||||
var last_day = $selected_days.find('fieldset:last');
|
|
||||||
var last_day_title = last_day.find('legend input').attr('title');
|
var last_day_title = last_day.find('legend input').attr('title');
|
||||||
|
var new_day_number = getLastDayNumber(last_day) + 1;
|
||||||
|
|
||||||
var re_id_hours = new RegExp('"d' + (nb_days - 1) + '-h', 'g');
|
var re_id_hours = new RegExp('"d' + (new_day_number - 1) + '-h', 'g');
|
||||||
var re_name_hours = new RegExp('name="horaires' + (nb_days - 1), 'g');
|
var re_name_hours = new RegExp('name="horaires' + (new_day_number - 1), 'g');
|
||||||
|
|
||||||
var new_day_html = last_day.html().replace(re_id_hours, '"d' + nb_days + '-h')
|
var new_day_html = last_day.html().replace(re_id_hours, '"d' + new_day_number + '-h')
|
||||||
.replace('id="day' + (nb_days - 1) + '"', 'id="day' + nb_days + '"')
|
.replace('id="day' + (new_day_number - 1) + '"', 'id="day' + new_day_number + '"')
|
||||||
.replace('for="day' + (nb_days - 1) + '"', 'for="day' + nb_days + '"')
|
.replace('for="day' + (new_day_number - 1) + '"', 'for="day' + new_day_number + '"')
|
||||||
.replace(re_name_hours, 'name="horaires' + nb_days)
|
.replace(re_name_hours, 'name="horaires' + new_day_number)
|
||||||
.replace(/value="(.*?)"/g, 'value=""')
|
.replace(/value="(.*?)"/g, 'value=""')
|
||||||
.replace(/hours" title="(.*?)"/g, 'hours" title="" p')
|
.replace(/hours" title="(.*?)"/g, 'hours" title="" p')
|
||||||
.replace('title="' + last_day_title + '"', 'title="' + last_day_title.substring(0, last_day_title.indexOf(' ')) + ' ' + (nb_days + 1) + '"');
|
.replace('title="' + last_day_title + '"', 'title="' + last_day_title.substring(0, last_day_title.indexOf(' ')) + ' ' + (new_day_number + 1) + '"');
|
||||||
|
|
||||||
last_day
|
last_day
|
||||||
.after('<fieldset>' + new_day_html + '</fieldset>')
|
.after('<fieldset>' + new_day_html + '</fieldset>')
|
||||||
.next().find('legend input').val(dateStr);
|
.next().find('legend input').val(dateStr);
|
||||||
$('#day' + (nb_days)).focus();
|
$('#day' + (new_day_number)).focus();
|
||||||
$removeaday_and_copyhours.removeClass('disabled');
|
$removeaday_and_copyhours.removeClass('disabled');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function manageRemoveadayAndCopyhoursButtons() {
|
||||||
|
var nb_days = $selected_days.find('fieldset').length;
|
||||||
|
$('#day' + (getLastDayNumber() - 1)).focus();
|
||||||
|
if (nb_days == 1) {
|
||||||
|
$removeaday_and_copyhours.addClass('disabled');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var useFirstEmptyDateField = function (dateStr) {
|
var useFirstEmptyDateField = function (dateStr) {
|
||||||
var used = false;
|
var used = false;
|
||||||
$selected_days.find('fieldset legend input').each(function () {
|
$selected_days.find('fieldset legend input').each(function () {
|
||||||
@ -218,11 +232,18 @@ $(document).ready(function () {
|
|||||||
|
|
||||||
$('#remove-a-day').on('click', function () {
|
$('#remove-a-day').on('click', function () {
|
||||||
$selected_days.find('fieldset:last').remove();
|
$selected_days.find('fieldset:last').remove();
|
||||||
var nb_days = $selected_days.find('fieldset').length;
|
|
||||||
$('#day' + (nb_days - 1)).focus();
|
manageRemoveadayAndCopyhoursButtons();
|
||||||
if (nb_days == 1) {
|
submitDaysAvalaible();
|
||||||
$removeaday_and_copyhours.addClass('disabled');
|
});
|
||||||
|
|
||||||
|
// Button "Remove the current day"
|
||||||
|
|
||||||
|
$(document).on('click', '.remove-day', function () {
|
||||||
|
if ($('#days_container').find('fieldset').length > 1) {
|
||||||
|
$(this).parents('fieldset').remove();
|
||||||
}
|
}
|
||||||
|
manageRemoveadayAndCopyhoursButtons();
|
||||||
submitDaysAvalaible();
|
submitDaysAvalaible();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -260,6 +260,7 @@
|
|||||||
"Copy hours of the first day": "Eilañ eurioù an devezh kentañ war an devezhioù all",
|
"Copy hours of the first day": "Eilañ eurioù an devezh kentañ war an devezhioù all",
|
||||||
"Remove a day": "Dilemel an devezh diwezhañ",
|
"Remove a day": "Dilemel an devezh diwezhañ",
|
||||||
"Add a day": "Ouzhpennañ un devezh",
|
"Add a day": "Ouzhpennañ un devezh",
|
||||||
|
"Remove this day": "BR_Supprimer ce jour",
|
||||||
"Remove all days": "Dilemel an holl zevezhioù",
|
"Remove all days": "Dilemel an holl zevezhioù",
|
||||||
"Remove all hours": "Dilemel an holl eurioù"
|
"Remove all hours": "Dilemel an holl eurioù"
|
||||||
},
|
},
|
||||||
|
@ -262,6 +262,7 @@
|
|||||||
"Copy hours of the first day": "Uhrzeiten des ersten Tags kopieren",
|
"Copy hours of the first day": "Uhrzeiten des ersten Tags kopieren",
|
||||||
"Remove a day": "Einen Tag entfernen",
|
"Remove a day": "Einen Tag entfernen",
|
||||||
"Add a day": "Einen Tag hinzufügen",
|
"Add a day": "Einen Tag hinzufügen",
|
||||||
|
"Remove this day": "DE_Supprimer ce jour",
|
||||||
"Remove all days": "Alle Tage entfernen",
|
"Remove all days": "Alle Tage entfernen",
|
||||||
"Remove all hours": "Alle Uhrzeiten entfernen"
|
"Remove all hours": "Alle Uhrzeiten entfernen"
|
||||||
},
|
},
|
||||||
|
@ -262,6 +262,7 @@
|
|||||||
"Copy hours of the first day": "Copy times from the first day",
|
"Copy hours of the first day": "Copy times from the first day",
|
||||||
"Remove a day": "Remove a day",
|
"Remove a day": "Remove a day",
|
||||||
"Add a day": "Add a day",
|
"Add a day": "Add a day",
|
||||||
|
"Remove this day": "Remove this day",
|
||||||
"Remove all days": "Remove all days",
|
"Remove all days": "Remove all days",
|
||||||
"Remove all hours": "Remove all times"
|
"Remove all hours": "Remove all times"
|
||||||
},
|
},
|
||||||
|
@ -262,6 +262,7 @@
|
|||||||
"Copy hours of the first day": "Copiar los horarios del primer día en los otros días",
|
"Copy hours of the first day": "Copiar los horarios del primer día en los otros días",
|
||||||
"Remove a day": "Borrar el último día",
|
"Remove a day": "Borrar el último día",
|
||||||
"Add a day": "Añadir un día",
|
"Add a day": "Añadir un día",
|
||||||
|
"Remove this day": "ES_Supprimer ce jour",
|
||||||
"Remove all days": "Borrar todos los días",
|
"Remove all days": "Borrar todos los días",
|
||||||
"Remove all hours": "Borrar todos los horarios"
|
"Remove all hours": "Borrar todos los horarios"
|
||||||
},
|
},
|
||||||
|
@ -262,6 +262,7 @@
|
|||||||
"Copy hours of the first day": "Reporter les horaires du premier jour sur les autres jours",
|
"Copy hours of the first day": "Reporter les horaires du premier jour sur les autres jours",
|
||||||
"Remove a day": "Supprimer le dernier jour",
|
"Remove a day": "Supprimer le dernier jour",
|
||||||
"Add a day": "Ajouter un jour",
|
"Add a day": "Ajouter un jour",
|
||||||
|
"Remove this day": "Supprimer ce jour",
|
||||||
"Remove all days": "Effacer tous les jours",
|
"Remove all days": "Effacer tous les jours",
|
||||||
"Remove all hours": "Effacer tous les horaires"
|
"Remove all hours": "Effacer tous les horaires"
|
||||||
},
|
},
|
||||||
|
@ -262,6 +262,7 @@
|
|||||||
"Copy hours of the first day": "Copiare gli orari del primo giorno",
|
"Copy hours of the first day": "Copiare gli orari del primo giorno",
|
||||||
"Remove a day": "Eliminare l'ultimo giorno",
|
"Remove a day": "Eliminare l'ultimo giorno",
|
||||||
"Add a day": "Aggiungere un giorno",
|
"Add a day": "Aggiungere un giorno",
|
||||||
|
"Remove this day": "IT_Supprimer ce jour",
|
||||||
"Remove all days": "Cancellare tutti i giorni",
|
"Remove all days": "Cancellare tutti i giorni",
|
||||||
"Remove all hours": "Cancellare tutti gli orari"
|
"Remove all hours": "Cancellare tutti gli orari"
|
||||||
},
|
},
|
||||||
|
@ -262,6 +262,7 @@
|
|||||||
"Copy hours of the first day": "Reportar los oraris del primièr jorn suls autres jorns",
|
"Copy hours of the first day": "Reportar los oraris del primièr jorn suls autres jorns",
|
||||||
"Remove a day": "Suprimir lo darrièr jorn",
|
"Remove a day": "Suprimir lo darrièr jorn",
|
||||||
"Add a day": "Ajustar un jorn",
|
"Add a day": "Ajustar un jorn",
|
||||||
|
"Remove this day": "OC_Supprimer ce jour",
|
||||||
"Remove all days": "Suprimir totes los jorns",
|
"Remove all days": "Suprimir totes los jorns",
|
||||||
"Remove all hours": "Suprimir totes los oraris"
|
"Remove all hours": "Suprimir totes los oraris"
|
||||||
},
|
},
|
||||||
|
@ -36,49 +36,60 @@
|
|||||||
<p>{__('Step 2 date', 'For each selected day, you can choose, or not, meeting hours (e.g.: "8h", "8:30", "8h-10h", "evening", etc.)')}</p>
|
<p>{__('Step 2 date', 'For each selected day, you can choose, or not, meeting hours (e.g.: "8h", "8:30", "8h-10h", "evening", etc.)')}</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{foreach $choices as $i=>$choice}
|
<div id="days_container">
|
||||||
{if $choice->getName()}
|
{foreach $choices as $i=>$choice}
|
||||||
{$day_value = $choice->getName()|date_format:$date_format['txt_date']}
|
{if $choice->getName()}
|
||||||
{else}
|
{$day_value = $choice->getName()|date_format:$date_format['txt_date']}
|
||||||
{$day_value = ''}
|
{else}
|
||||||
{/if}
|
{$day_value = ''}
|
||||||
<fieldset>
|
{/if}
|
||||||
<div class="form-group">
|
<fieldset>
|
||||||
<legend>
|
<div class="form-group">
|
||||||
<label class="sr-only" for="day{$i}">{__('Generic', 'Day')} {$i+1}</label>
|
<legend>
|
||||||
|
<label class="sr-only" for="day{$i}">{__('Generic', 'Day')} {$i+1}</label>
|
||||||
|
|
||||||
<div class="input-group date col-xs-7">
|
<div class="col-xs-10 col-sm-11">
|
||||||
<span class="input-group-addon"><i class="glyphicon glyphicon-calendar text-info"></i></span>
|
<div class="input-group date">
|
||||||
<input type="text" class="form-control" id="day{$i}" title="{__('Generic', 'Day')} {$i+1}"
|
<span class="input-group-addon"><i class="glyphicon glyphicon-calendar text-info"></i></span>
|
||||||
data-date-format="{__('Date', 'dd/mm/yyyy')}" aria-describedby="dateformat{$i}" name="days[]" value="{$day_value}"
|
<input type="text" class="form-control" id="day{$i}" title="{__('Generic', 'Day')} {$i+1}"
|
||||||
size="10" maxlength="10" placeholder="{__('Date', 'dd/mm/yyyy')}" autocomplete="nope"/>
|
data-date-format="{__('Date', 'dd/mm/yyyy')}" aria-describedby="dateformat{$i}" name="days[]" value="{$day_value}"
|
||||||
</div>
|
size="10" maxlength="10" placeholder="{__('Date', 'dd/mm/yyyy')}" autocomplete="nope"/>
|
||||||
<span id="dateformat{$i}" class="sr-only">({__('Date', 'dd/mm/yyyy')})</span>
|
</div>
|
||||||
</legend>
|
</div>
|
||||||
|
<div class="col-xs-2 col-sm-1">
|
||||||
|
<button type="button" title="{__('Step 2 date', 'Remove this day')}" class="remove-day btn btn-sm btn-link">
|
||||||
|
<span class="glyphicon glyphicon-remove text-danger"></span>
|
||||||
|
<span class="sr-only">{__('Step 2 date', 'Remove this day')}</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<span id="dateformat{$i}" class="sr-only">({__('Date', 'dd/mm/yyyy')})</span>
|
||||||
|
</legend>
|
||||||
|
|
||||||
|
{foreach $choice->getSlots() as $j=>$slot}
|
||||||
|
<div class="col-sm-2">
|
||||||
|
<label for="d{$i}-h{$j}" class="sr-only control-label">{__('Generic', 'Time')} {$j+1}</label>
|
||||||
|
<input type="text" class="form-control hours" title="{$day_value} - {__('Generic', 'Time')} {$j+1}"
|
||||||
|
placeholder="{__('Generic', 'Time')} {$j+1}" id="d{$i}-h{$j}" name="horaires{$i}[]" value="{$slot}"/>
|
||||||
|
</div>
|
||||||
|
{/foreach}
|
||||||
|
|
||||||
{foreach $choice->getSlots() as $j=>$slot}
|
|
||||||
<div class="col-sm-2">
|
<div class="col-sm-2">
|
||||||
<label for="d{$i}-h{$j}" class="sr-only control-label">{__('Generic', 'Time')} {$j+1}</label>
|
<div class="btn-group btn-group-xs" style="margin-top: 5px;">
|
||||||
<input type="text" class="form-control hours" title="{$day_value} - {__('Generic', 'Time')} {$j+1}"
|
<button type="button" title="{__('Step 2 date', 'Remove an hour')}" class="remove-an-hour btn btn-default">
|
||||||
placeholder="{__('Generic', 'Time')} {$j+1}" id="d{$i}-h{$j}" name="horaires{$i}[]" value="{$slot}"/>
|
<span class="glyphicon glyphicon-minus text-info"></span>
|
||||||
</div>
|
<span class="sr-only">{__('Step 2 date', 'Remove an hour')}</span>
|
||||||
{/foreach}
|
</button>
|
||||||
|
<button type="button" title="{__('Step 2 date', 'Add an hour')}" class="add-an-hour btn btn-default">
|
||||||
<div class="col-sm-2">
|
<span class="glyphicon glyphicon-plus text-success"></span>
|
||||||
<div class="btn-group btn-group-xs" style="margin-top: 5px;">
|
<span class="sr-only">{__('Step 2 date', 'Add an hour')}</span>
|
||||||
<button type="button" title="{__('Step 2 date', 'Remove an hour')}" class="remove-an-hour btn btn-default">
|
</button>
|
||||||
<span class="glyphicon glyphicon-minus text-info"></span>
|
</div>
|
||||||
<span class="sr-only">{__('Step 2 date', 'Remove an hour')}</span>
|
|
||||||
</button>
|
|
||||||
<button type="button" title="{__('Step 2 date', 'Add an hour')}" class="add-an-hour btn btn-default">
|
|
||||||
<span class="glyphicon glyphicon-plus text-success"></span>
|
|
||||||
<span class="sr-only">{__('Step 2 date', 'Add an hour')}</span>
|
|
||||||
</button>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</fieldset>
|
||||||
</fieldset>
|
{/foreach}
|
||||||
{/foreach}
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div class="col-md-4">
|
<div class="col-md-4">
|
||||||
|
Loading…
Reference in New Issue
Block a user