@osimatic/helpers-js 1.1.39 → 1.1.40

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 CHANGED
@@ -125,6 +125,26 @@ class InputPeriod {
125
125
 
126
126
  // input period de type : <select class="period">Aujourd'hui / Ce mois-ci / etc. / Personnalisé</select>
127
127
  class FormDate {
128
+
129
+ static fillYearSelect(select, nbYearsBefore=5, nbYearsAfter=0) {
130
+ const currentDate = new Date();
131
+ for (let year=currentDate.getUTCFullYear()-nbYearsBefore; year<=(currentDate.getUTCFullYear()+nbYearsAfter); year++) {
132
+ select.append('<option value="'+year+'">'+year+'</option>');
133
+ }
134
+ }
135
+
136
+ static fillMonthSelect(select, locale) {
137
+ for (let month=1; month<=12; month++) {
138
+ select.append('<option value="'+month+'">'+DateTime.getMonthNameByMonth(month, locale).capitalize()+'</option>');
139
+ }
140
+ }
141
+
142
+ static fillDayOfWeekSelect(select, locale) {
143
+ for (let dayOfWeek=1; dayOfWeek<=7; dayOfWeek++) {
144
+ select.append('<option value="'+dayOfWeek+'">'+DateTime.getDayNameByDayOfWeek(dayOfWeek, locale).capitalize()+'</option>');
145
+ }
146
+ }
147
+
128
148
  static initForm(form) {
129
149
 
130
150
  function fillPeriodSelect(select) {
package/location.js CHANGED
@@ -8,11 +8,15 @@ class Country {
8
8
  }
9
9
 
10
10
  static fillCountrySelect(select, defaultValue) {
11
- Object.entries(Country.getCountries()).forEach(([countryCode, countryName]) => select.append('<option value="'+countryCode+'">'+countryName+'</option>'));
11
+ if (select.children().length === 0) {
12
+ Object.entries(Country.getCountries()).forEach(([countryCode, countryName]) => select.append('<option value="' + countryCode + '">' + countryName + '</option>'));
13
+ }
12
14
  if (typeof defaultValue != 'undefined') {
13
15
  select.val(defaultValue);
14
16
  }
15
- select.selectpicker('refresh');
17
+ if (typeof select.selectpicker != 'undefined') {
18
+ select.selectpicker('refresh');
19
+ }
16
20
  }
17
21
  static getCountryName(countryCode) {
18
22
  if (Country.getCountries().hasOwnProperty(countryCode)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@osimatic/helpers-js",
3
- "version": "1.1.39",
3
+ "version": "1.1.40",
4
4
  "main": "main.js",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"