1
1
import { Component , ViewChild , ViewEncapsulation } from '@angular/core' ;
2
- import { ContextMenuComponent , ContextMenuSelectEvent , MenusModule } from "@progress/kendo-angular-menu" ;
3
- import { CellClickEvent , ExcelModule , GridComponent , GridModule , SelectableSettings } from "@progress/kendo-angular-grid" ;
2
+ import {
3
+ ContextMenuComponent ,
4
+ ContextMenuSelectEvent ,
5
+ MenusModule ,
6
+ } from '@progress/kendo-angular-menu' ;
7
+ import {
8
+ CellClickEvent ,
9
+ ExcelModule ,
10
+ GridComponent ,
11
+ GridModule ,
12
+ SelectableSettings ,
13
+ } from '@progress/kendo-angular-grid' ;
4
14
import { IconsModule } from '@progress/kendo-angular-icons' ;
5
15
import { SVGIcon , infoCircleIcon } from '@progress/kendo-svg-icons' ;
6
16
import { ChartConfig , Stock } from '../../model' ;
@@ -18,82 +28,96 @@ import { CommonModule } from '@angular/common';
18
28
@Component ( {
19
29
selector : 'app-stock-list' ,
20
30
standalone : true ,
21
- imports : [ MenusModule , GridModule , IconsModule , NumberFormatPipe , DialogsModule , ExcelModule , WindowComponent , DayChartComponent , WindowComponent , CommonModule ] ,
31
+ imports : [
32
+ MenusModule ,
33
+ GridModule ,
34
+ IconsModule ,
35
+ NumberFormatPipe ,
36
+ DialogsModule ,
37
+ ExcelModule ,
38
+ WindowComponent ,
39
+ DayChartComponent ,
40
+ WindowComponent ,
41
+ CommonModule ,
42
+ ] ,
22
43
templateUrl : './stock-list.component.html' ,
23
44
styleUrl : './stock-list.component.scss' ,
24
- encapsulation : ViewEncapsulation . None
45
+ encapsulation : ViewEncapsulation . None ,
25
46
} )
26
47
export class StockListComponent {
27
- @ViewChild ( 'gridmenu' ) public gridContextMenu : ContextMenuComponent | undefined ;
28
- @ViewChild ( 'grid' ) public grid : GridComponent | undefined ;
48
+ @ViewChild ( 'gridmenu' ) public gridContextMenu :
49
+ | ContextMenuComponent
50
+ | undefined ;
51
+ @ViewChild ( 'grid' ) public grid : GridComponent | undefined ;
29
52
30
- public infoIcon : SVGIcon = infoCircleIcon ;
53
+ public infoIcon : SVGIcon = infoCircleIcon ;
31
54
32
- public items : object [ ] = menuItems ;
33
- public opened = false ;
34
- public chartConfiguration : ChartConfig = { seriesType : 'line' , stack : false } ;
35
- public gridData : Stock [ ] = stocksInPortfolio ;
36
- public selectableSettings : SelectableSettings = {
37
- checkboxOnly : false ,
38
- mode : 'multiple'
39
- } ;
40
- public mySelection : Stock [ ] = stocksInPortfolio . slice ( 0 , 4 ) ;
55
+ public items : object [ ] = menuItems ;
56
+ public opened = false ;
57
+ public chartConfiguration : ChartConfig = { seriesType : 'line' , stack : false } ;
58
+ public gridData : Stock [ ] = stocksInPortfolio ;
59
+ public selectableSettings : SelectableSettings = {
60
+ checkboxOnly : false ,
61
+ mode : 'multiple' ,
62
+ drag : true ,
63
+ } ;
64
+ public mySelection : Stock [ ] = stocksInPortfolio . slice ( 0 , 4 ) ;
41
65
42
- constructor ( ) {
43
- this . allData = this . allData . bind ( this ) ;
44
- }
66
+ constructor ( ) {
67
+ this . allData = this . allData . bind ( this ) ;
68
+ }
45
69
46
- public onCellClick ( e : CellClickEvent ) : void {
47
- if ( e . type === 'contextmenu' ) {
48
- const originalEvent = e . originalEvent ;
49
- originalEvent . preventDefault ( ) ;
50
- this . gridContextMenu ?. show ( {
51
- left : originalEvent . pageX ,
52
- top : originalEvent . pageY
53
- } ) ;
54
- }
70
+ public onCellClick ( e : CellClickEvent ) : void {
71
+ if ( e . type === 'contextmenu' ) {
72
+ const originalEvent = e . originalEvent ;
73
+ originalEvent . preventDefault ( ) ;
74
+ this . gridContextMenu ?. show ( {
75
+ left : originalEvent . pageX ,
76
+ top : originalEvent . pageY ,
77
+ } ) ;
55
78
}
79
+ }
56
80
57
- public selectBy ( e : any ) {
58
- return e . dataItem ;
59
- }
81
+ public selectBy ( e : any ) {
82
+ return e . dataItem ;
83
+ }
60
84
61
- public onSelectionChange ( ) {
62
- if ( this . opened ) {
63
- setTimeout ( ( ) => {
64
- this . mySelection = [ ...this . mySelection ] ;
65
- } ) ;
66
- }
85
+ public onSelectionChange ( ) {
86
+ if ( this . opened ) {
87
+ setTimeout ( ( ) => {
88
+ this . mySelection = [ ...this . mySelection ] ;
89
+ } ) ;
67
90
}
91
+ }
68
92
69
- public onSelect ( e : ContextMenuSelectEvent ) : void {
70
- if ( e . item . text === 'Charts' || e . item . items !== undefined ) {
71
- return ;
72
- }
73
-
74
- if ( e . item . text === 'Export Excel' ) {
75
- this . grid ?. saveAsExcel ( ) ;
76
- } else {
77
- this . chartConfiguration = {
78
- chartName : e . item . text ,
79
- seriesType : getChartType ( e . item . text ) as SeriesType ,
80
- stack : getChartStack ( e . item . text )
81
- } ;
82
- if ( ! this . opened ) {
83
- this . opened = true ;
84
- }
85
- this . gridContextMenu ?. hide ( ) ;
86
- }
93
+ public onSelect ( e : ContextMenuSelectEvent ) : void {
94
+ if ( e . item . text === 'Charts' || e . item . items !== undefined ) {
95
+ return ;
87
96
}
88
97
89
- public allData ( ) {
90
- const result = {
91
- data : this . mySelection ,
92
- } ;
93
- return result ;
98
+ if ( e . item . text === 'Export Excel' ) {
99
+ this . grid ?. saveAsExcel ( ) ;
100
+ } else {
101
+ this . chartConfiguration = {
102
+ chartName : e . item . text ,
103
+ seriesType : getChartType ( e . item . text ) as SeriesType ,
104
+ stack : getChartStack ( e . item . text ) ,
105
+ } ;
106
+ if ( ! this . opened ) {
107
+ this . opened = true ;
108
+ }
109
+ this . gridContextMenu ?. hide ( ) ;
94
110
}
111
+ }
95
112
96
- public close ( ) {
97
- this . opened = false ;
98
- }
113
+ public allData ( ) {
114
+ const result = {
115
+ data : this . mySelection ,
116
+ } ;
117
+ return result ;
118
+ }
119
+
120
+ public close ( ) {
121
+ this . opened = false ;
122
+ }
99
123
}
0 commit comments