forked from p81075629/datagear
数据集表单页面添加属性编辑功能
This commit is contained in:
parent
f7abcc89f7
commit
2efd688232
|
@ -22,8 +22,6 @@ public interface DataSetEntity extends DataSet, CreateUserEntity<String>, DataPe
|
|||
/** 授权资源类型 */
|
||||
String AUTHORIZATION_RESOURCE_TYPE = "DataSet";
|
||||
|
||||
String PROPERTY_LABELS_SPLITTER = ",";
|
||||
|
||||
/** 数据集类型:SQL */
|
||||
String DATA_SET_TYPE_SQL = "SQL";
|
||||
|
||||
|
@ -78,49 +76,4 @@ public interface DataSetEntity extends DataSet, CreateUserEntity<String>, DataPe
|
|||
* @param createTime
|
||||
*/
|
||||
void setCreateTime(Date createTime);
|
||||
|
||||
/**
|
||||
* 获取属性集的标签文本表示形式。
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
String getPropertyLabelsText();
|
||||
|
||||
/**
|
||||
* 设置属性集的标签文本表示形式。
|
||||
*
|
||||
* @param text
|
||||
*/
|
||||
void setPropertyLabelsText(String text);
|
||||
|
||||
/**
|
||||
* 获取属性集的标签文本表示形式。
|
||||
*
|
||||
* @param properties
|
||||
* @return
|
||||
*/
|
||||
public static String getPropertyLabelsText(List<DataSetProperty> properties)
|
||||
{
|
||||
return DataSetProperty.concatLabels(properties, PROPERTY_LABELS_SPLITTER);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置属性集的标签文本表示形式。
|
||||
*
|
||||
* @param properties
|
||||
* @param text
|
||||
*/
|
||||
public static void setPropertyLabelsText(List<DataSetProperty> properties, String text)
|
||||
{
|
||||
String[] labels = DataSetProperty.splitLabels(text, PROPERTY_LABELS_SPLITTER);
|
||||
|
||||
if (labels == null || labels.length == 0)
|
||||
return;
|
||||
|
||||
for (int i = 0; i < Math.min(labels.length, properties.size()); i++)
|
||||
{
|
||||
if (i < labels.length)
|
||||
properties.get(i).setLabel(labels[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,8 +32,6 @@ public class JsonValueDataSetEntity extends JsonValueDataSet implements DataSetE
|
|||
/** 权限 */
|
||||
private int dataPermission = PERMISSION_NOT_LOADED;
|
||||
|
||||
private transient String _propertyLabelsText;
|
||||
|
||||
public JsonValueDataSetEntity()
|
||||
{
|
||||
super();
|
||||
|
@ -96,33 +94,4 @@ public class JsonValueDataSetEntity extends JsonValueDataSet implements DataSetE
|
|||
{
|
||||
this.dataPermission = dataPermission;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setProperties(List<DataSetProperty> properties)
|
||||
{
|
||||
super.setProperties(properties);
|
||||
|
||||
if(this._propertyLabelsText != null)
|
||||
DataSetEntity.setPropertyLabelsText(properties, this._propertyLabelsText);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPropertyLabelsText(String text)
|
||||
{
|
||||
List<DataSetProperty> properties = getProperties();
|
||||
|
||||
if(properties == null || properties.isEmpty())
|
||||
this._propertyLabelsText = text;
|
||||
else
|
||||
{
|
||||
this._propertyLabelsText = null;
|
||||
DataSetEntity.setPropertyLabelsText(properties, text);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPropertyLabelsText()
|
||||
{
|
||||
return DataSetEntity.getPropertyLabelsText(getProperties());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,8 +33,6 @@ public class SqlDataSetEntity extends SqlDataSet implements DataSetEntity
|
|||
/** 权限 */
|
||||
private int dataPermission = PERMISSION_NOT_LOADED;
|
||||
|
||||
private transient String _propertyLabelsText;
|
||||
|
||||
public SqlDataSetEntity()
|
||||
{
|
||||
super();
|
||||
|
@ -42,8 +40,7 @@ public class SqlDataSetEntity extends SqlDataSet implements DataSetEntity
|
|||
}
|
||||
|
||||
public SqlDataSetEntity(String id, String name, List<DataSetProperty> properties,
|
||||
SchemaConnectionFactory connectionFactory,
|
||||
String sql, User createUser)
|
||||
SchemaConnectionFactory connectionFactory, String sql, User createUser)
|
||||
{
|
||||
super(id, name, properties, connectionFactory, sql);
|
||||
this.createTime = new Date();
|
||||
|
@ -123,33 +120,4 @@ public class SqlDataSetEntity extends SqlDataSet implements DataSetEntity
|
|||
{
|
||||
this.dataPermission = dataPermission;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setProperties(List<DataSetProperty> properties)
|
||||
{
|
||||
super.setProperties(properties);
|
||||
|
||||
if(this._propertyLabelsText != null)
|
||||
DataSetEntity.setPropertyLabelsText(properties, this._propertyLabelsText);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPropertyLabelsText(String text)
|
||||
{
|
||||
List<DataSetProperty> properties = getProperties();
|
||||
|
||||
if(properties == null || properties.isEmpty())
|
||||
this._propertyLabelsText = text;
|
||||
else
|
||||
{
|
||||
this._propertyLabelsText = null;
|
||||
DataSetEntity.setPropertyLabelsText(properties, text);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPropertyLabelsText()
|
||||
{
|
||||
return DataSetEntity.getPropertyLabelsText(getProperties());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,8 +15,6 @@ import org.datagear.analysis.DataSetException;
|
|||
import org.datagear.analysis.DataSetResult;
|
||||
import org.datagear.analysis.support.AbstractDataSet;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
|
||||
/**
|
||||
* 概要数据集实体。
|
||||
*
|
||||
|
@ -98,19 +96,6 @@ public class SummaryDataSetEntity extends AbstractDataSet implements DataSetEnti
|
|||
this.dataPermission = dataPermission;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPropertyLabelsText(String text)
|
||||
{
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
@Override
|
||||
public String getPropertyLabelsText()
|
||||
{
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataSetResult getResult(Map<String, ?> paramValues) throws DataSetException
|
||||
{
|
||||
|
|
|
@ -601,11 +601,12 @@ dataSet.dataSetType.JSON_VALUE=JSON
|
|||
dataSet.dataSource=\u6570\u636E\u6E90
|
||||
dataSet.sql=SQL\u8BED\u53E5
|
||||
dataSet.json=JSON
|
||||
dataSet.propertyLabelsText.SQL=SQL\u7ED3\u679C\u5217\u6807\u7B7E
|
||||
dataSet.propertyLabelsText.JSON_VALUE=JSON\u5C5E\u6027\u6807\u7B7E
|
||||
dataSet.createUser=\u521B\u5EFA\u7528\u6237
|
||||
dataSet.createTime=\u521B\u5EFA\u65F6\u95F4
|
||||
dataSet.param=\u53C2\u6570
|
||||
dataSet.param.desc=\u5B9A\u4E49\u6570\u636E\u96C6\u7684\u8F93\u5165\u53C2\u6570
|
||||
dataSet.property=\u5C5E\u6027
|
||||
dataSet.property.desc=\u5B9A\u4E49\u6570\u636E\u96C6\u7684\u6570\u636E\u7ED3\u6784
|
||||
dataSet.setParamValue=\u8BBE\u7F6E\u53C2\u6570\u503C
|
||||
dataSet.loadMoreData=\u52A0\u8F7D\u66F4\u591A\u6570\u636E
|
||||
dataSet.refreshSqlResult=\u5237\u65B0\u67E5\u8BE2\u7ED3\u679C
|
||||
|
@ -613,8 +614,8 @@ dataSet.noMoreData=\u6CA1\u6709\u66F4\u591A\u6570\u636E\u4E86
|
|||
dataSet.previewButtonTip=\u9884\u89C8\u7ED3\u679C\u6570\u636E\uFF08\u7F16\u8F91\u533A\uFF1ACtrl+Enter\uFF09
|
||||
dataSet.DataCategory.DIMENSION=\u7EF4\u5EA6
|
||||
dataSet.DataCategory.SCALAR=\u91CF\u5EA6
|
||||
dataSet.propertyLabelsTextSplitByComma=\u591A\u4E2A\u6807\u7B7E\u4EE5\u82F1\u6587\u9017\u53F7(,)\u5206\u9694
|
||||
dataSet.validation.previewRequired=\u8BF7\u5148\u6267\u884C\u9884\u89C8\u786E\u4FDD\u6570\u636E\u6B63\u786E
|
||||
dataSet.validation.propertiesRequired=\u8BF7\u5B9A\u4E49\u6570\u636E\u96C6\u5C5E\u6027
|
||||
dataSet.auth.resouceTypeLabel=\u6570\u636E\u96C6
|
||||
dataSet.DataSetParam.name=\u540D\u79F0
|
||||
dataSet.DataSetParam.type=\u7C7B\u578B
|
||||
|
@ -634,6 +635,17 @@ dataSet.DataSetParam.InputType.RADIO=\u5355\u9009\u6846
|
|||
dataSet.DataSetParam.InputType.CHECKBOX=\u590D\u9009\u6846
|
||||
dataSet.DataSetParam.InputType.TEXTAREA=\u6587\u672C\u57DF
|
||||
dataSet.noDataSetParamDefined=\u6CA1\u6709\u5B9A\u4E49\u53C2\u6570
|
||||
dataSet.DataSetProperty.name=\u540D\u79F0
|
||||
dataSet.DataSetProperty.type=\u7C7B\u578B
|
||||
dataSet.DataSetProperty.label=\u5C55\u793A\u540D\u79F0
|
||||
dataSet.DataSetProperty.DataType.STRING=\u5B57\u7B26\u4E32
|
||||
dataSet.DataSetProperty.DataType.BOOLEAN=\u5E03\u5C14\u503C
|
||||
dataSet.DataSetProperty.DataType.INTEGER=\u6574\u6570
|
||||
dataSet.DataSetProperty.DataType.DECIMAL=\u5C0F\u6570
|
||||
dataSet.DataSetProperty.DataType.DATE=\u65E5\u671F
|
||||
dataSet.DataSetProperty.DataType.TIME=\u65F6\u95F4
|
||||
dataSet.DataSetProperty.DataType.TIMESTAMP=\u65F6\u95F4\u6233
|
||||
dataSet.noDataSetPropertyDefined=\u6CA1\u6709\u5B9A\u4E49\u5C5E\u6027
|
||||
|
||||
#Chart
|
||||
chart.manageChart=\u7BA1\u7406\u56FE\u8868
|
||||
|
|
|
@ -2186,7 +2186,7 @@ table.dataTable tbody tr .column-check .row-data-state .ui-icon{
|
|||
.page-form-dataSet .workspace-operation-wrapper .input-in-table{
|
||||
width: 90%!important;
|
||||
}
|
||||
.page-form-dataSet .form-item-value-workspace .error{
|
||||
.page-form-dataSet .form-item-workspace .error{
|
||||
display: block;
|
||||
}
|
||||
.page-form-dataSet .preview-param-value-panel{
|
||||
|
@ -2194,6 +2194,8 @@ table.dataTable tbody tr .column-check .row-data-state .ui-icon{
|
|||
display: none;
|
||||
padding: 0.5em 0.5em;
|
||||
max-height: 80%;
|
||||
min-width: 30%;
|
||||
max-width: 60%;
|
||||
overflow: auto;
|
||||
}
|
||||
.page-form-dataSet .preview-param-value-panel .ui-widget-header{
|
||||
|
|
|
@ -98,7 +98,7 @@ boolean readonly 是否只读操作,默认为false
|
|||
{
|
||||
var data = {"id" : row.id};
|
||||
|
||||
po.open(po.url("edit"), { data : data });
|
||||
po.open(po.url("edit"), { width: "85%", data : data });
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -127,6 +127,7 @@ boolean readonly 是否只读操作,默认为false
|
|||
|
||||
po.open(po.url("view"),
|
||||
{
|
||||
width: "85%",
|
||||
data : data
|
||||
});
|
||||
});
|
||||
|
|
|
@ -95,7 +95,7 @@ selectOperation 是否选择操作,允许为null
|
|||
{
|
||||
var data = {"id" : row.id};
|
||||
|
||||
po.open(po.url("edit"), { data : data });
|
||||
po.open(po.url("edit"), { width: "85%", data : data });
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -124,6 +124,7 @@ selectOperation 是否选择操作,允许为null
|
|||
|
||||
po.open(po.url("view"),
|
||||
{
|
||||
width: "85%",
|
||||
data : data
|
||||
});
|
||||
});
|
||||
|
|
|
@ -21,11 +21,11 @@ readonly 是否只读操作,允许为null
|
|||
<div class="form-head"></div>
|
||||
<div class="form-content">
|
||||
<#include "include/dataSet_form_html_name.ftl">
|
||||
<div class="form-item">
|
||||
<div class="form-item form-item-workspace">
|
||||
<div class="form-item-label">
|
||||
<label><@spring.message code='dataSet.json' /></label>
|
||||
</div>
|
||||
<div class="form-item-value form-item-value-workspace">
|
||||
<div class="form-item-value">
|
||||
<textarea name="value" class="ui-widget ui-widget-content" style="display:none;">${(dataSet.value)!''?html}</textarea>
|
||||
<div class="workspace-editor-wrapper ui-widget ui-widget-content">
|
||||
<div id="${pageId}-workspaceEditor" class="workspace-editor"></div>
|
||||
|
@ -33,14 +33,6 @@ readonly 是否只读操作,允许为null
|
|||
<#include "include/dataSet_form_html_wow.ftl" >
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-item">
|
||||
<div class="form-item-label">
|
||||
<label><@spring.message code='dataSet.propertyLabelsText.JSON_VALUE' /></label>
|
||||
</div>
|
||||
<div class="form-item-value">
|
||||
<input type="text" name="propertyLabelsText" class="ui-widget ui-widget-content" value="${(dataSet.propertyLabelsText)!''?html}" placeholder="<@spring.message code='dataSet.propertyLabelsTextSplitByComma' />" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-foot" style="text-align:center;">
|
||||
<#if !readonly>
|
||||
|
@ -82,16 +74,14 @@ readonly 是否只读操作,允许为null
|
|||
|
||||
po.initWorkspaceEditor(po.jsonEditor, po.element("textarea[name='value']").val());
|
||||
|
||||
po.isWorkspaceModified = function()
|
||||
{
|
||||
return po.isValueModified();
|
||||
};
|
||||
po.initWorkspaceTabs();
|
||||
|
||||
po.initDataSetPropertiesTable(po.dataSetProperties);
|
||||
|
||||
po.getAddParamName = function()
|
||||
{
|
||||
var selectionRange = po.sqlEditor.getSelectionRange();
|
||||
return (po.sqlEditor.session.getTextRange(selectionRange) || "");
|
||||
var selectionRange = po.jsonEditor.getSelectionRange();
|
||||
return (po.jsonEditor.session.getTextRange(selectionRange) || "");
|
||||
};
|
||||
po.initDataSetParamsTable(po.dataSetParams);
|
||||
|
||||
|
|
|
@ -33,11 +33,11 @@ readonly 是否只读操作,允许为null
|
|||
</#if>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-item">
|
||||
<div class="form-item form-item-workspace">
|
||||
<div class="form-item-label">
|
||||
<label><@spring.message code='dataSet.sql' /></label>
|
||||
</div>
|
||||
<div class="form-item-value form-item-value-workspace">
|
||||
<div class="form-item-value">
|
||||
<textarea name="sql" class="ui-widget ui-widget-content" style="display:none;">${(dataSet.sql)!''?html}</textarea>
|
||||
<div class="workspace-editor-wrapper ui-widget ui-widget-content">
|
||||
<div id="${pageId}-workspaceEditor" class="workspace-editor"></div>
|
||||
|
@ -45,14 +45,6 @@ readonly 是否只读操作,允许为null
|
|||
<#include "include/dataSet_form_html_wow.ftl" >
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-item">
|
||||
<div class="form-item-label">
|
||||
<label><@spring.message code='dataSet.propertyLabelsText.SQL' /></label>
|
||||
</div>
|
||||
<div class="form-item-value">
|
||||
<input type="text" name="propertyLabelsText" class="ui-widget ui-widget-content" value="${(dataSet.propertyLabelsText)!''?html}" placeholder="<@spring.message code='dataSet.propertyLabelsTextSplitByComma' />" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-foot" style="text-align:center;">
|
||||
<#if !readonly>
|
||||
|
@ -119,12 +111,10 @@ readonly 是否只读操作,允许为null
|
|||
|
||||
po.initWorkspaceEditor(po.sqlEditor, po.element("textarea[name='sql']").val());
|
||||
|
||||
po.isWorkspaceModified = function()
|
||||
{
|
||||
return po.isSqlModified();
|
||||
};
|
||||
po.initWorkspaceTabs();
|
||||
|
||||
po.initDataSetPropertiesTable(po.dataSetProperties);
|
||||
|
||||
po.getAddParamName = function()
|
||||
{
|
||||
var selectionRange = po.sqlEditor.getSelectionRange();
|
||||
|
@ -164,7 +154,6 @@ readonly 是否只读操作,允许为null
|
|||
po.previewOptions.success = function(previewResponse)
|
||||
{
|
||||
po.element("textarea[name='sql']").val(this.data.sql);
|
||||
po.dataSetProperties = (previewResponse.dataSetProperties || []);
|
||||
po.sqlEditor.focus();
|
||||
};
|
||||
|
||||
|
@ -231,18 +220,23 @@ readonly 是否只读操作,允许为null
|
|||
{
|
||||
"name" : "required",
|
||||
"schemaConnectionFactory.schema.title" : "required",
|
||||
"sql" : {"dataSetSqlRequired": true, "dataSetSqlPreviewRequired": true}
|
||||
"sql" : {"dataSetSqlRequired": true, "dataSetSqlPreviewRequired": true, "dataSetPropertiesRequired": true}
|
||||
},
|
||||
messages :
|
||||
{
|
||||
"name" : "<@spring.message code='validation.required' />",
|
||||
"schemaConnectionFactory.schema.title" : "<@spring.message code='validation.required' />",
|
||||
"sql" : {"dataSetSqlRequired": "<@spring.message code='validation.required' />", "dataSetSqlPreviewRequired": "<@spring.message code='dataSet.validation.previewRequired' />"}
|
||||
"sql" :
|
||||
{
|
||||
"dataSetSqlRequired": "<@spring.message code='validation.required' />",
|
||||
"dataSetSqlPreviewRequired": "<@spring.message code='dataSet.validation.previewRequired' />",
|
||||
"dataSetPropertiesRequired": "<@spring.message code='dataSet.validation.propertiesRequired' />"
|
||||
}
|
||||
},
|
||||
submitHandler : function(form)
|
||||
{
|
||||
var formData = $.formToJson(form);
|
||||
formData["properties"] = po.dataSetProperties;
|
||||
formData["properties"] = po.getFormDataSetProperties();
|
||||
formData["params"] = po.getFormDataSetParams();
|
||||
|
||||
$.postJson("${contextPath}/analysis/dataSet/${formAction}", formData,
|
||||
|
|
|
@ -124,7 +124,7 @@ boolean readonly 是否只读操作,默认为false
|
|||
{
|
||||
var data = {"id" : row.id};
|
||||
|
||||
po.open(po.url("edit"), { data : data });
|
||||
po.open(po.url("edit"), { width: "85%", data : data });
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -153,6 +153,7 @@ boolean readonly 是否只读操作,默认为false
|
|||
|
||||
po.open(po.url("view"),
|
||||
{
|
||||
width: "85%",
|
||||
data : data
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
<#--
|
||||
数据集表单页:预览、参数操作区
|
||||
数据集表单页:预览、参数、属性操作区
|
||||
-->
|
||||
<div class="workspace-operation-wrapper">
|
||||
<ul class="workspace-operation-nav">
|
||||
<li class="operation-preview"><a href="#${pageId}-previewResult"><@spring.message code='preview' /></a></li>
|
||||
<li class="operation-params"><a href="#${pageId}-dataSetParams"><@spring.message code='dataSet.param' /></a></li>
|
||||
<li class="operation-params" title="<@spring.message code='dataSet.param.desc' />"><a href="#${pageId}-dataSetParams"><@spring.message code='dataSet.param' /></a></li>
|
||||
<li class="operation-properties" title="<@spring.message code='dataSet.property.desc' />"><a href="#${pageId}-dataSetProperties"><@spring.message code='dataSet.property' /></a></li>
|
||||
</ul>
|
||||
<div id="${pageId}-previewResult" class="preview-result-table-wrapper minor-dataTable">
|
||||
<div class="operation">
|
||||
|
@ -12,7 +13,7 @@
|
|||
<button type="button" class="more-button ui-button ui-corner-all ui-widget ui-button-icon-only" title="<@spring.message code='dataSet.loadMoreData' />"><span class="ui-button-icon ui-icon ui-icon-arrowthick-1-s"></span><span class="ui-button-icon-space"> </span><@spring.message code='sqlpad.loadMoreData' /></button>
|
||||
<button type="button" class="refresh-button ui-button ui-corner-all ui-widget ui-button-icon-only" title="<@spring.message code='dataSet.refreshSqlResult' />"><span class="ui-button-icon ui-icon ui-icon-refresh"></span><span class="ui-button-icon-space"> </span><@spring.message code='sqlpad.refreshSqlResult' /></button>
|
||||
</div>
|
||||
<table id="${pageId}-previewResult-table" width='100%' class='hover stripe'></table>
|
||||
<table id="${pageId}-previewResultTable" width='100%' class='hover stripe'></table>
|
||||
<div class='no-more-data-flag ui-widget ui-widget-content' title="<@spring.message code='dataSet.noMoreData' />"></div>
|
||||
<div class="result-resolved-source"><textarea class="ui-widget ui-widget-content ui-corner-all"></textarea></div>
|
||||
</div>
|
||||
|
@ -23,6 +24,15 @@
|
|||
<button type="button" class="del-param-button ui-button ui-corner-all ui-widget ui-button-icon-only" title="<@spring.message code='delete' />"><span class="ui-button-icon ui-icon ui-icon-close"></span><span class="ui-button-icon-space"> </span><@spring.message code='delete' /></button>
|
||||
</#if>
|
||||
</div>
|
||||
<table id="${pageId}-dataSetParams-table" class='hover stripe'></table>
|
||||
<table id="${pageId}-dataSetParamsTable" class='hover stripe'></table>
|
||||
</div>
|
||||
<div id="${pageId}-dataSetProperties" class="properties-table-wrapper minor-dataTable">
|
||||
<div class="operation">
|
||||
<#if !readonly>
|
||||
<button type="button" class="add-property-button ui-button ui-corner-all ui-widget ui-button-icon-only" title="<@spring.message code='add' />"><span class="ui-button-icon ui-icon ui-icon-plus"></span><span class="ui-button-icon-space"> </span><@spring.message code='add' /></button>
|
||||
<button type="button" class="del-property-button ui-button ui-corner-all ui-widget ui-button-icon-only" title="<@spring.message code='delete' />"><span class="ui-button-icon ui-icon ui-icon-close"></span><span class="ui-button-icon-space"> </span><@spring.message code='delete' /></button>
|
||||
</#if>
|
||||
</div>
|
||||
<table id="${pageId}-dataSetPropertiesTable" class='hover stripe'></table>
|
||||
</div>
|
||||
</div>
|
|
@ -5,13 +5,12 @@
|
|||
page_js_obj.ftl
|
||||
|
||||
变量:
|
||||
//工作空间内容是否已有变更,不允许为null
|
||||
po.isWorkspaceModified = function(){ return true | false; }
|
||||
//预览URL,不允许为null
|
||||
po.previewOptions.url = "...";
|
||||
-->
|
||||
<#assign DataType=statics['org.datagear.analysis.DataSetParam$DataType']>
|
||||
<#assign InputType=statics['org.datagear.analysis.DataSetParam$InputType']>
|
||||
<#assign PropertyDataType=statics['org.datagear.analysis.DataSetProperty$DataType']>
|
||||
<#assign ParamDataType=statics['org.datagear.analysis.DataSetParam$DataType']>
|
||||
<#assign ParamInputType=statics['org.datagear.analysis.DataSetParam$InputType']>
|
||||
<script type="text/javascript">
|
||||
(function(po)
|
||||
{
|
||||
|
@ -30,12 +29,17 @@ po.previewOptions.url = "...";
|
|||
|
||||
po.dataSetParamsTableElement = function()
|
||||
{
|
||||
return po.element("#${pageId}-dataSetParams-table");
|
||||
return po.element("#${pageId}-dataSetParamsTable");
|
||||
};
|
||||
|
||||
po.previewResultTableElement = function()
|
||||
{
|
||||
return po.element("#${pageId}-previewResult-table");
|
||||
return po.element("#${pageId}-previewResultTable");
|
||||
};
|
||||
|
||||
po.dataSetPropertiesTableElement = function()
|
||||
{
|
||||
return po.element("#${pageId}-dataSetPropertiesTable");
|
||||
};
|
||||
|
||||
po.calWorkspaceOperationTableHeight = function()
|
||||
|
@ -45,12 +49,27 @@ po.previewOptions.url = "...";
|
|||
|
||||
po.initWorkspaceHeight = function()
|
||||
{
|
||||
var editorHeight = parseInt($(window).height()/11*5);
|
||||
var height = $(window).height();
|
||||
//减去上下留白
|
||||
height = height - height/10;
|
||||
//减去对话框标题高度
|
||||
if($.isInDialog(po.element()))
|
||||
height = height - 41;
|
||||
//减去其他表单元素高度
|
||||
height = height - po.element(".form-head").outerHeight(true);
|
||||
po.element(".form-content > .form-item:not(.form-item-workspace)").each(function()
|
||||
{
|
||||
height = height - $(this).outerHeight(true);
|
||||
});
|
||||
height = height - po.element(".form-foot").outerHeight(true);
|
||||
//减去杂项高度
|
||||
height = height - 41 - 10;
|
||||
|
||||
var errorInfoHeight = 25;
|
||||
|
||||
po.element(".workspace-editor-wrapper").height(editorHeight);
|
||||
po.element(".workspace-operation-wrapper").height(editorHeight);
|
||||
po.element(".form-item-value-workspace").height(editorHeight + errorInfoHeight);
|
||||
po.element(".form-item-workspace .form-item-value").height(height);
|
||||
po.element(".workspace-editor-wrapper").height(height - errorInfoHeight);
|
||||
po.element(".workspace-operation-wrapper").height(height - errorInfoHeight);
|
||||
};
|
||||
|
||||
po.initWorkspaceEditor = function(editor, initValue)
|
||||
|
@ -67,13 +86,8 @@ po.previewOptions.url = "...";
|
|||
exec: function(editor)
|
||||
{
|
||||
var $operationWrapper = po.element(".workspace-operation-wrapper");
|
||||
var activeIndex = $operationWrapper.tabs("option", "active");
|
||||
var $activeLi = $(".workspace-operation-nav > li:eq("+activeIndex+")", $operationWrapper);
|
||||
|
||||
if($activeLi.hasClass("operation-preview"))
|
||||
po.element(".preview-button").click();
|
||||
else
|
||||
$operationWrapper.tabs("option", "active", 0);
|
||||
$operationWrapper.tabs("option", "active", 0);
|
||||
po.element(".preview-button").click();
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -88,22 +102,160 @@ po.previewOptions.url = "...";
|
|||
{
|
||||
activate: function(event, ui)
|
||||
{
|
||||
var isPreviewResultTab = (ui.newPanel && ui.newPanel.hasClass("preview-result-table-wrapper"));
|
||||
if(isPreviewResultTab
|
||||
&& (po.isWorkspaceModified() || !po.previewResultTableElement().hasClass("preview-result-table-inited")))
|
||||
if(ui.newPanel.hasClass("preview-result-table-wrapper"))
|
||||
{
|
||||
//避免设置参数面板被隐藏
|
||||
event.stopPropagation();
|
||||
po.element(".preview-button").click();
|
||||
}
|
||||
else
|
||||
else if(ui.newPanel.hasClass("params-table-wrapper"))
|
||||
{
|
||||
po.dataSetParamsTableElement().DataTable().columns.adjust().fixedColumns().relayout();
|
||||
var dataTable = po.dataSetParamsTableElement().DataTable();
|
||||
dataTable.fixedColumns().relayout();
|
||||
dataTable.columns.adjust();
|
||||
}
|
||||
else if(ui.newPanel.hasClass("properties-table-wrapper"))
|
||||
{
|
||||
var dataTable = po.dataSetPropertiesTableElement().DataTable();
|
||||
dataTable.fixedColumns().relayout();
|
||||
dataTable.columns.adjust();
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
po.initDataSetPropertiesTable = function(initDataSetProperties, hideTabIfNone)
|
||||
{
|
||||
hideTabIfNone = (hideTabIfNone === undefined ? true : hideTabIfNone);
|
||||
|
||||
po.dataSetPropertiesTableElement().dataTable(
|
||||
{
|
||||
"columns" :
|
||||
[
|
||||
$.dataTableUtil.buildCheckCloumn("<@spring.message code='select' />"),
|
||||
{
|
||||
title: "<@spring.message code='dataSet.DataSetProperty.name' />",
|
||||
data: "name",
|
||||
render: function(data, type, row, meta)
|
||||
{
|
||||
return "<input type='text' value='"+$.escapeHtml(data)+"' class='dataSetPropertyName input-in-table ui-widget ui-widget-content' />";
|
||||
},
|
||||
width: "8em",
|
||||
defaultContent: "",
|
||||
orderable: true
|
||||
},
|
||||
{
|
||||
title: "<@spring.message code='dataSet.DataSetProperty.type' />",
|
||||
data: "type",
|
||||
render: function(data, type, row, meta)
|
||||
{
|
||||
data = (data || "${PropertyDataType.STRING}");
|
||||
|
||||
return "<select class='dataSetPropertyType input-in-table ui-widget ui-widget-content'>"
|
||||
+"<option value='${PropertyDataType.STRING}' "+(data == "${PropertyDataType.STRING}" ? "selected='selected'" : "")+"><@spring.message code='dataSet.DataSetProperty.DataType.STRING' /></option>"
|
||||
+"<option value='${PropertyDataType.INTEGER}' "+(data == "${PropertyDataType.INTEGER}" ? "selected='selected'" : "")+"><@spring.message code='dataSet.DataSetProperty.DataType.INTEGER' /></option>"
|
||||
+"<option value='${PropertyDataType.DECIMAL}' "+(data == "${PropertyDataType.DECIMAL}" ? "selected='selected'" : "")+"><@spring.message code='dataSet.DataSetProperty.DataType.DECIMAL' /></option>"
|
||||
+"<option value='${PropertyDataType.DATE}' "+(data == "${PropertyDataType.DATE}" ? "selected='selected'" : "")+"><@spring.message code='dataSet.DataSetProperty.DataType.DATE' /></option>"
|
||||
+"<option value='${PropertyDataType.TIME}' "+(data == "${PropertyDataType.TIME}" ? "selected='selected'" : "")+"><@spring.message code='dataSet.DataSetProperty.DataType.TIME' /></option>"
|
||||
+"<option value='${PropertyDataType.TIMESTAMP}' "+(data == "${PropertyDataType.TIMESTAMP}" ? "selected='selected'" : "")+"><@spring.message code='dataSet.DataSetProperty.DataType.TIMESTAMP' /></option>"
|
||||
+"<option value='${PropertyDataType.BOOLEAN}' "+(data == "${PropertyDataType.BOOLEAN}" ? "selected='selected'" : "")+"><@spring.message code='dataSet.DataSetProperty.DataType.BOOLEAN' /></option>"
|
||||
+"</select>";
|
||||
},
|
||||
width: "6em",
|
||||
defaultContent: "",
|
||||
orderable: true
|
||||
},
|
||||
{
|
||||
title: "<@spring.message code='dataSet.DataSetProperty.label' />",
|
||||
data: "label",
|
||||
render: function(data, type, row, meta)
|
||||
{
|
||||
return "<input type='text' value='"+$.escapeHtml(data)+"' class='dataSetPropertyLabel input-in-table ui-widget ui-widget-content' />";
|
||||
},
|
||||
width: "8em",
|
||||
defaultContent: "",
|
||||
orderable: true
|
||||
}
|
||||
],
|
||||
data: (initDataSetProperties || []),
|
||||
"scrollX": true,
|
||||
"autoWidth": true,
|
||||
"scrollY" : po.calWorkspaceOperationTableHeight(),
|
||||
"scrollCollapse": false,
|
||||
"paging" : false,
|
||||
"searching" : false,
|
||||
"ordering": false,
|
||||
"fixedColumns": { leftColumns: 1 },
|
||||
"select" : { style : 'os' },
|
||||
"language":
|
||||
{
|
||||
"emptyTable": "<@spring.message code='dataSet.noDataSetPropertyDefined' />",
|
||||
"zeroRecords" : "<@spring.message code='dataSet.noDataSetPropertyDefined' />"
|
||||
}
|
||||
});
|
||||
|
||||
$.dataTableUtil.bindCheckColumnEvent(po.dataSetPropertiesTableElement().DataTable());
|
||||
|
||||
po.element(".add-property-button").click(function()
|
||||
{
|
||||
po.dataSetPropertiesTableElement().DataTable().row.add({ name: "", type: "${PropertyDataType.STRING}", required: true, desc: "" }).draw();
|
||||
});
|
||||
|
||||
po.element(".del-property-button").click(function()
|
||||
{
|
||||
$.dataTableUtil.deleteSelectedRows(po.dataSetPropertiesTableElement().DataTable());
|
||||
});
|
||||
|
||||
po.dataSetPropertiesTableElement().on("click", ".input-in-table", function(event)
|
||||
{
|
||||
//阻止行选中
|
||||
event.stopPropagation();
|
||||
});
|
||||
|
||||
if(hideTabIfNone && (initDataSetProperties == null || initDataSetProperties.length == 0))
|
||||
po.hideDataSetPropertiesTab();
|
||||
};
|
||||
|
||||
po.showDataSetPropertiesTab = function()
|
||||
{
|
||||
po.element(".workspace-operation-nav .operation-properties").show();
|
||||
};
|
||||
|
||||
po.hideDataSetPropertiesTab = function()
|
||||
{
|
||||
po.element(".workspace-operation-nav .operation-properties").hide();
|
||||
};
|
||||
|
||||
po.hasFormDataSetProperty = function()
|
||||
{
|
||||
var $names = po.element(".properties-table-wrapper .dataSetPropertyName");
|
||||
return ($names.length > 0);
|
||||
};
|
||||
|
||||
po.getFormDataSetProperties = function()
|
||||
{
|
||||
var properties = [];
|
||||
|
||||
po.element(".properties-table-wrapper .dataSetPropertyName").each(function(i)
|
||||
{
|
||||
properties[i] = {};
|
||||
properties[i]["name"] = $(this).val();
|
||||
});
|
||||
po.element(".properties-table-wrapper .dataSetPropertyType").each(function(i)
|
||||
{
|
||||
properties[i]["type"] = $(this).val();
|
||||
});
|
||||
po.element(".properties-table-wrapper .dataSetPropertyLabel").each(function(i)
|
||||
{
|
||||
properties[i]["label"] = $(this).val();
|
||||
});
|
||||
|
||||
return properties;
|
||||
};
|
||||
|
||||
po.updateFormDataSetProperties = function(dataSetProperties)
|
||||
{
|
||||
var dataTable = po.dataSetPropertiesTableElement().DataTable();
|
||||
$.addDataTableData(dataTable, dataSetProperties, 0);
|
||||
};
|
||||
|
||||
//获取用于添加数据集参数的参数名
|
||||
po.getAddParamName = function()
|
||||
{
|
||||
|
@ -133,12 +285,12 @@ po.previewOptions.url = "...";
|
|||
data: "type",
|
||||
render: function(data, type, row, meta)
|
||||
{
|
||||
data = (data || "${DataType.STRING}");
|
||||
data = (data || "${ParamDataType.STRING}");
|
||||
|
||||
return "<select class='dataSetParamType input-in-table ui-widget ui-widget-content'>"
|
||||
+"<option value='${DataType.STRING}' "+(data == "${DataType.STRING}" ? "selected='selected'" : "")+"><@spring.message code='dataSet.DataSetParam.DataType.STRING' /></option>"
|
||||
+"<option value='${DataType.NUMBER}' "+(data == "${DataType.NUMBER}" ? "selected='selected'" : "")+"><@spring.message code='dataSet.DataSetParam.DataType.NUMBER' /></option>"
|
||||
+"<option value='${DataType.BOOLEAN}' "+(data == "${DataType.BOOLEAN}" ? "selected='selected'" : "")+"><@spring.message code='dataSet.DataSetParam.DataType.BOOLEAN' /></option>"
|
||||
+"<option value='${ParamDataType.STRING}' "+(data == "${ParamDataType.STRING}" ? "selected='selected'" : "")+"><@spring.message code='dataSet.DataSetParam.DataType.STRING' /></option>"
|
||||
+"<option value='${ParamDataType.NUMBER}' "+(data == "${ParamDataType.NUMBER}" ? "selected='selected'" : "")+"><@spring.message code='dataSet.DataSetParam.DataType.NUMBER' /></option>"
|
||||
+"<option value='${ParamDataType.BOOLEAN}' "+(data == "${ParamDataType.BOOLEAN}" ? "selected='selected'" : "")+"><@spring.message code='dataSet.DataSetParam.DataType.BOOLEAN' /></option>"
|
||||
+"</select>";
|
||||
},
|
||||
width: "6em",
|
||||
|
@ -177,17 +329,17 @@ po.previewOptions.url = "...";
|
|||
data: "inputType",
|
||||
render: function(data, type, row, meta)
|
||||
{
|
||||
data = (data || "${InputType.TEXT}");
|
||||
data = (data || "${ParamInputType.TEXT}");
|
||||
|
||||
return "<select class='dataSetParamInputType input-in-table ui-widget ui-widget-content'>"
|
||||
+"<option value='${InputType.TEXT}' "+(data == "${InputType.TEXT}" ? "selected='selected'" : "")+"><@spring.message code='dataSet.DataSetParam.InputType.TEXT' /></option>"
|
||||
+"<option value='${InputType.SELECT}' "+(data == "${InputType.SELECT}" ? "selected='selected'" : "")+"><@spring.message code='dataSet.DataSetParam.InputType.SELECT' /></option>"
|
||||
+"<option value='${InputType.DATE}' "+(data == "${InputType.DATE}" ? "selected='selected'" : "")+"><@spring.message code='dataSet.DataSetParam.InputType.DATE' /></option>"
|
||||
+"<option value='${InputType.TIME}' "+(data == "${InputType.TIME}" ? "selected='selected'" : "")+"><@spring.message code='dataSet.DataSetParam.InputType.TIME' /></option>"
|
||||
+"<option value='${InputType.DATETIME}' "+(data == "${InputType.DATETIME}" ? "selected='selected'" : "")+"><@spring.message code='dataSet.DataSetParam.InputType.DATETIME' /></option>"
|
||||
+"<option value='${InputType.RADIO}' "+(data == "${InputType.RADIO}" ? "selected='selected'" : "")+"><@spring.message code='dataSet.DataSetParam.InputType.RADIO' /></option>"
|
||||
+"<option value='${InputType.CHECKBOX}' "+(data == "${InputType.CHECKBOX}" ? "selected='selected'" : "")+"><@spring.message code='dataSet.DataSetParam.InputType.CHECKBOX' /></option>"
|
||||
+"<option value='${InputType.TEXTAREA}' "+(data == "${InputType.TEXTAREA}" ? "selected='selected'" : "")+"><@spring.message code='dataSet.DataSetParam.InputType.TEXTAREA' /></option>"
|
||||
+"<option value='${ParamInputType.TEXT}' "+(data == "${ParamInputType.TEXT}" ? "selected='selected'" : "")+"><@spring.message code='dataSet.DataSetParam.InputType.TEXT' /></option>"
|
||||
+"<option value='${ParamInputType.SELECT}' "+(data == "${ParamInputType.SELECT}" ? "selected='selected'" : "")+"><@spring.message code='dataSet.DataSetParam.InputType.SELECT' /></option>"
|
||||
+"<option value='${ParamInputType.DATE}' "+(data == "${ParamInputType.DATE}" ? "selected='selected'" : "")+"><@spring.message code='dataSet.DataSetParam.InputType.DATE' /></option>"
|
||||
+"<option value='${ParamInputType.TIME}' "+(data == "${ParamInputType.TIME}" ? "selected='selected'" : "")+"><@spring.message code='dataSet.DataSetParam.InputType.TIME' /></option>"
|
||||
+"<option value='${ParamInputType.DATETIME}' "+(data == "${ParamInputType.DATETIME}" ? "selected='selected'" : "")+"><@spring.message code='dataSet.DataSetParam.InputType.DATETIME' /></option>"
|
||||
+"<option value='${ParamInputType.RADIO}' "+(data == "${ParamInputType.RADIO}" ? "selected='selected'" : "")+"><@spring.message code='dataSet.DataSetParam.InputType.RADIO' /></option>"
|
||||
+"<option value='${ParamInputType.CHECKBOX}' "+(data == "${ParamInputType.CHECKBOX}" ? "selected='selected'" : "")+"><@spring.message code='dataSet.DataSetParam.InputType.CHECKBOX' /></option>"
|
||||
+"<option value='${ParamInputType.TEXTAREA}' "+(data == "${ParamInputType.TEXTAREA}" ? "selected='selected'" : "")+"><@spring.message code='dataSet.DataSetParam.InputType.TEXTAREA' /></option>"
|
||||
+"</select>";
|
||||
},
|
||||
width: "6em",
|
||||
|
@ -229,7 +381,7 @@ po.previewOptions.url = "...";
|
|||
{
|
||||
var name = (po.getAddParamName() || "");
|
||||
|
||||
po.dataSetParamsTableElement().DataTable().row.add({ name: name, type: "${DataType.STRING}", required: true, desc: "" }).draw();
|
||||
po.dataSetParamsTableElement().DataTable().row.add({ name: name, type: "${ParamDataType.STRING}", required: true, desc: "" }).draw();
|
||||
});
|
||||
|
||||
po.element(".del-param-button").click(function()
|
||||
|
@ -246,7 +398,7 @@ po.previewOptions.url = "...";
|
|||
|
||||
po.hasFormDataSetParam = function()
|
||||
{
|
||||
var $names = po.element(".dataSetParamName");
|
||||
var $names = po.element(".params-table-wrapper .dataSetParamName");
|
||||
return ($names.length > 0);
|
||||
};
|
||||
|
||||
|
@ -254,28 +406,28 @@ po.previewOptions.url = "...";
|
|||
{
|
||||
var params = [];
|
||||
|
||||
po.element(".dataSetParamName").each(function(i)
|
||||
po.element(".params-table-wrapper .dataSetParamName").each(function(i)
|
||||
{
|
||||
params[i] = {};
|
||||
params[i]["name"] = $(this).val();
|
||||
});
|
||||
po.element(".dataSetParamType").each(function(i)
|
||||
po.element(".params-table-wrapper .dataSetParamType").each(function(i)
|
||||
{
|
||||
params[i]["type"] = $(this).val();
|
||||
});
|
||||
po.element(".dataSetParamRequired").each(function(i)
|
||||
po.element(".params-table-wrapper .dataSetParamRequired").each(function(i)
|
||||
{
|
||||
params[i]["required"] = $(this).val();
|
||||
});
|
||||
po.element(".dataSetParamDesc").each(function(i)
|
||||
po.element(".params-table-wrapper .dataSetParamDesc").each(function(i)
|
||||
{
|
||||
params[i]["desc"] = $(this).val();
|
||||
});
|
||||
po.element(".dataSetParamInputType").each(function(i)
|
||||
po.element(".params-table-wrapper .dataSetParamInputType").each(function(i)
|
||||
{
|
||||
params[i]["inputType"] = $(this).val();
|
||||
});
|
||||
po.element(".dataSetParamInputPayload").each(function(i)
|
||||
po.element(".params-table-wrapper .dataSetParamInputPayload").each(function(i)
|
||||
{
|
||||
params[i]["inputPayload"] = $(this).val();
|
||||
});
|
||||
|
@ -286,7 +438,7 @@ po.previewOptions.url = "...";
|
|||
po.initPreviewParamValuePanel = function()
|
||||
{
|
||||
po.element(".preview-param-value-panel").draggable({ handle : ".ui-widget-header" });
|
||||
|
||||
|
||||
$(po.element()).on("click", function(event)
|
||||
{
|
||||
var $target = $(event.target);
|
||||
|
@ -325,7 +477,7 @@ po.previewOptions.url = "...";
|
|||
po.getFormDataSetParams(), formOptions);
|
||||
|
||||
$panel.show();
|
||||
$panel.position({ my : "right top", at : "left top", of : po.element("#${pageId}-previewResult")});
|
||||
$panel.position({ my : "right top", at : "left+5 top", of : po.element(".workspace-operation-wrapper")});
|
||||
};
|
||||
|
||||
//预览设置项
|
||||
|
@ -464,7 +616,14 @@ po.previewOptions.url = "...";
|
|||
data : po.previewOptions.data,
|
||||
success : function(previewResponse)
|
||||
{
|
||||
//previewResponse: { data: ..., resolvedSource: "...", startRow: ..., nextStartRow: ..., fetchSize: ... }
|
||||
//previewResponse:
|
||||
//{
|
||||
// data: ..., resolvedSource: "...", dataSetProperties: [...],
|
||||
// startRow: ..., nextStartRow: ..., fetchSize: ...
|
||||
//}
|
||||
|
||||
po.updateFormDataSetProperties(previewResponse.dataSetProperties);
|
||||
po.showDataSetPropertiesTab();
|
||||
|
||||
var tableData = (previewResponse.data || []);
|
||||
if(!$.isArray(tableData))
|
||||
|
@ -560,6 +719,11 @@ po.previewOptions.url = "...";
|
|||
|
||||
return row + 1;
|
||||
};
|
||||
|
||||
$.validator.addMethod("dataSetPropertiesRequired", function(value, element)
|
||||
{
|
||||
return po.hasFormDataSetProperty();
|
||||
});
|
||||
})
|
||||
(${pageId});
|
||||
</script>
|
Loading…
Reference in New Issue