• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

IgniteUI / igniteui-angular / 12910018683

22 Jan 2025 02:11PM CUT coverage: 91.611% (-0.003%) from 91.614%
12910018683

Pull #15287

github

web-flow
Merge 063924f5f into d4bf5f615
Pull Request #15287: Use provided in open method partial overlay settings - 19.0

12990 of 15228 branches covered (85.3%)

2 of 2 new or added lines in 2 files covered. (100.0%)

1 existing line in 1 file now uncovered.

26339 of 28751 relevant lines covered (91.61%)

34025.79 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

33.33
/projects/igniteui-angular/src/lib/grids/toolbar/grid-toolbar-exporter.component.ts
1
import { Component, Input, Output, EventEmitter, Inject, booleanAttribute } from '@angular/core';
2
import { first } from 'rxjs/operators';
3
import { BaseToolbarDirective } from './grid-toolbar.base';
4
import { IgxExcelTextDirective, IgxCSVTextDirective } from './common';
5
import {
6
    CsvFileTypes,
7
    IgxBaseExporter,
8
    IgxCsvExporterOptions,
9
    IgxCsvExporterService,
10
    IgxExcelExporterOptions,
11
    IgxExcelExporterService
12
} from '../../services/public_api';
13
import { IgxToggleDirective } from '../../directives/toggle/toggle.directive';
14
import { GridType } from '../common/grid.interface';
15
import { IgxToolbarToken } from './token';
16
import { NgIf } from '@angular/common';
17
import { IgxIconComponent } from '../../icon/icon.component';
18
import { IgxRippleDirective } from '../../directives/ripple/ripple.directive';
19
import { IgxButtonDirective } from '../../directives/button/button.directive';
20

21

22
export type IgxExporterOptions = IgxCsvExporterOptions | IgxExcelExporterOptions;
23

24
/* jsonAPIComplexObject */
25
/* wcAlternateName: ExporterEventArgs */
26
export interface IgxExporterEvent {
27
    exporter: IgxBaseExporter;
28
    /* alternateType: ExporterOptionsBase */
29
    options: IgxExporterOptions;
30
    grid: GridType;
31
    cancel: boolean;
32
}
33

34

35
/* blazorElement */
36
/* wcElementTag: igc-grid-toolbar-exporter */
37
/* blazorIndirectRender */
38
/* jsonAPIManageItemInMarkup */
39
/* singleInstanceIdentifier */
40
/**
41
 * Provides a pre-configured exporter component for the grid.
42
 *
43
 * @remarks
44
 * This component still needs the actual exporter service(s) provided in the DI chain
45
 * in order to export something.
46
 *
47
 * @igxModule IgxGridToolbarModule
48
 * @igxParent IgxGridToolbarComponent
49
 *
50
 */
51
@Component({
52
    selector: 'igx-grid-toolbar-exporter',
53
    templateUrl: './grid-toolbar-exporter.component.html',
54
    imports: [IgxButtonDirective, IgxRippleDirective, IgxIconComponent, NgIf, IgxToggleDirective, IgxExcelTextDirective, IgxCSVTextDirective]
55
})
56
export class IgxGridToolbarExporterComponent extends BaseToolbarDirective {
2✔
57

58
    /**
59
     * Show entry for CSV export.
60
     */
61
    @Input({ transform: booleanAttribute })
62
    public exportCSV = true;
7✔
63

64
    /**
65
     * Show entry for Excel export.
66
     */
67
    @Input({ transform: booleanAttribute })
68
    public exportExcel = true;
7✔
69

70
    /**
71
     * The name for the exported file.
72
     */
73
    @Input()
74
    public filename = 'ExportedData';
7✔
75

76
    /**
77
     * Emitted when starting an export operation. Re-emitted additionally
78
     * by the grid itself.
79
     */
80
    @Output()
81
    public exportStarted = new EventEmitter<IgxExporterEvent>();
7✔
82

83
    /**
84
     * Emitted on successful ending of an export operation.
85
     */
86
    @Output()
87
    public exportEnded = new EventEmitter<void>();
7✔
88

89
    /**
90
     * Indicates whether there is an export in progress.
91
     */
92
    protected isExporting = false;
7✔
93

94
    constructor(
95
        @Inject(IgxToolbarToken) toolbar: IgxToolbarToken,
96
        private excelExporter: IgxExcelExporterService,
7✔
97
        private csvExporter: IgxCsvExporterService,
7✔
98
    ) {
99
        super(toolbar);
7✔
100
    }
101

102
    protected exportClicked(type: 'excel' | 'csv', toggleRef?: IgxToggleDirective) {
103
        toggleRef?.close();
×
104
        this.export(type);
×
105
    }
106

107
    /* alternateName: exportGrid */
108
    /**
109
     * Export the grid's data
110
     * @param type File type to export
111
     */
112
    public export(type: 'excel' | 'csv'): void {
113
        let options: IgxExporterOptions;
114
        let exporter: IgxBaseExporter;
115

116
        switch (type) {
×
117
            case 'csv':
118
                options = new IgxCsvExporterOptions(this.filename, CsvFileTypes.CSV);
×
119
                exporter = this.csvExporter;
×
120
                break;
×
121
            case 'excel':
122
                options = new IgxExcelExporterOptions(this.filename);
×
123
                exporter = this.excelExporter;
×
124
        }
125

126
        const args = { exporter, options, grid: this.grid, cancel: false } as IgxExporterEvent;
×
127

128
        this.exportStarted.emit(args);
×
129
        this.grid.toolbarExporting.emit(args);
×
130
        this.isExporting = true;
×
131
        this.toolbar.showProgress = true;
×
132

133
        if (args.cancel) {
×
134
            return;
×
135
        }
136

137
        exporter.exportEnded.pipe(first()).subscribe(() => {
×
138
            this.exportEnded.emit();
×
139
            this.isExporting = false;
×
140
            this.toolbar.showProgress = false;
×
141
        });
142

143
        exporter.export(this.grid, options);
×
144
    }
145
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc