编辑表格功能:文件属性单元格编辑后显示客户端文件名而非服务端文件标识

This commit is contained in:
datagear 2018-12-19 10:56:52 +08:00
parent 3848789d83
commit 6e628cf556
5 changed files with 134 additions and 39 deletions

View File

@ -109,6 +109,8 @@ public class DataController extends AbstractSchemaModelController
@Autowired
private SqlTimeFormatter sqlTimeFormatter;
private int queryLeftClobLengthOnReading = 250;
public DataController()
{
super();
@ -223,6 +225,16 @@ public class DataController extends AbstractSchemaModelController
this.sqlTimeFormatter = sqlTimeFormatter;
}
public int getQueryLeftClobLengthOnReading()
{
return queryLeftClobLengthOnReading;
}
public void setQueryLeftClobLengthOnReading(int queryLeftClobLengthOnReading)
{
this.queryLeftClobLengthOnReading = queryLeftClobLengthOnReading;
}
@RequestMapping("/{schemaId}/{tableName}/query")
public String query(HttpServletRequest request, HttpServletResponse response,
org.springframework.ui.Model springModel, @PathVariable("schemaId") String schemaId,
@ -243,6 +255,8 @@ public class DataController extends AbstractSchemaModelController
}
}.execute();
setGridPageAttributes(request, springModel);
return "/data/data_grid";
}
@ -293,7 +307,7 @@ public class DataController extends AbstractSchemaModelController
}
}.execute();
setParseDateFormats(request, springModel);
setFormPageAttributes(request, springModel);
return "/data/data_form";
}
@ -418,7 +432,7 @@ public class DataController extends AbstractSchemaModelController
}
}.execute();
setParseDateFormats(request, springModel);
setFormPageAttributes(request, springModel);
return "/data/data_form";
}
@ -529,7 +543,7 @@ public class DataController extends AbstractSchemaModelController
}
}.execute();
setParseDateFormats(request, springModel);
setFormPageAttributes(request, springModel);
return "/data/data_form";
}
@ -564,6 +578,8 @@ public class DataController extends AbstractSchemaModelController
}
}.execute();
setGridPageAttributes(request, springModel);
return "/data/data_select_prop_value";
}
@ -627,7 +643,7 @@ public class DataController extends AbstractSchemaModelController
}
}.execute();
setParseDateFormats(request, springModel);
setFormPageAttributes(request, springModel);
return "/data/data_prop_value_form";
}
@ -710,7 +726,7 @@ public class DataController extends AbstractSchemaModelController
}
}.execute();
setParseDateFormats(request, springModel);
setFormPageAttributes(request, springModel);
return "/data/data_prop_value_form";
}
@ -799,7 +815,7 @@ public class DataController extends AbstractSchemaModelController
}
}.execute();
setParseDateFormats(request, springModel);
setFormPageAttributes(request, springModel);
return "/data/data_prop_value_form";
}
@ -834,6 +850,8 @@ public class DataController extends AbstractSchemaModelController
}
}.execute();
setGridPageAttributes(request, springModel);
return "/data/data_prop_value_grid";
}
@ -906,6 +924,8 @@ public class DataController extends AbstractSchemaModelController
}
}.execute();
setGridPageAttributes(request, springModel);
return "/data/data_prop_value_grid";
}
@ -933,7 +953,7 @@ public class DataController extends AbstractSchemaModelController
}
}.execute();
setParseDateFormats(request, springModel);
setFormPageAttributes(request, springModel);
return "/data/data_prop_value_form";
}
@ -1094,7 +1114,7 @@ public class DataController extends AbstractSchemaModelController
}
}.execute();
setParseDateFormats(request, springModel);
setFormPageAttributes(request, springModel);
return "/data/data_prop_value_form";
}
@ -1225,7 +1245,7 @@ public class DataController extends AbstractSchemaModelController
}
}.execute();
setParseDateFormats(request, springModel);
setFormPageAttributes(request, springModel);
return "/data/data_prop_value_form";
}
@ -1395,7 +1415,8 @@ public class DataController extends AbstractSchemaModelController
{
File blobToFilePlaceholder = new File(this.blobFileManagerDirectory, this.blobToFilePlaceholderName);
return new LOBConversionSetting(blobToFilePlaceholder, BLOB_TO_BYTES_PLACEHOLDER, 100);
return new LOBConversionSetting(blobToFilePlaceholder, BLOB_TO_BYTES_PLACEHOLDER,
this.queryLeftClobLengthOnReading);
}
/**
@ -1458,12 +1479,23 @@ public class DataController extends AbstractSchemaModelController
}
/**
* 设置日期格式
* 设置表格页面属性
*
* @param request
* @param springModel
*/
protected void setParseDateFormats(HttpServletRequest request, org.springframework.ui.Model springModel)
protected void setGridPageAttributes(HttpServletRequest request, org.springframework.ui.Model springModel)
{
springModel.addAttribute("queryLeftClobLengthOnReading", this.queryLeftClobLengthOnReading);
}
/**
* 设置表单页面属性
*
* @param request
* @param springModel
*/
protected void setFormPageAttributes(HttpServletRequest request, org.springframework.ui.Model springModel)
{
Locale locale = WebUtils.getLocale(request);

View File

@ -263,6 +263,7 @@ WebUtils.setPageId(request, gridPageId);
},
filePropertyUploadURL : "<c:url value='/data/file/upload' />",
filePropertyDeleteURL : "<c:url value='/data/file/delete' />",
filePropertyValueReturnDetail : true,
downloadSinglePropertyValueFile : function(property, propertyConcreteModel)
{
po.editGridFormPage.downloadSinglePropertyValueFile(property, propertyConcreteModel);

View File

@ -468,6 +468,15 @@
return index;
},
/**
* 获取指定属性值对应的属性模型
*/
getPropertyModelByValue : function(property, propertyValue)
{
//TODO 处理抽象属性
return property.model;
},
/**
* 判断属性是否是抽象属性
*
@ -1108,6 +1117,14 @@
if(this.isPrimitiveModel(model))
{
if(this.isFileTypeModel(model))
{
var rawValue = this.getFilePropertyRawValue(obj);
var showValue = this.getFilePropertyShowValue(obj);
obj = (showValue ? showValue : rawValue);
}
re=obj+"";
}
else
@ -1194,8 +1211,7 @@
}
else
{
//TODO 处理抽象属性
var propertyModel = property.model;
var propertyModel = this.getPropertyModelByValue(property, propertyValue);
var ignorePropertyName = this.findMappedByWith(property, propertyModel);
re = this.token(propertyModel, v, ignorePropertyName);
@ -1208,6 +1224,44 @@
return re;
},
/**
* 构建文件属性详细值对象
*/
toFilePropertyDetailValue : function(value, showValue)
{
return { "value" : value, "showValue" : showValue };
},
/**
* 是否是文件属性详细值对象
*/
isFilePropertyDetailValue : function(value)
{
return $.isPlainObject(value);
},
/**
* 获取原始文件属性值
*/
getFilePropertyRawValue : function(value)
{
if(this.isFilePropertyDetailValue(value))
return value.value;
else
return value;
},
/**
* 获取显示文件属性值
*/
getFilePropertyShowValue : function(value)
{
if(this.isFilePropertyDetailValue(value))
return value.showValue;
else
return undefined;
},
/**
* 判断是否有org.datagear.model.features.Select特性
*/

View File

@ -78,6 +78,10 @@
//可选,文件属性值删除时的文件参数名
filePropertyDeleteParamName : "file",
//可选,文件属性值是否采用详细信息对象,而非基本文件名称值
//详细信息对象格式:{ value : "...", showValue : "..." }
filePropertyValueReturnDetail : false,
//"readonly=false"时必须,下载单元文件属性值处理函数
downloadSinglePropertyValueFile : function(property, propertyConcreteModel){ throw new Error("TODO"); },
@ -542,7 +546,7 @@
{
var myPropName = $(this).attr("__propName");
var myproperty = $.model.getProperty(_this.options.model, myPropName);
var myConcreteModel = myproperty.model;//TODO 处理抽象属性
var myConcreteModel = $.model.getPropertyModelByValue(myproperty, propValue);
var callback = (_this.options.readonly ? _this.options.viewMultiplePropertyValue : _this.options.editMultiplePropertyValue);
callback.call(_this.element, myproperty, myConcreteModel);
@ -586,7 +590,7 @@
this._addValidatorRequired(property, propName);
},
/**
* 渲染文件上传表单元素
*/
@ -612,7 +616,9 @@
.html(options.labels.downloadFile)
.appendTo(valuediv);
if(!propValue)
var rawValue = $.model.getFilePropertyRawValue(propValue);
if(!rawValue)
fileDownloadButton.attr("disabled", true);
fileDownloadButton.button();
@ -621,12 +627,9 @@
{
var myPropName = $(this).attr("__propName");
var myproperty = $.model.getProperty(_this.options.model, myPropName);
var myPropertyWidget = _this._propertyWidgets[myPropName];
var propValue = myPropertyWidget.getValue();
var myConcreteModel = myproperty.model;//TODO 处理抽象属性
var myConcreteModel = $.model.getPropertyModelByValue(myproperty, propValue);
_this.options.downloadSinglePropertyValueFile.call(_this.element, myproperty, myConcreteModel, propValue);
_this.options.downloadSinglePropertyValueFile.call(_this.element, myproperty, myConcreteModel);
});
}
else
@ -666,7 +669,7 @@
var propValue = this.__propValue;
var propertyWidget = _this._propertyWidgets[propName];
propertyWidget.setValue(serverFileInfo.name, clientFileName, true);
propertyWidget.setValue({ "value" : serverFileInfo.name, "showValue" : clientFileName }, true);
$.fileuploadsuccessHandlerForUploadInfo(fileInfoDiv);
@ -715,15 +718,15 @@
var myproperty = $.model.getProperty(_this.options.model, myPropName);
var myPropertyWidget = _this._propertyWidgets[myPropName];
var myConcreteModel = myproperty.model;//TODO 处理抽象属性
var propValue = myPropertyWidget.getValue();
var myConcreteModel = $.model.getPropertyModelByValue(myproperty, propValue);
if("download" == action)
{
var propValue = myPropertyWidget.getValue();
var rawValue = $.model.getFilePropertyRawValue(propValue);
if(propValue)
_this.options.downloadSinglePropertyValueFile.call(_this.element, myproperty, myConcreteModel, propValue);
if(rawValue)
_this.options.downloadSinglePropertyValueFile.call(_this.element, myproperty, myConcreteModel);
}
else if("del" == action)
{
@ -742,20 +745,26 @@
propertyWidget.getValue = function()
{
return $(this.fileInputHidden).val();
if(options.filePropertyValueReturnDetail)
return $.model.toFilePropertyDetailValue($(this.fileInputHidden).val(), $(this.fileInputShow).val());
else
return $(this.fileInputHidden).val();
};
propertyWidget.setValue = function(value, showValue, reserveFileInfo)
propertyWidget.setValue = function(value, reserveFileInfo)
{
$(this.fileInputHidden).val(value ? value : "");
var rawValue = $.model.getFilePropertyRawValue(value);
var showValue = $.model.getFilePropertyShowValue(value);
$(this.fileInputHidden).val(rawValue ? rawValue : "");
if(showValue)
$(this.fileInputShow).val(showValue);
else
$(this.fileInputShow).val((value ? value : ""));
$(this.fileInputShow).val((rawValue ? rawValue : ""));
if(this.fileInfoDiv)
{
if(arguments.length >= 3 && reserveFileInfo)
if(reserveFileInfo)
;
else
$(this.fileInfoDiv).empty();
@ -863,7 +872,7 @@
{
var myPropName = $(this).attr("__propName");
var myproperty = $.model.getProperty(_this.options.model, myPropName);
var myConcreteModel = myproperty.model;//TODO 处理抽象属性
var myConcreteModel = $.model.getPropertyModelByValue(myproperty, propValue);
_this.options.viewSinglePropertyValue.call(_this.element, myproperty, myConcreteModel);
});
}
@ -880,7 +889,7 @@
{
var myPropName = $(this).attr("__propName");
var myproperty = $.model.getProperty(_this.options.model, myPropName);
var myConcreteModel = myproperty.model;//TODO 处理抽象属性
var myConcreteModel = $.model.getPropertyModelByValue(myproperty, propValue);
_this.options.deleteSinglePropertyValue.call(_this.element, myproperty, myConcreteModel);
}
@ -897,7 +906,7 @@
{
var myPropName = $(this).attr("__propName");
var myproperty = $.model.getProperty(_this.options.model, myPropName);
var myConcreteModel = myproperty.model;//TODO 处理抽象属性
var myConcreteModel = $.model.getPropertyModelByValue(myproperty, propValue);
var myPropertyWidget = _this._propertyWidgets[myPropName];
//属性值必须动态判断,因为界面编辑时也可能设置值
@ -912,7 +921,7 @@
{
var myPropName = $(this).attr("__propName");
var myproperty = $.model.getProperty(_this.options.model, myPropName);
var myConcreteModel = myproperty.model;//TODO 处理抽象属性
var myConcreteModel = $.model.getPropertyModelByValue(myproperty, propValue);
_this.options.selectSinglePropertyValue.call(_this.element, myproperty, myConcreteModel);
});
@ -937,7 +946,7 @@
var myPropName = $(ui.item.element).attr("__propName");
var myproperty = $.model.getProperty(_this.options.model, myPropName);
var myConcreteModel = myproperty.model;//TODO 处理抽象属性
var myConcreteModel = $.model.getPropertyModelByValue(myproperty, propValue);
/*
if("edit" == action)

View File

@ -757,7 +757,6 @@
var propertyIndex = thisColumn.propertyIndex;
var property = model.properties[propertyIndex];
var propertyModel = property.model;
renderValue = $.model.tokenProperty(property, data);
renderValue = $.truncateIf(renderValue, "...", thisColumn.stringDisplayThreshold);