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

IgniteUI / igniteui-angular-wrappers / 4427504397

pending completion
4427504397

push

github

GitHub
Update README.md

281 of 305 branches covered (92.13%)

Branch coverage included in aggregate %.

668 of 713 relevant lines covered (93.69%)

219.79 hits per line

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

83.61
/projects/igniteui-angular-wrappers/src/lib/igtree/igtree.component.ts
1
import {
2
  Component,
3
  ElementRef,
4
  IterableDiffers,
5
  KeyValueDiffers,
6
  ChangeDetectorRef,
7
  SimpleChanges,
8
  Input,
9
  Renderer2,
10
  OnInit,
11
  OnChanges,
12
  DoCheck
13
} from '@angular/core';
14
import { IgControlBase } from '../igcontrolbase/igcontrolbase';
15

16
@Component({
17
    selector: 'ig-tree',
18
    template: '<ng-content></ng-content>',
19
    inputs: [
20
      'widgetId',
21
      'options',
22
      'changeDetectionInterval',
23
      'disabled',
24
      'create',
25
      'width',
26
      'height',
27
      'checkboxMode',
28
      'singleBranchExpand',
29
      'hotTracking',
30
      'parentNodeImageUrl',
31
      'parentNodeImageClass',
32
      'parentNodeImageTooltip',
33
      'leafNodeImageUrl',
34
      'leafNodeImageClass',
35
      'leafNodeImageTooltip',
36
      'animationDuration',
37
      'pathSeparator',
38
      'dataSource',
39
      'dataSourceUrl',
40
      'dataSourceType',
41
      'responseDataKey',
42
      'responseDataType',
43
      'requestType',
44
      'responseContentType',
45
      'initialExpandDepth',
46
      'loadOnDemand',
47
      'bindings',
48
      'defaultNodeTarget',
49
      'dragAndDrop',
50
      'updateUrl',
51
      'dragAndDropSettings'
52
    ],
53
    outputs: ['dataBinding', 'dataBound', 'rendering', 'rendered', 'selectionChanging', 'selectionChanged', 'nodeCheckstateChanging', 'nodeCheckstateChanged', 'nodePopulating', 'nodePopulated', 'nodeCollapsing', 'nodeCollapsed', 'nodeExpanding', 'nodeExpanded', 'nodeClick', 'nodeDoubleClick', 'dragStart', 'drag', 'dragStop', 'nodeDropping', 'nodeDropped']
54
})
55
export class IgTreeComponent extends IgControlBase<IgTree> implements OnInit, OnChanges, DoCheck {
1✔
56
    private _dataSource: any;
57
    private _changes: any;
58
    @Input()
59
    public set dataSource(value: any) {
60
        this._dataSource = value;
3✔
61
    }
62

63
    @Input()
64
    public bindings: IgTreeBindings;
65

66
    constructor(el: ElementRef, renderer: Renderer2, differs: IterableDiffers, kvalDiffers: KeyValueDiffers, cdr: ChangeDetectorRef) {
67
        super(el, renderer, differs, kvalDiffers, cdr);
4✔
68
    }
69

70
    ngOnInit() {
71
        if (!this.options.dataSource && this._dataSource) {
4✔
72
            this.options.dataSource = this._dataSource;
3✔
73
        }
74
        super.ngOnInit();
4✔
75
    }
76
    public ngOnChanges(changes: SimpleChanges): void {
77
        const ds = 'dataSource';
4✔
78
        // const options = "options";
79
        if (ds in changes) {
4✔
80
            const value = changes[ds].currentValue;
3✔
81
            if (!this._differ && value) {
3✔
82
                try {
3✔
83
                    this._differ = this._differs.find(value).create();
3✔
84
                    this._changes = [];
3✔
85
                    this._dataSource.forEach(item => {
3✔
86
                      this._changes.push(this.kvalDiffers.find({}).create());
12✔
87
                    });
88
                } catch (e) {
89
                    throw new Error('Only binding to arrays is supported.');
×
90
                }
91
            }
92
        }
93
        super.ngOnChanges(changes);
4✔
94
    }
95
    ngDoCheck() {
96
        if (this._differ) {
7✔
97
            const changes = this._differ.diff(this._dataSource);
6✔
98
            // check if control is initialized
99
            const elem = jQuery(this._el).data(this._widgetName);
6✔
100
            if (changes && elem) {
6✔
101
                this.dataSourceApplyChanges(changes);
5✔
102
            }
103
            if (this._changes && elem) {
6✔
104
                // check recs
105
                for (let i = 0; i < this._dataSource.length; i++) {
6✔
106
                    const item = this._dataSource[i];
23✔
107
                    const rowChanges = this._changes[i].diff(item);
23✔
108
                    if (rowChanges) {
23✔
109
                        rowChanges.forEachChangedItem((change: any) => {
14✔
110
                            this.updateItem(item, change.currentValue, change.key);
1✔
111
                        });
112
                    }
113
                }
114
            }
115
        }
116
        super.ngDoCheck();
7✔
117
    }
118

119
    addItem(item, index) {
120
        this.dataBind();
13✔
121
        this._changes.push(this.kvalDiffers.find({}).create());
13✔
122

123
    }
124
    deleteItem(item, index) {
125
        this.dataBind();
1✔
126
        this._changes.splice(index, 1);
1✔
127
    }
128
    dataSourceApplyChanges(changes) {
129
        changes.forEachAddedItem(r => this.addItem(r.item, r.currentIndex));
13✔
130
        changes.forEachRemovedItem(r => { this.deleteItem(r.item, r.previousIndex); });
5✔
131

132
    }
133
    updateItem(item, value, key) {
134
        this.dataBind();
1✔
135
    }
136

137
    public markForCheck() {
138
        super.markForCheck();
×
139
        const bindings = this.bindings || this.options.bindings;
×
140
        if (bindings && bindings.childDataProperty) {
×
141
            this.dataBind();
×
142
        }
143
    }
144

145
    /**
146
     * Performs databinding on the igTree.
147
     */
148
    /* istanbul ignore next */
149
    public dataBind(): void { return; }
150

151
    /**
152
     * Toggles the checkstate of a node if checkboxMode is not set to off, otherwise does nothing.
153
     *
154
     * @param node     Specifies the node element the checkbox of which would be toggled.
155
     * @param event     Indicates the browser event which triggered this action, if this is not an API call.
156
     */
157
    /* istanbul ignore next */
158
    public toggleCheckstate(node: object, event?: object): void { return; }
159

160
    /**
161
     * Toggles the collapse/expand state for the specified node.
162
     *
163
     * @param node     Specifies the node element the checkbox of which would be toggled.
164
     * @param event     Indicates the browser event which triggered this action, if this is not an API call.
165
     */
166
    /* istanbul ignore next */
167
    public toggle(node: object, event?: object): void { return; }
168

169
    /**
170
     * Expands the tree down to the specified node and selects the node if specified.
171
     *
172
     * @param node     Specifies the node element down to which the tree would be expanded.
173
     * @param toSelect     Specifies the whether to select the node after expanding to it.
174
     */
175
    /* istanbul ignore next */
176
    public expandToNode(node: object, toSelect?: boolean): void { return; }
177

178
    /**
179
     * Expands the specified node.
180
     *
181
     * @param node     Specifies the node element to expand.
182
     */
183
    /* istanbul ignore next */
184
    public expand(node: object): void { return; }
185

186
    /**
187
     * Collapses the specified node.
188
     *
189
     * @param node     Specifies the node element to collapse.
190
     */
191
    /* istanbul ignore next */
192
    public collapse(node: object): void { return; }
193

194
    /**
195
     * Retrieves the parent node element of the specified node element.
196
     *
197
     * @param node     Specifies the jQuery selected node element to collapse.
198
     */
199
    /* istanbul ignore next */
200
    public parentNode(node: object): object { return; }
201

202
    /**
203
     * Retrieves the jQuery element of the node with the specified path.
204
     *
205
     * @param nodePath     Specifies the path to the required node.
206
     */
207
    /* istanbul ignore next */
208
    public nodeByPath(nodePath: string): object { return; }
209

210
    /**
211
     * Retrieves the jQuery element of the node with the specified value.
212
     *
213
     * @param value     Specifies the value of the required node.
214
     */
215
    /* istanbul ignore next */
216
    public nodesByValue(value: string): object { return; }
217

218
    /**
219
     * Retrieves all the node objects for the nodes that have their checkboxes checked.
220
     */
221
    /* istanbul ignore next */
222
    public checkedNodes(): any[] { return; }
223

224
    /**
225
     * Retrieves all the node objects for the nodes that have their checkboxes unchecked.
226
     */
227
    /* istanbul ignore next */
228
    public uncheckedNodes(): any[] { return; }
229

230
    /**
231
     * Retrieves all the node objects for the nodes that have their checkboxes partially checked.
232
     */
233
    /* istanbul ignore next */
234
    public partiallyCheckedNodes(): any[] { return; }
235

236
    /**
237
     * Selects a node.
238
     *
239
     * @param node     Specifies the node element to be selected.
240
     * @param event     Indicates the browser event which triggered this action, if this is not an API call.
241
     */
242
    /* istanbul ignore next */
243
    public select(node: object, event?: object): void { return; }
244

245
    /**
246
     * Deselects the specified node.
247
     *
248
     * @param node     Specifies the node element to be deselected.
249
     */
250
    /* istanbul ignore next */
251
    public deselect(node: object): void { return; }
252

253
    /**
254
     * Deselects all the selected nodes.
255
     */
256
    /* istanbul ignore next */
257
    public clearSelection(): void { return; }
258

259
    /**
260
     * Retrieves the node object for the selected node.
261
     */
262
    /* istanbul ignore next */
263
    public selectedNode(): object { return; }
264

265
    /**
266
     * Retrieves all node objects with the specified text (case sensitive).
267
     *
268
     * @param text     The text to search for.
269
     * @param parent     The node element to start the search from. If not specified then search would start from the root of the tree.
270
     */
271
    /* istanbul ignore next */
272
    public findNodesByText(text: string, parent?: object): any[] { return; }
273

274
    /**
275
     * Retrieves all node objects for the immediate children of the specified parent with the specified text (case sensitive).
276
     *
277
     * @param text     The text to search for.
278
     * @param parent     The node element the children of which would be searched.
279
     */
280
    /* istanbul ignore next */
281
    public findImmediateNodesByText(text: string, parent?: object): any[] { return; }
282

283
    /**
284
     * Retrieves the n-th jQuery node element child of the specified parent.
285
     *
286
     * @param index     Specifies the index the node at which to be retrieved.
287
     * @param parent     The parent node element to start the search from.
288
     */
289
    /* istanbul ignore next */
290
    public nodeByIndex(index: number, parent?: object): object { return; }
291

292
    /**
293
     * Retrieves a node object for the specified node element.
294
     *
295
     * @param element     Specifies the node element.
296
     */
297
    /* istanbul ignore next */
298
    public nodeFromElement(element: object): object { return; }
299

300
    /**
301
     * Retrieves a node object collection of the immediate children of the provided node element.
302
     *
303
     * @param parent     Specifies the node element.
304
     */
305
    /* istanbul ignore next */
306
    public children(parent: object): any[] { return; }
307

308
    /**
309
     * Retrieves a node object collection of the immediate children of the node with the provided path.
310
     *
311
     * @param path     Specifies the path of the node the children of which are to be retrieved.
312
     */
313
    /* istanbul ignore next */
314
    public childrenByPath(path: string): any[] { return; }
315

316
    /**
317
     * Returns true if the provided node element is selected and false otherwise.
318
     *
319
     * @param node     Specifies the node element.
320
     */
321
    /* istanbul ignore next */
322
    public isSelected(node: object): boolean { return; }
323

324
    /**
325
     * Returns true if the provided node element is expanded and false otherwise.
326
     *
327
     * @param node     Specifies the node element.
328
     */
329
    /* istanbul ignore next */
330
    public isExpanded(node: object): boolean { return; }
331

332
    /**
333
     * Returns true if the provided node element has its checkbox checkstate checked and false otherwise.
334
     *
335
     * @param node     Specifies the node element.
336
     */
337
    /* istanbul ignore next */
338
    public isChecked(node: object): boolean { return; }
339

340
    /**
341
     * Returns the specified node checkstate.
342
     *
343
     * @param node     Specifies the node element.
344
     */
345
    /* istanbul ignore next */
346
    public checkState(node: object): string { return; }
347

348
    /**
349
     * Adds a new array of nodes to the tree. New nodes are appended to the root or to a specified parent node, at a specified index.
350
     *
351
     * @param node     Specifies the data used to create the new nodeс.
352
     * @param parent     Specifies the element of the parent node the nodes are to be appended to.
353
     * @param nodeIndex     Specifies the index at which the nodes to be inserted.
354
     */
355
    /* istanbul ignore next */
356
    public addNode(node: object, parent?: object, nodeIndex?: number): void { return; }
357

358
    /**
359
     * Removes the node with with the specified path and all of its children.
360
     *
361
     * @param path     Specifies the path of the node to be removed.
362
     */
363
    /* istanbul ignore next */
364
    public removeAt(path: string): void { return; }
365

366
    /**
367
     * Removing all the nodes with the specified value.
368
     *
369
     * @param value     Specifies the value of the nodes to be removed.
370
     */
371
    /* istanbul ignore next */
372
    public removeNodesByValue(value: string): void { return; }
373

374
    /**
375
     * Performs a UI update on the provided node element with the provided data.
376
     *
377
     * @param element     Specifies the node to be updated.
378
     * @param data     Specifies the new data item the node would update according to.
379
     */
380
    /* istanbul ignore next */
381
    public applyChangesToNode(element: object, data: object): void { return; }
382

383
    /**
384
     * Returns the transaction log stack.
385
     */
386
    /* istanbul ignore next */
387
    public transactionLog(): any[] { return; }
388

389
    /**
390
     * Returns the data for the node with specified path.
391
     *
392
     * @param path     Specifies the node path for which the data is returned.
393
     */
394
    /* istanbul ignore next */
395
    public nodeDataFor(path: string): object { return; }
396

397
    /**
398
     * Destructor for the igTree widget.
399
     */
400
    /* istanbul ignore next */
401
    public destroy(): void { return; }
402
}
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