2
0
Эх сурвалжийг харах

add column moved from editor to table (now works with subtables)

Nicolas Cannasse 6 жил өмнө
parent
commit
7132ec334f

+ 0 - 5
hide/comp/cdb/Editor.hx

@@ -423,11 +423,6 @@ class Editor extends Component {
 			cursor.load(c);
 		});
 
-		if( sheet.columns.length == 0 ) {
-			new Element("<input type='button' value='Add a column'/>").appendTo(element).click(function(_) newColumn(sheet));
-			return;
-		}
-
 		var content = new Element("<table>");
 		tables = [];
 		new Table(this, sheet, content, displayMode);

+ 8 - 3
hide/comp/cdb/Table.hx

@@ -156,9 +156,14 @@ class Table extends Component {
 		}
 		element.append(tbody);
 
-		if( sheet.lines.length == 0 ) {
-			var l = J('<tr><td colspan="${sheet.columns.length + 1}"><a>Insert Line</a></td></tr>');
-			l.find("a").click(function(_) {
+		if( colCount == 0 ) {
+			var l = J('<tr><td><input type="button" value="Add a column"/></td></tr>').find("input").click(function(_) {
+				editor.newColumn(sheet);
+			});
+			element.append(l);
+		} else if( sheet.lines.length == 0 ) {
+			var l = J('<tr><td colspan="${sheet.columns.length + 1}"><input type="button" value="Insert Line"/></td></tr>');
+			l.find("input").click(function(_) {
 				editor.insertLine(this);
 				editor.cursor.set(this);
 			});