<commit_before>import async = require('../core/async');
import View = require('./View');

enum State {
  LEAF,
  COLLAPSED,
  EXPANDING,
  EXPANDED,
}

class TreeItemView extends View {
  static State = State;

  id: string;
  nameContainer: HTMLElement;
  caret: HTMLElement;
  childsContainer: HTMLElement;
  childs: TreeItemView[];
  $caretclick;
  state: State;

  constructor(id = null) {
    super();
    this.id = id;
    this.el.className = "tree-item";
    this.caret = document.createElement('span');
    this.nameContainer = document.createElement('div');
    this.caret.className = "fa fa-fw";
    this.$caretclick = null;
    this.state = State.LEAF;
    this.childsContainer = document.createElement('div');
    this.childsContainer.className = "tree-childs";
    this.childs = [];
    this.nameContainer.appendChild(this.caret);
    this.el.appendChild(this.nameContainer);
    this.el.appendChild(this.childsContainer);
  }

  setCanExpand(canexpand: boolean) {
    if (this.$caretclick && !canexpand) {
      this.state = State.LEAF;
      this.removeChildItems(true);
      this.caret.className = "fa fa-fw";
      this.caret.removeEventListener('click', this.$caretclick, false);
      this.$caretclick = null;
    }
    else if (!this.$caretclick && canexpand) {
      this.state = State.COLLAPSED;
      this.caret.className = "fa fa-fw fa-caret-right";
      this.caret.addEventListener('click', this.$caretclick = (e) => {
        this.toggle();
        e.stopPropagation();
        e.preventDefault();
      }, false);
    }
  }

  createChildItems(p: async.Async) {
    p.continue();
  }

  expand() {
    async.run(null, this.expandAsync.bind(this));
  }

  expandAsync(p) {
    this.state = State.EXPANDING;
    p.setFirstElements([
      this.createChildItems.bind(this),
      (p) => {<commit_msg>fix treeview expansion of non expandable node<commit_after>import async = require('../core/async');
import View = require('./View');

enum State {
  LEAF,
  COLLAPSED,
  EXPANDING,
  EXPANDED,
}

class TreeItemView extends View {
  static State = State;

  id: string;
  nameContainer: HTMLElement;
  caret: HTMLElement;
  childsContainer: HTMLElement;
  childs: TreeItemView[];
  $caretclick;
  state: State;

  constructor(id = null) {
    super();
    this.id = id;
    this.el.className = "tree-item";
    this.caret = document.createElement('span');
    this.nameContainer = document.createElement('div');
    this.caret.className = "fa fa-fw";
    this.$caretclick = null;
    this.state = State.LEAF;
    this.childsContainer = document.createElement('div');
    this.childsContainer.className = "tree-childs";
    this.childs = [];
    this.nameContainer.appendChild(this.caret);
    this.el.appendChild(this.nameContainer);
    this.el.appendChild(this.childsContainer);
  }

  setCanExpand(canexpand: boolean) {
    if (this.$caretclick && !canexpand) {
      this.state = State.LEAF;
      this.removeChildItems(true);
      this.caret.className = "fa fa-fw";
      this.caret.removeEventListener('click', this.$caretclick, false);
      this.$caretclick = null;
    }
    else if (!this.$caretclick && canexpand) {
      this.state = State.COLLAPSED;
      this.caret.className = "fa fa-fw fa-caret-right";
      this.caret.addEventListener('click', this.$caretclick = (e) => {
        this.toggle();
        e.stopPropagation();
        e.preventDefault();
      }, false);
    }
  }

  createChildItems(p: async.Async) {
    p.continue();
  }

  expand() {
    async.run(null, this.expandAsync.bind(this));
  }

  expandAsync(p) {
    if (this.state !== State.COLLAPSED) return p.continue();
    this.state = State.EXPANDING;
    p.setFirstElements([
      this.createChildItems.bind(this),
      (p) => {
{'fraction_non_alphanumeric': 0.14819759679572764, 'fraction_numerical': 0.0, 'mean_word_length': 3.1164835164835165, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4978833', 'n_tokens_mistral': 1245, 'n_tokens_neox': 1238, 'n_words': 217}