Kaynağa Gözat

CDB : convert text input into long_text when over 22 characters

https://app.clickup.com/t/1u0gg6d
Jed974 3 yıl önce
ebeveyn
işleme
8674a92462
1 değiştirilmiş dosya ile 19 ekleme ve 2 silme
  1. 19 2
      hide/comp/cdb/Cell.hx

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

@@ -568,11 +568,28 @@ class Cell extends Component {
 			var textSpan = element.wrapInner("<span>").find("span");
 			var textHeight = textSpan.height();
 			var textWidth = textSpan.width();
-			var longText = textHeight > 25 || str.indexOf("\n") >= 0;
+			var longText = textHeight > 25 || str.indexOf("\n") >= 0 || str.length > 22;
 			element.empty();
 			element.addClass("edit");
 			var i = new Element(longText ? "<textarea>" : "<input>").appendTo(element);
-			i.keypress(function(e) e.stopPropagation());
+			i.keypress(function(e) {
+				if (!longText) {
+					longText = i.val().length > 22;
+					if (longText) {
+						var old = currentValue;
+						// hack to tranform the input into textarea
+						var newVal = i.val();
+						Reflect.setField(line.obj, column.name, newVal+"x");
+						refresh();
+						Reflect.setField(line.obj, column.name,old);
+						currentValue = newVal;
+						edit();
+						(cast element.find("textarea")[0] : js.html.TextAreaElement).setSelectionRange(newVal.length,newVal.length);
+						e.preventDefault();
+					}
+				}
+				e.stopPropagation();
+			});
 			i.dblclick(function(e) e.stopPropagation());
 			//if( str != "" && (table.displayMode == Properties || table.displayMode == AllProperties) )
 			//	i.css({ width : Math.ceil(textWidth - 3) + "px" }); -- bug if small text ?