cavalion-vcl 1.1.40 → 1.1.44

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,23 @@
1
+ ### 2022/01/03 - 1.1.44
2
+
3
+ * Adding `context` parameter to Array:onFilterObject-event, which can be used as a cache for a specific filter context (updateFilter-call)
4
+ * Introducing List.prototype.**valueByColumnAndRow** - used to obtain the value that will be rendered (useful for inline filtering)
5
+
6
+ ### 2021/12/29 - 1.1.43
7
+
8
+ - Styling glassy-overlays with text-shadow
9
+ - **ui/Tabs**: Fixing styling bug
10
+ - **ui/List**: Introducing `groupByColumn()`
11
+ - **data/Query**: `requestPage()` now returns a Promise
12
+
13
+ ### 2021/12/28 - 1.1.42
14
+
15
+ - Fix alignment bug `#CVLN-20211228-1`
16
+
17
+ ### 2021/12/17 - 1.1.41
18
+
19
+ * Working around autoWidth bug (ListColumn)
20
+
1
21
  ### 2021/12/07 - 1.1.40
2
22
 
3
23
  * Updating
package/ISSUES.md CHANGED
@@ -1,3 +1,12 @@
1
+ # BUG Panel.prototype.getClientRect `#CVLN-20211228-1`
2
+
3
+ // TODO, Erhm, what about the padding? #CVLN-20211228-1
4
+
5
+ * padding is not handled correctly ()
6
+ * publiek-putten
7
+ * details > right > [tabs | containers]
8
+
9
+
1
10
  # BUG Rendering rows fails
2
11
 
3
12
  When `#source` (linked to `#list`) updates while `#list` is not visible, the following usually occurs (no rows visible):
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cavalion-vcl",
3
- "version": "1.1.40",
3
+ "version": "1.1.44",
4
4
  "description": "Visual Component Library for vcl-comps",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/src/data/Array.js CHANGED
@@ -185,11 +185,11 @@ define(function(require) {
185
185
 
186
186
  updateFilter: function(notify) {
187
187
  if(this._onFilterObject !== null && this._array !== null) {
188
- var arr = [];
188
+ var arr = [], context = {};
189
189
  this._arr = this._array;
190
190
  for(var i = 0; i < this._array.length; ++i) {
191
191
  var obj = this._array[i];
192
- if(this.fire("onFilterObject", [obj, i, this]) !== true) {
192
+ if(this.fire("onFilterObject", [obj, i, context]) !== true) {
193
193
  arr.push(obj);
194
194
  }
195
195
  }
@@ -340,7 +340,7 @@ define(function(require) {
340
340
  "onFilterObject": {
341
341
  type: Type.FUNCTION,
342
342
  editorInfo: {
343
- defaultValue: "(function(object, index) {\n\t//return {true} to exclude item from exposed array\n})"
343
+ defaultValue: "(function(object, index, context) {\n\t//return {true} to exclude item from exposed array\n})"
344
344
  }
345
345
  },
346
346
  "onGetAttributeValue": {
@@ -222,19 +222,20 @@ define(function(require) {
222
222
  var index;
223
223
  if(this._pageQueue && (index = this._pageQueue.indexOf(page)) !== -1) {
224
224
  if(index !== this._pageQueue.length - 1) {
225
+ /* make more urgent */
225
226
  this._pageQueue.splice(index, 1);
226
227
  this._pageQueue.push(page);
227
228
  }
228
229
  }
229
- return;
230
+ return this._pageReqs[page]; // Promise.resolve( ... )
230
231
  }
231
232
 
232
233
  /*- make sure additional requests for 'page' are ignored */
233
234
  this._pageReqs[page] = WAITING;
234
235
  if((criteria = this.getRequestCriteria(page)) === null) {
235
236
  // console.debug(this._entity, "requestPage: page", page, "no criteria, skip");
236
- delete me._pageReqs[page];
237
- return;
237
+ delete this._pageReqs[page];
238
+ return Promise.resolve(null);
238
239
  }
239
240
 
240
241
  if(this._request !== null) {
@@ -244,14 +245,14 @@ define(function(require) {
244
245
  }
245
246
 
246
247
  this._pageQueue.push(page);
247
- this._request.then(function() {
248
+ return this._request.then(function() {
248
249
  var page = me._pageQueue.pop();
249
250
  // console.debug(me._entity, "popping page", page);
250
251
 
251
252
  delete me._pageReqs[page]; /* delete WAITING tag */
252
- me.requestPage(page, true); /*- make sure that we remain busy */
253
+ return me.requestPage(page, true); /*- make sure that we remain busy */
253
254
  });
254
- return;
255
+ // return;
255
256
  }
256
257
 
257
258
  var EM = this.getEM(); var start = Date.now();
@@ -297,6 +298,8 @@ define(function(require) {
297
298
  if(!wasBusy) {
298
299
  this.notify(SourceEvent.busyChanged, true, page);
299
300
  }
301
+
302
+ return this._request;
300
303
  },
301
304
  getAttributeValue: function(name, index) {
302
305
  /** @overrides ../data/Source.prototype.getAttributeValue */
@@ -1,6 +1,6 @@
1
1
  "use vcl/ui/Node, vcl/ui/Button";
2
2
 
3
- ["vcl/Application", {
3
+ [("vcl/Application"), {
4
4
  onLoad: function() {
5
5
  var img = document.body.childNodes[0];
6
6
  if(img && img.nodeName === "IMG") {
@@ -13,7 +13,7 @@
13
13
  document.body);
14
14
  }
15
15
  }, [
16
- ["vcl/ui/Panel", "window", {
16
+ [("vcl/ui/Panel"), "window", {
17
17
  align: "client",
18
18
  classes: "animated",
19
19
  css: {
@@ -27,7 +27,7 @@
27
27
  ".with-shadow": "box-shadow:rgba(0, 0, 0, 0.4) 0px 1px 2px 0px;",
28
28
  ".transparent": "background-color:transparent;",
29
29
  ".glassy-overlay": {
30
- "": "pointer-events: none; color:rgba(5,5,5,0.95);",
30
+ "": "pointer-events: none; color:rgba(5,5,5,0.95); text-shadow: rgb(255 255 255) 0px 0px 12px, #00000094 0px 0px 5px;",
31
31
  ">.{./Element}": "pointer-events: auto;",
32
32
  ">.glassy:not(.no-margin)": "margin: 32px;",
33
33
  ">.glassy": {
@@ -1,17 +1,19 @@
1
1
  "js/minify, devtools/Resources";
2
2
 
3
+ var RM = require("devtools/Resources");
4
+
3
5
  var Handlers = {
4
- merge_lib: function() {
6
+ merge_lib() {
5
7
  var vars = this._owner.getVars();
6
8
  vars.modules = vars.modules.concat(vars.extraModules);
7
9
  this._owner.render();
8
10
  },
9
- merge_app: function() {
11
+ merge_app() {
10
12
  var vars = this._owner.getVars();
11
13
  vars.components = vars.components.concat(vars.extraComponents);
12
14
  this._owner.render();
13
15
  },
14
- make_app: function() {
16
+ make_app() {
15
17
  // FIXME This should be moved to Factory?
16
18
 
17
19
  var Component = require("vcl/Component");
@@ -29,8 +31,7 @@ var Handlers = {
29
31
  for(k in Factory.implicit_sources) {
30
32
  v = Factory.implicit_sources[k];
31
33
 
32
- source.push(String.format("define(\"%s\", %s);", k,
33
- JSON.stringify(v)));
34
+ source.push(String.format("define(\"%s\", %s);", k, JSON.stringify(v)));
34
35
  }
35
36
  source.push("\n\n/*- Implicit Sources (blocks) */");
36
37
  Factory = require("blocks/Factory");
@@ -48,8 +49,7 @@ var Handlers = {
48
49
  if(uri.indexOf(".js") === uri.length - 3) {
49
50
  text = minify(text);
50
51
  }
51
- source.push(String.format("define(\"%s\", %s);",
52
- uri, JSON.stringify(text)));
52
+ source.push(String.format("define(\"%s\", %s);", uri, JSON.stringify(text)));
53
53
  }
54
54
  if(--count === 0) {
55
55
  scope['extra-components'].setValue(source.join("\n"));
@@ -72,13 +72,24 @@ var Handlers = {
72
72
  });
73
73
  });
74
74
  },
75
- push_app: function() {
76
- var RM = require("devtools/Resources");
77
- var uri = this.vars(["app-js"]); if(!uri) { return alert("app-js not set"); }
75
+ push_app(evt) {
76
+ var uri = this.vars(["app-js"]);
77
+ if(!uri) {
78
+ return alert("app-js not set");
79
+ }
80
+
81
+ if(confirm("Make?")) {
82
+ Handlers.make_app.apply(this, [evt]);
83
+ }
84
+
78
85
  var text = this.ud("#extra-components").getValue();
79
- this.print("pushing", RM.update(uri, { text: text }));
86
+ RM.get(uri).then(res => {
87
+ res.text = text;
88
+ res = RM.update(uri, res).then(res => alert("Pushed"));
89
+ this.print("Push app-js", res);
90
+ });
80
91
  },
81
- make_styles: function() {
92
+ make_styles() {
82
93
  var ctx = requirejs.s.contexts._;
83
94
  var scope = this.scope();
84
95
  var styles = this.vars(["styles"]).map(_ => "text!" + _.split("!").pop()).filter(_ => _);
@@ -87,7 +98,7 @@ var Handlers = {
87
98
  scope['extra-styles'].setValue(args.join("\n"));
88
99
  });
89
100
  },
90
- set_lib: function() {
101
+ set_lib() {
91
102
  var scope = this.scope();
92
103
  var modules = this.vars(["modules", true]);
93
104
  var components = this.vars(["components", true]);
@@ -95,7 +106,7 @@ var Handlers = {
95
106
  var all = JSON.parse(scope.modules.getValue());
96
107
  scope['extra-modules'].setValue(all.join("\n"));
97
108
  },
98
- set_app: function() {
109
+ set_app() {
99
110
  var scope = this.scope();
100
111
  var components = this.vars(["components", true]);
101
112
 
@@ -176,76 +187,76 @@ var Handlers = {
176
187
  }
177
188
 
178
189
  }, [
179
- ["vcl/ui/Group", {}, [
180
- $(("vcl/ui/CheckGroup"), "app.js", {
190
+ [("vcl/ui/Group"), {}, [
191
+ [("vcl/ui/CheckGroup"), "app.js", {
181
192
  text: "app.js",
182
193
  expanded: true
183
194
  }, [
184
- $(("vcl/ui/Group"), {}, [
185
- $(("vcl/ui/Input"), "components", {
195
+ [("vcl/ui/Group"), {}, [
196
+ [("vcl/ui/Input"), "components", {
186
197
  element: "textarea"
187
- }),
188
- $(("vcl/ui/Input"), "extra-components", {
198
+ }],
199
+ [("vcl/ui/Input"), "extra-components", {
189
200
  element: "textarea"
190
- }),
191
- $(("vcl/ui/Input"), "implicit-components", {
201
+ }],
202
+ [("vcl/ui/Input"), "implicit-components", {
192
203
  element: "textarea"
193
- })
194
- ]),
195
- $(("vcl/ui/Button"), {
204
+ }]
205
+ ]],
206
+ [("vcl/ui/Button"), {
196
207
  content: "Merge",
197
208
  onClick: Handlers.merge_app
198
- }),
199
- $(("vcl/ui/Button"), {
209
+ }],
210
+ [("vcl/ui/Button"), {
200
211
  content: ">>>",
201
212
  onClick: Handlers.set_app
202
- }),
203
- $(("vcl/ui/Button"), {
213
+ }],
214
+ [("vcl/ui/Button"), {
204
215
  content: "Make",
205
216
  onClick: Handlers.make_app
206
- }),
207
- $(("vcl/ui/Button"), {
217
+ }],
218
+ [("vcl/ui/Button"), {
208
219
  content: "Push",
209
220
  onClick: Handlers.push_app
210
- })
211
- ]),
212
- $(("vcl/ui/CheckGroup"), "styles.less", {
221
+ }]
222
+ ]],
223
+ [("vcl/ui/CheckGroup"), "styles.less", {
213
224
  text: "styles.less",
214
225
  expanded: true
215
226
  }, [
216
- $(("vcl/ui/Group"), {}, [
217
- $(("vcl/ui/Input"), "styles", {
227
+ [("vcl/ui/Group"), {}, [
228
+ [("vcl/ui/Input"), "styles", {
218
229
  element: "textarea"
219
- }),
220
- $(("vcl/ui/Input"), "extra-styles", {
230
+ }],
231
+ [("vcl/ui/Input"), "extra-styles", {
221
232
  element: "textarea"
222
- }),
223
- ]),
224
- $(("vcl/ui/Button"), {
233
+ }],
234
+ ]],
235
+ [("vcl/ui/Button"), {
225
236
  content: "Make",
226
237
  onClick: Handlers.make_styles
227
- })
228
- ]),
229
- $(("vcl/ui/CheckGroup"), "lib.js", {
238
+ }]
239
+ ]],
240
+ [("vcl/ui/CheckGroup"), "lib.js", {
230
241
  text: "lib.js",
231
242
  expanded: true
232
243
  }, [
233
- $(("vcl/ui/Group"), {}, [
234
- $(("vcl/ui/Input"), "modules", {
244
+ [("vcl/ui/Group"), {}, [
245
+ [("vcl/ui/Input"), "modules", {
235
246
  element: "textarea"
236
- }),
237
- $(("vcl/ui/Input"), "extra-modules", {
247
+ }],
248
+ [("vcl/ui/Input"), "extra-modules", {
238
249
  element: "textarea"
239
- }),
240
- ]),
241
- $(("vcl/ui/Button"), {
250
+ }],
251
+ ]],
252
+ [("vcl/ui/Button"), {
242
253
  content: "Merge",
243
254
  onClick: Handlers.merge_lib
244
- }),
245
- $(("vcl/ui/Button"), {
255
+ }],
256
+ [("vcl/ui/Button"), {
246
257
  content: ">>>",
247
258
  onClick: Handlers.set_lib
248
- })
249
- ])
259
+ }]
260
+ ]]
250
261
  ]]
251
262
  ]];
@@ -16,7 +16,7 @@
16
16
  '.right': "float: right;",
17
17
  '.{Button}': {
18
18
  outline: "none",
19
- '&:not(.right)': "margin-right: 16px;",
19
+ '&:not(.right)': "margin-right: 8px;",
20
20
  'background': "none",
21
21
  'background-color': "transparent",
22
22
  'border': "none",
package/src/ui/List.js CHANGED
@@ -580,6 +580,15 @@ define(function(require) {
580
580
  }
581
581
  return null;
582
582
  },
583
+ getColumnByName: function(name) {
584
+ for(var i = 0, l = this._columns.length; i < l; ++i) {
585
+ var c = this._columns[i];
586
+ if(c._custom === false && c._name === name) {
587
+ return c;
588
+ }
589
+ }
590
+ return null;
591
+ },
583
592
  insertColumn: function(column, index) {
584
593
  this._columns.push(column);
585
594
  column._list = this;
@@ -814,6 +823,36 @@ define(function(require) {
814
823
  oncolumndrop: function() {
815
824
  return this.fire("onColumnDropped", arguments);
816
825
  },
826
+
827
+ valueByColumnAndRow(column, row) {
828
+ var value, orgValue;
829
+ if(column._attribute !== "") {
830
+ orgValue = (value = this._source.getAttributeValue(column._attribute, row));
831
+ }
832
+ if(column._wantsNullValues || (value !== null && value !== undefined)) {
833
+ if(column._displayFormat !== "") {
834
+ value = String.format(column._displayFormat, value);
835
+ }
836
+ if(column._onGetValue !== null) {
837
+ value = column.fire("onGetValue", [value, row, this._source]);
838
+ }
839
+ if(this._onColumnGetValue !== null) {
840
+ value = this.fire("onColumnGetValue", [column, value, row, this._source]);
841
+ }
842
+ if(this._formatDates === true && this.isDate(value)) {
843
+ value = this.formatDate(value);
844
+ }
845
+ }
846
+ return value;
847
+ },
848
+ groupByColumn(column) {
849
+ var r = {};
850
+ this._source.getObjects().forEach((obj, row) => {
851
+ var value = this.getValueByColumnAndRow(column, row);
852
+ (r[value] = r[value] || []).push(obj);
853
+ });
854
+ return r;
855
+ },
817
856
 
818
857
  hasSelection: function() {
819
858
  return this._selection.length > 0;
@@ -241,6 +241,11 @@ define(function(require) {
241
241
  }
242
242
  return r;
243
243
  },
244
+
245
+
246
+ groupBy: function() {
247
+ return this._list.groupByColumn(this);
248
+ },
244
249
 
245
250
  sizing: function(evt) {
246
251
  },
@@ -342,8 +347,13 @@ define(function(require) {
342
347
  return this._autoWidthValue;
343
348
  },
344
349
  setAutoWidthValue: function(value, force) {
345
- if(value === "&nbsp;") value = " ";
346
350
  value = value.trim();
351
+ if(value === "&nbsp;") value = " ";
352
+
353
+ if(value.length <= 10) {
354
+ value += "W";
355
+ }
356
+
347
357
  if(force === true || (this._autoWidthValue !== value && value.length > this._autoWidthValue.length)) {
348
358
  this._autoWidthValue = value;
349
359
  if(this._node !== null) {
package/src/ui/Panel.js CHANGED
@@ -32,25 +32,11 @@ define(function (require) {
32
32
  };
33
33
  return animations[animation];
34
34
  }
35
-
36
- /**
37
- *
38
- */
39
35
  function swap(obj, a1, a2) {
40
36
  var v = obj[a1];
41
37
  obj[a1] = obj[a2];
42
38
  obj[a2] = v;
43
39
  }
44
-
45
- /**
46
- *
47
- * @param control
48
- * @param left
49
- * @param top
50
- * @param right
51
- * @param bottom
52
- * @param callback
53
- */
54
40
  function setBounds(control, left, top, right, bottom, callback) {
55
41
  if (control.setBounds(left, top, right, bottom, undefined, undefined, callback) === undefined) {
56
42
  callback();
@@ -145,7 +131,7 @@ define(function (require) {
145
131
  */
146
132
  if (align === "top") {
147
133
  setBounds(control, cr.left, cr.top, cr.right, U, function () {
148
- if(zoom != 1.0) {
134
+ if(zoom !== 1.0) {
149
135
  console.log("alignControls", control._name, control);
150
136
  cr.top += (control._height * zoom);
151
137
  } else {
@@ -155,7 +141,7 @@ define(function (require) {
155
141
  });
156
142
  } else if (align === "bottom") {
157
143
  setBounds(control, cr.left, U, cr.right, cr.bottom, function () {
158
- if(zoom != 1.0) {
144
+ if(zoom !== 1.0) {
159
145
  console.log("alignControls", control._name, control);
160
146
  cr.bottom += (control._height / zoom);
161
147
  } else {
@@ -177,6 +163,7 @@ define(function (require) {
177
163
  });
178
164
  }
179
165
  }
166
+ // console.log(thisObj._name, align, js.mixIn(cr));
180
167
  } else {
181
168
  controls.splice(i, 1);
182
169
  next();
@@ -251,11 +238,11 @@ define(function (require) {
251
238
  cr = {
252
239
  left: parseFloat(cs.getPropertyValue("padding-left")) || 0,
253
240
  top: parseFloat(cs.getPropertyValue("padding-top")) || 0,
254
- right: w - (w * (1 / this._zoom) * f),
255
- bottom: h - (h * (1 / this._zoom) * f)
256
- // TODO, Erhm, what about the padding?
257
- // right: f * (parseFloat(cs.getPropertyValue("padding-right")) || 0),
258
- // bottom: f * (parseFloat(cs.getPropertyValue("padding-bottom")) || 0)
241
+ // right: w - (w * (1 / this._zoom) * f),
242
+ // bottom: h - (h * (1 / this._zoom) * f)
243
+ // TODO, Erhm, what about the padding? #CVLN-20211228-1
244
+ right: f * (parseFloat(cs.getPropertyValue("padding-right")) || 0),
245
+ bottom: f * (parseFloat(cs.getPropertyValue("padding-bottom")) || 0)
259
246
  };
260
247
  }
261
248
  // console.log(this._name, JSON.stringify(cr));
@@ -478,7 +465,7 @@ define(function (require) {
478
465
  height: this._node.clientHeight
479
466
  });
480
467
  }
481
-
468
+ // console.log(this, "setBounds", bounds);
482
469
  this.alignControls();
483
470
  },
484
471
  setBoundsValidated: function (left, top, right, bottom, width, height) {
package/src/ui/Tabs.js CHANGED
@@ -14,13 +14,13 @@ define(function(require) {
14
14
  "background-color": "#f0f0f0",
15
15
  'height': "26px",
16
16
  "padding-left": "2px",
17
- "padding-top": "3px",
18
17
  // "border-top": "1px solid silver",
19
18
 
20
19
  "&.gradient":{
21
20
  "background-image": "-webkit-gradient(linear, 0% 0%, 0% 100%, from(#F5F5F5), to(#E5E5E5))",
22
21
  },
23
22
  "&:not(.bottom)": {
23
+ "padding-top": "3px",
24
24
  "border-bottom": "1px solid silver"
25
25
  },
26
26
  "&.bottom.inset": {