@finqu/cool 1.2.8 → 1.2.9

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.8 (https://finqu.fi)
3
3
  * Copyright 2011-2020 Finqu Oy
4
4
  * Licensed under the ISC license - (http://opensource.org/licenses/ISC)
5
5
  */
@@ -2258,7 +2258,7 @@
2258
2258
  _this3.preventClose = false;
2259
2259
 
2260
2260
  if (_this3.itemsToExclude.length > 0) {
2261
- _this3.itemsToExclude = _this3.itemsToExclude.map(Number);
2261
+ _this3.itemsToExclude = _this3.itemsToExclude.map(String);
2262
2262
  }
2263
2263
 
2264
2264
  if (_this3.opts.setData) {
@@ -2267,17 +2267,37 @@
2267
2267
 
2268
2268
  if (_this3.$el.data('setData') && _this3.$el.data('setData') != '') {
2269
2269
  _this3.data = _this3.$el.data('setData');
2270
+ } // Convert data to be array so filters doesn't fail
2271
+
2272
+
2273
+ if (!Array.isArray(_this3.data[_this3.name]) && _this3.data[_this3.name] !== '' && _this3.data[_this3.name].length > 0) {
2274
+ var arr = _this3.data[_this3.name].toString().trim().split(',');
2275
+
2276
+ _this3.data[_this3.name] = arr;
2277
+ } // Convert all values to string format to make filtering more simple
2278
+
2279
+
2280
+ if (_this3.data[_this3.name].length > 0) {
2281
+ _this3.data[_this3.name] = _this3.data[_this3.name].map(String);
2270
2282
  }
2271
2283
 
2272
- if (_this3.data[_this3.name] !== 'undefined' && _this3.data[_this3.name].length > 0 && self.itemsToExclude) {
2284
+ if (_this3.data[_this3.name].length > 0 && _this3.itemsToExclude.length > 0) {
2273
2285
  _this3.data[_this3.name] = _this3.data[_this3.name].filter(function (item) {
2274
- return self.itemsToExclude.indexOf(parseInt(item.id, 10)) === -1;
2286
+ if (item[self.primaryKeyword]) {
2287
+ return self.itemsToExclude.indexOf(item[self.primaryKeyword].toString()) === -1;
2288
+ } else {
2289
+ return self.itemsToExclude.indexOf(item.toString()) === -1;
2290
+ }
2275
2291
  });
2276
2292
  }
2277
2293
 
2278
- if (_this3.items !== 'undefined' && _this3.items.lengths > 0 && self.itemsToExclude) {
2294
+ if (_this3.items.length > 0 && _this3.itemsToExclude.length > 0) {
2279
2295
  _this3.items = _this3.items.filter(function (item) {
2280
- return self.itemsToExclude.indexOf(parseInt(item.id, 10)) === -1;
2296
+ if (item[self.primaryKeyword]) {
2297
+ return self.itemsToExclude.indexOf(item[self.primaryKeyword].toString()) === -1;
2298
+ } else {
2299
+ return self.itemsToExclude.indexOf(item.toString()) === -1;
2300
+ }
2281
2301
  });
2282
2302
  }
2283
2303
 
@@ -2306,6 +2326,18 @@
2306
2326
 
2307
2327
  secondaryResolve();
2308
2328
  } else {
2329
+ var selectItems = _this3.$select.find('.select-item');
2330
+
2331
+ if (selectItems.length > 0 && _this3.itemsToExclude.length > 0) {
2332
+ $.each(selectItems, function (i, el) {
2333
+ var val = $(el).find(':input').val();
2334
+
2335
+ if (self.itemsToExclude.indexOf(val) > -1) {
2336
+ $(el).remove();
2337
+ }
2338
+ });
2339
+ }
2340
+
2309
2341
  secondaryResolve();
2310
2342
  }
2311
2343
  }).then(function () {
@@ -2498,7 +2530,7 @@
2498
2530
  var val = $(this).val();
2499
2531
 
2500
2532
  if (this.checked) {
2501
- self.data[self.name] = val;
2533
+ self.data[self.name] = [val];
2502
2534
  self.$select.find('input[type="radio"]').not($(this)).prop('checked', false);
2503
2535
  self.$select.find('input[type="radio"]').not($(this)).removeClass('checked');
2504
2536
  } else {
@@ -2617,11 +2649,11 @@
2617
2649
  return item;
2618
2650
  });
2619
2651
  var itemIds = items.map(function (item) {
2620
- return parseInt(item.id, 10);
2652
+ return item.id.toString();
2621
2653
  }); // Remove value from data if it doesn't exist anymore
2622
2654
 
2623
2655
  self.data[self.name] = self.data[self.name].filter(function (value) {
2624
- return itemIds.indexOf(parseInt(value, 10)) > -1;
2656
+ return itemIds.indexOf(value.toString()) > -1;
2625
2657
  });
2626
2658
 
2627
2659
  if (self.data[self.name].length == 0) {
@@ -2629,7 +2661,7 @@
2629
2661
  }
2630
2662
 
2631
2663
  items = items.filter(function (item) {
2632
- return self.data[self.name].indexOf(item.id) > -1 && self.itemsToExclude.indexOf(parseInt(item.id, 10)) === -1 && parseInt(item.id, 10) > 0;
2664
+ return self.data[self.name].indexOf(item.id) > -1 && self.itemsToExclude.indexOf(item.id) === -1 && item.id != 0;
2633
2665
  });
2634
2666
 
2635
2667
  var result = self._renderItemList(items);
@@ -2663,7 +2695,7 @@
2663
2695
  });
2664
2696
  } else if (self.type == 'radio') {
2665
2697
  var $input = $inputs.filter(function () {
2666
- return this.value == self.data[self.name];
2698
+ return this.value == self.data[self.name][0];
2667
2699
  });
2668
2700
  $input.prop('checked', true);
2669
2701
  $input.addClass('checked');
@@ -2680,10 +2712,10 @@
2680
2712
  // Remove value from data if it doesn't exist anymore
2681
2713
  var $inputs = this.$scrollableContent.find(':input');
2682
2714
  var inputValues = $inputs.length > 0 ? $inputs.map(function () {
2683
- return parseInt(this.value, 10);
2715
+ return this.value.toString();
2684
2716
  }).get() : [];
2685
2717
  this.data[this.name] = this.data[this.name].filter(function (value) {
2686
- return inputValues.indexOf(parseInt(value, 10)) > -1;
2718
+ return inputValues.indexOf(value.toString()) > -1;
2687
2719
  });
2688
2720
 
2689
2721
  if (this.data[this.name].length == 0) {
@@ -2706,7 +2738,7 @@
2706
2738
  });
2707
2739
  } else if (this.type == 'radio') {
2708
2740
  var $input = $inputs.filter(function () {
2709
- return this.value == self.data[self.name];
2741
+ return this.value == self.data[self.name][0];
2710
2742
  });
2711
2743
  $input.prop('checked', true);
2712
2744
  $input.addClass('checked');
@@ -2743,7 +2775,7 @@
2743
2775
  return item;
2744
2776
  });
2745
2777
  items = items.filter(function (item) {
2746
- return self.data[self.name].indexOf(item.id) === -1 && self.itemsToExclude.indexOf(parseInt(item.id, 10)) === -1 && parseInt(item.id, 10) > 0;
2778
+ return self.data[self.name].indexOf(item.id) === -1 && self.itemsToExclude.indexOf(item.id) === -1 && item.id != 0;
2747
2779
  });
2748
2780
 
2749
2781
  var result = self._renderItemList(items);
@@ -2902,7 +2934,7 @@
2902
2934
  }
2903
2935
 
2904
2936
  items = items.filter(function (item) {
2905
- return self.itemsToExclude.indexOf(parseInt(item.id, 10)) === -1;
2937
+ return self.itemsToExclude.indexOf(item[self.primaryKeyword].toString()) === -1;
2906
2938
  });
2907
2939
  items.forEach(function (item) {
2908
2940
  _this7.items.push(item);
@@ -2928,7 +2960,7 @@
2928
2960
  return this.value == item.id;
2929
2961
  });
2930
2962
 
2931
- var val = parseInt($input.val(), 10);
2963
+ var val = $input.val().toString();
2932
2964
  $input.prop('checked', true);
2933
2965
  _this7.data[_this7.name].indexOf(val) === -1 ? _this7.data[_this7.name].push(val) : false;
2934
2966
 
@@ -2941,7 +2973,7 @@
2941
2973
  return this.value == item.id;
2942
2974
  });
2943
2975
 
2944
- var val = parseInt($input.val(), 10);
2976
+ var val = $input.val().toString();
2945
2977
  $input.prop('checked', true);
2946
2978
  $input.addClass('checked');
2947
2979
  _this7.data[_this7.name].indexOf(val) === -1 ? _this7.data[_this7.name] = [val] : false;
@@ -3016,11 +3048,11 @@
3016
3048
  ids = data;
3017
3049
  }
3018
3050
 
3019
- ids = ids.map(Number);
3051
+ ids = ids.map(String);
3020
3052
 
3021
3053
  if (this.items.length > 0) {
3022
3054
  result = $.grep(this.items, function (item) {
3023
- return ids.indexOf(parseInt(item.id, 10)) > -1;
3055
+ return ids.indexOf(item.id.toString()) > -1;
3024
3056
  });
3025
3057
 
3026
3058
  if (segment) {
@@ -3049,11 +3081,11 @@
3049
3081
  ids = data;
3050
3082
  }
3051
3083
 
3052
- ids = ids.map(Number);
3084
+ ids = ids.map(String);
3053
3085
 
3054
3086
  if (this.items.length > 0) {
3055
3087
  result = $.grep(this.items, function (item) {
3056
- return ids.indexOf(parseInt(item.id, 10)) > -1;
3088
+ return ids.indexOf(item.id.toString()) > -1;
3057
3089
  });
3058
3090
 
3059
3091
  if (segment) {