changeset 1995:21fb938ab077

merged
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Wed, 13 Feb 2013 13:33:57 +0100
parents e0a036c7f7f7 (current diff) 02f24ba9623d (diff)
children 8a20af6b9081 374eb595d6ba
files
diffstat 3 files changed, 18 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/constants/forms.py	Wed Feb 13 13:32:23 2013 +0100
+++ b/MoinMoin/constants/forms.py	Wed Feb 13 13:33:57 2013 +0100
@@ -24,6 +24,7 @@
 WIDGET_HIDDEN = u'hidden'
 
 WIDGET_SELECT = u'select'
+WIDGET_SELECT_SUBMIT = u'select_submit'
 WIDGET_MULTI_SELECT = u'multi_select'
 
 WIDGET_READONLY_STRING_LIST = u'readonly_string_list'
--- a/MoinMoin/forms.py	Wed Feb 13 13:32:23 2013 +0100
+++ b/MoinMoin/forms.py	Wed Feb 13 13:33:57 2013 +0100
@@ -75,6 +75,15 @@
 
 Select = Enum.with_properties(widget=WIDGET_SELECT)
 
+# SelectSubmit is like Select in that it is rendered as a group of controls
+# with different (predefined) `value`s for the same `name`. But the controls are
+# submit buttons instead of radio buttons.
+#
+# This is used to present the user several "OK" buttons with slightly different
+# semantics, like "Update" and "Update and Close" on a ticket page, or
+# "Save as Draft" and "Publish" when editing a blog entry.
+SelectSubmit = Enum.with_properties(widget=WIDGET_SELECT_SUBMIT)
+
 
 # Need a better name to capture the behavior
 class MyJoinedString(JoinedString):
--- a/MoinMoin/templates/forms.html	Wed Feb 13 13:32:23 2013 +0100
+++ b/MoinMoin/templates/forms.html	Wed Feb 13 13:33:57 2013 +0100
@@ -54,6 +54,7 @@
       'search': search,
       'hidden': raw_input,
       'select': select,
+      'select_submit': select_submit,
       'multi_select': multi_select,
       'readonly_string_list': readonly_string_list,
       'readonly_item_link_list': readonly_item_link_list,
@@ -164,6 +165,13 @@
   </dd>
 {% endmacro %}
 
+{% macro select_submit(field) %}
+  {% set labels = field.properties.get('labels', {}) %}
+  {% for value in field.valid_values %}
+    {{ gen.button(field, type='submit', value=value, contents=labels.get(value, value)) }}
+  {% endfor %}
+{% endmacro %}
+
 {% macro multi_select(field) %}
   {% set valid_values = field.member_schema.valid_values %}
   {% set labels = field.member_schema.properties.get('labels', {}) %}