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

View File

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

View File

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