@hpcc-js/other 3.4.10 → 3.5.0

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,500 +1,500 @@
1
- import { d3Event, PropertyExt, select as d3Select, selectAll as d3SelectAll, SVGWidget } from "@hpcc-js/common";
2
-
3
- import "../src/Opportunity.css";
4
-
5
- export class Column extends PropertyExt {
6
- _owner: Opportunity;
7
-
8
- constructor() {
9
- super();
10
- }
11
-
12
- owner(): Opportunity;
13
- owner(_: Opportunity): this;
14
- owner(_?: Opportunity): Opportunity | this {
15
- if (!arguments.length) return this._owner;
16
- this._owner = _;
17
- return this;
18
- }
19
-
20
- valid(): boolean {
21
- return !!this.headerLabel();
22
- }
23
- }
24
- Column.prototype._class += " other_Opportunity.Column";
25
-
26
- export interface Column {
27
- headerLabel(): string;
28
- headerLabel(_: string): this;
29
- }
30
- Column.prototype.publish("headerLabel", null, "string", "Header value of a table", function (this: Column) { return this._owner ? this._owner.columns() : []; }, { tags: ["Basic"], optional: true });
31
-
32
- export class MouseHoverColumn extends PropertyExt {
33
- _owner: Opportunity;
34
-
35
- constructor() {
36
- super();
37
- }
38
-
39
- owner(): Opportunity;
40
- owner(_: Opportunity): this;
41
- owner(_?: Opportunity): Opportunity | this {
42
- if (!arguments.length) return this._owner;
43
- this._owner = _;
44
- return this;
45
- }
46
-
47
- valid(): boolean {
48
- return !!this.hoverValue() && !!this.hoverList();
49
- }
50
- }
51
- MouseHoverColumn.prototype._class += " other_Opportunity.MouseHoverColumn";
52
-
53
- export interface MouseHoverColumn {
54
- hoverValue(): string;
55
- hoverValue(_: string): this;
56
- hoverList(): string;
57
- hoverList(_: string): this;
58
- }
59
- MouseHoverColumn.prototype.publish("hoverValue", null, "string", "Hover value of a table", function () { return this._owner ? this._owner.columns() : []; }, { tags: ["Basic"], optional: true });
60
- MouseHoverColumn.prototype.publish("hoverList", null, "set", "Hover value of a table", function () { return this._owner ? this._owner.getIds() : []; }, { tags: ["Basic"], optional: true });
61
-
62
- export class ColumnDropdown extends PropertyExt {
63
- _owner: Opportunity;
64
-
65
- constructor() {
66
- super();
67
- }
68
-
69
- owner(): Opportunity;
70
- owner(_: Opportunity): this;
71
- owner(_?: Opportunity): Opportunity | this {
72
- if (!arguments.length) return this._owner;
73
- this._owner = _;
74
- return this;
75
- }
76
-
77
- valid(): boolean {
78
- return !!this.columnIndex() && !!this.ColumnDropdownList();
79
- }
80
- }
81
- ColumnDropdown.prototype._class += " other_Opportunity.ColumnDropdown";
82
-
83
- export interface ColumnDropdown {
84
- columnIndex(): number;
85
- columnIndex(_: number): this;
86
- ColumnDropdownList(): string;
87
- ColumnDropdownList(_: string): this;
88
- }
89
- ColumnDropdown.prototype.publish("columnIndex", null, "number", "Column index for display context data based on column dropdown list selction", {}, { tags: ["Basic", "Shared"] });
90
- ColumnDropdown.prototype.publish("ColumnDropdownList", null, "set", "column value of a table", function () { return this._owner ? this._owner.getIds() : []; }, { tags: ["Basic"], optional: true });
91
-
92
- export class Opportunity extends SVGWidget {
93
- groupCount;
94
- svg;
95
- tooltipdiv;
96
- Column;
97
- MouseHoverColumn;
98
- ColumnDropdown;
99
-
100
- constructor() {
101
- super();
102
- this._drawStartPos = "origin";
103
- this.groupCount = 7;
104
- }
105
- enter(domNode, element) {
106
- super.enter(domNode, element);
107
- const paddingTop = 30;
108
- const nodeRectHeight = 14;
109
- const verticalPadding = 10;
110
- const h = (this.data().length + 1) * (nodeRectHeight + verticalPadding + 1) + paddingTop;
111
- this.svg = element.append("g")
112
- .attr("width", ((this.groupCount * 100) + 1))
113
- .attr("height", h);
114
- this.svg.append("defs").append("marker")
115
- .classed("arrowhead", true)
116
- .attr("id", "end-arrow")
117
- .attr("viewBox", "0 -5 10 10")
118
- .attr("refX", 6)
119
- .attr("markerWidth", 8)
120
- .attr("markerHeight", 8)
121
- .attr("orient", "auto")
122
- .append("svg:path")
123
- .attr("d", "M0,-5L10,0L0,5")
124
- .attr("fill", "rgb(100,100,100)");
125
- this.tooltipdiv = d3Select("body").append("div")
126
- .attr("class", "other_Opportunity-tooltip tooltip")
127
- .style("opacity", 0);
128
- }
129
- update(domNode, element) {
130
- super.update(domNode, element);
131
- const context = this;
132
- const data = this.data();
133
- const dropDownOption = this.opportunityId();
134
- data.sort(function (a, b) {
135
- if (a.cur_group > b.cur_group) return 1;
136
- else if (a.cur_group < b.cur_group) return -1;
137
- else return 0;
138
- });
139
- const groups = [];
140
- for (let i = 1; i <= context.groupCount; i++) {
141
- groups.push(i);
142
- }
143
- const paddingTop = 30;
144
- const nodeRectHeight = 14;
145
- const verticalPadding = 10;
146
- const h = (data.length + 1) * (nodeRectHeight + verticalPadding + 1) + paddingTop;
147
- const w = this.width();
148
- const nodeRectWidthPadding = 30;
149
- const nodeRectWidth = ((w / context.groupCount) - nodeRectWidthPadding);
150
- // Groups ---
151
- const group = this.svg.selectAll(".group").data(groups);
152
- group.enter().append("rect")
153
- .attr("class", "group");
154
- group
155
- .attr("x", function (d, i) {
156
- return (i * w / context.groupCount) + 1;
157
- })
158
- .attr("y", paddingTop)
159
- .attr("width", w / this.groupCount)
160
- .attr("height", h - paddingTop);
161
- group.exit().remove();
162
- // Group Headings ---
163
- const groupHeadings = this.svg.selectAll(".group_headings").data(groups);
164
- groupHeadings.enter().append("text")
165
- .attr("class", "group_headings")
166
- .attr("y", 20);
167
- groupHeadings
168
- .attr("x", function (d, i) {
169
- return (i * w / context.groupCount) + ((w / context.groupCount) / context.groupCount);
170
- })
171
- .text(function (d, i) {
172
- if (context.headerLabels().length > 0) {
173
- if (context.headerLabels()[i] && (context.headerLabels()[i]).headerLabel()) {
174
- return (context.headerLabels()[i]).headerLabel();
175
- }
176
- }
177
- return "";
178
- });
179
- groupHeadings.exit().remove();
180
- if (this.previousGroup() === "prev_group" && this.currentGroup() === "cur_group") {
181
- // Node Date Change ---
182
- const node_date_change = this.svg.selectAll(".node_date_change").data(data);
183
- node_date_change.enter().append("g")
184
- .attr("class", "node_date_change update")
185
- .on("mouseover", function (d) {
186
- context.tooltipdiv.transition()
187
- .duration(200)
188
- .style("opacity", 0.9);
189
- let htmlInput = "<span style='font-weight:bolder'>" + "Close Date Change " + "</span>" + "<br/>";
190
- const mouseHoverMapping = context.mouseHover();
191
- mouseHoverMapping.forEach(function (obj, index) {
192
- if (obj.hoverValue() !== undefined) {
193
- htmlInput = htmlInput + "<span style='font-weight:bold'>" + obj.hoverValue() + ": " + "</span>" + d[obj.hoverList()] + "<br/>";
194
- }
195
- });
196
- let prevDate = d.prevdate + "";
197
- prevDate = prevDate.replace(/(\d\d\d\d)(\d\d)(\d\d)/g, "$3-$2-$1");
198
- let fromDate = d.curdate + "";
199
- fromDate = fromDate.replace(/(\d\d\d\d)(\d\d)(\d\d)/g, "$3-$2-$1");
200
- htmlInput = htmlInput + "<span style='font-weight:bold'>" + "From: " + "</span>" + prevDate + "<br/>" + "<span style='font-weight:bold'>" + "To: " + "</span>" + fromDate + "<br/>";
201
- const event = d3Event();
202
- context.tooltipdiv.html(htmlInput)
203
- .style("left", (event.pageX) + "px")
204
- .style("top", (event.pageY - 50) + "px");
205
- })
206
- .on("mouseout", function (d) {
207
- context.tooltipdiv.transition()
208
- .duration(500)
209
- .style("opacity", 0);
210
- })
211
- .each(function (d) {
212
- const element2 = d3Select(this);
213
- element2.append("rect")
214
- .attr("class", "node_date_change_rect")
215
- .attr("width", 5)
216
- .attr("height", nodeRectHeight)
217
- .attr("rx", 6)
218
- .attr("ry", 6);
219
- });
220
- node_date_change
221
- .attr("transform", function (d, i) {
222
- return "translate(" + ((9 * w / context.groupCount) + (nodeRectWidthPadding) - 80) + "," + ((i + (i * (nodeRectHeight + verticalPadding))) + 12 + paddingTop) + ")";
223
- });
224
- node_date_change.exit().remove();
225
- // Node Prev Group ---
226
- const node_prev_group = this.svg.selectAll(".node_prev_group").data(data);
227
- node_prev_group.enter().append("g")
228
- .attr("class", "node_prev_group")
229
- .on("mouseover", function (d, i) {
230
- context.tooltipdiv.transition()
231
- .duration(200)
232
- .style("opacity", 0.9);
233
- let tooltipHtml = "";
234
- const mouseHoverMapping = context.mouseHover();
235
- mouseHoverMapping.forEach(function (obj, index) {
236
- if (obj.hoverValue() !== undefined) {
237
- tooltipHtml = tooltipHtml + "<span style='font-weight:bold'>" + obj.hoverValue() + ": " + "</span>" + d[obj.hoverList()] + "<br/>";
238
- }
239
- });
240
- const event = d3Event();
241
- context.tooltipdiv.html(tooltipHtml)
242
- .style("left", (event.pageX) + "px")
243
- .style("top", (event.pageY - 100) + "px");
244
- })
245
- .on("mouseout", function (d) {
246
- context.tooltipdiv.transition()
247
- .duration(500)
248
- .style("opacity", 0);
249
- })
250
- .each(function (d) {
251
- const element2 = d3Select(this);
252
- element2.append("rect")
253
- .attr("class", "node_prev_rect")
254
- .attr("rx", 6)
255
- .attr("ry", 6);
256
- element2.append("text")
257
- .attr("class", "node_prev_text");
258
- });
259
- node_prev_group
260
- .classed("update", true)
261
- .classed("changed", function (d) {
262
- return d.delta !== 0;
263
- })
264
- .attr("transform", function (d, i) {
265
- return "translate(" + ((((d.prev_group - 1)) * w / context.groupCount) + (nodeRectWidthPadding / 2)) + "," + ((i + (i * (nodeRectHeight + verticalPadding))) + 10 + paddingTop) + ")";
266
- })
267
- .each(function (d) {
268
- const element2 = d3Select(this);
269
- // Change Lines ---
270
- const changeLines = element2.selectAll(".arrow").data(d.delta !== 0 ? [d] : []);
271
- changeLines.enter().append("line")
272
- .attr("class", "arrow update");
273
- changeLines
274
- .attr("x1", function (d2) {
275
- return (d2.delta > 0) ? nodeRectWidth : 0;
276
- })
277
- .attr("y1", nodeRectHeight / 2)
278
- .attr("x2", function (d2) {
279
- return (d2.delta > 0) ? (nodeRectWidth + nodeRectWidthPadding - 4) + ((Math.abs(d2.delta) - 1)) * (w / context.groupCount) : ((-nodeRectWidthPadding - ((Math.abs(d2.delta) - 1)) * (w / context.groupCount)) + 4);
280
- })
281
- .attr("y2", nodeRectHeight / 2)
282
- .style("stroke-dasharray", ("3, 3"))
283
- .style("stroke", "rgb(100,100,100)")
284
- .style("marker-end", "url(#end-arrow)")
285
- .style("opacity", "1");
286
- changeLines.exit().remove();
287
- });
288
- const node_previous_rect = node_prev_group.select(".node_prev_rect");
289
- node_previous_rect
290
- .attr("width", nodeRectWidth)
291
- .attr("height", nodeRectHeight);
292
- const node_previous_text = node_prev_group.select(".node_prev_text");
293
- node_previous_text
294
- .attr("dy", (nodeRectHeight / 2) + 3)
295
- .attr("dx", (nodeRectWidth / 4))
296
- .text(function (d) {
297
- if (typeof d[dropDownOption] === "number")
298
- return d[dropDownOption];
299
- else
300
- return d[dropDownOption].substring(0, 14);
301
- });
302
- node_prev_group.exit().remove();
303
- // Node Cur Group ---
304
- const node_cur_group = this.svg.selectAll(".node_cur_group").data(data);
305
- node_cur_group.enter().append("g")
306
- .attr("class", "node_cur_group")
307
- .attr("transform", function (d, i) {
308
- return "translate(" + ((((d.prev_group - 1)) * w / context.groupCount) + (nodeRectWidthPadding / 2)) + "," + ((i + (i * (nodeRectHeight + verticalPadding))) + 10 + paddingTop) + ")";
309
- })
310
- .on("mouseover", function (d, i) {
311
- context.tooltipdiv.transition()
312
- .duration(200)
313
- .style("opacity", 0.9);
314
- let tooltipHtml = "";
315
- const mouseHoverMapping = context.mouseHover();
316
- mouseHoverMapping.forEach(function (obj, index) {
317
- if (obj.hoverValue() !== undefined) {
318
- tooltipHtml = tooltipHtml + "<span style='font-weight:bold'>" + obj.hoverValue() + ": " + "</span>" + d[obj.hoverList()] + "<br/>";
319
- }
320
- });
321
- const event = d3Event();
322
- context.tooltipdiv.html(tooltipHtml)
323
- .style("left", (event.pageX) + "px")
324
- .style("top", (event.pageY - 100) + "px");
325
- })
326
- .on("mouseout", function (d) {
327
- context.tooltipdiv.transition()
328
- .duration(500)
329
- .style("opacity", 0);
330
- })
331
- .each(function (d) {
332
- const element2 = d3Select(this);
333
- element2.append("rect")
334
- .attr("class", "node_cur_rect")
335
- .attr("fill", function (d2: any) {
336
- let color;
337
- if (d2.delta < 0 || d2.cur_group === 7) {
338
- color = "#F78181";
339
- } else {
340
- color = "#A9F5A9";
341
- }
342
- return color;
343
- })
344
- .attr("rx", 6)
345
- .attr("ry", 6);
346
- element2.append("a")
347
- .append("text")
348
- .attr("class", "node_cur_text");
349
- });
350
- node_cur_group
351
- .classed("update", true)
352
- .classed("changed", function (d) {
353
- return d.delta !== 0;
354
- })
355
- .transition().duration(800)
356
- .ease("linear")
357
- .attr("transform", function (d, i) {
358
- return "translate(" + ((((d.cur_group) - 1) * w / context.groupCount) + (nodeRectWidthPadding / 2)) + "," + ((i + (i * (nodeRectHeight + verticalPadding))) + 10 + paddingTop) + ")";
359
- })
360
- .each("end", function () {
361
- d3SelectAll(".arrow").style("opacity", "1");
362
- });
363
- const node_current_anchor = node_cur_group.select(".node_cur_group a");
364
- node_current_anchor.classed("update", true)
365
- .attr("xlink:href", function (d) {
366
- return context.url() + d.id;
367
- })
368
- .attr("xlink:show", "new");
369
- const node_current_rect = node_cur_group.select(".node_cur_rect");
370
- node_current_rect
371
- .attr("width", nodeRectWidth)
372
- .attr("height", nodeRectHeight);
373
- const node_current_text = node_cur_group.select(".node_cur_text");
374
- node_current_text
375
- .classed("update", true)
376
- .attr("dy", (nodeRectHeight / 2) + 3)
377
- .attr("dx", (nodeRectWidth / 4))
378
- .style("fill", "blue")
379
- .text(function (d) {
380
- if (typeof d[dropDownOption] === "number")
381
- return d[dropDownOption];
382
- else
383
- return d[dropDownOption].substring(0, 14);
384
- });
385
- node_cur_group.exit().remove();
386
- }
387
- for (let colIndex = 0; colIndex < context.columnData().length; colIndex++) {
388
- if ((context.columnData()[colIndex]) && (context.columnData()[colIndex]).ColumnDropdownList()) {
389
- const columnData = this.svg.selectAll(".columnDataText_" + colIndex).data(data);
390
- columnData.enter().append("g")
391
- .attr("class", "columnDataText_" + colIndex + " update")
392
- .each(function (d) {
393
- const element2 = d3Select(this);
394
- element2.append("text");
395
- });
396
- columnData
397
- .attr("transform", function (d, i) {
398
- return "translate(" + (((context.columnData()[colIndex]).columnIndex() * w / context.groupCount) + (nodeRectWidthPadding / 2)) + "," + ((i + (i * (nodeRectHeight + verticalPadding))) + 12 + paddingTop) + ")";
399
- })
400
- .attr("width", 5)
401
- .attr("height", nodeRectHeight)
402
- .attr("rx", 6)
403
- .attr("ry", 6);
404
- const textLable = columnData.select("text");
405
- textLable
406
- .attr("y", -6)
407
- .attr("dy", (nodeRectHeight) + 14)
408
- .attr("dx", 0)
409
- .attr("height", 20)
410
- .attr("width", 29)
411
- .text(function (d, i) {
412
- return d[(context.columnData()[colIndex]).ColumnDropdownList()];
413
- });
414
- columnData.exit().remove();
415
- }
416
- }
417
- }
418
- exit(domNode, element) {
419
- super.exit(domNode, element);
420
- }
421
-
422
- getIds() {
423
- const dropdownList = this.columns();
424
- dropdownList.unshift("default");
425
- return dropdownList;
426
- }
427
- }
428
- Opportunity.prototype._class += " other_Opportunity";
429
- Opportunity.prototype.Column = Column;
430
- Opportunity.prototype.MouseHoverColumn = MouseHoverColumn;
431
- Opportunity.prototype.ColumnDropdown = ColumnDropdown;
432
-
433
- export interface Opportunity {
434
- previousGroup(): string;
435
- previousGroup(_: string): this;
436
- previousGroup_exists(): boolean;
437
- currentGroup(): string;
438
- currentGroup(_: string): this;
439
- currentGroup_exists(): boolean;
440
- opportunityId(): string;
441
- opportunityId(_: string): this;
442
- opportunityId_exists(): boolean
443
- url(): string;
444
- url(_: string): this;
445
- url_exists(): boolean;
446
- // width(): number;
447
- // width(_: number): this;
448
- addColumn(): string;
449
- addColumn(_: string): this;
450
- addColumn_exists(): boolean;
451
- removeColumn(): string;
452
- removeColumn(_: string): this;
453
- removeColumn_exists(): boolean;
454
- headerLabels(): any[];
455
- headerLabels(_: any[]): this;
456
- headerLabels_exists(): boolean;
457
- mouseHover(): any[];
458
- mouseHover(_: any[]): this;
459
- mouseHover_exists(): boolean;
460
- columnData(): any[];
461
- columnData(_: any[]): this;
462
- columnData_exists(): boolean;
463
- }
464
-
465
- Opportunity.prototype.publish("previousGroup", "", "set", "label in Opportunity", function () { return this.getIds(); }, { tags: ["Basic", "Shared"] });
466
- Opportunity.prototype.publish("currentGroup", "", "set", "label in Opportunity", function () { return this.getIds(); }, { tags: ["Basic", "Shared"] });
467
- Opportunity.prototype.publish("opportunityId", "id", "set", "Id for label in Opportunity", function () { return this.getIds(); }, { tags: ["Basic", "Shared"] });
468
- Opportunity.prototype.publish("url", null, "string", "URL in Opportunity", {}, { tags: ["Basic", "Shared"] });
469
- Opportunity.prototype.publish("width", 1100, "number", "label in Opportunity", {}, { tags: ["Basic", "Shared"] });
470
- Opportunity.prototype.publish("addColumn", null, "string", "number of columns in a table", {}, {
471
- tags: ["Basic", "Shared"],
472
- editor_input: (context, widget, cell, param) => {
473
- cell.append("button")
474
- .attr("id", context.id() + "_addColumn" + param.id)
475
- .classed("property-input custom-editor-input addColumn update", true)
476
- .text("AddColumn")
477
- .on("click", function () {
478
- widget.groupCount = widget.groupCount + 1;
479
- const new_value_after_click = "Added a new column";
480
- context.setProperty(widget, param.id, new_value_after_click);
481
- });
482
- }
483
- });
484
- Opportunity.prototype.publish("removeColumn", null, "string", "number of columns in a table", function () { return this.columns(); }, {
485
- tags: ["Basic", "Shared"],
486
- editor_input: (context, widget, cell, param) => {
487
- cell.append("button")
488
- .attr("id", context.id() + "_removeColumn" + param.id)
489
- .classed("property-input custom-editor-input removeColumn update", true)
490
- .text("RemoveColumn")
491
- .on("click", function () {
492
- widget.groupCount = widget.groupCount - 1;
493
- const new_value_after_click = "Removed a column";
494
- context.setProperty(widget, param.id, new_value_after_click);
495
- });
496
- }
497
- });
498
- Opportunity.prototype.publish("headerLabels", [], "propertyArray", "Source Columns", null, { autoExpand: Column });
499
- Opportunity.prototype.publish("mouseHover", [], "propertyArray", "mouse hover options", null, { autoExpand: MouseHoverColumn });
500
- Opportunity.prototype.publish("columnData", [], "propertyArray", "column data", null, { autoExpand: ColumnDropdown });
1
+ import { d3Event, PropertyExt, select as d3Select, selectAll as d3SelectAll, SVGWidget } from "@hpcc-js/common";
2
+
3
+ import "../src/Opportunity.css";
4
+
5
+ export class Column extends PropertyExt {
6
+ _owner: Opportunity;
7
+
8
+ constructor() {
9
+ super();
10
+ }
11
+
12
+ owner(): Opportunity;
13
+ owner(_: Opportunity): this;
14
+ owner(_?: Opportunity): Opportunity | this {
15
+ if (!arguments.length) return this._owner;
16
+ this._owner = _;
17
+ return this;
18
+ }
19
+
20
+ valid(): boolean {
21
+ return !!this.headerLabel();
22
+ }
23
+ }
24
+ Column.prototype._class += " other_Opportunity.Column";
25
+
26
+ export interface Column {
27
+ headerLabel(): string;
28
+ headerLabel(_: string): this;
29
+ }
30
+ Column.prototype.publish("headerLabel", null, "string", "Header value of a table", function (this: Column) { return this._owner ? this._owner.columns() : []; }, { tags: ["Basic"], optional: true });
31
+
32
+ export class MouseHoverColumn extends PropertyExt {
33
+ _owner: Opportunity;
34
+
35
+ constructor() {
36
+ super();
37
+ }
38
+
39
+ owner(): Opportunity;
40
+ owner(_: Opportunity): this;
41
+ owner(_?: Opportunity): Opportunity | this {
42
+ if (!arguments.length) return this._owner;
43
+ this._owner = _;
44
+ return this;
45
+ }
46
+
47
+ valid(): boolean {
48
+ return !!this.hoverValue() && !!this.hoverList();
49
+ }
50
+ }
51
+ MouseHoverColumn.prototype._class += " other_Opportunity.MouseHoverColumn";
52
+
53
+ export interface MouseHoverColumn {
54
+ hoverValue(): string;
55
+ hoverValue(_: string): this;
56
+ hoverList(): string;
57
+ hoverList(_: string): this;
58
+ }
59
+ MouseHoverColumn.prototype.publish("hoverValue", null, "string", "Hover value of a table", function () { return this._owner ? this._owner.columns() : []; }, { tags: ["Basic"], optional: true });
60
+ MouseHoverColumn.prototype.publish("hoverList", null, "set", "Hover value of a table", function () { return this._owner ? this._owner.getIds() : []; }, { tags: ["Basic"], optional: true });
61
+
62
+ export class ColumnDropdown extends PropertyExt {
63
+ _owner: Opportunity;
64
+
65
+ constructor() {
66
+ super();
67
+ }
68
+
69
+ owner(): Opportunity;
70
+ owner(_: Opportunity): this;
71
+ owner(_?: Opportunity): Opportunity | this {
72
+ if (!arguments.length) return this._owner;
73
+ this._owner = _;
74
+ return this;
75
+ }
76
+
77
+ valid(): boolean {
78
+ return !!this.columnIndex() && !!this.ColumnDropdownList();
79
+ }
80
+ }
81
+ ColumnDropdown.prototype._class += " other_Opportunity.ColumnDropdown";
82
+
83
+ export interface ColumnDropdown {
84
+ columnIndex(): number;
85
+ columnIndex(_: number): this;
86
+ ColumnDropdownList(): string;
87
+ ColumnDropdownList(_: string): this;
88
+ }
89
+ ColumnDropdown.prototype.publish("columnIndex", null, "number", "Column index for display context data based on column dropdown list selction", {}, { tags: ["Basic", "Shared"] });
90
+ ColumnDropdown.prototype.publish("ColumnDropdownList", null, "set", "column value of a table", function () { return this._owner ? this._owner.getIds() : []; }, { tags: ["Basic"], optional: true });
91
+
92
+ export class Opportunity extends SVGWidget {
93
+ groupCount;
94
+ svg;
95
+ tooltipdiv;
96
+ Column;
97
+ MouseHoverColumn;
98
+ ColumnDropdown;
99
+
100
+ constructor() {
101
+ super();
102
+ this._drawStartPos = "origin";
103
+ this.groupCount = 7;
104
+ }
105
+ enter(domNode, element) {
106
+ super.enter(domNode, element);
107
+ const paddingTop = 30;
108
+ const nodeRectHeight = 14;
109
+ const verticalPadding = 10;
110
+ const h = (this.data().length + 1) * (nodeRectHeight + verticalPadding + 1) + paddingTop;
111
+ this.svg = element.append("g")
112
+ .attr("width", ((this.groupCount * 100) + 1))
113
+ .attr("height", h);
114
+ this.svg.append("defs").append("marker")
115
+ .classed("arrowhead", true)
116
+ .attr("id", "end-arrow")
117
+ .attr("viewBox", "0 -5 10 10")
118
+ .attr("refX", 6)
119
+ .attr("markerWidth", 8)
120
+ .attr("markerHeight", 8)
121
+ .attr("orient", "auto")
122
+ .append("svg:path")
123
+ .attr("d", "M0,-5L10,0L0,5")
124
+ .attr("fill", "rgb(100,100,100)");
125
+ this.tooltipdiv = d3Select("body").append("div")
126
+ .attr("class", "other_Opportunity-tooltip tooltip")
127
+ .style("opacity", 0);
128
+ }
129
+ update(domNode, element) {
130
+ super.update(domNode, element);
131
+ const context = this;
132
+ const data = this.data();
133
+ const dropDownOption = this.opportunityId();
134
+ data.sort(function (a, b) {
135
+ if (a.cur_group > b.cur_group) return 1;
136
+ else if (a.cur_group < b.cur_group) return -1;
137
+ else return 0;
138
+ });
139
+ const groups = [];
140
+ for (let i = 1; i <= context.groupCount; i++) {
141
+ groups.push(i);
142
+ }
143
+ const paddingTop = 30;
144
+ const nodeRectHeight = 14;
145
+ const verticalPadding = 10;
146
+ const h = (data.length + 1) * (nodeRectHeight + verticalPadding + 1) + paddingTop;
147
+ const w = this.width();
148
+ const nodeRectWidthPadding = 30;
149
+ const nodeRectWidth = ((w / context.groupCount) - nodeRectWidthPadding);
150
+ // Groups ---
151
+ const group = this.svg.selectAll(".group").data(groups);
152
+ group.enter().append("rect")
153
+ .attr("class", "group");
154
+ group
155
+ .attr("x", function (d, i) {
156
+ return (i * w / context.groupCount) + 1;
157
+ })
158
+ .attr("y", paddingTop)
159
+ .attr("width", w / this.groupCount)
160
+ .attr("height", h - paddingTop);
161
+ group.exit().remove();
162
+ // Group Headings ---
163
+ const groupHeadings = this.svg.selectAll(".group_headings").data(groups);
164
+ groupHeadings.enter().append("text")
165
+ .attr("class", "group_headings")
166
+ .attr("y", 20);
167
+ groupHeadings
168
+ .attr("x", function (d, i) {
169
+ return (i * w / context.groupCount) + ((w / context.groupCount) / context.groupCount);
170
+ })
171
+ .text(function (d, i) {
172
+ if (context.headerLabels().length > 0) {
173
+ if (context.headerLabels()[i] && (context.headerLabels()[i]).headerLabel()) {
174
+ return (context.headerLabels()[i]).headerLabel();
175
+ }
176
+ }
177
+ return "";
178
+ });
179
+ groupHeadings.exit().remove();
180
+ if (this.previousGroup() === "prev_group" && this.currentGroup() === "cur_group") {
181
+ // Node Date Change ---
182
+ const node_date_change = this.svg.selectAll(".node_date_change").data(data);
183
+ node_date_change.enter().append("g")
184
+ .attr("class", "node_date_change update")
185
+ .on("mouseover", function (d) {
186
+ context.tooltipdiv.transition()
187
+ .duration(200)
188
+ .style("opacity", 0.9);
189
+ let htmlInput = "<span style='font-weight:bolder'>" + "Close Date Change " + "</span>" + "<br/>";
190
+ const mouseHoverMapping = context.mouseHover();
191
+ mouseHoverMapping.forEach(function (obj, index) {
192
+ if (obj.hoverValue() !== undefined) {
193
+ htmlInput = htmlInput + "<span style='font-weight:bold'>" + obj.hoverValue() + ": " + "</span>" + d[obj.hoverList()] + "<br/>";
194
+ }
195
+ });
196
+ let prevDate = d.prevdate + "";
197
+ prevDate = prevDate.replace(/(\d\d\d\d)(\d\d)(\d\d)/g, "$3-$2-$1");
198
+ let fromDate = d.curdate + "";
199
+ fromDate = fromDate.replace(/(\d\d\d\d)(\d\d)(\d\d)/g, "$3-$2-$1");
200
+ htmlInput = htmlInput + "<span style='font-weight:bold'>" + "From: " + "</span>" + prevDate + "<br/>" + "<span style='font-weight:bold'>" + "To: " + "</span>" + fromDate + "<br/>";
201
+ const event = d3Event();
202
+ context.tooltipdiv.html(htmlInput)
203
+ .style("left", (event.pageX) + "px")
204
+ .style("top", (event.pageY - 50) + "px");
205
+ })
206
+ .on("mouseout", function (d) {
207
+ context.tooltipdiv.transition()
208
+ .duration(500)
209
+ .style("opacity", 0);
210
+ })
211
+ .each(function (d) {
212
+ const element2 = d3Select(this);
213
+ element2.append("rect")
214
+ .attr("class", "node_date_change_rect")
215
+ .attr("width", 5)
216
+ .attr("height", nodeRectHeight)
217
+ .attr("rx", 6)
218
+ .attr("ry", 6);
219
+ });
220
+ node_date_change
221
+ .attr("transform", function (d, i) {
222
+ return "translate(" + ((9 * w / context.groupCount) + (nodeRectWidthPadding) - 80) + "," + ((i + (i * (nodeRectHeight + verticalPadding))) + 12 + paddingTop) + ")";
223
+ });
224
+ node_date_change.exit().remove();
225
+ // Node Prev Group ---
226
+ const node_prev_group = this.svg.selectAll(".node_prev_group").data(data);
227
+ node_prev_group.enter().append("g")
228
+ .attr("class", "node_prev_group")
229
+ .on("mouseover", function (d, i) {
230
+ context.tooltipdiv.transition()
231
+ .duration(200)
232
+ .style("opacity", 0.9);
233
+ let tooltipHtml = "";
234
+ const mouseHoverMapping = context.mouseHover();
235
+ mouseHoverMapping.forEach(function (obj, index) {
236
+ if (obj.hoverValue() !== undefined) {
237
+ tooltipHtml = tooltipHtml + "<span style='font-weight:bold'>" + obj.hoverValue() + ": " + "</span>" + d[obj.hoverList()] + "<br/>";
238
+ }
239
+ });
240
+ const event = d3Event();
241
+ context.tooltipdiv.html(tooltipHtml)
242
+ .style("left", (event.pageX) + "px")
243
+ .style("top", (event.pageY - 100) + "px");
244
+ })
245
+ .on("mouseout", function (d) {
246
+ context.tooltipdiv.transition()
247
+ .duration(500)
248
+ .style("opacity", 0);
249
+ })
250
+ .each(function (d) {
251
+ const element2 = d3Select(this);
252
+ element2.append("rect")
253
+ .attr("class", "node_prev_rect")
254
+ .attr("rx", 6)
255
+ .attr("ry", 6);
256
+ element2.append("text")
257
+ .attr("class", "node_prev_text");
258
+ });
259
+ node_prev_group
260
+ .classed("update", true)
261
+ .classed("changed", function (d) {
262
+ return d.delta !== 0;
263
+ })
264
+ .attr("transform", function (d, i) {
265
+ return "translate(" + ((((d.prev_group - 1)) * w / context.groupCount) + (nodeRectWidthPadding / 2)) + "," + ((i + (i * (nodeRectHeight + verticalPadding))) + 10 + paddingTop) + ")";
266
+ })
267
+ .each(function (d) {
268
+ const element2 = d3Select(this);
269
+ // Change Lines ---
270
+ const changeLines = element2.selectAll(".arrow").data(d.delta !== 0 ? [d] : []);
271
+ changeLines.enter().append("line")
272
+ .attr("class", "arrow update");
273
+ changeLines
274
+ .attr("x1", function (d2) {
275
+ return (d2.delta > 0) ? nodeRectWidth : 0;
276
+ })
277
+ .attr("y1", nodeRectHeight / 2)
278
+ .attr("x2", function (d2) {
279
+ return (d2.delta > 0) ? (nodeRectWidth + nodeRectWidthPadding - 4) + ((Math.abs(d2.delta) - 1)) * (w / context.groupCount) : ((-nodeRectWidthPadding - ((Math.abs(d2.delta) - 1)) * (w / context.groupCount)) + 4);
280
+ })
281
+ .attr("y2", nodeRectHeight / 2)
282
+ .style("stroke-dasharray", ("3, 3"))
283
+ .style("stroke", "rgb(100,100,100)")
284
+ .style("marker-end", "url(#end-arrow)")
285
+ .style("opacity", "1");
286
+ changeLines.exit().remove();
287
+ });
288
+ const node_previous_rect = node_prev_group.select(".node_prev_rect");
289
+ node_previous_rect
290
+ .attr("width", nodeRectWidth)
291
+ .attr("height", nodeRectHeight);
292
+ const node_previous_text = node_prev_group.select(".node_prev_text");
293
+ node_previous_text
294
+ .attr("dy", (nodeRectHeight / 2) + 3)
295
+ .attr("dx", (nodeRectWidth / 4))
296
+ .text(function (d) {
297
+ if (typeof d[dropDownOption] === "number")
298
+ return d[dropDownOption];
299
+ else
300
+ return d[dropDownOption].substring(0, 14);
301
+ });
302
+ node_prev_group.exit().remove();
303
+ // Node Cur Group ---
304
+ const node_cur_group = this.svg.selectAll(".node_cur_group").data(data);
305
+ node_cur_group.enter().append("g")
306
+ .attr("class", "node_cur_group")
307
+ .attr("transform", function (d, i) {
308
+ return "translate(" + ((((d.prev_group - 1)) * w / context.groupCount) + (nodeRectWidthPadding / 2)) + "," + ((i + (i * (nodeRectHeight + verticalPadding))) + 10 + paddingTop) + ")";
309
+ })
310
+ .on("mouseover", function (d, i) {
311
+ context.tooltipdiv.transition()
312
+ .duration(200)
313
+ .style("opacity", 0.9);
314
+ let tooltipHtml = "";
315
+ const mouseHoverMapping = context.mouseHover();
316
+ mouseHoverMapping.forEach(function (obj, index) {
317
+ if (obj.hoverValue() !== undefined) {
318
+ tooltipHtml = tooltipHtml + "<span style='font-weight:bold'>" + obj.hoverValue() + ": " + "</span>" + d[obj.hoverList()] + "<br/>";
319
+ }
320
+ });
321
+ const event = d3Event();
322
+ context.tooltipdiv.html(tooltipHtml)
323
+ .style("left", (event.pageX) + "px")
324
+ .style("top", (event.pageY - 100) + "px");
325
+ })
326
+ .on("mouseout", function (d) {
327
+ context.tooltipdiv.transition()
328
+ .duration(500)
329
+ .style("opacity", 0);
330
+ })
331
+ .each(function (d) {
332
+ const element2 = d3Select(this);
333
+ element2.append("rect")
334
+ .attr("class", "node_cur_rect")
335
+ .attr("fill", function (d2: any) {
336
+ let color;
337
+ if (d2.delta < 0 || d2.cur_group === 7) {
338
+ color = "#F78181";
339
+ } else {
340
+ color = "#A9F5A9";
341
+ }
342
+ return color;
343
+ })
344
+ .attr("rx", 6)
345
+ .attr("ry", 6);
346
+ element2.append("a")
347
+ .append("text")
348
+ .attr("class", "node_cur_text");
349
+ });
350
+ node_cur_group
351
+ .classed("update", true)
352
+ .classed("changed", function (d) {
353
+ return d.delta !== 0;
354
+ })
355
+ .transition().duration(800)
356
+ .ease("linear")
357
+ .attr("transform", function (d, i) {
358
+ return "translate(" + ((((d.cur_group) - 1) * w / context.groupCount) + (nodeRectWidthPadding / 2)) + "," + ((i + (i * (nodeRectHeight + verticalPadding))) + 10 + paddingTop) + ")";
359
+ })
360
+ .each("end", function () {
361
+ d3SelectAll(".arrow").style("opacity", "1");
362
+ });
363
+ const node_current_anchor = node_cur_group.select(".node_cur_group a");
364
+ node_current_anchor.classed("update", true)
365
+ .attr("xlink:href", function (d) {
366
+ return context.url() + d.id;
367
+ })
368
+ .attr("xlink:show", "new");
369
+ const node_current_rect = node_cur_group.select(".node_cur_rect");
370
+ node_current_rect
371
+ .attr("width", nodeRectWidth)
372
+ .attr("height", nodeRectHeight);
373
+ const node_current_text = node_cur_group.select(".node_cur_text");
374
+ node_current_text
375
+ .classed("update", true)
376
+ .attr("dy", (nodeRectHeight / 2) + 3)
377
+ .attr("dx", (nodeRectWidth / 4))
378
+ .style("fill", "blue")
379
+ .text(function (d) {
380
+ if (typeof d[dropDownOption] === "number")
381
+ return d[dropDownOption];
382
+ else
383
+ return d[dropDownOption].substring(0, 14);
384
+ });
385
+ node_cur_group.exit().remove();
386
+ }
387
+ for (let colIndex = 0; colIndex < context.columnData().length; colIndex++) {
388
+ if ((context.columnData()[colIndex]) && (context.columnData()[colIndex]).ColumnDropdownList()) {
389
+ const columnData = this.svg.selectAll(".columnDataText_" + colIndex).data(data);
390
+ columnData.enter().append("g")
391
+ .attr("class", "columnDataText_" + colIndex + " update")
392
+ .each(function (d) {
393
+ const element2 = d3Select(this);
394
+ element2.append("text");
395
+ });
396
+ columnData
397
+ .attr("transform", function (d, i) {
398
+ return "translate(" + (((context.columnData()[colIndex]).columnIndex() * w / context.groupCount) + (nodeRectWidthPadding / 2)) + "," + ((i + (i * (nodeRectHeight + verticalPadding))) + 12 + paddingTop) + ")";
399
+ })
400
+ .attr("width", 5)
401
+ .attr("height", nodeRectHeight)
402
+ .attr("rx", 6)
403
+ .attr("ry", 6);
404
+ const textLable = columnData.select("text");
405
+ textLable
406
+ .attr("y", -6)
407
+ .attr("dy", (nodeRectHeight) + 14)
408
+ .attr("dx", 0)
409
+ .attr("height", 20)
410
+ .attr("width", 29)
411
+ .text(function (d, i) {
412
+ return d[(context.columnData()[colIndex]).ColumnDropdownList()];
413
+ });
414
+ columnData.exit().remove();
415
+ }
416
+ }
417
+ }
418
+ exit(domNode, element) {
419
+ super.exit(domNode, element);
420
+ }
421
+
422
+ getIds() {
423
+ const dropdownList = this.columns();
424
+ dropdownList.unshift("default");
425
+ return dropdownList;
426
+ }
427
+ }
428
+ Opportunity.prototype._class += " other_Opportunity";
429
+ Opportunity.prototype.Column = Column;
430
+ Opportunity.prototype.MouseHoverColumn = MouseHoverColumn;
431
+ Opportunity.prototype.ColumnDropdown = ColumnDropdown;
432
+
433
+ export interface Opportunity {
434
+ previousGroup(): string;
435
+ previousGroup(_: string): this;
436
+ previousGroup_exists(): boolean;
437
+ currentGroup(): string;
438
+ currentGroup(_: string): this;
439
+ currentGroup_exists(): boolean;
440
+ opportunityId(): string;
441
+ opportunityId(_: string): this;
442
+ opportunityId_exists(): boolean
443
+ url(): string;
444
+ url(_: string): this;
445
+ url_exists(): boolean;
446
+ // width(): number;
447
+ // width(_: number): this;
448
+ addColumn(): string;
449
+ addColumn(_: string): this;
450
+ addColumn_exists(): boolean;
451
+ removeColumn(): string;
452
+ removeColumn(_: string): this;
453
+ removeColumn_exists(): boolean;
454
+ headerLabels(): any[];
455
+ headerLabels(_: any[]): this;
456
+ headerLabels_exists(): boolean;
457
+ mouseHover(): any[];
458
+ mouseHover(_: any[]): this;
459
+ mouseHover_exists(): boolean;
460
+ columnData(): any[];
461
+ columnData(_: any[]): this;
462
+ columnData_exists(): boolean;
463
+ }
464
+
465
+ Opportunity.prototype.publish("previousGroup", "", "set", "label in Opportunity", function () { return this.getIds(); }, { tags: ["Basic", "Shared"] });
466
+ Opportunity.prototype.publish("currentGroup", "", "set", "label in Opportunity", function () { return this.getIds(); }, { tags: ["Basic", "Shared"] });
467
+ Opportunity.prototype.publish("opportunityId", "id", "set", "Id for label in Opportunity", function () { return this.getIds(); }, { tags: ["Basic", "Shared"] });
468
+ Opportunity.prototype.publish("url", null, "string", "URL in Opportunity", {}, { tags: ["Basic", "Shared"] });
469
+ Opportunity.prototype.publish("width", 1100, "number", "label in Opportunity", {}, { tags: ["Basic", "Shared"] });
470
+ Opportunity.prototype.publish("addColumn", null, "string", "number of columns in a table", {}, {
471
+ tags: ["Basic", "Shared"],
472
+ editor_input: (context, widget, cell, param) => {
473
+ cell.append("button")
474
+ .attr("id", context.id() + "_addColumn" + param.id)
475
+ .classed("property-input custom-editor-input addColumn update", true)
476
+ .text("AddColumn")
477
+ .on("click", function () {
478
+ widget.groupCount = widget.groupCount + 1;
479
+ const new_value_after_click = "Added a new column";
480
+ context.setProperty(widget, param.id, new_value_after_click);
481
+ });
482
+ }
483
+ });
484
+ Opportunity.prototype.publish("removeColumn", null, "string", "number of columns in a table", function () { return this.columns(); }, {
485
+ tags: ["Basic", "Shared"],
486
+ editor_input: (context, widget, cell, param) => {
487
+ cell.append("button")
488
+ .attr("id", context.id() + "_removeColumn" + param.id)
489
+ .classed("property-input custom-editor-input removeColumn update", true)
490
+ .text("RemoveColumn")
491
+ .on("click", function () {
492
+ widget.groupCount = widget.groupCount - 1;
493
+ const new_value_after_click = "Removed a column";
494
+ context.setProperty(widget, param.id, new_value_after_click);
495
+ });
496
+ }
497
+ });
498
+ Opportunity.prototype.publish("headerLabels", [], "propertyArray", "Source Columns", null, { autoExpand: Column });
499
+ Opportunity.prototype.publish("mouseHover", [], "propertyArray", "mouse hover options", null, { autoExpand: MouseHoverColumn });
500
+ Opportunity.prototype.publish("columnData", [], "propertyArray", "column data", null, { autoExpand: ColumnDropdown });