@osimatic/helpers-js 1.2.5 → 1.2.7

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.
Files changed (2) hide show
  1. package/form_helper.js +25 -1
  2. package/package.json +1 -1
package/form_helper.js CHANGED
@@ -258,6 +258,30 @@ class FormHelper {
258
258
  return null;
259
259
  }
260
260
 
261
+ static extractErrorMessageOfJson(json, onlyIfUniqueError=false) {
262
+ if (typeof json == 'undefined' || json == null) {
263
+ return null;
264
+ }
265
+
266
+ if (typeof json.error != 'undefined') {
267
+ return json.error;
268
+ }
269
+
270
+ if (onlyIfUniqueError && !json.length || json.length > 1) {
271
+ return null;
272
+ }
273
+
274
+ if (typeof json[0] != 'undefined' && typeof json[0].error != 'undefined') {
275
+ return json[0].error;
276
+ }
277
+
278
+ if (typeof json[0] != 'undefined' && Array.isArray(json[0]) && json[0].length === 2) {
279
+ return json[0][1];
280
+ }
281
+
282
+ return null;
283
+ }
284
+
261
285
  static hideFormErrors(form) {
262
286
  form.find('div.form_errors').remove();
263
287
  return form;
@@ -573,7 +597,7 @@ class ArrayField {
573
597
  return false;
574
598
  });
575
599
  divAdd.find('a.add').off('click').click(function () {
576
- submitAddNewItem(divAdd.find('input[type="text"]').val(), divAdd);
600
+ submitAddNewItem(divAdd.find('input.form-control[type="text"]').val(), divAdd);
577
601
  return false;
578
602
  });
579
603
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@osimatic/helpers-js",
3
- "version": "1.2.5",
3
+ "version": "1.2.7",
4
4
  "main": "main.js",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"