Skip to content

Commit

Permalink
改进图表编辑页面的结果数据格式设置功能,添加启用/禁用操作按钮,确保不保存默认结果数据格式信息
Browse files Browse the repository at this point in the history
  • Loading branch information
datageartech committed Jun 3, 2021
1 parent f462597 commit 1615919
Show file tree
Hide file tree
Showing 7 changed files with 87 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,6 @@ public void resolveResultDataTest_resultDataFormat() throws Throwable
// 字符串
{
ResultDataFormat resultDataFormat = new ResultDataFormat();
resultDataFormat.setDateType(ResultDataFormat.TYPE_STRING);
resultDataFormat.setTimeType(ResultDataFormat.TYPE_STRING);
resultDataFormat.setTimestampType(ResultDataFormat.TYPE_STRING);
resultDataFormat.setDateFormat("yyyy年MM月dd日");
resultDataFormat.setTimeFormat("HH时mm分ss秒");
resultDataFormat.setTimestampFormat("yyyy年MM月dd日HH时mm分ss秒");
Expand Down Expand Up @@ -279,6 +276,9 @@ public void resolveResultDataTest_resultDataFormat() throws Throwable
// 无
{
ResultDataFormat resultDataFormat = new ResultDataFormat();
resultDataFormat.setDateType(ResultDataFormat.TYPE_NONE);
resultDataFormat.setTimeType(ResultDataFormat.TYPE_NONE);
resultDataFormat.setTimestampType(ResultDataFormat.TYPE_NONE);

DataFormat dataFormat = dataSet.createDataSetPropertyValueConverter().getDataFormat();
SimpleDateFormat dateFormat = new SimpleDateFormat(dataFormat.getDateFormat());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,6 @@ protected MbSqlDialect buildByDialectClassName(Connection cn, String dialectClas
try
{
Class<?> dialectClass = Class.forName(dialectClassName);
@SuppressWarnings("deprecation")
MbSqlDialect dialect = (MbSqlDialect) dialectClass.newInstance();

if (StringUtil.isEmpty(dialect.getIdentifierQuote()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,12 @@ public void setServletContext(ServletContext servletContext)
public String add(HttpServletRequest request, HttpServletResponse response, org.springframework.ui.Model model)
{
HtmlChartWidgetEntity chart = new HtmlChartWidgetEntity();
chart.setResultDataFormat(createDefaultResultDataFormat());
setCookieAnalysisProject(request, response, chart);

model.addAttribute("chart", chart);
model.addAttribute("chartPluginVO", toWriteJsonTemplateModel(null));
model.addAttribute("initResultDataFormat", createDefaultResultDataFormat());
model.addAttribute("enableResultDataFormat", false);
model.addAttribute(KEY_TITLE_MESSAGE_KEY, "chart.addChart");
model.addAttribute(KEY_FORM_ACTION, "save");

Expand All @@ -171,16 +172,16 @@ public String edit(HttpServletRequest request, HttpServletResponse response, org

chart.setPlugin(toHtmlChartPluginVO(request, chart.getPlugin()));

if (chart.getResultDataFormat() == null)
chart.setResultDataFormat(createDefaultResultDataFormat());

HtmlChartPluginVO chartPluginVO = (chart.getPlugin() != null
? getHtmlChartPluginVO(request, chart.getPlugin().getId())
: null);

model.addAttribute("chart", chart);
model.addAttribute("chartPluginVO", toWriteJsonTemplateModel(chartPluginVO));
model.addAttribute("chartDataSets", toWriteJsonTemplateModel(toChartDataSetViewObjs(chart.getChartDataSets())));
model.addAttribute("initResultDataFormat",
(chart.getResultDataFormat() != null ? chart.getResultDataFormat() : createDefaultResultDataFormat()));
model.addAttribute("enableResultDataFormat", (chart.getResultDataFormat() != null));
model.addAttribute(KEY_TITLE_MESSAGE_KEY, "chart.editChart");
model.addAttribute(KEY_FORM_ACTION, "save");

Expand Down Expand Up @@ -240,6 +241,9 @@ public String view(HttpServletRequest request, HttpServletResponse response, org
model.addAttribute("chart", chart);
model.addAttribute("chartPluginVO", toWriteJsonTemplateModel(chartPluginVO));
model.addAttribute("chartDataSets", toWriteJsonTemplateModel(toChartDataSetViewObjs(chart.getChartDataSets())));
model.addAttribute("initResultDataFormat",
(chart.getResultDataFormat() != null ? chart.getResultDataFormat() : createDefaultResultDataFormat()));
model.addAttribute("enableResultDataFormat", (chart.getResultDataFormat() != null));
model.addAttribute(KEY_TITLE_MESSAGE_KEY, "chart.viewChart");
model.addAttribute(KEY_READONLY, true);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ none=无
moveUp=上移
moveDown=下移
setting=设置
enable=启用
disable=禁用

pagination.label=#{page}/#{pages},共#{total}条,每页#{pageSize}条

Expand Down Expand Up @@ -800,6 +802,8 @@ chart.setDataSetParamValue=设置数据集参数值
chart.chartDataSet.clearParamValueTip=清除数据集参数值,可在图表展示时设置
chart.resultDataFormat=数据格式
chart.resultDataFormat.desc=图表展示时,日期类数据的展示格式
chart.resultDataFormatEnable=是否启用
chart.resultDataFormatEnable.desc=如果禁用,将清除已设置的格式,恢复为采用系统默认格式
chart.resultDataFormat.TYPE_NUMBER=数值
chart.resultDataFormat.TYPE_STRING=字符串
chart.resultDataFormat.dateType=日期类型
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ none=None
moveUp=Move up
moveDown=Move down
setting=Setting
enable=Enable
disable=Disable

pagination.label=Page:#{page}/#{pages} Total:#{total} Page size:#{pageSize}

Expand Down Expand Up @@ -800,6 +802,8 @@ chart.setDataSetParamValue=Set parameter value
chart.chartDataSet.clearParamValueTip=Clear parameter value, can be set later when chart is shown
chart.resultDataFormat=Data format
chart.resultDataFormat.desc=The date value format when chart shown
chart.resultDataFormatEnable=Enable
chart.resultDataFormatEnable.desc=If disabled, the default format will be used
chart.resultDataFormat.TYPE_NUMBER=Number
chart.resultDataFormat.TYPE_STRING=String
chart.resultDataFormat.dateType=Date type
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2900,7 +2900,7 @@ table.dataTable tbody tr td select{
.page-form-chart .dataformat-panel{
position: absolute;
right: 40%;
bottom: -0.41em;
bottom: -2.41em;
width: 60%;
margin-right: -1rem;
display: none;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,27 @@ readonly 是否只读操作,允许为null
<div class="form">
<div class="form-content">
<div class="form-item">
<div class="form-item-label">
<label title="<@spring.message code='chart.resultDataFormatEnable.desc' />">
<@spring.message code='chart.resultDataFormatEnable' />
</label>
</div>
<div class="form-item-value">
<div class="resultDataFormatEnable-radios">
<label for="${pageId}-resultDataFormatEnable-0" title="">
<@spring.message code='enable' />
</label>
<input type="radio" id="${pageId}-resultDataFormatEnable-0" name="resultDataFormatEnable" value="true"
<#if enableResultDataFormat>checked="checked"</#if> />
<label for="${pageId}-resultDataFormatEnable-1" title="">
<@spring.message code='disable' />
</label>
<input type="radio" id="${pageId}-resultDataFormatEnable-1" name="resultDataFormatEnable" value="false"
<#if !enableResultDataFormat>checked="checked"</#if> />
</div>
</div>
</div>
<div class="form-item resultDataFormatEnableAware">
<div class="form-item-label">
<label><@spring.message code='chart.resultDataFormat.dateType' /></label>
</div>
Expand All @@ -93,28 +114,28 @@ readonly 是否只读操作,允许为null
<@spring.message code='chart.resultDataFormat.TYPE_STRING' />
</label>
<input type="radio" id="${pageId}-resultDataFormat-dateType-0"
<#if ResultDataFormat.TYPE_STRING == chart.resultDataFormat.dateType>checked="checked"</#if>
<#if ResultDataFormat.TYPE_STRING == initResultDataFormat.dateType>checked="checked"</#if>
name="resultDataFormat.dateType" value="${ResultDataFormat.TYPE_STRING}" />
<label for="${pageId}-resultDataFormat-dateType-1" title="">
<@spring.message code='chart.resultDataFormat.TYPE_NUMBER' />
</label>
<input type="radio" id="${pageId}-resultDataFormat-dateType-1"
<#if ResultDataFormat.TYPE_NUMBER == chart.resultDataFormat.dateType>checked="checked"</#if>
<#if ResultDataFormat.TYPE_NUMBER == initResultDataFormat.dateType>checked="checked"</#if>
name="resultDataFormat.dateType" value="${ResultDataFormat.TYPE_NUMBER}" />
</div>
</div>
</div>
<div class="form-item">
<div class="form-item resultDataFormatEnableAware">
<div class="form-item-label">
<label title="<@spring.message code='chart.resultDataFormat.dateFormat.desc' />">
<@spring.message code='chart.resultDataFormat.dateFormat' />
</label>
</div>
<div class="form-item-value">
<input name="resultDataFormat.dateFormat" type="text" value="${(chart.resultDataFormat.dateFormat)!}" class="ui-widget ui-widget-content" />
<input name="resultDataFormat.dateFormat" type="text" value="${(initResultDataFormat.dateFormat)!}" class="ui-widget ui-widget-content" />
</div>
</div>
<div class="form-item">
<div class="form-item resultDataFormatEnableAware">
<div class="form-item-label">
<label><@spring.message code='chart.resultDataFormat.timeType' /></label>
</div>
Expand All @@ -124,28 +145,28 @@ readonly 是否只读操作,允许为null
<@spring.message code='chart.resultDataFormat.TYPE_STRING' />
</label>
<input type="radio" id="${pageId}-resultDataFormat-timeType-0"
<#if ResultDataFormat.TYPE_STRING == chart.resultDataFormat.timeType>checked="checked"</#if>
<#if ResultDataFormat.TYPE_STRING == initResultDataFormat.timeType>checked="checked"</#if>
name="resultDataFormat.timeType" value="${ResultDataFormat.TYPE_STRING}" />
<label for="${pageId}-resultDataFormat-timeType-1" title="">
<@spring.message code='chart.resultDataFormat.TYPE_NUMBER' />
</label>
<input type="radio" id="${pageId}-resultDataFormat-timeType-1"
<#if ResultDataFormat.TYPE_NUMBER == chart.resultDataFormat.timeType>checked="checked"</#if>
<#if ResultDataFormat.TYPE_NUMBER == initResultDataFormat.timeType>checked="checked"</#if>
name="resultDataFormat.timeType" value="${ResultDataFormat.TYPE_NUMBER}" />
</div>
</div>
</div>
<div class="form-item">
<div class="form-item resultDataFormatEnableAware">
<div class="form-item-label">
<label title="<@spring.message code='chart.resultDataFormat.timeFormat.desc' />">
<@spring.message code='chart.resultDataFormat.timeFormat' />
</label>
</div>
<div class="form-item-value">
<input name="resultDataFormat.timeFormat" type="text" value="${(chart.resultDataFormat.timeFormat)!}" class="ui-widget ui-widget-content" />
<input name="resultDataFormat.timeFormat" type="text" value="${(initResultDataFormat.timeFormat)!}" class="ui-widget ui-widget-content" />
</div>
</div>
<div class="form-item">
<div class="form-item resultDataFormatEnableAware">
<div class="form-item-label">
<label><@spring.message code='chart.resultDataFormat.timestampType' /></label>
</div>
Expand All @@ -155,25 +176,25 @@ readonly 是否只读操作,允许为null
<@spring.message code='chart.resultDataFormat.TYPE_STRING' />
</label>
<input type="radio" id="${pageId}-resultDataFormat-timestampType-0"
<#if ResultDataFormat.TYPE_STRING == chart.resultDataFormat.timestampType>checked="checked"</#if>
<#if ResultDataFormat.TYPE_STRING == initResultDataFormat.timestampType>checked="checked"</#if>
name="resultDataFormat.timestampType" value="${ResultDataFormat.TYPE_STRING}" />
<label for="${pageId}-resultDataFormat-timestampType-1" title="">
<@spring.message code='chart.resultDataFormat.TYPE_NUMBER' />
</label>
<input type="radio" id="${pageId}-resultDataFormat-timestampType-1"
<#if ResultDataFormat.TYPE_NUMBER == chart.resultDataFormat.timestampType>checked="checked"</#if>
<#if ResultDataFormat.TYPE_NUMBER == initResultDataFormat.timestampType>checked="checked"</#if>
name="resultDataFormat.timestampType" value="${ResultDataFormat.TYPE_NUMBER}" />
</div>
</div>
</div>
<div class="form-item">
<div class="form-item resultDataFormatEnableAware">
<div class="form-item-label">
<label title="<@spring.message code='chart.resultDataFormat.timestampFormat.desc' />">
<@spring.message code='chart.resultDataFormat.timestampFormat' />
</label>
</div>
<div class="form-item-value">
<input name="resultDataFormat.timestampFormat" type="text" value="${(chart.resultDataFormat.timestampFormat)!}" class="ui-widget ui-widget-content" />
<input name="resultDataFormat.timestampFormat" type="text" value="${(initResultDataFormat.timestampFormat)!}" class="ui-widget ui-widget-content" />
</div>
</div>
</div>
Expand Down Expand Up @@ -228,18 +249,23 @@ readonly 是否只读操作,允许为null
<script type="text/javascript">
(function(po)
{
po.chartPluginVO = <@writeJson var=chartPluginVO />;
po.chartDataSets = <@writeJson var=chartDataSets />;
$.initButtons(po.element());
po.initAnalysisProject("${((chart.analysisProject.id)!'')?js_string?no_esc}", "${((chart.analysisProject.name)!'')?js_string?no_esc}");
po.element(".form-item-value-chartDataSet").height($(window).height()/5*2);
po.element("input[name='updateIntervalRadio']").checkboxradio({icon:false});
po.element(".updateInterval-radios").controlgroup();
po.element("input[name='resultDataFormatEnable']").checkboxradio({icon:false});
po.element("input[name='resultDataFormat.dateType']").checkboxradio({icon:false});
po.element("input[name='resultDataFormat.timeType']").checkboxradio({icon:false});
po.element("input[name='resultDataFormat.timestampType']").checkboxradio({icon:false});
//隐藏元素设置controlgroup组件没有圆角效果,所以这里先显示设置后再隐藏
po.element(".dataformat-panel").addClass("transparency").show();
po.element(".resultDataFormatEnable-radios").controlgroup();
po.element(".resultDataFormat-dateType-radios").controlgroup();
po.element(".resultDataFormat-timeType-radios").controlgroup();
po.element(".resultDataFormat-timestampType-radios").controlgroup();
Expand All @@ -250,8 +276,31 @@ readonly 是否只读操作,允许为null
return "${contextPath}/analysis/chart/" + action;
};
po.chartPluginVO = <@writeJson var=chartPluginVO />;
po.chartDataSets = <@writeJson var=chartDataSets />;
po.updateResultDataFormatPanelEnable = function(enable)
{
if(enable == null)
enable = ("true" == po.element("input[name='resultDataFormatEnable']:checked").val());
var enableMethod = (enable ? "enable" : "disable");
po.element("input[name='resultDataFormat.dateType']").checkboxradio(enableMethod);
po.element("input[name='resultDataFormat.timeType']").checkboxradio(enableMethod);
po.element("input[name='resultDataFormat.timestampType']").checkboxradio(enableMethod);
po.element("input[name='resultDataFormat.dateFormat']").prop("disabled", !enable);
po.element("input[name='resultDataFormat.timeFormat']").prop("disabled", !enable);
po.element("input[name='resultDataFormat.timestampFormat']").prop("disabled", !enable);
if(enable)
po.element(".resultDataFormatEnableAware").removeClass("ui-state-disabled");
else
po.element(".resultDataFormatEnableAware").addClass("ui-state-disabled");
};
po.element("input[name='resultDataFormatEnable']").on("change", function()
{
po.updateResultDataFormatPanelEnable();
});
po.element(".selectChartPluginButton").click(function()
{
Expand Down Expand Up @@ -872,7 +921,7 @@ readonly 是否只读操作,允许为null
},
submitHandler : function(form)
{
var data = $.formToJson(form, ["dataSignValidation", "updateIntervalRadio"]);
var data = $.formToJson(form, ["dataSignValidation", "updateIntervalRadio", "resultDataFormatEnable"]);
data["chartDataSetVOs"] = po.getFormChartDataSets();
$.ajaxJson($(form).attr("action"),
Expand Down Expand Up @@ -921,6 +970,7 @@ readonly 是否只读操作,允许为null
po.initChartPlugin(po.chartPluginVO);
po.initChartDataSets();
po.updateResultDataFormatPanelEnable();
})
(${pageId});
</script>
Expand Down

0 comments on commit 1615919

Please sign in to comment.