# Copyright (c) 2011 gocept gmbh & co. kg
# See also LICENSE.txt

import zeit.cms.browser.view
import zeit.edit.browser.view
import zope.app.pagetemplate
import zope.formlib.form


class Forms(object):
    """View that collects all inline forms."""


FormGroup = zope.viewlet.viewlet.SimpleViewletClass('layout.forms.pt')

FoldableFormGroup = zope.viewlet.viewlet.SimpleViewletClass('layout.foldable-forms.pt')

FormLoader = zope.viewlet.viewlet.SimpleViewletClass('layout.form-loader.pt')


class InlineForm(zeit.cms.browser.form.WidgetCSSMixin,
                 zope.formlib.form.SubPageEditForm,
                 zeit.edit.browser.view.UndoableMixin,
                 zeit.cms.browser.view.Base):

    template = zope.app.pagetemplate.ViewPageTemplateFile('inlineform.pt')

    css_class = None

    def __call__(self):
        self.mark_transaction_undoable()
        return super(InlineForm, self).__call__()

@@ -59,16 +59,62 @@
 SE.txt%0A%0A
+from zeit.cms.i18n import MessageFactory as _%0A
 import z
@@ -846,25 +846,91 @@
     
-def __call__(self
+@zope.formlib.form.action(_('Apply'))%0A    def handle_edit_action(self, action, data
 ):%0A 
@@ -1012,15 +1012,37 @@
 lf).
-__call__(
+handle_edit_action.success(data
 )%0A

Mark transactions undoable only if the form may actually be writing something