@osimatic/helpers-js 1.1.50 → 1.1.51
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.
- package/form_date.js +38 -38
- package/package.json +1 -1
package/form_date.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// input period de type : Du <input type="date" name="start_date" /> au <input type="date" name="end_date" />
|
|
2
2
|
class InputPeriod {
|
|
3
3
|
|
|
4
|
-
static addLinks(form
|
|
4
|
+
static addLinks(form) {
|
|
5
5
|
let divParent = form.find('input[type="date"][data-add_period_select_links]').parent();
|
|
6
6
|
if (divParent.hasClass('input-group')) {
|
|
7
7
|
divParent = divParent.parent();
|
|
@@ -16,98 +16,98 @@ class InputPeriod {
|
|
|
16
16
|
+'<a href="#" class="period_select_current_year">Cette année</a>'
|
|
17
17
|
+'</div>'
|
|
18
18
|
);
|
|
19
|
-
this.init(form
|
|
19
|
+
this.init(form);
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
static init(form
|
|
22
|
+
static init(form) {
|
|
23
23
|
let link;
|
|
24
24
|
//console.log(form.find('a.period_select_current_week'));
|
|
25
25
|
|
|
26
26
|
if ((link = form.find('a.period_select_today')).length) {
|
|
27
|
-
link.click(function() { InputPeriod.selectToday($(this)
|
|
27
|
+
link.click(function() { InputPeriod.selectToday($(this)); return false; });
|
|
28
28
|
}
|
|
29
29
|
if ((link = form.find('a.period_select_yesterday')).length) {
|
|
30
|
-
link.click(function() { InputPeriod.selectPreviousDay($(this), 1
|
|
30
|
+
link.click(function() { InputPeriod.selectPreviousDay($(this), 1); return false; });
|
|
31
31
|
}
|
|
32
32
|
if ((link = form.find('a.period_select_tomorrow')).length) {
|
|
33
|
-
link.click(function() { InputPeriod.selectFollowingDay($(this), 1
|
|
33
|
+
link.click(function() { InputPeriod.selectFollowingDay($(this), 1); return false; });
|
|
34
34
|
}
|
|
35
35
|
if ((link = form.find('a.period_select_current_week')).length) {
|
|
36
|
-
link.click(function() { InputPeriod.selectCurrentWeek($(this)
|
|
36
|
+
link.click(function() { InputPeriod.selectCurrentWeek($(this)); return false; });
|
|
37
37
|
}
|
|
38
38
|
if ((link = form.find('a.period_select_last_week')).length) {
|
|
39
|
-
link.click(function() { InputPeriod.selectPreviousWeek($(this), 1
|
|
39
|
+
link.click(function() { InputPeriod.selectPreviousWeek($(this), 1); return false; });
|
|
40
40
|
}
|
|
41
41
|
if ((link = form.find('a.period_select_current_month')).length) {
|
|
42
|
-
link.click(function() { InputPeriod.selectCurrentMonth($(this)
|
|
42
|
+
link.click(function() { InputPeriod.selectCurrentMonth($(this)); return false; });
|
|
43
43
|
}
|
|
44
44
|
if ((link = form.find('a.period_select_last_month')).length) {
|
|
45
|
-
link.click(function() { InputPeriod.selectPreviousMonth($(this), 1
|
|
45
|
+
link.click(function() { InputPeriod.selectPreviousMonth($(this), 1); return false; });
|
|
46
46
|
}
|
|
47
47
|
if ((link = form.find('a.period_select_current_year')).length) {
|
|
48
|
-
link.click(function() { InputPeriod.selectCurrentYear($(this)
|
|
48
|
+
link.click(function() { InputPeriod.selectCurrentYear($(this)); return false; });
|
|
49
49
|
}
|
|
50
50
|
if ((link = form.find('a.period_select_last_year')).length) {
|
|
51
|
-
link.click(function() { InputPeriod.
|
|
51
|
+
link.click(function() { InputPeriod.selectPreviousYear($(this), 1); return false; });
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
|
|
56
|
-
static selectToday(link
|
|
56
|
+
static selectToday(link) {
|
|
57
57
|
let date = new Date();
|
|
58
|
-
this.selectPeriod(link, date, date
|
|
58
|
+
this.selectPeriod(link, date, date);
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
static selectPreviousDay(lien, nbDays
|
|
62
|
-
this.selectFollowingDay(lien, -nbDays
|
|
61
|
+
static selectPreviousDay(lien, nbDays) {
|
|
62
|
+
this.selectFollowingDay(lien, -nbDays);
|
|
63
63
|
}
|
|
64
|
-
static selectFollowingDay(lien, nbDays
|
|
64
|
+
static selectFollowingDay(lien, nbDays) {
|
|
65
65
|
let date = new Date();
|
|
66
66
|
date.setDate(date.getDate() + nbDays);
|
|
67
|
-
this.selectPeriod(lien, date, date
|
|
67
|
+
this.selectPeriod(lien, date, date);
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
-
static selectCurrentWeek(lien
|
|
70
|
+
static selectCurrentWeek(lien) {
|
|
71
71
|
let date = new Date();
|
|
72
72
|
this.selectPeriod(lien, DateTime.getFirstDayOfWeek(date), DateTime.getLastDayOfWeek(date));
|
|
73
73
|
}
|
|
74
|
-
static selectPreviousWeek(lien, nbWeeks
|
|
75
|
-
this.selectFollowingWeek(lien, -nbWeeks
|
|
74
|
+
static selectPreviousWeek(lien, nbWeeks) {
|
|
75
|
+
this.selectFollowingWeek(lien, -nbWeeks);
|
|
76
76
|
}
|
|
77
|
-
static selectFollowingWeek(lien, nbWeeks
|
|
77
|
+
static selectFollowingWeek(lien, nbWeeks) {
|
|
78
78
|
let date = new Date();
|
|
79
79
|
date.setDate(date.getDate() + (7*nbWeeks));
|
|
80
|
-
this.selectPeriod(lien, DateTime.getFirstDayOfWeek(date), DateTime.getLastDayOfWeek(date)
|
|
80
|
+
this.selectPeriod(lien, DateTime.getFirstDayOfWeek(date), DateTime.getLastDayOfWeek(date));
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
-
static selectCurrentMonth(lien
|
|
83
|
+
static selectCurrentMonth(lien) {
|
|
84
84
|
let date = new Date();
|
|
85
|
-
this.selectPeriod(lien, DateTime.getFirstDayOfMonth(date), DateTime.getLastDayOfMonth(date)
|
|
85
|
+
this.selectPeriod(lien, DateTime.getFirstDayOfMonth(date), DateTime.getLastDayOfMonth(date));
|
|
86
86
|
}
|
|
87
|
-
static selectPreviousMonth(lien, nbMonths
|
|
88
|
-
this.selectFollowingMonth(lien, -nbMonths
|
|
87
|
+
static selectPreviousMonth(lien, nbMonths) {
|
|
88
|
+
this.selectFollowingMonth(lien, -nbMonths);
|
|
89
89
|
}
|
|
90
|
-
static selectFollowingMonth(lien, nbMonths
|
|
90
|
+
static selectFollowingMonth(lien, nbMonths) {
|
|
91
91
|
let date = new Date();
|
|
92
92
|
date.setDate(1);
|
|
93
93
|
date.setMonth(date.getMonth() + nbMonths);
|
|
94
|
-
this.selectPeriod(lien, DateTime.getFirstDayOfMonth(date), DateTime.getLastDayOfMonth(date)
|
|
94
|
+
this.selectPeriod(lien, DateTime.getFirstDayOfMonth(date), DateTime.getLastDayOfMonth(date));
|
|
95
95
|
}
|
|
96
96
|
|
|
97
|
-
static selectCurrentYear(lien
|
|
98
|
-
this.selectFollowingYear(lien, 0
|
|
97
|
+
static selectCurrentYear(lien) {
|
|
98
|
+
this.selectFollowingYear(lien, 0);
|
|
99
99
|
}
|
|
100
|
-
static selectPreviousYear(lien, nbAnneesMoins
|
|
101
|
-
this.selectFollowingYear(lien, -nbAnneesMoins
|
|
100
|
+
static selectPreviousYear(lien, nbAnneesMoins) {
|
|
101
|
+
this.selectFollowingYear(lien, -nbAnneesMoins);
|
|
102
102
|
}
|
|
103
|
-
static selectFollowingYear(lien, nbAnneesMoins
|
|
103
|
+
static selectFollowingYear(lien, nbAnneesMoins) {
|
|
104
104
|
let date = new Date();
|
|
105
105
|
date.setFullYear(date.getFullYear() + nbAnneesMoins);
|
|
106
|
-
this.selectPeriod(lien, DateTime.getFirstDayOfYear(date), DateTime.getLastDayOfYear(date)
|
|
106
|
+
this.selectPeriod(lien, DateTime.getFirstDayOfYear(date), DateTime.getLastDayOfYear(date));
|
|
107
107
|
}
|
|
108
108
|
|
|
109
109
|
|
|
110
|
-
static selectPeriod(link, startDate, endDate
|
|
110
|
+
static selectPeriod(link, startDate, endDate) {
|
|
111
111
|
let inputPeriodStart = link.parent().parent().find('input[type="date"]').filter('[name="date_start"], [name="start_date"], [name="start_period"], [name="period_start_date"]');
|
|
112
112
|
let inputPeriodEnd = link.parent().parent().find('input[type="date"]').filter('[name="date_end"], [name="end_date"], [name="end_period"], [name="period_end_date"]');
|
|
113
113
|
if (inputPeriodStart.length === 0 || inputPeriodEnd.length === 0) {
|
|
@@ -115,8 +115,8 @@ class InputPeriod {
|
|
|
115
115
|
return;
|
|
116
116
|
}
|
|
117
117
|
|
|
118
|
-
inputPeriodStart.val(DateTime.getDateForInputDate(startDate
|
|
119
|
-
inputPeriodEnd.val(DateTime.getDateForInputDate(endDate
|
|
118
|
+
inputPeriodStart.val(DateTime.getDateForInputDate(startDate));
|
|
119
|
+
inputPeriodEnd.val(DateTime.getDateForInputDate(endDate));
|
|
120
120
|
}
|
|
121
121
|
|
|
122
122
|
}
|