@finqu/cool 1.2.8 → 1.2.10

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.
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * Cool UI v1.2.7 (https://finqu.fi)
2
+ * Cool UI v1.2.9 (https://finqu.fi)
3
3
  * Copyright 2011-2020 Finqu Oy
4
4
  * Licensed under the ISC license - (http://opensource.org/licenses/ISC)
5
5
  */
@@ -2254,7 +2254,7 @@ function (_AbstractUIComponent) {
2254
2254
  _this3.preventClose = false;
2255
2255
 
2256
2256
  if (_this3.itemsToExclude.length > 0) {
2257
- _this3.itemsToExclude = _this3.itemsToExclude.map(Number);
2257
+ _this3.itemsToExclude = _this3.itemsToExclude.map(String);
2258
2258
  }
2259
2259
 
2260
2260
  if (_this3.opts.setData) {
@@ -2263,17 +2263,37 @@ function (_AbstractUIComponent) {
2263
2263
 
2264
2264
  if (_this3.$el.data('setData') && _this3.$el.data('setData') != '') {
2265
2265
  _this3.data = _this3.$el.data('setData');
2266
+ } // Convert data to be array so filters doesn't fail
2267
+
2268
+
2269
+ if (!Array.isArray(_this3.data[_this3.name]) && _this3.data[_this3.name] !== '' && _this3.data[_this3.name].length > 0) {
2270
+ var arr = _this3.data[_this3.name].toString().trim().split(',');
2271
+
2272
+ _this3.data[_this3.name] = arr;
2273
+ } // Convert all values to string format to make filtering more simple
2274
+
2275
+
2276
+ if (_this3.data[_this3.name].length > 0) {
2277
+ _this3.data[_this3.name] = _this3.data[_this3.name].map(String);
2266
2278
  }
2267
2279
 
2268
- if (_this3.data[_this3.name] !== 'undefined' && _this3.data[_this3.name].length > 0 && self.itemsToExclude) {
2280
+ if (_this3.data[_this3.name].length > 0 && _this3.itemsToExclude.length > 0) {
2269
2281
  _this3.data[_this3.name] = _this3.data[_this3.name].filter(function (item) {
2270
- return self.itemsToExclude.indexOf(parseInt(item.id, 10)) === -1;
2282
+ if (item[self.primaryKeyword]) {
2283
+ return self.itemsToExclude.indexOf(item[self.primaryKeyword].toString()) === -1;
2284
+ } else {
2285
+ return self.itemsToExclude.indexOf(item.toString()) === -1;
2286
+ }
2271
2287
  });
2272
2288
  }
2273
2289
 
2274
- if (_this3.items !== 'undefined' && _this3.items.lengths > 0 && self.itemsToExclude) {
2290
+ if (_this3.items.length > 0 && _this3.itemsToExclude.length > 0) {
2275
2291
  _this3.items = _this3.items.filter(function (item) {
2276
- return self.itemsToExclude.indexOf(parseInt(item.id, 10)) === -1;
2292
+ if (item[self.primaryKeyword]) {
2293
+ return self.itemsToExclude.indexOf(item[self.primaryKeyword].toString()) === -1;
2294
+ } else {
2295
+ return self.itemsToExclude.indexOf(item.toString()) === -1;
2296
+ }
2277
2297
  });
2278
2298
  }
2279
2299
 
@@ -2302,6 +2322,18 @@ function (_AbstractUIComponent) {
2302
2322
 
2303
2323
  secondaryResolve();
2304
2324
  } else {
2325
+ var selectItems = _this3.$select.find('.select-item');
2326
+
2327
+ if (selectItems.length > 0 && _this3.itemsToExclude.length > 0) {
2328
+ $.each(selectItems, function (i, el) {
2329
+ var val = $(el).find(':input').val();
2330
+
2331
+ if (self.itemsToExclude.indexOf(val) > -1) {
2332
+ $(el).remove();
2333
+ }
2334
+ });
2335
+ }
2336
+
2305
2337
  secondaryResolve();
2306
2338
  }
2307
2339
  }).then(function () {
@@ -2494,7 +2526,7 @@ function (_AbstractUIComponent) {
2494
2526
  var val = $(this).val();
2495
2527
 
2496
2528
  if (this.checked) {
2497
- self.data[self.name] = val;
2529
+ self.data[self.name] = [val];
2498
2530
  self.$select.find('input[type="radio"]').not($(this)).prop('checked', false);
2499
2531
  self.$select.find('input[type="radio"]').not($(this)).removeClass('checked');
2500
2532
  } else {
@@ -2613,11 +2645,11 @@ function (_AbstractUIComponent) {
2613
2645
  return item;
2614
2646
  });
2615
2647
  var itemIds = items.map(function (item) {
2616
- return parseInt(item.id, 10);
2648
+ return item.id.toString();
2617
2649
  }); // Remove value from data if it doesn't exist anymore
2618
2650
 
2619
2651
  self.data[self.name] = self.data[self.name].filter(function (value) {
2620
- return itemIds.indexOf(parseInt(value, 10)) > -1;
2652
+ return itemIds.indexOf(value.toString()) > -1;
2621
2653
  });
2622
2654
 
2623
2655
  if (self.data[self.name].length == 0) {
@@ -2625,7 +2657,7 @@ function (_AbstractUIComponent) {
2625
2657
  }
2626
2658
 
2627
2659
  items = items.filter(function (item) {
2628
- return self.data[self.name].indexOf(item.id) > -1 && self.itemsToExclude.indexOf(parseInt(item.id, 10)) === -1 && parseInt(item.id, 10) > 0;
2660
+ return self.data[self.name].indexOf(item.id) > -1 && self.itemsToExclude.indexOf(item.id) === -1 && item.id != 0;
2629
2661
  });
2630
2662
 
2631
2663
  var result = self._renderItemList(items);
@@ -2659,7 +2691,7 @@ function (_AbstractUIComponent) {
2659
2691
  });
2660
2692
  } else if (self.type == 'radio') {
2661
2693
  var $input = $inputs.filter(function () {
2662
- return this.value == self.data[self.name];
2694
+ return this.value == self.data[self.name][0];
2663
2695
  });
2664
2696
  $input.prop('checked', true);
2665
2697
  $input.addClass('checked');
@@ -2676,10 +2708,10 @@ function (_AbstractUIComponent) {
2676
2708
  // Remove value from data if it doesn't exist anymore
2677
2709
  var $inputs = this.$scrollableContent.find(':input');
2678
2710
  var inputValues = $inputs.length > 0 ? $inputs.map(function () {
2679
- return parseInt(this.value, 10);
2711
+ return this.value.toString();
2680
2712
  }).get() : [];
2681
2713
  this.data[this.name] = this.data[this.name].filter(function (value) {
2682
- return inputValues.indexOf(parseInt(value, 10)) > -1;
2714
+ return inputValues.indexOf(value.toString()) > -1;
2683
2715
  });
2684
2716
 
2685
2717
  if (this.data[this.name].length == 0) {
@@ -2702,7 +2734,7 @@ function (_AbstractUIComponent) {
2702
2734
  });
2703
2735
  } else if (this.type == 'radio') {
2704
2736
  var $input = $inputs.filter(function () {
2705
- return this.value == self.data[self.name];
2737
+ return this.value == self.data[self.name][0];
2706
2738
  });
2707
2739
  $input.prop('checked', true);
2708
2740
  $input.addClass('checked');
@@ -2739,7 +2771,7 @@ function (_AbstractUIComponent) {
2739
2771
  return item;
2740
2772
  });
2741
2773
  items = items.filter(function (item) {
2742
- return self.data[self.name].indexOf(item.id) === -1 && self.itemsToExclude.indexOf(parseInt(item.id, 10)) === -1 && parseInt(item.id, 10) > 0;
2774
+ return self.data[self.name].indexOf(item.id) === -1 && self.itemsToExclude.indexOf(item.id) === -1 && item.id != 0;
2743
2775
  });
2744
2776
 
2745
2777
  var result = self._renderItemList(items);
@@ -2898,7 +2930,7 @@ function (_AbstractUIComponent) {
2898
2930
  }
2899
2931
 
2900
2932
  items = items.filter(function (item) {
2901
- return self.itemsToExclude.indexOf(parseInt(item.id, 10)) === -1;
2933
+ return self.itemsToExclude.indexOf(item[self.primaryKeyword].toString()) === -1;
2902
2934
  });
2903
2935
  items.forEach(function (item) {
2904
2936
  _this7.items.push(item);
@@ -2924,7 +2956,7 @@ function (_AbstractUIComponent) {
2924
2956
  return this.value == item.id;
2925
2957
  });
2926
2958
 
2927
- var val = parseInt($input.val(), 10);
2959
+ var val = $input.val().toString();
2928
2960
  $input.prop('checked', true);
2929
2961
  _this7.data[_this7.name].indexOf(val) === -1 ? _this7.data[_this7.name].push(val) : false;
2930
2962
 
@@ -2937,7 +2969,7 @@ function (_AbstractUIComponent) {
2937
2969
  return this.value == item.id;
2938
2970
  });
2939
2971
 
2940
- var val = parseInt($input.val(), 10);
2972
+ var val = $input.val().toString();
2941
2973
  $input.prop('checked', true);
2942
2974
  $input.addClass('checked');
2943
2975
  _this7.data[_this7.name].indexOf(val) === -1 ? _this7.data[_this7.name] = [val] : false;
@@ -3012,11 +3044,11 @@ function (_AbstractUIComponent) {
3012
3044
  ids = data;
3013
3045
  }
3014
3046
 
3015
- ids = ids.map(Number);
3047
+ ids = ids.map(String);
3016
3048
 
3017
3049
  if (this.items.length > 0) {
3018
3050
  result = $.grep(this.items, function (item) {
3019
- return ids.indexOf(parseInt(item.id, 10)) > -1;
3051
+ return ids.indexOf(item.id.toString()) > -1;
3020
3052
  });
3021
3053
 
3022
3054
  if (segment) {
@@ -3045,11 +3077,11 @@ function (_AbstractUIComponent) {
3045
3077
  ids = data;
3046
3078
  }
3047
3079
 
3048
- ids = ids.map(Number);
3080
+ ids = ids.map(String);
3049
3081
 
3050
3082
  if (this.items.length > 0) {
3051
3083
  result = $.grep(this.items, function (item) {
3052
- return ids.indexOf(parseInt(item.id, 10)) > -1;
3084
+ return ids.indexOf(item.id.toString()) > -1;
3053
3085
  });
3054
3086
 
3055
3087
  if (segment) {