Browse Source

added guid column type

Nicolas Cannasse 7 months ago
parent
commit
4a8234ff6a

+ 8 - 7
hide/comp/cdb/Cell.hx

@@ -305,12 +305,13 @@ class Cell {
 		return view;
 	}
 
-	function canViewSubColumn( sheet : cdb.Sheet, column : String ) {
+	function canViewSubColumn( sheet : cdb.Sheet, c : cdb.Data.Column ) {
 		var view = getSheetView(sheet);
-		return view == null || view.show == null || view.show.indexOf(column) >= 0;
+		if( c.type == TGuid && !c.opt && !editor.showGUIDs )
+			return false;
+		return view == null || view.show == null || view.show.indexOf(c.name) >= 0;
 	}
 
-
 	public static function isIdScope( origin : cdb.Sheet, sheet : cdb.Sheet, ?scope ) {
 		if( origin.idCol == null ) return false;
 		if( scope == null ) scope = origin.idCol.scope;
@@ -401,7 +402,7 @@ class Cell {
 			}
 		case TString if( c.kind == Script ):  // wrap content in div because td cannot have max-height
 			v == "" ? val(" ") : html('<div class="script">${colorizeScript(c,v, sheet.idCol == null ? null : Reflect.field(obj, sheet.idCol.name))}</div>');
-		case TString, TLayer(_):
+		case TString, TLayer(_), TGuid:
 			v == "" ? val(" ") : html(spacesToNBSP(StringTools.htmlEscape(v).split("\n").join("<br/>")));
 		case TRef(sname):
 			if( v == "" )
@@ -428,7 +429,7 @@ class Cell {
 				for( c in ps.columns ) {
 					if(c.type == TString && c.kind == Script)
 						continue;
-					if( !canViewSubColumn(ps, c.name) ) continue;
+					if( !canViewSubColumn(ps, c) ) continue;
 					var h = valueHtml(c, Reflect.field(v, c.name), ps, v, scope);
 					if( h.str != "" && h.str != " " )
 					{
@@ -458,7 +459,7 @@ class Cell {
 			for( c in ps.columns ) {
 				var pval = Reflect.field(v, c.name);
 				if( pval == null && c.opt ) continue;
-				if( !canViewSubColumn(ps, c.name) ) continue;
+				if( !canViewSubColumn(ps, c) ) continue;
 				out.push(c.name+" : "+valueHtml(c, pval, ps, v, scope).str);
 			}
 			scope.pop();
@@ -830,7 +831,7 @@ class Cell {
 		switch( column.type ) {
 		case TString if( column.kind == Script ):
 			open();
-		case TInt, TFloat, TString, TId, TDynamic:
+		case TInt, TFloat, TString, TId, TDynamic, TGuid:
 			var val = value;
 			if (column.display == Percent) {
 				val *= 100;

+ 16 - 1
hide/comp/cdb/Editor.hx

@@ -82,6 +82,7 @@ class Editor extends Component {
 	public var cursorStates : Array<UndoState> = [];
 	public var cursorIndex : Int = 0;
 	public var formulas : Formulas;
+	public var showGUIDs = false;
 
 	public var gradientEditor: GradientEditor;
 
@@ -2124,10 +2125,24 @@ class Editor extends Component {
 			})});
 
 			switch(col.type) {
-			case TId | TString:
+			case TId | TString | TGuid:
 				menu.push({ label : "Sort", click: () -> table.sortBy(col), enabled : table.displayMode != AllProperties });
 			default:
 			}
+
+			var hasGUID = false;
+			for( s in base.sheets )
+				for( c in s.columns )
+					if( c.type == TGuid ) {
+						hasGUID = true;
+						break;
+					}
+			if( hasGUID ) {
+				menu.push({ label : "Display GUIDs", checked : showGUIDs, click : function() {
+					showGUIDs = !showGUIDs;
+					refresh();
+				} });
+			}
 		}
 
 		if( col.type == TString && col.kind == Script )

+ 1 - 1
hide/comp/cdb/Formulas.hx

@@ -416,7 +416,7 @@ class FormulasView extends hide.view.Script {
 				case TList, TProperties:
 					var t = TInst(cdefs.get(s.name+"@"+c.name),[]);
 					c.type == TList ? @:privateAccess check.checker.types.getType("Array",[t]) : t;
-				case TString, TFile:
+				case TString, TFile, TGuid:
 					tstring;
 				}
 				if( t == null ) continue;

+ 3 - 0
hide/comp/cdb/ModalColumnForm.hx

@@ -59,6 +59,7 @@ class ModalColumnForm extends Modal {
 				<option value="gradient">Gradient</option>
 				<option value="curve">Curve</option>
 				<option value="custom">Custom Type</option>
+				<option value="guid">GUID</option>
 				</select>
 				</tr>
 
@@ -425,6 +426,8 @@ class ModalColumnForm extends Modal {
 			TDynamic;
 		case "properties":
 			TProperties;
+		case "guid":
+			TGuid;
 		default:
 			return null;
 		}

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

@@ -99,6 +99,15 @@ class Table extends Component {
 	public function refresh() {
 		element.empty();
 		columns = view == null || view.show == null ? sheet.columns : [for( c in sheet.columns ) if( view.show.indexOf(c.name) >= 0 ) c];
+		if( !editor.showGUIDs ) {
+			var cols = null;
+			for( c in columns )
+				if( c.type == TGuid && !c.opt ) {
+					if( cols == null ) cols = columns.copy();
+					cols.remove(c);
+				}
+			if( cols != null ) columns = cols;
+		}
 		switch( displayMode ) {
 		case Table:
 			refreshTable();