keep current filter when submitting a form.

svn path=/plone.app.discussion/trunk/; revision=27715
This commit is contained in:
Timo Stollenwerk 2009-06-29 11:11:58 +00:00
parent c25557650f
commit dd7f59c104
3 changed files with 35 additions and 15 deletions

View File

@ -28,30 +28,33 @@
<metal:main fill-slot="main">
<tal:main-macro metal:define-macro="main"
tal:define="items view/comments">
tal:define="items view/comments;
filter view/filter|nothing;">
<h1 class="documentFirstHeading" i18n:translate="title_review">
Review comments
</h1>
<ul class="filter">
<li class="all">
<form method="post"
action="#"
tal:attributes="action string:${context/absolute_url}/@@moderate-comments">
<input type="submit" value="All" class="context" />
<input type="submit" value="All" class="context"
tal:attributes="class python: not filter and 'context selected' or 'context'" />
</form>
</li>
<li class="pending">
<form method="post" action="#" tal:attributes="action string:${context/absolute_url}/@@moderate-comments">
<input type="hidden" name="form.button.FilterPending" value="1" />
<input type="submit" value="Pending" class="context" />
<input type="hidden" name="form.button.Filter" value="pending" />
<input type="submit" value="Pending" class="context"
tal:attributes="class python:filter == 'pending' and 'context selected' or 'context'"/>
</form>
</li>
<li class="approved">
<form method="post" action="#" tal:attributes="action string:${context/absolute_url}/@@moderate-comments">
<input type="hidden" name="form.button.FilterPublished" value="1" />
<input type="submit" value="Published" class="context" />
<input type="hidden" name="form.button.Filter" value="published" />
<input type="submit" value="Published" class="context"
tal:attributes="class python:filter == 'published' and 'context selected' or 'context'"/>
</form>
</li>
<!--
@ -126,13 +129,13 @@
<td tal:content="structure python:view.cook(item.Description)" />
<td style="width: 11em;">
<form action=""
class="background-form"
class="background-form workflow_action"
method="post"
style="display: inline"
tal:attributes="action string:${item/getURL}/@@moderate-publish-comment"
tal:condition="python:item.review_state == 'pending'">
<input type="hidden" name="comment_id" tal:attributes="value item/getId" />
<input type="hidden" name="workflow_action" tal:attributes="value view/transition" />
<input type="hidden" name="form.button.Filter" tal:attributes="value filter" value="" />
<input class="context comment-publish-button"
type="submit"
value="Publish"
@ -141,10 +144,10 @@
</form>
<form action=""
method="post"
class="background-form"
style="display: inline"
class="background-form delete"
tal:attributes="action string:${item/getURL}/@@moderate-delete-comment">
<input type="hidden" name="comment_id" tal:attributes="value item/getId" />
<input type="hidden" name="form.button.Filter" tal:attributes="value filter" value="" />
<input class="destructive comment-delete-button"
type="submit"
value="Delete"

View File

@ -15,10 +15,14 @@ class View(BrowserView):
context = aq_inner(self.context)
if self.request.has_key('form.button.FilterPending'):
if self.request.has_key('form.button.Filter'):
self.filter = self.request.get('form.button.Filter')
if self.filter == 'pending':
self.comments = self.comments_pending()
elif self.request.has_key('form.button.FilterPublished'):
elif self.filter == "published":
self.comments = self.comments_published()
else:
raise ValueError('Value %s for filter is not know.' % self.filter)
else:
self.comments = self.comments_all()
return self.template()

View File

@ -53,6 +53,7 @@
ul.filter {
margin: 0.5em 0 0.5em 0em;
}
.filter li {
display: inline;
}
@ -65,6 +66,18 @@ ul.filter {
display: inline;
}
.filter .selected {
background-color: #DEE7EC;
}
#dobulkaction {
margin: 0.2em 0;
}
form.workflow_action {
float: left;
}
form.delete {
float: right;
}