@osimatic/helpers-js 1.0.85 → 1.0.87

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_helper.js CHANGED
@@ -202,6 +202,10 @@ class FormHelper {
202
202
  form.find('input[type="password"]').wrap('<div class="input-group password"></div>').after(linkTogglePassword);
203
203
  }
204
204
 
205
+ static hideField(inputOrSelect) {
206
+ inputOrSelect.closest('.form-group').addClass('hide');
207
+ }
208
+
205
209
  // ------------------------------------------------------------
206
210
  // Messages erreur
207
211
  // ------------------------------------------------------------
package/location.js CHANGED
@@ -310,6 +310,10 @@ class PostalAddress {
310
310
  separator = '<br/>';
311
311
  }
312
312
 
313
+ function empty(value) {
314
+ return typeof value == 'undefined' || value == null || value === '';
315
+ }
316
+
313
317
  /*
314
318
  var address = new Address({
315
319
  country: "USA",
@@ -324,23 +328,25 @@ class PostalAddress {
324
328
  console.log(formatted);
325
329
  */
326
330
 
327
- var addressDataForPluging = {
328
- streetAddress: addressData.streetAddress+(addressData.additionalAddress!=null&&addressData.additionalAddress!==''?"\n"+addressData.additionalAddress:''),
329
- postalCode: addressData.postalCode,
330
- locality: addressData.locality,
331
- region: addressData.state,
332
- countryCode: addressData.countryCode,
333
- country: Country.getCountryName(addressData.countryCode),
331
+ addressData['countryCode'] = !empty(addressData['countryCode'])?addressData['countryCode']:null;
332
+
333
+ let addressDataForPluging = {
334
+ streetAddress: (!empty(addressData['streetAddress'])?addressData['streetAddress']:'')+(!empty(addressData['additionalAddress'])?"\n"+addressData['additionalAddress']:''),
335
+ postalCode: !empty(addressData['postalCode'])?addressData['postalCode']:null,
336
+ locality: !empty(addressData['locality'])?addressData['locality']:null,
337
+ region: !empty(addressData['state'])?addressData['state']:null,
338
+ countryCode: addressData['countryCode'],
339
+ country: Country.getCountryName(addressData['countryCode']),
334
340
  };
335
- if (addressDataForPluging.locality == null) {
336
- addressDataForPluging.locality = addressData.suburb;
341
+ if (addressDataForPluging['locality'] == null && !empty(addressData['suburb'])) {
342
+ addressDataForPluging['locality'] = addressData['suburb'];
337
343
  }
338
- if (addressDataForPluging.locality == null) {
339
- addressDataForPluging.locality = addressData.stateDistrict;
344
+ if (addressDataForPluging['locality'] == null && !empty(addressData['stateDistrict'])) {
345
+ addressDataForPluging['locality'] = addressData['stateDistrict'];
340
346
  }
341
347
 
342
- var af = new AddressFmt();
343
- var formattedAddress = af.format(new Address(addressDataForPluging));
348
+ let af = new AddressFmt();
349
+ let formattedAddress = af.format(new Address(addressDataForPluging));
344
350
  return formattedAddress.replace(/\n+/g, separator);
345
351
  }
346
352
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@osimatic/helpers-js",
3
- "version": "1.0.85",
3
+ "version": "1.0.87",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"