<commit_before>
var editor;

Dependency.autorun(function() {
  editor = Dependency.get('editorService');
});

Template.geNodeModal.onCreated(function() {
  var node = editor.modals.edit.node();
  if (node) {
    this.storage = {
      _id: node._id,
      name: node.name,
      types: getTypes(node.type),
      selected: new ReactiveVar(),
      create: false
    };
  } else {
    this.storage = {
      name: '',
      types: getTypes(),
      parents: new ReactiveVar([]),
      selected: new ReactiveVar(),
      create: true
    };
  }
});

Template.geNodeModal.helpers({
  name: function() {
    return Template.instance().storage.name;
  },
  types: function() {
    return Template.instance().storage.types;
  },
  parents: function() {
    var t = Template.instance();
    var selected = t.storage.selected;

    if (selected.get() && t.storage.create) {
      var temp = t.storage.parents.get();
      temp.push(selected.get());
      t.storage.parents.set(temp);
      selected.set(null);
    } else if (selected.get() && !t.storage.create) {
      editor.nodes.parent.add(t.storage._id, selected.get()._id);
      selected.set(null);
    }

    return t.storage.create ? t.storage.parents.get() : editor.nodes.parents(t.storage._id);
  },<commit_msg>Disable node type radios upon node edit<commit_after>
var editor;

Dependency.autorun(function() {
  editor = Dependency.get('editorService');
});

Template.geNodeModal.onCreated(function() {
  var node = editor.modals.edit.node();
  if (node) {
    this.storage = {
      _id: node._id,
      name: node.name,
      types: getTypes(node.type),
      selected: new ReactiveVar(),
      create: false
    };
  } else {
    this.storage = {
      name: '',
      types: getTypes(),
      parents: new ReactiveVar([]),
      selected: new ReactiveVar(),
      create: true
    };
  }
});

Template.geNodeModal.onRendered(function() {
  var node = editor.modals.edit.node();
  if (node) {
    this.$('.radio input').attr('disabled', 'disabled');
  }
});

Template.geNodeModal.helpers({
  name: function() {
    return Template.instance().storage.name;
  },
  types: function() {
    return Template.instance().storage.types;
  },
  parents: function() {
    var t = Template.instance();
    var selected = t.storage.selected;

    if (selected.get() && t.storage.create) {
      var temp = t.storage.parents.get();
      temp.push(selected.get());
      t.storage.parents.set(temp);
      selected.set(null);
    } else if (selected.get() && !t.storage.create) {
      editor.nodes.parent.add(t.storage._id, selected.get()._id);
      selected.set(null);
    }

    return t.storage.create ? t.storage.parents.get() : editor.nodes.parents(t.storage._id);
  },
{'fraction_non_alphanumeric': 0.16697315189407871, 'fraction_numerical': 0.0, 'mean_word_length': 2.8526912181303117, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '4937706', 'n_tokens_mistral': 876, 'n_tokens_neox': 872, 'n_words': 163}