!7

concept Feature {
  S feature, status;
}

module Features > DynCRUD<Feature> {
  *() { super(Feature); }
  
  afterVisualize {
    replaceComponent(crud.tableSearcher.tfInput, func(JComponent c) -> JComponent {
      centerAndEastWithMargin(c, jbutton("Add feature...", rThread {
        addFeature(searchTerm())
      }))
    });
    onEnter(crud.tableSearcher.tfInput, rThread { addFeature(searchTerm()) });
  }
  
  void addFeature(fS term) enter {
    final JTextField tf1 = jtextfield(or2(term, dm_topInput())), tf2 = jtextfield();
    showFormTitled("Add Feature",
      "Feature:", tf1,
      "Status:", tf2,
      rThread {
        S feature = gtt(tf1), status = gtt(tf2);
        uniq_sync(Feature, +feature, +status);
      });
    focus(nempty(term) ? tf2 : tf1);
  }
}