liuyg
2021-07-02 25ce610f6ecca7325e7a743dc032c4a76559c63d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
define([
    'dstore/Tree',
    './createSyncStore',
    './stateData',
    'dojo/_base/array'
], function (Tree, createSyncStore, stateData, arrayUtil) {
 
    var nextId = 0;
    var topHeavyData = arrayUtil.map(stateData.items, function (state) {
        return {
            id: nextId++,
            abbreviation: state.abbreviation,
            name: state.name,
            hasChildren: true,
            parent: null
        };
    });
 
    // Store with few children and many parents to exhibit any
    // issues due to bugs related to total disregarding level
    arrayUtil.forEach(topHeavyData, function (state) {
        topHeavyData.push({
            id: nextId++,
            abbreviation: 'US',
            name: 'United States of America',
            hasChildren: false,
            parent: state.id
        });
    });
 
    return createSyncStore({ data: topHeavyData }, Tree).getRootCollection();
});