From 1c8a41dc0202d380e5b9598df60adce67202671c Mon Sep 17 00:00:00 2001 From: Olivier PEREZ Date: Mon, 30 Nov 2015 22:06:07 +0100 Subject: [PATCH] Add has-error CSS class when dates are not ordered + stop checking if first date is not passed --- CHANGELOG.md | 2 +- js/app/date_poll.js | 19 ++++++++++++------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2a11800..58147e0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -103,7 +103,7 @@ ## Changelog du 21 juin 2011 (pyg@framasoft.net) - très nombreuses modifications CSS - - modification adminstuds.php : ajout de classes aux formulaires et ajout de stripslashes à l'affichage (TODO: à généraliser) + - modification adminstuds.php : ajout de classes aux formulaires et ajout de stripslashes à l'affichage - modification infos_sondages.php : simplification du tableau de choix, ajouts de CSS, ajouts de labels pour faciliter la selection ## Changelog version 0.6.7 (mai 2011) diff --git a/js/app/date_poll.js b/js/app/date_poll.js index 50195f7..35a78fb 100644 --- a/js/app/date_poll.js +++ b/js/app/date_poll.js @@ -54,7 +54,7 @@ $(document).ready(function () { // creates assoc array for date var df = []; - for (var dc = 0; dc < 6; dc++) { + for (var dc = 0; dc < dtsplit.length; dc++) { df[dfsplit[dc]] = dtsplit[dc]; } @@ -77,7 +77,6 @@ $(document).ready(function () { var re_id_hours = new RegExp('"d' + (nb_days - 1) + '-h', 'g'); var re_name_hours = new RegExp('name="horaires' + (nb_days - 1), 'g'); - // TODO Faire mieux que remplacer des chaines de caractères var new_day_html = last_day.html().replace(re_id_hours, '"d' + nb_days + '-h') .replace('id="day' + (nb_days - 1) + '"', 'id="day' + nb_days + '"') .replace('for="day' + (nb_days - 1) + '"', 'for="day' + nb_days + '"') @@ -234,13 +233,16 @@ $(document).ready(function () { var startDate = parseDate(startDateField.val(), window.date_formats.DATE); var endDate = parseDate(endDateField.val(), window.date_formats.DATE); - console.log('start_date as date', startDate); - console.log('start_end as date', endDate); + // Clear error classes + startDateField.parent().removeClass('has-error'); + endDateField.parent().removeClass('has-error'); - if (startDate <= endDate && startDate > new Date()) { + // console.log('start_date as date', startDate); + // console.log('start_end as date', endDate); + if (startDate <= endDate) { while (startDate <= endDate) { var dateStr = formatDate(startDate, window.date_formats.DATE); - if(!useFirstEmptyDateField(dateStr)) { + if (!useFirstEmptyDateField(dateStr)) { newDateFields(dateStr); } startDate.setDate(startDate.getDate() + 1); @@ -251,8 +253,11 @@ $(document).ready(function () { endDateField.val(''); $('#add_days').modal('hide'); submitDaysAvalaible(); + } else { - console.log('err'); + startDateField.parent().addClass('has-error'); + endDateField.parent().addClass('has-error'); + } });