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

IgniteUI / igniteui-angular / 13331632524

14 Feb 2025 02:51PM UTC coverage: 22.015% (-69.6%) from 91.622%
13331632524

Pull #15372

github

web-flow
Merge d52d57714 into bcb78ae0a
Pull Request #15372: chore(*): test ci passing

1990 of 15592 branches covered (12.76%)

431 of 964 new or added lines in 18 files covered. (44.71%)

19956 existing lines in 307 files now uncovered.

6452 of 29307 relevant lines covered (22.02%)

249.17 hits per line

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

0.0
/projects/igniteui-angular/src/lib/services/transaction/igx-hierarchical-transaction.ts
1
import { HierarchicalTransaction, HierarchicalState, TransactionType } from './transaction';
2
import { IgxTransactionService } from './igx-transaction';
3
import { DataUtil } from '../../data-operations/data-util';
4
import { HierarchicalTransactionService } from './hierarchical-transaction';
5

6
/** @experimental @hidden */
7
export class IgxHierarchicalTransactionService<T extends HierarchicalTransaction, S extends HierarchicalState>
8
    extends IgxTransactionService<T, S> implements HierarchicalTransactionService<T, S> {
9

10
    public override getAggregatedChanges(mergeChanges: boolean): T[] {
UNCOV
11
        const result: T[] = [];
×
UNCOV
12
        this._states.forEach((state: S, key: any) => {
×
UNCOV
13
            const value = mergeChanges ? this.mergeValues(state.recordRef, state.value) : this.cloneStrategy.clone(state.value);
×
UNCOV
14
            this.clearArraysFromObject(value);
×
UNCOV
15
            result.push({ id: key, path: state.path, newValue: value, type: state.type } as T);
×
16
        });
UNCOV
17
        return result;
×
18
    }
19

20
    public override commit(data: any[], primaryKeyOrId?: any, childDataKey?: any, id?: any): void {
UNCOV
21
        if (childDataKey !== undefined) {
×
UNCOV
22
            let transactions = this.getAggregatedChanges(true);
×
UNCOV
23
            if (id !== undefined) {
×
UNCOV
24
                transactions = transactions.filter(t => t.id === id);
×
25
            }
UNCOV
26
            DataUtil.mergeHierarchicalTransactions(data, transactions, childDataKey, primaryKeyOrId, this.cloneStrategy, true);
×
UNCOV
27
            this.clear(id);
×
28
        } else {
UNCOV
29
            super.commit(data, primaryKeyOrId);
×
30
        }
31
    }
32

33
    protected override updateState(states: Map<any, S>, transaction: T, recordRef?: any): void {
UNCOV
34
        super.updateState(states, transaction, recordRef);
×
35

36
        //  if transaction has no path, e.g. flat data source, get out
UNCOV
37
        if (!transaction.path) {
×
UNCOV
38
            return;
×
39
        }
40

UNCOV
41
        const currentState = states.get(transaction.id);
×
UNCOV
42
        if (currentState) {
×
UNCOV
43
            currentState.path = transaction.path;
×
44
        }
45

46
        //  if transaction has path, Hierarchical data source, and it is DELETE
47
        //  type transaction for all child rows remove ADD states and update
48
        //  transaction type and value of UPDATE states
UNCOV
49
        if (transaction.type === TransactionType.DELETE) {
×
UNCOV
50
            states.forEach((v: S, k: any) => {
×
UNCOV
51
                if (v.path && v.path.indexOf(transaction.id) !== -1) {
×
UNCOV
52
                    switch (v.type) {
×
53
                        case TransactionType.ADD:
UNCOV
54
                            states.delete(k);
×
UNCOV
55
                            break;
×
56
                        case TransactionType.UPDATE:
UNCOV
57
                            states.get(k).type = TransactionType.DELETE;
×
UNCOV
58
                            states.get(k).value = null;
×
59
                    }
60
                }
61
            });
62
        }
63
    }
64

65
    //  TODO: remove this method. Force cloning to strip child arrays when needed instead
66
    private clearArraysFromObject(obj: any) {
UNCOV
67
        if (obj) {
×
UNCOV
68
            for (const prop of Object.keys(obj)) {
×
UNCOV
69
                if (Array.isArray(obj[prop])) {
×
UNCOV
70
                    delete obj[prop];
×
71
                }
72
            }
73
        }
74
    }
75
}
76

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