{"size": 2385, "ext": "js", "max_stars_repo_path": "public-interface/dashboard/public/js/directives/listTree.js", "max_stars_repo_name": "wagmarcel/oisp-frontend", "max_stars_repo_stars_event_min_datetime": "2019-04-19T01:35:24.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-01T11:41:55.000Z", "max_issues_repo_path": "public-interface/dashboard/public/js/directives/listTree.js", "max_issues_repo_name": "wagmarcel/oisp-frontend", "max_issues_repo_issues_event_min_datetime": "2018-01-17T13:38:55.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-18T16:14:51.000Z", "max_forks_repo_path": "public-interface/dashboard/public/js/directives/listTree.js", "max_forks_repo_name": "wagmarcel/oisp-frontend", "max_forks_repo_forks_event_min_datetime": "2018-01-16T09:57:29.000Z", "max_forks_repo_forks_event_max_datetime": "2020-07-03T13:11:28.000Z"}
{"max_stars_count": 4, "max_issues_count": 143, "max_forks_count": 21, "avg_line_length": 35.5970149254, "max_line_length": 146, "alphanum_fraction": 0.5257861635}
/**
 * Copyright (c) 2014 Intel Corporation
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

'use strict';
iotApp.directive('treeList', function () {
    return {
        restrict: 'E',
        template: '<div style="display: none"><ul><tree-list-item ng-repeat="item in tree" item="item"></tree-list-item></ul></div>',
        replace: true,
        transclude: true,
        scope: {
            tree: '=',
            eagerInit: "=",
            selectGroup: '&'
        },
        link: function (scope, element) {
            scope.$on('repeat-done', function(){
                angular.element('#hierarchy').menu({
                    content: element.html(),
                    positionOpts: { posX: 'left', posY: 'top' },
                    //maxHeight:100,
                    crumbDefaultText: '',
                    linkHover: 'fg-menu-li-hover',
                    eagerInit: scope.eagerInit || false,
                    chooseItemCallback: scope.selectGroup
                });
            });
        }
    };
});
iotApp.directive('treeListItem', function ($compile, $timeout) {
    return {
        restrict: 'E',
        template: '<li><a href="#" data-id="{{item.id}}">{{item.name}}</a></li>',
        replace: true,
        transclude: true,
        scope: {
            item: "="
        },
        link: function (scope, element) {
            scope.$watch('item.children', function(it) {
                if(it !== undefined && it.length !== undefined && it.length > 0){
                    element.append($compile('<ul><tree-list-item ng-repeat="child in item.children" item="child"></tree-list-item></ul>')(scope));
                }
            });

            if (scope.$parent.$last){ // ISSUE IS HERE
                $timeout(function(){
                    scope.$emit('repeat-done');
                });
            }
        }
    };
});