浏览代码

added cdb.groupID

Nicolas Cannasse 4 年之前
父节点
当前提交
0c4b7bd1f1
共有 3 个文件被更改,包括 21 次插入0 次删除
  1. 1 0
      hide/comp/cdb/Cell.hx
  2. 19 0
      hide/comp/cdb/Line.hx
  3. 1 0
      hide/comp/cdb/ScriptTable.hx

+ 1 - 0
hide/comp/cdb/Cell.hx

@@ -379,6 +379,7 @@ class Cell extends Component {
 			[
 				"cdb."+table.sheet.name => line.obj,
 				"cdb.objID" => objID,
+				"cdb.groupID" => line.getGroupID(),
 			]
 		).check(ecode);
 		if( error != null )

+ 19 - 0
hide/comp/cdb/Line.hx

@@ -31,6 +31,25 @@ class Line extends Component {
 		}
 	}
 
+	public function getGroupID() {
+		var t = table;
+		var line = this;
+		while( t.parent != null ) {
+			line = Std.downcast(t, SubTable).cell.line;
+			t = t.parent;
+		}
+		var seps = t.sheet.separators;
+		var i = seps.length - 1;
+		while( i >= 0 ) {
+			if( seps[i] < line.index ) {
+				var t = t.sheet.props.separatorTitles[i];
+				if( t != null ) return t;
+			}
+			i--;
+		}
+		return null;
+	}
+
 	public function evaluate() {
 		for( c in cells )
 			@:privateAccess c.evaluate();

+ 1 - 0
hide/comp/cdb/ScriptTable.hx

@@ -52,6 +52,7 @@ class ScriptTable extends SubTable {
 		var checker = new ScriptEditor.ScriptChecker(editor.config,"cdb."+cell.getDocumentName(),[
 			"cdb."+cell.table.sheet.name => cell.line.obj,
 			"cdb.objID" => ids.join(":"),
+			"cdb.groupID" => cell.line.getGroupID(),
 		]);
 		script = new ScriptEditor(cell.value, checker, div);
 		script.onSave = saveValue;