Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Nikola Balog
erp5
Commits
bb0dba8a
Commit
bb0dba8a
authored
Feb 13, 2024
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Plain Diff
Fix boolean in DateTimeField TALES with ERP5JS
See merge request
!1873
parents
1532fabb
98af4f25
Changes
11
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
2573 additions
and
34 deletions
+2573
-34
bt5/erp5_ui_test/SkinTemplateItem/portal_skins/erp5_ui_test/Foo_viewDateTimeField.xml
...eItem/portal_skins/erp5_ui_test/Foo_viewDateTimeField.xml
+1
-0
bt5/erp5_ui_test/SkinTemplateItem/portal_skins/erp5_ui_test/Foo_viewDateTimeField/my_date_time_field_with_tales.xml
...t/Foo_viewDateTimeField/my_date_time_field_with_tales.xml
+2406
-0
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_datetimefield_html.html
...m/web_page_module/rjs_gadget_erp5_datetimefield_html.html
+4
-3
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_datetimefield_html.xml
...em/web_page_module/rjs_gadget_erp5_datetimefield_html.xml
+3
-3
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_datetimefield_js.js
...eItem/web_page_module/rjs_gadget_erp5_datetimefield_js.js
+10
-10
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_datetimefield_js.xml
...Item/web_page_module/rjs_gadget_erp5_datetimefield_js.xml
+3
-3
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_page_form_js.js
...plateItem/web_page_module/rjs_gadget_erp5_page_form_js.js
+2
-2
bt5/erp5_web_renderjs_ui_test/PathTemplateItem/portal_tests/renderjs_ui_date_time_field_zuite/testDateTimeFieldTALESDateOnly.xml
..._date_time_field_zuite/testDateTimeFieldTALESDateOnly.xml
+62
-0
bt5/erp5_web_renderjs_ui_test/PathTemplateItem/portal_tests/renderjs_ui_date_time_field_zuite/testDateTimeFieldTALESDateOnly.zpt
..._date_time_field_zuite/testDateTimeFieldTALESDateOnly.zpt
+66
-0
product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/gadget_global.js.js
...inTemplateItem/portal_skins/erp5_core/gadget_global.js.js
+14
-11
product/ERP5OOo/tests/testOOoStyle.py
product/ERP5OOo/tests/testOOoStyle.py
+2
-2
No files found.
bt5/erp5_ui_test/SkinTemplateItem/portal_skins/erp5_ui_test/Foo_viewDateTimeField.xml
View file @
bb0dba8a
...
@@ -103,6 +103,7 @@
...
@@ -103,6 +103,7 @@
<list>
<list>
<string>
my_start_date
</string>
<string>
my_start_date
</string>
<string>
my_stop_date
</string>
<string>
my_stop_date
</string>
<string>
my_date_time_field_with_tales
</string>
</list>
</list>
</value>
</value>
</item>
</item>
...
...
bt5/erp5_ui_test/SkinTemplateItem/portal_skins/erp5_ui_test/Foo_viewDateTimeField/my_date_time_field_with_tales.xml
0 → 100644
View file @
bb0dba8a
This diff is collapsed.
Click to expand it.
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_datetimefield_html.html
View file @
bb0dba8a
...
@@ -8,10 +8,11 @@
...
@@ -8,10 +8,11 @@
<link
rel=
"http://www.renderjs.org/rel/interface"
href=
"interface_erp5_form_content_provider.html"
>
<link
rel=
"http://www.renderjs.org/rel/interface"
href=
"interface_erp5_form_content_provider.html"
>
<!-- renderjs -->
<!-- renderjs -->
<script
src=
"rsvp.js"
type=
"text/javascript"
></script>
<script
src=
"rsvp.js"
></script>
<script
src=
"renderjs.js"
type=
"text/javascript"
></script>
<script
src=
"renderjs.js"
></script>
<script
src=
"gadget_global.js"
></script>
<!-- custom script -->
<!-- custom script -->
<script
src=
"gadget_erp5_field_datetime.js"
type=
"text/javascript"
></script>
<script
src=
"gadget_erp5_field_datetime.js"
></script>
</head>
</head>
<body>
<body>
...
...
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_datetimefield_html.xml
View file @
bb0dba8a
...
@@ -226,7 +226,7 @@
...
@@ -226,7 +226,7 @@
</item>
</item>
<item>
<item>
<key>
<string>
actor
</string>
</key>
<key>
<string>
actor
</string>
</key>
<value>
<string>
zop
e
</string>
</value>
<value>
<string>
ERP5TypeTestCas
e
</string>
</value>
</item>
</item>
<item>
<item>
<key>
<string>
comment
</string>
</key>
<key>
<string>
comment
</string>
</key>
...
@@ -240,7 +240,7 @@
...
@@ -240,7 +240,7 @@
</item>
</item>
<item>
<item>
<key>
<string>
serial
</string>
</key>
<key>
<string>
serial
</string>
</key>
<value>
<string>
969.41949.34822.1423
3
</string>
</value>
<value>
<string>
1014.23421.40553.4850
3
</string>
</value>
</item>
</item>
<item>
<item>
<key>
<string>
state
</string>
</key>
<key>
<string>
state
</string>
</key>
...
@@ -260,7 +260,7 @@
...
@@ -260,7 +260,7 @@
</tuple>
</tuple>
<state>
<state>
<tuple>
<tuple>
<float>
1
536676302.67
</float>
<float>
1
707223949.31
</float>
<string>
UTC
</string>
<string>
UTC
</string>
</tuple>
</tuple>
</state>
</state>
...
...
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_datetimefield_js.js
View file @
bb0dba8a
/*global window, rJS, RSVP*/
/*global window, rJS, RSVP
, asBoolean
*/
/*jslint indent: 2, maxlen: 80 */
/*jslint indent: 2, maxlen: 80 */
(
function
(
window
,
rJS
,
RSVP
)
{
(
function
(
window
,
rJS
,
RSVP
,
asBoolean
)
{
"
use strict
"
;
"
use strict
"
;
var
ZONE_LIST
=
[
var
ZONE_LIST
=
[
...
@@ -322,26 +322,26 @@
...
@@ -322,26 +322,26 @@
if
(
options
===
undefined
||
options
.
format
===
"
erp5
"
)
{
if
(
options
===
undefined
||
options
.
format
===
"
erp5
"
)
{
if
(
value
!==
""
)
{
if
(
value
!==
""
)
{
if
(
gadget
.
state
.
date_only
===
0
)
{
if
(
!
asBoolean
(
gadget
.
state
.
date_only
)
)
{
value
+=
"
+0000
"
;
value
+=
"
+0000
"
;
}
}
value
=
new
Date
(
value
);
value
=
new
Date
(
value
);
year
=
value
.
getUTCFullYear
();
year
=
value
.
getUTCFullYear
();
month
=
value
.
getUTCMonth
()
+
1
;
month
=
value
.
getUTCMonth
()
+
1
;
date
=
value
.
getUTCDate
();
date
=
value
.
getUTCDate
();
if
(
gadget
.
state
.
hide_day
===
1
)
{
if
(
asBoolean
(
gadget
.
state
.
hide_day
)
)
{
date
=
1
;
date
=
1
;
}
}
//get time
//get time
if
(
gadget
.
state
.
date_only
===
0
)
{
if
(
!
asBoolean
(
gadget
.
state
.
date_only
)
)
{
if
(
gadget
.
state
.
allow_empty_time
===
1
)
{
if
(
asBoolean
(
gadget
.
state
.
allow_empty_time
)
)
{
hour
=
0
;
hour
=
0
;
minute
=
0
;
minute
=
0
;
}
else
{
}
else
{
hour
=
value
.
getUTCHours
();
hour
=
value
.
getUTCHours
();
minute
=
value
.
getUTCMinutes
();
minute
=
value
.
getUTCMinutes
();
}
}
if
(
gadget
.
state
.
ampm_time_style
===
1
)
{
if
(
asBoolean
(
gadget
.
state
.
ampm_time_style
)
)
{
if
(
hour
>
12
)
{
if
(
hour
>
12
)
{
result
[
gadget
.
state
.
subfield_ampm_key
]
=
"
pm
"
;
result
[
gadget
.
state
.
subfield_ampm_key
]
=
"
pm
"
;
hour
-=
12
;
hour
-=
12
;
...
@@ -353,7 +353,7 @@
...
@@ -353,7 +353,7 @@
result
[
gadget
.
state
.
subfield_minute_key
]
=
minute
;
result
[
gadget
.
state
.
subfield_minute_key
]
=
minute
;
}
}
if
(
gadget
.
state
.
hidden_day_is_last_day
===
1
)
{
if
(
asBoolean
(
gadget
.
state
.
hidden_day_is_last_day
)
)
{
if
(
month
===
12
)
{
if
(
month
===
12
)
{
year
+=
1
;
year
+=
1
;
month
=
1
;
month
=
1
;
...
@@ -375,7 +375,7 @@
...
@@ -375,7 +375,7 @@
}
}
}
else
{
}
else
{
//if no value, return empty data
//if no value, return empty data
if
(
gadget
.
state
.
date_only
===
0
)
{
if
(
!
asBoolean
(
gadget
.
state
.
date_only
)
)
{
result
[
gadget
.
state
.
subfield_hour_key
]
=
""
;
result
[
gadget
.
state
.
subfield_hour_key
]
=
""
;
result
[
gadget
.
state
.
subfield_minute_key
]
=
""
;
result
[
gadget
.
state
.
subfield_minute_key
]
=
""
;
}
}
...
@@ -406,4 +406,4 @@
...
@@ -406,4 +406,4 @@
return
true
;
return
true
;
},
{
mutex
:
'
changestate
'
});
},
{
mutex
:
'
changestate
'
});
}(
window
,
rJS
,
RSVP
));
}(
window
,
rJS
,
RSVP
,
asBoolean
));
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_datetimefield_js.xml
View file @
bb0dba8a
...
@@ -216,7 +216,7 @@
...
@@ -216,7 +216,7 @@
</item>
</item>
<item>
<item>
<key>
<string>
actor
</string>
</key>
<key>
<string>
actor
</string>
</key>
<value>
<string>
zop
e
</string>
</value>
<value>
<string>
ERP5TypeTestCas
e
</string>
</value>
</item>
</item>
<item>
<item>
<key>
<string>
comment
</string>
</key>
<key>
<string>
comment
</string>
</key>
...
@@ -230,7 +230,7 @@
...
@@ -230,7 +230,7 @@
</item>
</item>
<item>
<item>
<key>
<string>
serial
</string>
</key>
<key>
<string>
serial
</string>
</key>
<value>
<string>
988.26496.42040.868
6
</string>
</value>
<value>
<string>
1014.23430.20338.6297
6
</string>
</value>
</item>
</item>
<item>
<item>
<key>
<string>
state
</string>
</key>
<key>
<string>
state
</string>
</key>
...
@@ -250,7 +250,7 @@
...
@@ -250,7 +250,7 @@
</tuple>
</tuple>
<state>
<state>
<tuple>
<tuple>
<float>
1
609253131.46
</float>
<float>
1
707224080.57
</float>
<string>
UTC
</string>
<string>
UTC
</string>
</tuple>
</tuple>
</state>
</state>
...
...
bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_page_form_js.js
View file @
bb0dba8a
...
@@ -182,8 +182,8 @@ and handling data send&receive.
...
@@ -182,8 +182,8 @@ and handling data send&receive.
is_refresh
:
options
.
is_refresh
||
false
is_refresh
:
options
.
is_refresh
||
false
};
};
// options.editable differs when it comes from
the
erp5_launcher of FormBox - try to unify it here
// options.editable differs when it comes from
an option in URL param, from
erp5_launcher of FormBox - try to unify it here
if
(
asBoolean
(
options
.
editable
))
{
if
(
options
.
editable
!==
"
false
"
&&
asBoolean
(
options
.
editable
))
{
options
.
editable
=
1
;
options
.
editable
=
1
;
}
else
{
}
else
{
options
.
editable
=
0
;
options
.
editable
=
0
;
...
...
bt5/erp5_web_renderjs_ui_test/PathTemplateItem/portal_tests/renderjs_ui_date_time_field_zuite/testDateTimeFieldTALESDateOnly.xml
0 → 100644
View file @
bb0dba8a
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"ZopePageTemplate"
module=
"Products.PageTemplates.ZopePageTemplate"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
_bind_names
</string>
</key>
<value>
<object>
<klass>
<global
name=
"_reconstructor"
module=
"copy_reg"
/>
</klass>
<tuple>
<global
name=
"NameAssignments"
module=
"Shared.DC.Scripts.Bindings"
/>
<global
name=
"object"
module=
"__builtin__"
/>
<none/>
</tuple>
<state>
<dictionary>
<item>
<key>
<string>
_asgns
</string>
</key>
<value>
<dictionary>
<item>
<key>
<string>
name_subpath
</string>
</key>
<value>
<string>
traverse_subpath
</string>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key>
<string>
content_type
</string>
</key>
<value>
<string>
text/html
</string>
</value>
</item>
<item>
<key>
<string>
expand
</string>
</key>
<value>
<int>
0
</int>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
testDateTimeFieldTALESDateOnly
</string>
</value>
</item>
<item>
<key>
<string>
output_encoding
</string>
</key>
<value>
<string>
utf-8
</string>
</value>
</item>
<item>
<key>
<string>
title
</string>
</key>
<value>
<unicode></unicode>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
bt5/erp5_web_renderjs_ui_test/PathTemplateItem/portal_tests/renderjs_ui_date_time_field_zuite/testDateTimeFieldTALESDateOnly.zpt
0 → 100644
View file @
bb0dba8a
<html
xmlns:tal=
"http://xml.zope.org/namespaces/tal"
xmlns:metal=
"http://xml.zope.org/namespaces/metal"
>
<head>
<meta
http-equiv=
"Content-Type"
content=
"text/html; charset=UTF-8"
>
<title>
Test RenderJS UI
</title>
</head>
<body>
<table
cellpadding=
"1"
cellspacing=
"1"
border=
"1"
>
<thead>
<tr><td
rowspan=
"1"
colspan=
"3"
>
Test RenderJS UI
</td></tr>
</thead><tbody>
<tal:block
metal:use-macro=
"here/Zuite_CommonTemplate/macros/init"
/>
<!-- Clean Up -->
<tr>
<td>
open
</td>
<td>
${base_url}/bar_module/ListBoxZuite_reset
</td>
<td></td>
</tr>
<tr>
<td>
assertTextPresent
</td>
<td>
Reset Successfully.
</td>
<td></td>
</tr>
<!-- Initialize -->
<tr>
<td>
open
</td>
<td>
${base_url}/bar_module/BarModule_createObjects?num:int=1
</td>
<td></td>
</tr>
<tr>
<td>
assertTextPresent
</td>
<td>
Created Successfully.
</td>
<td></td>
</tr>
<tr>
<td>
open
</td>
<td>
${base_url}/web_site_module/renderjs_runner/#/bar_module/0?editable=true
</td>
<td></td>
</tr>
<tal:block
metal:use-macro=
"here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_app_loaded"
/>
<tal:block
metal:use-macro=
"here/Zuite_CommonTemplateForRenderjsUi/macros/go_to_bar_datetime_field_view"
/>
<!-- Actual test -->
<tr>
<td>
assertValue
</td>
<td>
//input[@name='field_my_date_time_field_with_tales']
</td>
<td>
2001-02-03
</td>
</tr>
<tr>
<td>
type
</td>
<td>
//input[@name='field_my_date_time_field_with_tales']
</td>
<td>
2003-02-01
</td>
</tr>
<tal:block
metal:use-macro=
"here/Zuite_CommonTemplateForRenderjsUi/macros/click_save"
/>
<tal:block
metal:use-macro=
"here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_content_loaded"
/>
<tr>
<td>
assertValue
</td>
<td>
//input[@name='field_my_date_time_field_with_tales']
</td>
<td>
2003-02-01
</td>
</tr>
</tbody></table>
</body>
</html>
\ No newline at end of file
product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/gadget_global.js.js
View file @
bb0dba8a
...
@@ -9,10 +9,14 @@
...
@@ -9,10 +9,14 @@
Calling isEmpty(x) is more robust than expression !x.
Calling isEmpty(x) is more robust than expression !x.
*/
*/
function
isEmpty
(
value
)
{
function
isEmpty
(
value
)
{
return
(
value
===
undefined
||
return
(
value
===
null
||
(
value
===
undefined
)
||
value
.
length
===
0
||
(
value
===
null
)
||
(
typeof
value
===
"
number
"
&&
isNaN
(
value
)));
((
typeof
value
===
"
number
"
)
?
isNaN
(
value
)
:
(
Object
.
keys
(
value
).
length
===
0
)
)
);
}
}
window
.
isEmpty
=
isEmpty
;
window
.
isEmpty
=
isEmpty
;
...
@@ -27,7 +31,7 @@
...
@@ -27,7 +31,7 @@
/** Return first non-empty variable or the last one.
/** Return first non-empty variable or the last one.
Calling get
NonEmp
y(a, b, "") is more robust way of writing a || b || "".
Calling get
FirstNonEmpt
y(a, b, "") is more robust way of writing a || b || "".
Variables coercing to false (e.g 0) do not get skipped anymore.
Variables coercing to false (e.g 0) do not get skipped anymore.
*/
*/
function
getFirstNonEmpty
(
first_argument
)
{
function
getFirstNonEmpty
(
first_argument
)
{
...
@@ -47,18 +51,17 @@
...
@@ -47,18 +51,17 @@
}
}
window
.
getFirstNonEmpty
=
getFirstNonEmpty
;
window
.
getFirstNonEmpty
=
getFirstNonEmpty
;
/** Convert anything to boolean value correctly (even "false" will be false)*/
/**
* Convert anything to boolean value with rules similar to python.
*/
function
asBoolean
(
obj
)
{
function
asBoolean
(
obj
)
{
if
(
typeof
obj
===
"
boolean
"
)
{
if
(
typeof
obj
===
"
boolean
"
)
{
return
obj
;
return
obj
;
}
}
if
(
typeof
obj
===
"
string
"
)
{
return
obj
.
toLowerCase
()
===
"
true
"
||
obj
===
"
1
"
;
}
if
(
typeof
obj
===
"
number
"
)
{
if
(
typeof
obj
===
"
number
"
)
{
return
obj
!==
0
;
return
Boolean
(
obj
)
}
}
return
Boolean
(
obj
);
return
!
isEmpty
(
obj
);
}
}
window
.
asBoolean
=
asBoolean
;
window
.
asBoolean
=
asBoolean
;
...
...
product/ERP5OOo/tests/testOOoStyle.py
View file @
bb0dba8a
...
@@ -528,13 +528,13 @@ class TestOOoStyle(ERP5TypeTestCase, ZopeTestCase.Functional):
...
@@ -528,13 +528,13 @@ class TestOOoStyle(ERP5TypeTestCase, ZopeTestCase.Functional):
if
self
.
skin
==
'ODT'
:
if
self
.
skin
==
'ODT'
:
return
tree
.
xpath
(
'normalize-space((//table[2]//tr//td)[3])'
)
return
tree
.
xpath
(
'normalize-space((//table[2]//tr//td)[3])'
)
elif
self
.
skin
==
'ODS'
:
elif
self
.
skin
==
'ODS'
:
return
tree
.
xpath
(
'normalize-space(//table//tr[
7
]/td)'
)
return
tree
.
xpath
(
'normalize-space(//table//tr[
8
]/td)'
)
def
get_date_time_listbox_stat_value
(
tree
):
def
get_date_time_listbox_stat_value
(
tree
):
if
self
.
skin
==
'ODT'
:
if
self
.
skin
==
'ODT'
:
return
tree
.
xpath
(
'normalize-space((//table[2]//tr//td)[4])'
)
return
tree
.
xpath
(
'normalize-space((//table[2]//tr//td)[4])'
)
elif
self
.
skin
==
'ODS'
:
elif
self
.
skin
==
'ODS'
:
return
tree
.
xpath
(
'normalize-space(//table//tr[
8
]/td)'
)
return
tree
.
xpath
(
'normalize-space(//table//tr[
9
]/td)'
)
response
=
self
.
publish
(
response
=
self
.
publish
(
'%s/Foo_viewDateTimeField?format=html&input_order=ymd&date_only:int=1'
%
foo
.
getPath
(),
basic
=
self
.
auth
)
'%s/Foo_viewDateTimeField?format=html&input_order=ymd&date_only:int=1'
%
foo
.
getPath
(),
basic
=
self
.
auth
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment