Browse Source

fixed cdb view filtering (close #59)

Nicolas Cannasse 5 years ago
parent
commit
489c77398a
2 changed files with 17 additions and 11 deletions
  1. 17 2
      hide/comp/cdb/Cell.hx
  2. 0 9
      hide/comp/cdb/Table.hx

+ 17 - 2
hide/comp/cdb/Cell.hx

@@ -98,6 +98,21 @@ class Cell extends Component {
 		}
 		}
 	}
 	}
 
 
+	function canViewSubColumn( sheet : cdb.Sheet, column : String ) {
+		var view = table.editor.view;
+		if( view == null )
+			return true;
+		var path = sheet.name.split("@");
+		var view = view.get(path.shift());
+		for( name in path ) {
+			var sub = view.sub == null ? null : view.sub.get(name);
+			if( sub == null )
+				return true;
+			view = sub;
+		}
+		return view.show == null || view.show.indexOf(column) >= 0;
+	}
+
 	public function valueHtml( c : cdb.Data.Column, v : Dynamic, sheet : cdb.Sheet, obj : Dynamic ) : String {
 	public function valueHtml( c : cdb.Data.Column, v : Dynamic, sheet : cdb.Sheet, obj : Dynamic ) : String {
 		if( v == null ) {
 		if( v == null ) {
 			if( c.opt )
 			if( c.opt )
@@ -144,7 +159,7 @@ class Cell extends Component {
 					case TList, TProperties:
 					case TList, TProperties:
 						continue;
 						continue;
 					default:
 					default:
-						if( !table.canViewSubColumn(column.name, c.name) ) continue;
+						if( !canViewSubColumn(ps, c.name) ) continue;
 						var h = valueHtml(c, Reflect.field(v, c.name), ps, v);
 						var h = valueHtml(c, Reflect.field(v, c.name), ps, v);
 						if( h != "" && h != " " )
 						if( h != "" && h != " " )
 							vals.push(h);
 							vals.push(h);
@@ -173,7 +188,7 @@ class Cell extends Component {
 			for( c in ps.columns ) {
 			for( c in ps.columns ) {
 				var pval = Reflect.field(v, c.name);
 				var pval = Reflect.field(v, c.name);
 				if( pval == null && c.opt ) continue;
 				if( pval == null && c.opt ) continue;
-				if( !table.canViewSubColumn(column.name, c.name) ) continue;
+				if( !canViewSubColumn(ps, c.name) ) continue;
 				out.push(c.name+" : "+valueHtml(c, pval, ps, v));
 				out.push(c.name+" : "+valueHtml(c, pval, ps, v));
 			}
 			}
 			return out.join("<br/>");
 			return out.join("<br/>");

+ 0 - 9
hide/comp/cdb/Table.hx

@@ -53,15 +53,6 @@ class Table extends Component {
 		return view == null || (view.edit != null && view.edit.indexOf(name) >= 0);
 		return view == null || (view.edit != null && view.edit.indexOf(name) >= 0);
 	}
 	}
 
 
-	public function canViewSubColumn( name : String, column : String ) {
-		if( view == null )
-			return true;
-		var sub = view.sub == null ? null : view.sub.get(name);
-		if( sub == null )
-			return true;
-		return sub.show == null || sub.show.indexOf(column) >= 0;
-	}
-
 	public function close() {
 	public function close() {
 		for( t in @:privateAccess editor.tables.copy() )
 		for( t in @:privateAccess editor.tables.copy() )
 			if( t.parent == this )
 			if( t.parent == this )