cavalion-vcl 1.1.44 → 1.1.47

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/CHANGELOG.md CHANGED
@@ -1,3 +1,24 @@
1
+ ### 2022/01/18 - 1.1.47
2
+
3
+ `#CVLN-20220118-1`
4
+
5
+ * Workaround for weird rendering bug in ui/List
6
+
7
+ ### 2022/01/18 - 1.1.46
8
+
9
+ * **ui/List**: Adding "ignore-busy" class behaviour
10
+ * **ui/List**: Refactoring `groupByColumn(...)` -> `groupBy(column, ...)`
11
+ * **ui/List**: Refactoring `render` => `render_` (vcl/Control.prototype.render was not being overridden/nameclashing)
12
+
13
+
14
+ ### 2022/01/07 - 1.1.45
15
+
16
+ * **data/Array**: Fix for `context` parameter in `onFilterObject`-event
17
+
18
+ ### 2022/01/04
19
+
20
+ - Adding sort-features to ui/List, -Column and -Header
21
+
1
22
  ### 2022/01/03 - 1.1.44
2
23
 
3
24
  * Adding `context` parameter to Array:onFilterObject-event, which can be used as a cache for a specific filter context (updateFilter-call)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cavalion-vcl",
3
- "version": "1.1.44",
3
+ "version": "1.1.47",
4
4
  "description": "Visual Component Library for vcl-comps",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/src/data/Array.js CHANGED
@@ -185,7 +185,7 @@ define(function(require) {
185
185
 
186
186
  updateFilter: function(notify) {
187
187
  if(this._onFilterObject !== null && this._array !== null) {
188
- var arr = [], context = {};
188
+ var arr = [], context = { source: this };
189
189
  this._arr = this._array;
190
190
  for(var i = 0; i < this._array.length; ++i) {
191
191
  var obj = this._array[i];
@@ -310,12 +310,15 @@ define(function(require) {
310
310
  });
311
311
  }
312
312
 
313
+ var A = this._arr;
313
314
  this.assertArray();
314
315
  try {
315
316
  // TODO Hmm, this sorting of _arr feels a lil' dodgy TBH...
316
- this._arr && window.Array.prototype.sort.apply(this._arr, arguments);
317
+ // this._arr && window.Array.prototype.sort.apply(this._arr, arguments);
318
+ this._arr = this._array;
317
319
  return window.Array.prototype.sort.apply(this._array, arguments);
318
320
  } finally {
321
+ this._arr = A;
319
322
  this.arrayChanged();
320
323
  }
321
324
  }
@@ -358,9 +358,6 @@ define(function(require) {
358
358
  return this._attributes !== "" ? this._attributes.split(",") : [];
359
359
  },
360
360
  processResult: function(res, page, criteria) {
361
-
362
- //this.print("page/" + page + "/processResult", {res: res, criteria: criteria});
363
-
364
361
  var instances = res.instances;
365
362
  var tuples = res.tuples;
366
363
  var size = instances.length;
@@ -371,7 +368,7 @@ define(function(require) {
371
368
  this.notify(SourceEvent.layoutChanged);
372
369
  }
373
370
 
374
- if(this._arr === null || this._arr.length === 0) {
371
+ if(this._arr === null/* || this._arr.length === 0*/) {
375
372
  if(!res.hasOwnProperty("count")) {
376
373
  if(this._count === false && page === 0 && res.instances.length === 0) {
377
374
  res.count = 0;
@@ -337,7 +337,7 @@ var Handlers = {
337
337
  // @overrides ui/forms/Home<>
338
338
  container.setVisible(false);
339
339
  container.setParent(scope.client);
340
- node.setText(params.title || "&nbsp;");
340
+ node.setText(params.text || params.title || "&nbsp;");
341
341
  node.setVar("control", container);
342
342
  node.setParent(parent || scope.tree);
343
343
  node.update(function() {
package/src/ui/List.js CHANGED
@@ -102,6 +102,15 @@ define(function(require) {
102
102
  _onColumnGetValue: null,
103
103
  _onColumnRenderCell: null,
104
104
 
105
+ /**-- #CVLN-20220118-1-workaround */
106
+ visibleChanged() {
107
+ if(this.isVisible()) {
108
+ // this.print("#CVLN-20220118-1 Calling rowHeightChanged-workaround");
109
+ this._body.rowHeightChanged();
110
+ }
111
+ return this.inherited(arguments);
112
+ },
113
+
105
114
  /**-- overrides ../Component.prototype */
106
115
  destroy: function() {
107
116
  /** @overrides ../Component.prototype.destroy */
@@ -212,7 +221,7 @@ define(function(require) {
212
221
  var topRow = parseInt(me._nodes.body.scrollTop / me._rowHeight, 10);
213
222
  me._topRow = topRow;
214
223
 
215
- me.render();
224
+ me.render_();
216
225
  }
217
226
 
218
227
  return this.inherited(arguments);
@@ -336,7 +345,7 @@ define(function(require) {
336
345
  },
337
346
 
338
347
  notifyEvent: function(event, data) {},
339
- render: function(bodyUpdateRows/*TODO*/) {
348
+ render_: function(bodyUpdateRows/*TODO*/) {
340
349
  if(bodyUpdateRows) return this._body.updateRows();
341
350
 
342
351
  var vrc = this.getVisibleRowCount(true);
@@ -346,8 +355,6 @@ define(function(require) {
346
355
  }
347
356
 
348
357
  var start = this._topRow - this._rowBuffer;
349
-
350
-
351
358
  var end = start + vrc + this._rowBuffer * 2;
352
359
 
353
360
  if(start < 0) {
@@ -390,7 +397,7 @@ define(function(require) {
390
397
  }
391
398
  }, 50);
392
399
  }
393
- this._body.render();
400
+ this._body.render_();
394
401
  },
395
402
  renderCell: function(cell, row, column) {
396
403
  var value, orgValue;
@@ -489,7 +496,7 @@ define(function(require) {
489
496
  }
490
497
  this.setSelection([]);
491
498
  //this.alignControls();
492
- this.render();
499
+ this.render_();
493
500
  }
494
501
  },
495
502
 
@@ -533,7 +540,7 @@ define(function(require) {
533
540
  setVisibleRowCount: function(value) {
534
541
  if(this._visibleRowCount !== value) {
535
542
  this._visibleRowCount = value;
536
- this.render();
543
+ this.render_();
537
544
  }
538
545
  },
539
546
 
@@ -655,12 +662,13 @@ define(function(require) {
655
662
  this.notifyEvent("columnsChanged");
656
663
  },
657
664
  updateColumns: function() {
658
- this.resetColumnAutoWidth();
659
-
660
665
  var updateColumns = this.updateColumns;
661
666
  this.updateColumns = function() {
662
667
  console.log("updateColumns blocked");
663
668
  };
669
+
670
+ this.resetColumnAutoWidth();
671
+
664
672
  try {
665
673
  if(this._source !== null) {
666
674
  var columns = [].concat(this._columns);
@@ -668,15 +676,6 @@ define(function(require) {
668
676
  var changed = false;
669
677
  var attrs = this._source.getAttributeNames();
670
678
 
671
- // sort(function(i1, i2) {
672
- // var s1 = i1.split(".").length;
673
- // var s2 = i2.split(".").length;
674
- // if(s1 !== s2) {
675
- // return s1 < s2 ? -1 : 1;
676
- // }
677
- // return i1 < i2 ? -1 : 1;
678
- // });
679
-
680
679
  for(var i = 0; i < attrs.length; ++i) {
681
680
  var column = this.getColumnByAttribute(attrs[i]);
682
681
  if(column === null) {
@@ -721,7 +720,7 @@ define(function(require) {
721
720
  for(var i = 0; i < this._columns.length; ++i) {
722
721
  this._columns[i].setAutoWidthValue("", true);
723
722
  }
724
- this.render();
723
+ this.render_();
725
724
  },
726
725
  getAutoColumns: function() {
727
726
  return this._autoColumns;
@@ -760,7 +759,7 @@ define(function(require) {
760
759
  break;
761
760
 
762
761
  case SourceEvent.busyChanged:
763
- if(data && this._topRow > 0) { /* TODO what about scrolling up? */
762
+ if((data && this._topRow > 0) || this.hasClass("ignore-busy")) { /* TODO what about scrolling up? */
764
763
  return;
765
764
  }
766
765
  this.setTimeout("update-busy", function() {
@@ -825,10 +824,7 @@ define(function(require) {
825
824
  },
826
825
 
827
826
  valueByColumnAndRow(column, row) {
828
- var value, orgValue;
829
- if(column._attribute !== "") {
830
- orgValue = (value = this._source.getAttributeValue(column._attribute, row));
831
- }
827
+ var value = this._source.getAttributeValue(column._attribute, row);
832
828
  if(column._wantsNullValues || (value !== null && value !== undefined)) {
833
829
  if(column._displayFormat !== "") {
834
830
  value = String.format(column._displayFormat, value);
@@ -845,14 +841,47 @@ define(function(require) {
845
841
  }
846
842
  return value;
847
843
  },
848
- groupByColumn(column) {
844
+ groupBy(column/*, ... TODO */) {
849
845
  var r = {};
850
846
  this._source.getObjects().forEach((obj, row) => {
851
- var value = this.getValueByColumnAndRow(column, row);
847
+ var value = this.valueByColumnAndRow(column, row);
852
848
  (r[value] = r[value] || []).push(obj);
853
849
  });
854
850
  return r;
855
851
  },
852
+ sortBy(column, dir, numeric) {
853
+
854
+ if(typeof column === "string") {
855
+ column = column.split(" ");
856
+ if(arguments.length === 1) {
857
+ dir = column[1];
858
+ }
859
+ if(column.length === 2) {
860
+ numeric = column[2] === "numeric";
861
+ }
862
+ column = this.getColumnByName(column[0]);
863
+ } else if(typeof column === "number") {
864
+ column = this.getColumn();
865
+ }
866
+
867
+ this._source.sort((i1, i2) => {
868
+
869
+ var row1 = this._source._array.indexOf(i1);
870
+ var row2 = this._source._array.indexOf(i2);
871
+
872
+ i1 = this.valueByColumnAndRow(column, row1);
873
+ i2 = this.valueByColumnAndRow(column, row2);
874
+
875
+ if(numeric === true) {
876
+ if(isNaN(i1 = parseFloat(i1))) return 1;
877
+ if(isNaN(i2 = parseFloat(i2))) return -1;
878
+ }
879
+
880
+ if(i1 === i2) return 0;
881
+
882
+ return (dir === "desc" ? -1 : 1) * (i1 < i2 ? -1 : 1);
883
+ });
884
+ },
856
885
 
857
886
  hasSelection: function() {
858
887
  return this._selection.length > 0;
@@ -53,7 +53,7 @@ define(function(require) {
53
53
  getList: function() {
54
54
  return this._parent !== null ? this._parent : null;
55
55
  },
56
- render: function() {
56
+ render_: function() {
57
57
  var list = this.getList();
58
58
  if(list.getCount() === 0) {
59
59
  this._firstRow = 0;
@@ -242,9 +242,8 @@ define(function(require) {
242
242
  return r;
243
243
  },
244
244
 
245
-
246
245
  groupBy: function() {
247
- return this._list.groupByColumn(this);
246
+ return this._list.groupBy(this);
248
247
  },
249
248
 
250
249
  sizing: function(evt) {
@@ -9,9 +9,7 @@ define(function(require) {
9
9
  var ListColumn = require("js/referenceClass!./List");
10
10
 
11
11
  var ListHeader = {
12
-
13
12
  inherits: Panel,
14
-
15
13
  prototype: {
16
14
 
17
15
  "@css": {
@@ -44,30 +42,17 @@ define(function(require) {
44
42
  }
45
43
  },
46
44
 
47
- /**
48
- *
49
- constructor: function() {
50
- },
51
- */
52
-
53
- /**
54
- * @overrides ../Control.prototype
55
- */
45
+ /** @overrides ../Control.prototype */
56
46
  _align: "top",
57
47
  _autoSize: "height",
58
48
  _content: "<div></div>",
59
49
 
60
- /**
61
- * @overrides ../Control.prototype.getClientNode
62
- */
63
50
  getClientNode: function() {
51
+ /** overrides ../Control.prototype.getClientNode */
64
52
  return this._node.childNodes[0];
65
53
  },
66
-
67
- /**
68
- * @overrides ../Control.prototype.setParent
69
- */
70
54
  setParent: function(value) {
55
+ /** overrides ../Control.prototype.setParent */
71
56
  if(this._parent !== value) {
72
57
  if(this._parent !== null) {
73
58
  Method.disconnect(this._parent, "notifyEvent", this, "listNotifyEvent");
@@ -81,11 +66,8 @@ define(function(require) {
81
66
  }
82
67
  }
83
68
  },
84
-
85
- /**
86
- * @overrides ../Control.prototype.dispatchChildEvent
87
- */
88
69
  dispatchChildEvent: function(component, name, evt, f) {
70
+ /** overrides ../Control.prototype.dispatchChildEvent */
89
71
  if(component instanceof ListColumn && component._parent === this) {
90
72
  if(name === "dragstart" && component.hasClass("size") === false) {
91
73
  var listview = this.getList();
@@ -141,25 +123,16 @@ define(function(require) {
141
123
  return this.inherited(arguments);
142
124
  },
143
125
 
144
- /**
145
- *
146
- */
147
126
  listNotifyEvent: function(event, data) {
148
127
  if(event === "setScrollLeft" && this._node !== null) {
149
128
  this._node/*.childNodes[0]*/.scrollLeft = data;
150
129
  }
151
130
  },
152
-
153
- /**
154
- *
155
- */
156
131
  getList: function() {
157
132
  return this._parent !== null ? this._parent : null;
158
133
  }
159
134
  },
160
-
161
135
  properties: {
162
-
163
136
  "align": {
164
137
  set: Method,
165
138
  type: Panel.ALIGN
@@ -172,4 +145,4 @@ define(function(require) {
172
145
  };
173
146
 
174
147
  return (ListHeader = Class.define(require, ListHeader));
175
- });
148
+ });