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
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
Romain Courteaud
erp5
Commits
a89afa43
Commit
a89afa43
authored
Apr 02, 2014
by
Vincent Pelletier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Formulator: Support disabled items in all ItemWidget subclasses.
parent
2e139aec
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
14 deletions
+19
-14
product/Formulator/Widget.py
product/Formulator/Widget.py
+19
-14
No files found.
product/Formulator/Widget.py
View file @
a89afa43
...
@@ -775,6 +775,17 @@ class ItemsWidget(Widget):
...
@@ -775,6 +775,17 @@ class ItemsWidget(Widget):
default
=
""
,
default
=
""
,
required
=
0
)
required
=
0
)
@
staticmethod
def
render_element
(
tag
,
**
kw
):
"""
Similar to global render_element, but render None values as disabled
elements.
"""
if
kw
[
'value'
]
is
None
:
kw
.
pop
(
'value'
)
kw
[
'disabled'
]
=
None
return
render_element
(
tag
,
**
kw
)
class
SingleItemsWidget
(
ItemsWidget
):
class
SingleItemsWidget
(
ItemsWidget
):
"""A widget with a number of items that has only a single
"""A widget with a number of items that has only a single
selectable item.
selectable item.
...
@@ -1119,14 +1130,11 @@ class ListWidget(SingleItemsWidget):
...
@@ -1119,14 +1130,11 @@ class ListWidget(SingleItemsWidget):
return
"
\
n
"
.
join
([
list_widget
,
input_hidden
])
return
"
\
n
"
.
join
([
list_widget
,
input_hidden
])
def
render_item
(
self
,
text
,
value
,
key
,
css_class
,
extra_item
):
def
render_item
(
self
,
text
,
value
,
key
,
css_class
,
extra_item
):
if
value
is
None
:
return
self
.
render_element
(
'option'
,
contents
=
text
,
value
=
value
,
return
render_element
(
'option'
,
contents
=
text
,
disabled
=
None
,
extra
=
extra_item
)
return
render_element
(
'option'
,
contents
=
text
,
value
=
value
,
extra
=
extra_item
)
extra
=
extra_item
)
def
render_selected_item
(
self
,
text
,
value
,
key
,
css_class
,
extra_item
):
def
render_selected_item
(
self
,
text
,
value
,
key
,
css_class
,
extra_item
):
return
render_element
(
'option'
,
contents
=
text
,
value
=
value
,
return
self
.
render_element
(
'option'
,
contents
=
text
,
value
=
value
,
selected
=
None
,
extra
=
extra_item
)
selected
=
None
,
extra
=
extra_item
)
ListWidgetInstance
=
ListWidget
()
ListWidgetInstance
=
ListWidget
()
...
@@ -1161,14 +1169,11 @@ class MultiListWidget(MultiItemsWidget):
...
@@ -1161,14 +1169,11 @@ class MultiListWidget(MultiItemsWidget):
return
"
\
n
"
.
join
([
multi_list
,
input_hidden
])
return
"
\
n
"
.
join
([
multi_list
,
input_hidden
])
def
render_item
(
self
,
text
,
value
,
key
,
css_class
,
extra_item
):
def
render_item
(
self
,
text
,
value
,
key
,
css_class
,
extra_item
):
if
value
is
None
:
return
self
.
render_element
(
'option'
,
contents
=
text
,
value
=
value
,
return
render_element
(
'option'
,
contents
=
text
,
disabled
=
None
,
extra
=
extra_item
)
return
render_element
(
'option'
,
contents
=
text
,
value
=
value
,
extra
=
extra_item
)
extra
=
extra_item
)
def
render_selected_item
(
self
,
text
,
value
,
key
,
css_class
,
extra_item
):
def
render_selected_item
(
self
,
text
,
value
,
key
,
css_class
,
extra_item
):
return
render_element
(
'option'
,
contents
=
text
,
value
=
value
,
return
self
.
render_element
(
'option'
,
contents
=
text
,
value
=
value
,
selected
=
None
,
extra
=
extra_item
)
selected
=
None
,
extra
=
extra_item
)
MultiListWidgetInstance
=
MultiListWidget
()
MultiListWidgetInstance
=
MultiListWidget
()
...
@@ -1202,7 +1207,7 @@ class RadioWidget(SingleItemsWidget):
...
@@ -1202,7 +1207,7 @@ class RadioWidget(SingleItemsWidget):
return
string
.
join
(
rendered_items
,
"<br />"
)
return
string
.
join
(
rendered_items
,
"<br />"
)
def
render_item
(
self
,
text
,
value
,
key
,
css_class
,
extra_item
):
def
render_item
(
self
,
text
,
value
,
key
,
css_class
,
extra_item
):
return
render_element
(
'input'
,
return
self
.
render_element
(
'input'
,
type
=
"radio"
,
type
=
"radio"
,
css_class
=
css_class
,
css_class
=
css_class
,
name
=
key
,
name
=
key
,
...
@@ -1210,7 +1215,7 @@ class RadioWidget(SingleItemsWidget):
...
@@ -1210,7 +1215,7 @@ class RadioWidget(SingleItemsWidget):
extra
=
extra_item
)
+
text
extra
=
extra_item
)
+
text
def
render_selected_item
(
self
,
text
,
value
,
key
,
css_class
,
extra_item
):
def
render_selected_item
(
self
,
text
,
value
,
key
,
css_class
,
extra_item
):
return
render_element
(
'input'
,
return
self
.
render_element
(
'input'
,
type
=
"radio"
,
type
=
"radio"
,
css_class
=
css_class
,
css_class
=
css_class
,
name
=
key
,
name
=
key
,
...
@@ -1247,7 +1252,7 @@ class MultiCheckBoxWidget(MultiItemsWidget):
...
@@ -1247,7 +1252,7 @@ class MultiCheckBoxWidget(MultiItemsWidget):
return
string
.
join
(
rendered_items
,
"<br />"
)
return
string
.
join
(
rendered_items
,
"<br />"
)
def
render_item
(
self
,
text
,
value
,
key
,
css_class
,
extra_item
):
def
render_item
(
self
,
text
,
value
,
key
,
css_class
,
extra_item
):
return
render_element
(
'input'
,
return
self
.
render_element
(
'input'
,
type
=
"checkbox"
,
type
=
"checkbox"
,
css_class
=
css_class
,
css_class
=
css_class
,
name
=
key
,
name
=
key
,
...
@@ -1255,7 +1260,7 @@ class MultiCheckBoxWidget(MultiItemsWidget):
...
@@ -1255,7 +1260,7 @@ class MultiCheckBoxWidget(MultiItemsWidget):
extra
=
extra_item
)
+
text
extra
=
extra_item
)
+
text
def
render_selected_item
(
self
,
text
,
value
,
key
,
css_class
,
extra_item
):
def
render_selected_item
(
self
,
text
,
value
,
key
,
css_class
,
extra_item
):
return
render_element
(
'input'
,
return
self
.
render_element
(
'input'
,
type
=
"checkbox"
,
type
=
"checkbox"
,
css_class
=
css_class
,
css_class
=
css_class
,
name
=
key
,
name
=
key
,
...
...
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