You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by ja...@apache.org on 2020/11/30 02:30:25 UTC
[ofbiz-framework] branch trunk updated: Improved: Move
page-specific script links to html template (OFBIZ-11799)
This is an automated email from the ASF dual-hosted git repository.
jamesyong pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/ofbiz-framework.git
The following commit(s) were added to refs/heads/trunk by this push:
new a3fbb66 Improved: Move page-specific script links to html template (OFBIZ-11799)
a3fbb66 is described below
commit a3fbb66479ec5b985998d2b929456258e2256280
Author: James Yong <ja...@apache.org>
AuthorDate: Mon Nov 30 10:29:08 2020 +0800
Improved: Move page-specific script links to html template (OFBIZ-11799)
Use importLibrary js function to load time-related js and css for date time picker.
Tested page at /ordermgr/control/findreturn and /ordermgr/control/orderentry
---
.../template/macro/HtmlFormMacroLibrary.ftl | 10 +++++++
.../webapp/common/js/util/OfbizUtil.js | 35 ++++++++++++++--------
themes/common-theme/widget/CommonScreens.xml | 4 ---
themes/common-theme/widget/Theme.xml | 2 --
4 files changed, 32 insertions(+), 19 deletions(-)
diff --git a/themes/common-theme/template/macro/HtmlFormMacroLibrary.ftl b/themes/common-theme/template/macro/HtmlFormMacroLibrary.ftl
index bec17c0..5a4fb0a 100644
--- a/themes/common-theme/template/macro/HtmlFormMacroLibrary.ftl
+++ b/themes/common-theme/template/macro/HtmlFormMacroLibrary.ftl
@@ -93,6 +93,8 @@ under the License.
<#macro renderDateTimeField name className alert dateType timeDropdownParamName defaultDateTimeString localizedIconTitle timeHourName timeMinutesName minutes isTwelveHour ampmName amSelected pmSelected compositeType timeDropdown="" classString="" hour1="" hour2="" shortDateInput="" title="" value="" size="" maxlength="" id="" formName="" mask="" event="" action="" step="" timeValues="" tabindex="" disabled="">
<span class="view-calendar">
<#local cultureInfo = Static["org.apache.ofbiz.common.JsLanguageFilesMappingUtil"].getFile("datejs", locale)/>
+ <#local timePicker = "/common/js/jquery/plugins/datetimepicker/jquery-ui-timepicker-addon-1.6.3.min.js,/common/js/jquery/plugins/datetimepicker/jquery-ui-timepicker-addon-1.6.3.min.css">
+ <#local timePickerLang = Static["org.apache.ofbiz.common.JsLanguageFilesMappingUtil"].getFile("dateTime", locale)/>
<#if dateType!="time" >
<input type="text" <#if tabindex?has_content> tabindex="${tabindex}"</#if> name="${name}_i18n" <@renderClass className alert /><#rt/>
<#if title?has_content> title="${title}"</#if>
@@ -110,6 +112,8 @@ under the License.
<#if maxlength?has_content> maxlength="${maxlength}"</#if>
<#if mask?has_content> data-mask="${mask}"</#if><#rt/>
<#if cultureInfo?has_content> data-cultureinfo="${cultureInfo}"</#if><#rt/>
+ <#if timePicker?has_content> data-timepicker="${timePicker}"</#if><#rt/>
+ <#if timePickerLang?has_content> data-timepickerlang="${timePickerLang}"</#if><#rt/>
data-shortdate="${shortDateInput?string}"
<#if id?has_content> id="${id}"</#if>/><#rt/>
<#if timeDropdown?has_content && timeDropdown=="time-dropdown">
@@ -410,6 +414,8 @@ under the License.
</#if>
<#local shortDateInput = "date" == dateType/>
<#local cultureInfo = Static["org.apache.ofbiz.common.JsLanguageFilesMappingUtil"].getFile("datejs", locale)/>
+ <#local timePicker = "/common/js/jquery/plugins/datetimepicker/jquery-ui-timepicker-addon-1.6.3.min.js,/common/js/jquery/plugins/datetimepicker/jquery-ui-timepicker-addon-1.6.3.min.css"/>
+ <#local timePickerLang = Static["org.apache.ofbiz.common.JsLanguageFilesMappingUtil"].getFile("dateTime", locale)/>
<span class="view-calendar">
<input id="${id}_fld0_value" type="text" <@renderClass className alert />
<#if name?has_content> name="${name?html}_fld0_value"</#if>
@@ -419,6 +425,8 @@ under the License.
<#if maxlength?has_content> maxlength="${maxlength}"</#if>
<#if tabindex?has_content> tabindex="${tabindex}"</#if><#rt/>
<#if cultureInfo?has_content> data-cultureinfo="${cultureInfo}"</#if><#rt/>
+ <#if timePicker?has_content> data-timepicker="${timePicker}"</#if><#rt/>
+ <#if timePickerLang?has_content> data-timepickerlang="${timePickerLang}"</#if><#rt/>
data-shortdate="${shortDateInput?string}"
/>
<#if titleStyle?has_content>
@@ -441,6 +449,8 @@ under the License.
<#if size?has_content> size="${size}"</#if>
<#if maxlength?has_content> maxlength="${maxlength}"</#if>
<#if cultureInfo?has_content> data-cultureinfo="${cultureInfo}"</#if><#rt/>
+ <#if timePicker?has_content> data-timePicker="${timePicker}"</#if><#rt/>
+ <#if timePickerLang?has_content> data-timepickerlang="${timePickerLang}"</#if><#rt/>
data-shortdate="${shortDateInput?string}"
/><#rt/>
<#if titleStyle?has_content>
diff --git a/themes/common-theme/webapp/common/js/util/OfbizUtil.js b/themes/common-theme/webapp/common/js/util/OfbizUtil.js
index 73c31f3..bf3f469 100644
--- a/themes/common-theme/webapp/common/js/util/OfbizUtil.js
+++ b/themes/common-theme/webapp/common/js/util/OfbizUtil.js
@@ -399,19 +399,28 @@ function bindObservers(bind_element) {
dateFormat: 'yy-mm-dd'
})
} else {
- element.datetimepicker({
- showSecond: true,
- // showMillisec: true,
- timeFormat: 'HH:mm:ss',
- stepHour: 1,
- stepMinute: 1,
- stepSecond: 1,
- showOn: 'button',
- buttonImage: '',
- buttonText: '',
- buttonImageOnly: false,
- dateFormat: 'yy-mm-dd'
- })
+ var libTimePicker = element.data("timepicker");
+ if (libTimePicker) {
+ libTimePicker = libTimePicker.split(",");
+ importLibrary(libTimePicker, function () {
+ var libTimePickerLang = [element.data("timepickerlang")];
+ importLibrary(libTimePickerLang, function () {
+ element.datetimepicker({
+ showSecond: true,
+ // showMillisec: true,
+ timeFormat: 'HH:mm:ss',
+ stepHour: 1,
+ stepMinute: 1,
+ stepSecond: 1,
+ showOn: 'button',
+ buttonImage: '',
+ buttonText: '',
+ buttonImageOnly: false,
+ dateFormat: 'yy-mm-dd'
+ })
+ });
+ });
+ }
}
});
jQuery(bind_element).on("click", ".fieldgroup li.collapsed, .fieldgroup li.expanded", function(e){
diff --git a/themes/common-theme/widget/CommonScreens.xml b/themes/common-theme/widget/CommonScreens.xml
index 381e5eb..336f74b 100644
--- a/themes/common-theme/widget/CommonScreens.xml
+++ b/themes/common-theme/widget/CommonScreens.xml
@@ -124,7 +124,6 @@ under the License.
<actions>
<set field="layoutSettings.javaScripts[+0]" value="${groovy: org.apache.ofbiz.common.JsLanguageFilesMapping.JQuery.getFilePath(initialLocaleComplete)}" global="true" />
<set field="layoutSettings.javaScripts[+0]" value="${groovy: org.apache.ofbiz.common.JsLanguageFilesMapping.Validation.getFilePath(initialLocaleComplete)}" global="true" />
- <set field="layoutSettings.javaScripts[+0]" value="${groovy: org.apache.ofbiz.common.JsLanguageFilesMapping.DateTime.getFilePath(initialLocaleComplete)}" global="true" />
<!-- Jgrowl -->
<set field="layoutSettings.styleSheets[+0]" value="/common/js/jquery/plugins/jquery-jgrowl/jquery.jgrowl-1.4.6.min.css" global="true" />
<!-- Set default user locale from browser -->
@@ -346,7 +345,6 @@ under the License.
<set field="messagesTemplateLocation" from-field="layoutSettings.VT_MSG_TMPLT_LOC" default-value="component://common-theme/template/includes/Messages.ftl"/>
<set field="layoutSettings.styleSheets[]" value="/common/js/jquery/plugins/featherlight/featherlight-1.7.13.min.css" global="true"/>
<set field="layoutSettings.javaScripts[+0]" value="/common/js/jquery/plugins/featherlight/featherlight-1.7.13.min.js" global="true"/>
- <set field="layoutSettings.javaScripts[+0]" value="/common/js/jquery/plugins/datetimepicker/jquery-ui-timepicker-addon-1.6.3.min.js"/>
<set field="layoutSettings.javaScripts[+0]" value="/common/js/jquery/ui/jquery-ui-1.12.1.min.js"/>
<set field="layoutSettings.javaScripts[+0]" value="/common/js/jquery/plugins/validate/jquery.validate.min.js"/>
<set field="layoutSettings.javaScripts[+0]" value="/common/js/jquery/plugins/browser-plugin/jquery.browser-0.1.0.min.js" global="true"/>
@@ -433,7 +431,6 @@ under the License.
<set field="layoutSettings.javaScripts[+0]" value="${groovy: org.apache.ofbiz.common.JsLanguageFilesMapping.JQuery.getFilePath(initialLocaleComplete)}" global="true"/>
<set field="layoutSettings.javaScripts[+0]" value="${groovy: org.apache.ofbiz.common.JsLanguageFilesMapping.Validation.getFilePath(initialLocaleComplete)}" global="true"/>
- <set field="layoutSettings.javaScripts[+0]" value="/common/js/jquery/plugins/datetimepicker/jquery-ui-timepicker-addon-1.6.3.min.js" global="true"/>
<set field="layoutSettings.javaScripts[+0]" value="/common/js/jquery/ui/jquery-ui-1.12.1.min.js" global="true"/>
<set field="layoutSettings.javaScripts[+0]" value="/common/js/jquery/plugins/validate/jquery.validate.min.js" global="true"/>
<set field="layoutSettings.javaScripts[+0]" value="/common/js/jquery/plugins/browser-plugin/jquery.browser-0.1.0.min.js" global="true"/>
@@ -441,7 +438,6 @@ under the License.
<set field="layoutSettings.javaScripts[+0]" value="/common/js/jquery/jquery-3.5.1.min.js" global="true"/>
<!-- jQuery CSSs -->
<set field="layoutSettings.styleSheets[+0]" value="/common/js/jquery/ui/jquery-ui-1.12.1.min.css" global="true" />
- <set field="layoutSettings.styleSheets[+0]" value="/common/js/jquery/plugins/datetimepicker/jquery-ui-timepicker-addon-1.6.3.min.css" global="true" />
<set field="layoutSettings.javaScripts[]" value="/common/js/util/OfbizUtil.js" global="true"/>
<set field="layoutSettings.javaScripts[]" value="/common/js/util/fieldlookup.js" global="true"/>
diff --git a/themes/common-theme/widget/Theme.xml b/themes/common-theme/widget/Theme.xml
index b9b4958..9e581b1 100644
--- a/themes/common-theme/widget/Theme.xml
+++ b/themes/common-theme/widget/Theme.xml
@@ -61,7 +61,6 @@ under the License.
<property name="VT_HDR_JAVASCRIPT['add']" value="/common/js/jquery/jquery-migrate-3.3.0.min.js"/>
<property name="VT_HDR_JAVASCRIPT['add']" value="/common/js/jquery/plugins/browser-plugin/jquery.browser-0.1.0.min.js"/>
<property name="VT_HDR_JAVASCRIPT['add']" value="/common/js/jquery/ui/jquery-ui-1.12.1.min.js"/>
- <property name="VT_HDR_JAVASCRIPT['add']" value="/common/js/jquery/plugins/datetimepicker/jquery-ui-timepicker-addon-1.6.3.min.js"/>
<property name="VT_HDR_JAVASCRIPT['add']" value="/common/js/jquery/plugins/validate/jquery.validate.min.js"/>
<property name="VT_HDR_JAVASCRIPT['add']" value="/common/js/util/OfbizUtil.js"/>
<property name="VT_HDR_JAVASCRIPT['add']" value="/common/js/util/fieldlookup.js"/>
@@ -74,7 +73,6 @@ under the License.
<property name="VT_HDR_JAVASCRIPT['add']" value="/common/js/util/application.js"/>
<!--Css styles: don't load them since they differ depending on theme -->
<property name="VT_STYLESHEET['add']" value="/common/js/jquery/ui/jquery-ui-1.12.1.min.css"/>
- <property name="VT_STYLESHEET['add']" value="/common/js/jquery/plugins/datetimepicker/jquery-ui-timepicker-addon-1.6.3.min.css"/>
<property name="VT_STYLESHEET['add']" value="/common/css/info.css"/>
</theme-properties>