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 e405d35 Improved: Move page-specific script links to html template
(OFBIZ-11799)
e405d35 is described below
commit e405d35c080a94c07205a24ea4d2dedeab8aa4a9
Author: James Yong <[email protected]>
AuthorDate: Sat Dec 5 23:23:04 2020 +0800
Improved: Move page-specific script links to html template (OFBIZ-11799)
Use importLibrary js function to load locale-specific datepicker js.
Corrected locale naming in macro to use '.locale'.
Tested page at /ordermgr/control/findreturn and
/ordermgr/control/orderentry.
---
.../template/macro/HtmlFormMacroLibrary.ftl | 13 ++++++++----
.../webapp/common/js/util/OfbizUtil.js | 23 ++++++++++++----------
themes/common-theme/widget/CommonScreens.xml | 2 --
3 files changed, 22 insertions(+), 16 deletions(-)
diff --git a/themes/common-theme/template/macro/HtmlFormMacroLibrary.ftl
b/themes/common-theme/template/macro/HtmlFormMacroLibrary.ftl
index 5a4fb0a..3d3feac 100644
--- a/themes/common-theme/template/macro/HtmlFormMacroLibrary.ftl
+++ b/themes/common-theme/template/macro/HtmlFormMacroLibrary.ftl
@@ -92,9 +92,10 @@ 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 cultureInfo =
Static["org.apache.ofbiz.common.JsLanguageFilesMappingUtil"].getFile("datejs",
.locale)/>
+ <#local datePickerLang =
Static["org.apache.ofbiz.common.JsLanguageFilesMappingUtil"].getFile("jquery",
.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)/>
+ <#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>
@@ -112,6 +113,7 @@ 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 datePickerLang?has_content>
data-datepickerlang="${datePickerLang}"</#if><#rt/>
<#if timePicker?has_content> data-timepicker="${timePicker}"</#if><#rt/>
<#if timePickerLang?has_content>
data-timepickerlang="${timePickerLang}"</#if><#rt/>
data-shortdate="${shortDateInput?string}"
@@ -413,9 +415,10 @@ under the License.
<#local className = className + " date-time-picker"/>
</#if>
<#local shortDateInput = "date" == dateType/>
- <#local cultureInfo =
Static["org.apache.ofbiz.common.JsLanguageFilesMappingUtil"].getFile("datejs",
locale)/>
+ <#local cultureInfo =
Static["org.apache.ofbiz.common.JsLanguageFilesMappingUtil"].getFile("datejs",
.locale)/>
+ <#local datePickerLang =
Static["org.apache.ofbiz.common.JsLanguageFilesMappingUtil"].getFile("jquery",
.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)/>
+ <#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>
@@ -425,6 +428,7 @@ 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 datePickerLang?has_content>
data-datepickerlang="${datePickerLang}"</#if><#rt/>
<#if timePicker?has_content>
data-timepicker="${timePicker}"</#if><#rt/>
<#if timePickerLang?has_content>
data-timepickerlang="${timePickerLang}"</#if><#rt/>
data-shortdate="${shortDateInput?string}"
@@ -449,6 +453,7 @@ 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 datePickerLang?has_content>
data-datepickerlang="${datePickerLang}"</#if><#rt/>
<#if timePicker?has_content>
data-timePicker="${timePicker}"</#if><#rt/>
<#if timePickerLang?has_content>
data-timepickerlang="${timePickerLang}"</#if><#rt/>
data-shortdate="${shortDateInput?string}"
diff --git a/themes/common-theme/webapp/common/js/util/OfbizUtil.js
b/themes/common-theme/webapp/common/js/util/OfbizUtil.js
index bf3f469..4bda2cc 100644
--- a/themes/common-theme/webapp/common/js/util/OfbizUtil.js
+++ b/themes/common-theme/webapp/common/js/util/OfbizUtil.js
@@ -389,22 +389,25 @@ function bindObservers(bind_element) {
});
}
});
+ var libDatePickerLang = [element.data("datepickerlang")];
if (shortDate) {
- element.datepicker({
- showWeek: true,
- showOn: 'button',
- buttonImage: '',
- buttonText: '',
- buttonImageOnly: false,
- dateFormat: 'yy-mm-dd'
- })
+ importLibrary(libDatePickerLang, function () {
+ element.datepicker({
+ showWeek: true,
+ showOn: 'button',
+ buttonImage: '',
+ buttonText: '',
+ buttonImageOnly: false,
+ dateFormat: 'yy-mm-dd'
+ })
+ });
} else {
var libTimePicker = element.data("timepicker");
if (libTimePicker) {
libTimePicker = libTimePicker.split(",");
importLibrary(libTimePicker, function () {
- var libTimePickerLang = [element.data("timepickerlang")];
- importLibrary(libTimePickerLang, function () {
+ var libDateTimePickerLang =
libDatePickerLang.concat([element.data("timepickerlang")]);
+ importLibrary(libDateTimePickerLang, function () {
element.datetimepicker({
showSecond: true,
// showMillisec: true,
diff --git a/themes/common-theme/widget/CommonScreens.xml
b/themes/common-theme/widget/CommonScreens.xml
index 336f74b..49d49ab 100644
--- a/themes/common-theme/widget/CommonScreens.xml
+++ b/themes/common-theme/widget/CommonScreens.xml
@@ -122,7 +122,6 @@ under the License.
<screen name="GlobalActions">
<section>
<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" />
<!-- Jgrowl -->
<set field="layoutSettings.styleSheets[+0]"
value="/common/js/jquery/plugins/jquery-jgrowl/jquery.jgrowl-1.4.6.min.css"
global="true" />
@@ -428,7 +427,6 @@ under the License.
<!-- The default (global) java scripts -->
<!-- jQuery part -->
<!-- Load available JS Language Files -->
- <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/ui/jquery-ui-1.12.1.min.js" global="true"/>