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

IgniteUI / igniteui-angular / 13548823408

26 Feb 2025 04:36PM CUT coverage: 91.555% (-0.04%) from 91.599%
13548823408

Pull #15223

github

web-flow
Merge 3ac8087aa into 786685675
Pull Request #15223: fix(pivot-grid): added createRow method for grid based events - 19.0

12997 of 15250 branches covered (85.23%)

0 of 18 new or added lines in 2 files covered. (0.0%)

135 existing lines in 23 files now uncovered.

26344 of 28774 relevant lines covered (91.55%)

34046.37 hits per line

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

88.33
/projects/igniteui-angular/src/lib/action-strip/action-strip.component.ts
1
import {
2
    Component,
3
    Directive,
4
    HostBinding,
5
    Input,
6
    Renderer2,
7
    ViewContainerRef,
8
    ContentChildren,
9
    QueryList,
10
    ViewChild,
11
    TemplateRef,
12
    AfterContentInit,
13
    ChangeDetectorRef,
14
    AfterViewInit,
15
    ElementRef,
16
    booleanAttribute
17
} from '@angular/core';
18
import { ActionStripResourceStringsEN, IActionStripResourceStrings } from '../core/i18n/action-strip-resources';
19
import { IgxDropDownComponent } from '../drop-down/drop-down.component';
20
import { CloseScrollStrategy, OverlaySettings } from '../services/public_api';
21
import { IgxGridActionsBaseDirective } from './grid-actions/grid-actions-base.directive';
22
import { IgxDropDownItemComponent } from '../drop-down/drop-down-item.component';
23
import { IgxIconComponent } from '../icon/icon.component';
24
import { IgxDropDownItemNavigationDirective } from '../drop-down/drop-down-navigation.directive';
25
import { IgxToggleActionDirective } from '../directives/toggle/toggle.directive';
26
import { IgxRippleDirective } from '../directives/ripple/ripple.directive';
27
import { NgIf, NgFor, NgTemplateOutlet } from '@angular/common';
28
import { getCurrentResourceStrings } from '../core/i18n/resources';
29
import { IgxIconButtonDirective } from '../directives/button/icon-button.directive';
30
import { IgxActionStripToken } from './token';
31

32
@Directive({
33
    selector: '[igxActionStripMenuItem]',
34
    standalone: true
35
})
36
export class IgxActionStripMenuItemDirective {
2✔
37
    constructor(public templateRef: TemplateRef<any>) {}
7✔
38
}
39

40
/* blazorElement */
41
/* jsonAPIManageItemInMarkup */
42
/* jsonAPIManageCollectionInMarkup */
43
/* wcElementTag: igc-action-strip */
44
/* blazorIndirectRender */
45
/* singleInstanceIdentifier */
46
/* contentParent: GridBaseDirective */
47
/* contentParent: RowIsland */
48
/* contentParent: HierarchicalGrid */
49
/**
50
 * Action Strip provides templatable area for one or more actions.
51
 *
52
 * @igxModule IgxActionStripModule
53
 *
54
 * @igxTheme igx-action-strip-theme
55
 *
56
 * @igxKeywords action, strip, actionStrip, pinning, editing
57
 *
58
 * @igxGroup Data Entry & Display
59
 *
60
 * @igxParent IgxGridComponent, IgxTreeGridComponent, IgxHierarchicalGridComponent, IgxRowIslandComponent, *
61
 *
62
 * @remarks
63
 * The Ignite UI Action Strip is a container, overlaying its parent container,
64
 * and displaying action buttons with action applicable to the parent component the strip is instantiated or shown for.
65
 *
66
 * @example
67
 * ```html
68
 * <igx-action-strip #actionStrip>
69
 *     <igx-icon (click)="doSomeAction()"></igx-icon>
70
 * </igx-action-strip>
71
 */
72
@Component({
73
    selector: 'igx-action-strip',
74
    templateUrl: 'action-strip.component.html',
75
    imports: [
76
        NgIf,
77
        NgFor,
78
        NgTemplateOutlet,
79
        IgxIconButtonDirective,
80
        IgxRippleDirective,
81
        IgxToggleActionDirective,
82
        IgxDropDownItemNavigationDirective,
83
        IgxIconComponent,
84
        IgxDropDownComponent,
85
        IgxDropDownItemComponent
86
    ],
87
    providers: [{ provide: IgxActionStripToken, useExisting: IgxActionStripComponent }]
88
})
89
export class IgxActionStripComponent implements IgxActionStripToken, AfterContentInit, AfterViewInit {
2✔
90

91
    /* blazorSuppress */
92
    /**
93
     * Sets the context of an action strip.
94
     * The context should be an instance of a @Component, that has element property.
95
     * This element will be the placeholder of the action strip.
96
     *
97
     * @example
98
     * ```html
99
     * <igx-action-strip [context]="cell"></igx-action-strip>
100
     * ```
101
     */
102
    @Input()
103
    public context: any;
104

105
    /**
106
     * Menu Items ContentChildren inside the Action Strip
107
     *
108
     * @hidden
109
     * @internal
110
     */
111
    @ContentChildren(IgxActionStripMenuItemDirective)
112
    public _menuItems: QueryList<IgxActionStripMenuItemDirective>;
113

114

115
    /* blazorInclude */
116
    /* contentChildren */
117
    /* blazorTreatAsCollection */
118
    /* blazorCollectionName: GridActionsBaseDirectiveCollection */
119
    /**
120
     * ActionButton as ContentChildren inside the Action Strip
121
     *
122
     * @hidden
123
     * @internal
124
     */
125
    @ContentChildren(IgxGridActionsBaseDirective)
126
    public actionButtons: QueryList<IgxGridActionsBaseDirective>;
127

128
    /**
129
     * Gets/Sets the visibility of the Action Strip.
130
     * Could be used to set if the Action Strip will be initially hidden.
131
     *
132
     * @example
133
     * ```html
134
     *  <igx-action-strip [hidden]="false">
135
     * ```
136
     */
137
    @Input({ transform: booleanAttribute })
138
    public hidden = false;
123✔
139

140

141
    /**
142
     * Gets/Sets the resource strings.
143
     *
144
     * @remarks
145
     * By default it uses EN resources.
146
     */
147
    @Input()
148
    public set resourceStrings(value: IActionStripResourceStrings) {
UNCOV
149
        this._resourceStrings = Object.assign({}, this._resourceStrings, value);
×
150
    }
151

152
    public get resourceStrings(): IActionStripResourceStrings {
153
        return this._resourceStrings;
34✔
154
    }
155

156
    /**
157
     * Hide or not the Action Strip based on if it is a menu.
158
     *
159
     * @hidden
160
     * @internal
161
     */
162
    public get hideOnRowLeave(): boolean {
163
        if (this.menu.items.length === 0) {
1!
164
            return true;
1✔
UNCOV
165
        } else if (this.menu.items.length > 0) {
×
UNCOV
166
            if (this.menu.collapsed) {
×
167
                return true;
×
168
            } else {
169
                return false;
×
170
            }
171
        }
172
    }
173

174
    /**
175
     * Reference to the menu
176
     *
177
     * @hidden
178
     * @internal
179
     */
180
    @ViewChild('dropdown')
181
    public menu: IgxDropDownComponent;
182

183
    /**
184
     * Getter for menu overlay settings
185
     *
186
     * @hidden
187
     * @internal
188
     */
189
    public menuOverlaySettings: OverlaySettings = { scrollStrategy: new CloseScrollStrategy() };
123✔
190

191
    private _hidden = false;
123✔
192
    private _resourceStrings = getCurrentResourceStrings(ActionStripResourceStringsEN);
123✔
193
    private _originalParent!: HTMLElement;
194

195
    constructor(
196
        private _viewContainer: ViewContainerRef,
123✔
197
        private renderer: Renderer2,
123✔
198
        protected el: ElementRef,
123✔
199
        /** @hidden @internal **/
200
        public cdr: ChangeDetectorRef,
123✔
201
    ) { }
202

203
    /**
204
     * Menu Items list.
205
     *
206
     * @hidden
207
     * @internal
208
     */
209
    public get menuItems() {
210
        const actions = [];
1,982✔
211
        this.actionButtons.forEach(button => {
1,982✔
212
            if (button.asMenuItems) {
2,230✔
213
                const children = button.buttons;
176✔
214
                if (children) {
176✔
215
                    children.toArray().forEach(x => actions.push(x));
156✔
216
                }
217
            }
218
        });
219
        return [... this._menuItems.toArray(), ...actions];
1,982✔
220
    }
221

222

223
    /**
224
     * Getter for the 'display' property of the current `IgxActionStrip`
225
     */
226
    @HostBinding('style.display')
227
    private get display(): string {
228
        return this.hidden ? 'none' : 'flex';
950✔
229
    }
230

231
    /**
232
     * Host `attr.class` binding.
233
     */
234
    @HostBinding('class.igx-action-strip')
235
    protected hostClass = 'igx-action-strip';
123✔
236

237
    /**
238
     * @hidden
239
     * @internal
240
     */
241
    public ngAfterContentInit() {
242
        this.actionButtons.forEach(button => {
123✔
243
            button.strip = this;
135✔
244
        });
245
        this.actionButtons.changes.subscribe(() => {
123✔
UNCOV
246
            this.actionButtons.forEach(button => {
×
UNCOV
247
                button.strip = this;
×
248
            });
249
        });
250
    }
251

252
    /**
253
     * @hidden
254
     * @internal
255
     */
256
    public ngAfterViewInit() {
257
        this.menu.selectionChanging.subscribe(($event) => {
123✔
258
            const newSelection = ($event.newSelection as any).elementRef.nativeElement;
3✔
259
            let allButtons = [];
3✔
260
            this.actionButtons.forEach(actionButtons => {
3✔
261
                if (actionButtons.asMenuItems) {
3✔
262
                    allButtons = [...allButtons, ...actionButtons.buttons.toArray()];
3✔
263
                }
264
            });
265
            const button = allButtons.find(x => newSelection.contains(x.container.nativeElement));
4✔
266
            if (button) {
3✔
267
                button.actionClick.emit();
3✔
268
            }
269
        });
270
        this._originalParent = this._viewContainer.element.nativeElement?.parentElement;
123✔
271
    }
272

273
    /**
274
     * Showing the Action Strip and appending it the specified context element.
275
     *
276
     * @param context
277
     * @example
278
     * ```typescript
279
     * this.actionStrip.show(row);
280
     * ```
281
     */
282
    public show(context?: any): void {
283
        this.hidden = false;
36✔
284
        if (!context) {
36✔
285
            return;
1✔
286
        }
287
        // when shown for different context make sure the menu won't stay opened
288
        if (this.context !== context) {
35✔
289
            this.closeMenu();
33✔
290
        }
291
        this.context = context;
35✔
292
        if (this.context && this.context.element) {
35✔
293
            this.renderer.appendChild(context.element.nativeElement, this._viewContainer.element.nativeElement);
30✔
294
        }
295
        this.cdr.detectChanges();
35✔
296
    }
297

298
    /**
299
     * Hiding the Action Strip and removing it from its current context element.
300
     *
301
     * @example
302
     * ```typescript
303
     * this.actionStrip.hide();
304
     * ```
305
     */
306
    public hide(): void {
307
        this.hidden = true;
43✔
308
        this.closeMenu();
43✔
309
        if (this._originalParent) {
43✔
310
            // D.P. fix(elements) don't detach native DOM, instead move back. Might not matter for Angular, but Elements will destroy
311
            this.renderer.appendChild(this._originalParent, this._viewContainer.element.nativeElement);
2✔
312
        } else if (this.context && this.context.element) {
41✔
313
            this.renderer.removeChild(this.context.element.nativeElement, this._viewContainer.element.nativeElement);
28✔
314
        }
315
    }
316

317
    /**
318
     * Close the menu if opened
319
     *
320
     * @hidden
321
     * @internal
322
     */
323
    private closeMenu(): void {
324
        if (this.menu && !this.menu.collapsed) {
76✔
325
            this.menu.close();
4✔
326
        }
327
    }
328
}
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