<commit_before>package cards.ui.input;

import cards.components.Component;
import cards.model.SchemaType;
import cards.ui.widgets.Button;
import cards.ui.widgets.Menu;
import js.html.Element;

class ObjectEditor extends BaseObjectEditor {
  var menuAdd : Menu;
  var buttonAdd : Button;
  var inited = false;
  public function new(container : Element, parent : Component, fields : Array<FieldInfo>) {
    super(container, parent, fields);

    buttonAdd = toolbar.left.addButton('', Config.icons.addMenu);
    buttonAdd.enabled.set(false);

    buttonAdd.clicks
      .subscribe(function(_) {
        menuAdd.anchorTo(buttonAdd.component.el);
        menuAdd.visible.stream.set(true);
      });

    menuAdd = new Menu({});
    inited = true;
    setAddState();
  }

  override public function removeField(name : String) {
    super.removeField(name);
    setAddState();
  }

  override public function realizeField(name : String) {
    super.realizeField(name);
    setAddState();
  }

  function setAddState() {
    if(!inited) return;
    var fields = this.fields.copy().filter(function(field) {
      return !editors.exists(field.name);
    });
    var enabled = fields.length > 0;
    buttonAdd.enabled.set(enabled);
    if(enabled) {
      menuAdd.clear();
      fields.map(function(field) {
        var button = new Button('add <b>${field.name}</b>');
        button.clicks
          .subscribe(function(_) {
            realizeField(field.name);
            setAddState();
          });
        menuAdd.addItem(button.component);
      });
    }
  }
}<commit_msg>set correct inheritance in ObjectEditor<commit_after>package cards.ui.input;

import cards.components.Component;
import cards.model.SchemaType;
import cards.ui.widgets.Button;
import cards.ui.widgets.Menu;
import js.html.Element;

class ObjectEditor extends BaseObjectEditor {
  var menuAdd : Menu;
  var buttonAdd : Button;
  var inited = false;
  public function new(container : Element, parent : Component, fields : Array<FieldInfo>) {
    super(container, parent, fields);

    buttonAdd = toolbar.left.addButton('', Config.icons.addMenu);
    buttonAdd.enabled.set(false);

    buttonAdd.clicks
      .subscribe(function(_) {
        menuAdd.anchorTo(buttonAdd.component.el);
        menuAdd.visible.stream.set(true);
      });

    menuAdd = new Menu({ parent : component });
    inited = true;
    setAddState();
  }

  override public function removeField(name : String) {
    super.removeField(name);
    setAddState();
  }

  override public function realizeField(name : String) {
    super.realizeField(name);
    setAddState();
  }

  function setAddState() {
    if(!inited) return;
    var fields = this.fields.copy().filter(function(field) {
      return !editors.exists(field.name);
    });
    var enabled = fields.length > 0;
    buttonAdd.enabled.set(enabled);
    if(enabled) {
      menuAdd.clear();
      fields.map(function(field) {
        var button = new Button('add <b>${field.name}</b>');
        button.clicks
          .subscribe(function(_) {
            realizeField(field.name);
            setAddState();
          });
        menuAdd.addItem(button.component);
      });
    }
  }
}
{'fraction_non_alphanumeric': 0.13017565872020076, 'fraction_numerical': 0.0006273525721455458, 'mean_word_length': 3.0012547051442913, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 11, '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': '6325660', 'n_tokens_mistral': 964, 'n_tokens_neox': 941, 'n_words': 188}