Commit 954f2e70 by Simon

v1.1.0: fix beug css et fix beug ajout de deux dates dans deux formats diférents

parent 9f26d4b5
@import url('https://fonts.googleapis.com/css?family=Roboto:400,500');
.doodle-table {
border-collapse: collapse;
width: 100%;
......@@ -13,7 +11,7 @@
}
.doodle-table thead tr th, .doodle-table tbody tr td {
color: #2c2c2c;
color: #2c2c2c !important;
}
.doodle-table thead tr th{
......@@ -167,6 +165,9 @@
outline: none;
}
.doodle-table #myDatepicker input, .doodle-table .timepicker input {
border-right: none;
}
.doodle-table #date:hover {
background: #fdf2f2 !important;
......@@ -231,7 +232,7 @@
background: #f0f0f0;
border: 1px solid #dfdfdf !important;
color: #adadad;
border-radius: 2px;
border-radius: 0 2px 2px 0 !important;
}
.doodle-table .label_input input {
......
......@@ -306,6 +306,7 @@
this.json = null;
this.days = [];
this.hours = this.config.defaultHours || [];
this.dateFormat = this.config.outputDateFormat || 'DD/MM/YYYY';
this.outputJson = {};
this.init = true;
......@@ -327,6 +328,8 @@
this.createEvents();
this.initCSS();
console.log('OUTPUT', this.outputJson);
};
this.reinit = () => {
......@@ -454,16 +457,18 @@
let $tbody = $('<tbody>');
let html, tbodyFinal;
if (!$.isEmptyObject(this.outputJson)) {
console.log('this.json', this.json);
if (!$.isEmptyObject(this.json) || !$.isEmptyObject(this.outputJson)) {
for(let index in this.days) {
let $tr = $('<tr>');
let formatDateDay = moment(this.days[index], 'DD/MM/YYYY').locale('fr').format('dddd DD');
let formatDateMonth = moment(this.days[index], 'DD/MM/YYYY').locale('fr').format('MMMM');
let formatDate = moment(this.days[index], 'DD/MM/YYYY').format('DDMMYYYY');
let date = this.days[index];
html = $tr.append('<td id="date"><span class="date_format"><b>' + formatDateDay + '</b> ' + formatDateMonth + '</span><div class="delete_row"><a href="#"><img src='+ CLOSEIMG +' /></a></div></td>')
.append(this.createBodyContent(formatDate))
.append(this.createBodyContent(date))
.append('<td></td>');
......@@ -529,6 +534,7 @@
*/
function createInputBox(hour, day, checked) {
console.log('day', day);
let dayFormat = moment(day, 'DD/MM/YYYY').format('DDMMYYYY');
let isChecked = checked ? 'checked' : '';
let data = dayFormat + '_' + hour;
......@@ -600,6 +606,7 @@
*/
this.getDays = () => {
this.days = Object.keys(this.json);
console.log('getDays',this.days);
};
/**
......@@ -621,6 +628,7 @@
*/
this.getJsonData = () => {
let dataJson = $(this.config.input).val();
console.log('getJSONDATA');
if(this.isJsonString(dataJson)){
this.json = JSON.parse(dataJson);
......@@ -640,8 +648,15 @@
this.populateOutputJson = () => {
for (let index in this.json) {
if (this.json[index].length === 0 ) {
console.log('PROUT');
this.addInOutputObject(index)
}
for (let i in this.json[index]) {
let dayFormat = moment(index, 'DD/MM/YYYY').format('DDMMYYYY');
let dayFormat = moment(index, 'DD/MM/YYYY').format(this.dateFormat);
console.log('LO', [dayFormat, this.json[index][i]]);
this.addInOutputObject([dayFormat, this.json[index][i]] )
}
......@@ -699,6 +714,8 @@
let isChecked = $(e.target).is(':checked');
if (isChecked) {
console.log('Pipa wesh', data);
this.addInOutputObject(data);
$(e.target).parent().parent().css('background', '#e2deef');
} else {
......@@ -715,7 +732,8 @@
* @returns {boolean}
*/
this.keyExist = (key) => {
if (moment(key, 'DD/MM/YYYY').format('DD/MM/YYYY') === key) {
console.log(key);
if (moment(key, this.dateFormat).format(this.dateFormat) === key) {
if (this.days.indexOf(key) === -1) {
return true
}
......@@ -745,17 +763,21 @@
//Force la fermeture du datePicker
$('#myDatepicker').datepicker('hide');
let formatDateDay = moment(e.date).locale('fr').format('DDMMYYYY');
let formatDateOnSneFou = moment(e.date).locale('fr').format('DD/MM/YYYY');
//let formatDateDay = moment(e.date).locale('fr').format('DDMMYYYY');
let formatDateOnSneFou = moment(e.date).locale('fr').format(this.dateFormat);
console.log('formatDateOnSneFou dehors', formatDateOnSneFou);
if (this.keyExist(formatDateOnSneFou)) {
this.days.push(formatDateOnSneFou);
this.addInOutputObject(formatDateDay);
console.log('formatDateOnSneFou dedans', formatDateOnSneFou);
this.addInOutputObject(formatDateOnSneFou);
}
//Tri les dates
let formatDate = this.dateFormat;
this.days.sort(function(a,b) {
return moment(a, 'DD/MM/YYYY') - moment(b, 'DD/MM/YYYY');
return moment(a, formatDate) - moment(b, formatDate);
});
this.reinit();
......@@ -804,10 +826,9 @@
let date = $(e.target).parent().parent().parent().find('span').text();
let formatDateDay = moment(date, 'dddd DD MMMM').locale('fr').format('DDMMYYYY');
let formatDateOnSneFou = moment(date, 'dddd DD MMMM').locale('fr').format('DD/MM/YYYY');
let formatDateDay = moment(date, 'dddd DD MMMM').locale('fr').format(this.dateFormat);
let index = this.days.indexOf(formatDateOnSneFou);
let index = this.days.indexOf(formatDateDay);
if (index !== -1) {
this.days.splice(index, 1)
......@@ -854,14 +875,18 @@
* @param data
*/
this.addInOutputObject = (data) => {
console.log('DATA', data);
if (typeof data === 'string') {
this.outputJson[data] = [];
} else {
if (!this.outputJson[data[0]]) {
this.outputJson[data[0]] = [];
let dayFormat = moment(data[0], 'DDMMYYYY').format(this.dateFormat);
if (!this.outputJson[dayFormat]) {
this.outputJson[dayFormat] = [];
}
let output = this.outputJson[data[0]];
let output = this.outputJson[dayFormat];
if (output.indexOf(data[1]) === -1) {
output.push(data[1]);
......@@ -919,7 +944,8 @@
editMode: false,
output: '',
input: '',
defaultHours: []
defaultHours: [],
outputDateFormat: ''
};
return $.extend({}, defaultOptions, options);
......
{
"name": "doodle",
"author": "Simon <simon@appolo.fr>",
"version": "1.0.7",
"version": "1.1.0",
"main": "dist/js/doodle.js",
"repository": {
"type": "git",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment