Line.hx 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. package hide.comp.cdb;
  2. class Line extends Component {
  3. public var index : Int;
  4. public var table : Table;
  5. public var obj(get, never) : Dynamic;
  6. public var cells : Array<Cell>;
  7. public var columns : Array<cdb.Data.Column>;
  8. public var subTable : SubTable;
  9. public function new(table, columns, index, root) {
  10. super(null,root);
  11. this.table = table;
  12. this.index = index;
  13. this.columns = columns;
  14. cells = [];
  15. }
  16. inline function get_obj() return table.sheet.lines[index];
  17. public function create() {
  18. var view = table.view;
  19. element.removeClass("hidden");
  20. for( c in columns ) {
  21. var v = new Element("<td>").addClass("c");
  22. v.appendTo(this.element);
  23. var cell = new Cell(v, this, c);
  24. if( c.type == TId && view != null && view.forbid != null && view.forbid.indexOf(cell.value) >= 0 )
  25. element.addClass("hidden");
  26. }
  27. }
  28. public function getGroupID() {
  29. var t = table;
  30. var line = this;
  31. while( t.parent != null ) {
  32. line = Std.downcast(t, SubTable).cell.line;
  33. t = t.parent;
  34. }
  35. var seps = t.sheet.separators;
  36. var i = seps.length - 1;
  37. while( i >= 0 ) {
  38. if( seps[i] < line.index ) {
  39. var t = t.sheet.props.separatorTitles[i];
  40. if( t != null ) return t;
  41. }
  42. i--;
  43. }
  44. return null;
  45. }
  46. public function evaluate() {
  47. for( c in cells )
  48. @:privateAccess c.evaluate();
  49. }
  50. public function hide() {
  51. if( subTable != null ) {
  52. subTable.close();
  53. subTable = null;
  54. }
  55. cells = [];
  56. element.children('td.c').remove();
  57. element.addClass("hidden");
  58. }
  59. }