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
Laurent S
erp5
Commits
0db642f9
Commit
0db642f9
authored
Jun 09, 2017
by
Kazuhiko Shiozaki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Formulator: add a new input style "number" in DateTimeField.
parent
366a6364
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
71 additions
and
1 deletion
+71
-1
product/Formulator/StandardFields.py
product/Formulator/StandardFields.py
+69
-0
product/Formulator/Widget.py
product/Formulator/Widget.py
+2
-1
No files found.
product/Formulator/StandardFields.py
View file @
0db642f9
...
@@ -136,6 +136,8 @@ class DateTimeField(ZMIField):
...
@@ -136,6 +136,8 @@ class DateTimeField(ZMIField):
self
.
sub_form
=
create_datetime_text_sub_form
()
self
.
sub_form
=
create_datetime_text_sub_form
()
elif
input_style
==
'list'
:
elif
input_style
==
'list'
:
self
.
sub_form
=
create_datetime_list_sub_form
()
self
.
sub_form
=
create_datetime_list_sub_form
()
elif
input_style
==
'number'
:
self
.
sub_form
=
create_datetime_number_sub_form
()
else
:
else
:
assert
0
,
"Unknown input_style '%s'"
%
input_style
assert
0
,
"Unknown input_style '%s'"
%
input_style
...
@@ -147,6 +149,8 @@ class DateTimeField(ZMIField):
...
@@ -147,6 +149,8 @@ class DateTimeField(ZMIField):
year_field
=
self
.
sub_form
.
get_field
(
'year'
,
include_disabled
=
1
)
year_field
=
self
.
sub_form
.
get_field
(
'year'
,
include_disabled
=
1
)
year_field
.
overrides
[
'items'
]
=
BoundMethod
(
self
,
year_field
.
overrides
[
'items'
]
=
BoundMethod
(
self
,
'_override_year_items'
)
'_override_year_items'
)
elif
value
==
'number'
:
self
.
sub_form
=
create_datetime_number_sub_form
()
else
:
else
:
assert
0
,
"Unknown input_style."
assert
0
,
"Unknown input_style."
self
.
on_value_css_class_changed
(
self
.
values
[
'css_class'
])
self
.
on_value_css_class_changed
(
self
.
values
[
'css_class'
])
...
@@ -299,6 +303,71 @@ def create_datetime_list_sub_form():
...
@@ -299,6 +303,71 @@ def create_datetime_list_sub_form():
sub_form
.
add_fields
([
hour
,
minute
,
ampm
,
timezone
],
"time"
)
sub_form
.
add_fields
([
hour
,
minute
,
ampm
,
timezone
],
"time"
)
return
sub_form
return
sub_form
def
create_datetime_number_sub_form
():
sub_form
=
BasicForm
()
year
=
IntegerField
(
'year'
,
title
=
"Year"
,
required
=
0
,
input_type
=
'number'
,
extra
=
'min="0" max="9999"'
,
display_width
=
4
,
display_maxwidth
=
4
,
max_length
=
4
)
month
=
IntegerField
(
'month'
,
title
=
"Month"
,
required
=
0
,
input_type
=
'number'
,
extra
=
'min="1" max="12"'
,
display_width
=
2
,
display_maxwidth
=
2
,
max_length
=
2
)
day
=
IntegerField
(
'day'
,
title
=
"Day"
,
required
=
0
,
input_type
=
'number'
,
extra
=
'min="1" max="31"'
,
display_width
=
2
,
display_maxwidth
=
2
,
max_length
=
2
)
sub_form
.
add_group
(
"date"
)
sub_form
.
add_fields
([
year
,
month
,
day
],
"date"
)
hour
=
IntegerField
(
'hour'
,
title
=
"Hour"
,
required
=
0
,
input_type
=
'number'
,
extra
=
'min="0" max="23"'
,
display_width
=
2
,
display_maxwidth
=
2
,
max_length
=
2
)
minute
=
IntegerField
(
'minute'
,
title
=
"Minute"
,
required
=
0
,
input_type
=
'number'
,
extra
=
'min="0" max="59"'
,
display_width
=
2
,
display_maxwidth
=
2
,
max_length
=
2
)
ampm
=
StringField
(
'ampm'
,
title
=
"am/pm"
,
required
=
0
,
display_width
=
2
,
display_maxwidth
=
2
,
max_length
=
2
)
timezone
=
ListField
(
'timezone'
,
title
=
"Timezone"
,
required
=
0
,
default
=
'GMT'
,
items
=
Widget
.
gmt_timezones
,
size
=
1
)
sub_form
.
add_fields
([
hour
,
minute
,
ampm
,
timezone
],
"time"
)
return
sub_form
def
create_items
(
start
,
end
,
digits
=
0
):
def
create_items
(
start
,
end
,
digits
=
0
):
result
=
[(
"-"
,
""
)]
result
=
[(
"-"
,
""
)]
if
digits
:
if
digits
:
...
...
product/Formulator/Widget.py
View file @
0db642f9
...
@@ -1376,7 +1376,8 @@ class DateTimeWidget(Widget):
...
@@ -1376,7 +1376,8 @@ class DateTimeWidget(Widget):
"as text, while 'list' will use dropdown lists instead."
),
"as text, while 'list' will use dropdown lists instead."
),
default
=
"text"
,
default
=
"text"
,
items
=
[(
"text"
,
"text"
),
items
=
[(
"text"
,
"text"
),
(
"list"
,
"list"
)],
(
"list"
,
"list"
),
(
"number"
,
"number"
)],
size
=
1
)
size
=
1
)
default_timezone
=
fields
.
ListField
(
'default_timezone'
,
default_timezone
=
fields
.
ListField
(
'default_timezone'
,
...
...
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