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