Commit e50432e3 by Simon

v1.1.1 fix de beugs doodle et ajout format date sur le front

parent 26b48bcc
...@@ -8,6 +8,15 @@ ...@@ -8,6 +8,15 @@
npm install npm install
```` ````
# Options
| Parameters | Options | Description |
|--|--|--|
|editMode| false (default) | Enable doodle's backend|
|input| '' | jQuery selector input to attach or select json|
|defaultHours|[] (default)|Set default hours|
|outputDateFormat|''|Define output date format|
## FrontEnd ## FrontEnd
app.js app.js
```javascript ```javascript
......
...@@ -258,14 +258,20 @@ ...@@ -258,14 +258,20 @@
* @param data * @param data
*/ */
this.addInOutputObject = (data) => { this.addInOutputObject = (data) => {
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]);
output.sort(function(a,b) {
return moment(a, 'HH:mm') - moment(b, 'HH:mm');
});
} }
}; };
...@@ -274,15 +280,17 @@ ...@@ -274,15 +280,17 @@
* @param data * @param data
*/ */
this.removeInOutputObject = (data) => { this.removeInOutputObject = (data) => {
if (this.outputJson[data[0]]) { let dayFormat = moment(data[0], 'DDMMYYYY').format(this.dateFormat);
let output = this.outputJson[data[0]];
if (this.outputJson[dayFormat]) {
let output = this.outputJson[dayFormat];
let index = output.indexOf(data[1]); let index = output.indexOf(data[1]);
if (index !== -1) { if (index !== -1) {
output.splice(index, 1); output.splice(index, 1);
if (output.length === 0) { if (output.length === 0) {
delete this.outputJson[data[0]]; delete this.outputJson[dayFormat];
} }
} }
} }
...@@ -620,7 +628,7 @@ ...@@ -620,7 +628,7 @@
* Get Json data * Get Json data
*/ */
this.getJsonData = () => { this.getJsonData = () => {
let dataJson = $(this.config.input).val(); let dataJson = $(this.config.inputSelector).val();
if(this.isJsonString(dataJson)){ if(this.isJsonString(dataJson)){
this.json = JSON.parse(dataJson); this.json = JSON.parse(dataJson);
...@@ -687,7 +695,7 @@ ...@@ -687,7 +695,7 @@
* Generate JSON * Generate JSON
*/ */
this.createJSON = () => { this.createJSON = () => {
let $input = $(this.config.output); let $input = $(this.config.inputSelector);
if ($input.length > 0) { if ($input.length > 0) {
$input.val(JSON.stringify(this.outputJson)); $input.val(JSON.stringify(this.outputJson));
...@@ -776,7 +784,7 @@ ...@@ -776,7 +784,7 @@
//Permet de mettre dans le bon format DD:mm, le timePicker retourne mauvais format //Permet de mettre dans le bon format DD:mm, le timePicker retourne mauvais format
if (splitHour[0].length === 1) { if (splitHour[0].length === 1) {
let goodHourFormat = '0' + splitHour[0] + ':' + splitHour[1]; let goodHourFormat = '0' + splitHour[0];
if (this.keyExist(goodHourFormat)) { if (this.keyExist(goodHourFormat)) {
this.hours.push(goodHourFormat); this.hours.push(goodHourFormat);
} }
...@@ -882,7 +890,7 @@ ...@@ -882,7 +890,7 @@
* @param data * @param data
*/ */
this.removeInOutputObject = (data) => { this.removeInOutputObject = (data) => {
let dayFormat = moment(data[0], 'DDMMYYYY').format(this.dateFormat); let dayFormat = moment(data[0], this.dateFormat).format(this.dateFormat);
if (this.outputJson[dayFormat]) { if (this.outputJson[dayFormat]) {
let output = this.outputJson[dayFormat]; let output = this.outputJson[dayFormat];
...@@ -927,8 +935,7 @@ ...@@ -927,8 +935,7 @@
function initializeConfig() { function initializeConfig() {
let defaultOptions = { let defaultOptions = {
editMode: false, editMode: false,
output: '', inputSelector: '',
input: '',
defaultHours: [], defaultHours: [],
outputDateFormat: '' outputDateFormat: ''
}; };
......
{ {
"name": "doodle", "name": "doodle",
"author": "Simon <simon@appolo.fr>", "author": "Simon <simon@appolo.fr>",
"version": "1.1.0", "version": "1.1.1",
"main": "dist/js/doodle.js", "main": "dist/js/doodle.js",
"repository": { "repository": {
"type": "git", "type": "git",
......
$( document ).ready(function() { $( document ).ready(function() {
$('.doodle').Doodle({ $('.doodle').Doodle({
editMode: true, editMode: true,
output: '#inputVal', inputSelector: '#inputVal'
input: '#inputVal'
}); });
}); });
\ No newline at end of file
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