@osimatic/helpers-js 1.0.23 → 1.0.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,8 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <module type="WEB_MODULE" version="4">
3
+ <component name="NewModuleRootManager">
4
+ <content url="file://$MODULE_DIR$" />
5
+ <orderEntry type="inheritedJdk" />
6
+ <orderEntry type="sourceFolder" forTests="false" />
7
+ </component>
8
+ </module>
@@ -0,0 +1,8 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ProjectModuleManager">
4
+ <modules>
5
+ <module fileurl="file://$PROJECT_DIR$/.idea/helpers-js.iml" filepath="$PROJECT_DIR$/.idea/helpers-js.iml" />
6
+ </modules>
7
+ </component>
8
+ </project>
package/.idea/vcs.xml ADDED
@@ -0,0 +1,6 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="VcsDirectoryMappings">
4
+ <mapping directory="$PROJECT_DIR$" vcs="Git" />
5
+ </component>
6
+ </project>
package/changelog.txt CHANGED
@@ -26,3 +26,11 @@ getValuesByKeyInArrayOfArrays(array, ...) -> array.getValuesByKeyInArrayOfArrays
26
26
  hasGetUserMedia() -> non remplacé
27
27
 
28
28
  paginationAsList(...) -> Pagination.paginate(...)
29
+
30
+ getDateObjectSelected(lien) -> getSelectedDate(lien.closest('.form-group')
31
+ selectFormDate(lien) -> setSelectedDate(lien.closest('.form-group')
32
+ majSelectPeriode() / majSelectCompare() -> updatePeriodSelect(form)
33
+
34
+ let URL_REFRESH = ... -> HTTPRequest.setRefreshTokenUrl(URL_REFRESH)
35
+ let _httpHeaders = {...} -> HTTPRequest.setHeader(key, value);
36
+ let httpHeaders = {...} -> HTTPRequest.setHeader(key, value);
package/date_time.js CHANGED
@@ -419,128 +419,4 @@ class SqlDateTime {
419
419
  }
420
420
 
421
421
 
422
- class InputPeriod {
423
-
424
- static addLinks(form) {
425
- let divParent = form.find('input[type="date"][data-add_period_select_links]').parent();
426
- if (divParent.hasClass('input-group')) {
427
- divParent = divParent.parent();
428
- }
429
- divParent.append(''
430
- +'<div class="select_period_links">'
431
- +'<a href="#" class="period_select_yesterday">Hier</a> - '
432
- +'<a href="#" class="period_select_current_week">Cette semaine</a> - '
433
- +'<a href="#" class="period_select_last_week">La semaine dernière</a> - '
434
- +'<a href="#" class="period_select_current_month">Ce mois-ci</a> - '
435
- +'<a href="#" class="period_select_last_month">Le mois dernier</a> - '
436
- +'<a href="#" class="period_select_current_year">Cette année</a>'
437
- +'</div>'
438
- );
439
- this.init(form);
440
- }
441
-
442
- static init(form) {
443
- let link;
444
- //console.log(form.find('a.period_select_current_week'));
445
-
446
- if ((link = form.find('a.period_select_today')).length) {
447
- link.click(function() { InputPeriod.selectToday($(this)); return false; });
448
- }
449
- if ((link = form.find('a.period_select_yesterday')).length) {
450
- link.click(function() { InputPeriod.selectPreviousDay($(this), 1); return false; });
451
- }
452
- if ((link = form.find('a.period_select_tomorrow')).length) {
453
- link.click(function() { InputPeriod.selectFollowingDay($(this), 1); return false; });
454
- }
455
- if ((link = form.find('a.period_select_current_week')).length) {
456
- link.click(function() { InputPeriod.selectCurrentWeek($(this)); return false; });
457
- }
458
- if ((link = form.find('a.period_select_last_week')).length) {
459
- link.click(function() { InputPeriod.selectPreviousWeek($(this), 1); return false; });
460
- }
461
- if ((link = form.find('a.period_select_current_month')).length) {
462
- link.click(function() { InputPeriod.selectCurrentMonth($(this)); return false; });
463
- }
464
- if ((link = form.find('a.period_select_last_month')).length) {
465
- link.click(function() { InputPeriod.selectPreviousMonth($(this), 1); return false; });
466
- }
467
- if ((link = form.find('a.period_select_current_year')).length) {
468
- link.click(function() { InputPeriod.selectCurrentYear($(this)); return false; });
469
- }
470
- if ((link = form.find('a.period_select_last_year')).length) {
471
- link.click(function() { InputPeriod.selectCurrentYear($(this), 1); return false; });
472
- }
473
- }
474
-
475
-
476
- static selectToday(link) {
477
- let date = new Date();
478
- this.selectPeriod(link, date, date);
479
- }
480
-
481
- static selectPreviousDay(lien, nbDays) {
482
- this.selectFollowingDay(lien, -nbDays);
483
- }
484
- static selectFollowingDay(lien, nbDays) {
485
- let date = new Date();
486
- date.setDate(date.getDate() + nbDays);
487
- this.selectPeriod(lien, date, date);
488
- }
489
-
490
- static selectCurrentWeek(lien) {
491
- let date = new Date();
492
- this.selectPeriod(lien, DateTime.getFirstDayOfWeek(date), DateTime.getLastDayOfWeek(date));
493
- }
494
- static selectPreviousWeek(lien, nbWeeks) {
495
- this.selectFollowingWeek(lien, -nbWeeks);
496
- }
497
- static selectFollowingWeek(lien, nbWeeks) {
498
- let date = new Date();
499
- date.setDate(date.getDate() + (7*nbWeeks));
500
- this.selectPeriod(lien, DateTime.getFirstDayOfWeek(date), DateTime.getLastDayOfWeek(date));
501
- }
502
-
503
- static selectCurrentMonth(lien) {
504
- let date = new Date();
505
- this.selectPeriod(lien, DateTime.getFirstDayOfMonth(date), DateTime.getLastDayOfMonth(date));
506
- }
507
- static selectPreviousMonth(lien, nbMonths) {
508
- this.selectFollowingMonth(lien, -nbMonths);
509
- }
510
- static selectFollowingMonth(lien, nbMonths) {
511
- let date = new Date();
512
- date.setDate(1);
513
- date.setMonth(date.getMonth() + nbMonths);
514
- this.selectPeriod(lien, DateTime.getFirstDayOfMonth(date), DateTime.getLastDayOfMonth(date));
515
- }
516
-
517
- static selectCurrentYear(lien) {
518
- this.selectFollowingYear(lien, 0);
519
- }
520
- static selectPreviousYear(lien, nbAnneesMoins) {
521
- this.selectFollowingYear(lien, -nbAnneesMoins);
522
- }
523
- static selectFollowingYear(lien, nbAnneesMoins) {
524
- let date = new Date();
525
- date.setFullYear(date.getFullYear() + nbAnneesMoins);
526
- this.selectPeriod(lien, DateTime.getFirstDayOfYear(date), DateTime.getLastDayOfYear(date));
527
- }
528
-
529
-
530
- static selectPeriod(link, startDate, endDate) {
531
- let inputPeriodStart = link.parent().parent().find('input[type="date"]').filter('[name="date_start"], [name="start_date"], [name="start_period"], [name="period_start_date"]');
532
- let inputPeriodEnd = link.parent().parent().find('input[type="date"]').filter('[name="date_end"], [name="end_date"], [name="end_period"], [name="period_end_date"]');
533
- if (inputPeriodStart.length == 0 || inputPeriodEnd.length == 0) {
534
- console.log('no period input found');
535
- return;
536
- }
537
-
538
- //console.log(startDate);
539
- //console.log(endDate);
540
- inputPeriodStart.val(DateTime.getSqlDate(startDate));
541
- inputPeriodEnd.val(DateTime.getSqlDate(endDate));
542
- }
543
-
544
- }
545
-
546
- module.exports = { DateTime, TimestampUnix, SqlDate, SqlTime, SqlDateTime, InputPeriod };
422
+ module.exports = { DateTime, TimestampUnix, SqlDate, SqlTime, SqlDateTime };
package/file.js CHANGED
@@ -12,9 +12,9 @@ class File {
12
12
  }
13
13
  var type = contentType;
14
14
 
15
- var blob = new Blob([data], {
16
- type: type
17
- });
15
+ var blob = new Blob([data], {
16
+ type: type
17
+ });
18
18
 
19
19
  //console.log('disposition: '+disposition+' ; filename: '+filename+' ; type: '+type);
20
20
  //console.log('blob: %o', blob);
@@ -37,30 +37,30 @@ class File {
37
37
  a.click();
38
38
  }
39
39
 
40
- setTimeout(function () {
41
- URL.revokeObjectURL(downloadUrl);
42
- }, 100); // cleanup
40
+ setTimeout(function () {
41
+ URL.revokeObjectURL(downloadUrl);
42
+ }, 100); // cleanup
43
43
  }
44
44
  }
45
45
 
46
- static formatFileSize(fileSizeInBytes, fractionDigits, locale) {
47
- fractionDigits = (typeof fractionDigits != 'undefined' ? fractionDigits : 2);
48
- var i = -1;
49
- var byteUnits = ['kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
50
- if (fileSizeInBytes === 0) {
51
- return '0 ' + byteUnits[0];
52
- }
53
- do {
54
- fileSizeInBytes = fileSizeInBytes / 1024;
55
- i++;
56
- }
57
- while (fileSizeInBytes > 1024);
58
- //var size = Math.max(fileSizeInBytes, 0.1).toFixed(fractionDigits);
59
- var size = Math.max(fileSizeInBytes, 0.1);
60
- return (new Intl.NumberFormat(locale, {
61
- maximumFractionDigits: fractionDigits
62
- }).format(size)) + ' ' + byteUnits[i];
63
- }
46
+ static formatFileSize(fileSizeInBytes, fractionDigits, locale) {
47
+ fractionDigits = (typeof fractionDigits != 'undefined' ? fractionDigits : 2);
48
+ var i = -1;
49
+ var byteUnits = ['kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
50
+ if (fileSizeInBytes === 0) {
51
+ return '0 ' + byteUnits[0];
52
+ }
53
+ do {
54
+ fileSizeInBytes = fileSizeInBytes / 1024;
55
+ i++;
56
+ }
57
+ while (fileSizeInBytes > 1024);
58
+ //var size = Math.max(fileSizeInBytes, 0.1).toFixed(fractionDigits);
59
+ var size = Math.max(fileSizeInBytes, 0.1);
60
+ return (new Intl.NumberFormat(locale, {
61
+ maximumFractionDigits: fractionDigits
62
+ }).format(size)) + ' ' + byteUnits[i];
63
+ }
64
64
  }
65
65
 
66
66
  const CSV_FILE_EXTENSION = "csv";