submit bulkactions with an AJAX call.

svn path=/plone.app.discussion/trunk/; revision=27720
This commit is contained in:
Timo Stollenwerk 2009-06-29 13:38:00 +00:00
parent 8df9ad9cf4
commit 502015b14e
3 changed files with 27 additions and 8 deletions

View File

@ -1,7 +1,7 @@
jq(document).ready(function() { jq(document).ready(function() {
/***************************************************************** /*****************************************************************
* Check or uncheck all checkboxes. * Check or uncheck all checkboxes
*****************************************************************/ *****************************************************************/
jq("input[name='check_all']").click(function(){ jq("input[name='check_all']").click(function(){
if(jq(this).val()==0){ if(jq(this).val()==0){
@ -16,4 +16,23 @@ jq(document).ready(function() {
} }
}); });
}); /*****************************************************************
* Bulk actions
*****************************************************************/
jq('form.bulkactions').submit(function(e) {
e.preventDefault();
var target = jq(this).attr('action');
var params = jq(this).serialize();
var valArray = jq('input:checkbox:checked');
jq.post(target, params, function(data) {
valArray.each(function () {
row = jq(this).parent().parent();
row.fadeOut("normal", function() {
row.remove();
});
});
});
});
});

View File

@ -68,7 +68,7 @@
<form method="post" <form method="post"
action="#" action="#"
class="kssattr-serveraction-foldercontents_update_table" class="bulkactions"
tal:attributes="action string:${context/absolute_url}/@@bulk-actions"> tal:attributes="action string:${context/absolute_url}/@@bulk-actions">
<select name="form.select.BulkAction"> <select name="form.select.BulkAction">
<option selected="selected" value="-1" i18n:translate="title_bulkactions">Bulk Actions</option> <option selected="selected" value="-1" i18n:translate="title_bulkactions">Bulk Actions</option>
@ -77,6 +77,7 @@
<!--<option value="mark_as_spam" i18n:translate="bulkactions_markasspam">Mark as Spam</option>--> <!--<option value="mark_as_spam" i18n:translate="bulkactions_markasspam">Mark as Spam</option>-->
<option value="delete" i18n:translate="bulkactions_delete">Delete</option> <option value="delete" i18n:translate="bulkactions_delete">Delete</option>
</select> </select>
<input type="hidden" name="form.button.Filter" tal:attributes="value filter" value="" />
<input id="dobulkaction" <input id="dobulkaction"
type="submit" type="submit"
class="standalone allowMultiSubmit" class="standalone allowMultiSubmit"

View File

@ -6,7 +6,7 @@ from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile
from Products.CMFCore.utils import getToolByName from Products.CMFCore.utils import getToolByName
class View(BrowserView): class View(BrowserView):
""" """Moderation View
""" """
template = ViewPageTemplateFile('moderation.pt') template = ViewPageTemplateFile('moderation.pt')
@ -119,14 +119,15 @@ class BulkActionsView(BrowserView):
context = aq_inner(self.context) context = aq_inner(self.context)
if self.request.has_key('form.button.BulkAction'): if self.request.has_key('form.select.BulkAction'):
bulkaction = self.request.get('form.select.BulkAction') bulkaction = self.request.get('form.select.BulkAction')
paths = self.request.get('paths') paths = self.request.get('paths')
if bulkaction == '-1': if bulkaction == '-1':
return self.context.REQUEST.RESPONSE.redirect(self.context.REQUEST.HTTP_REFERER) # no bulk action was selected
pass
elif bulkaction == 'retract': elif bulkaction == 'retract':
self.retract(paths) self.retract(paths)
elif bulkaction == 'publish': elif bulkaction == 'publish':
@ -138,8 +139,6 @@ class BulkActionsView(BrowserView):
else: else:
raise KeyError raise KeyError
return self.context.REQUEST.RESPONSE.redirect(self.context.REQUEST.HTTP_REFERER)
def retract(self, paths): def retract(self, paths):
raise NotImplementedError raise NotImplementedError