differentiate between delete and publish AJAX calls.
svn path=/plone.app.discussion/trunk/; revision=27725
This commit is contained in:
		
							parent
							
								
									4a934a2967
								
							
						
					
					
						commit
						a00dea41e3
					
				@ -16,6 +16,7 @@ jq(document).ready(function() {
 | 
				
			|||||||
	      }
 | 
						      }
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /*****************************************************************
 | 
					    /*****************************************************************
 | 
				
			||||||
     * Comment actions (delete, publish)
 | 
					     * Comment actions (delete, publish)
 | 
				
			||||||
     *****************************************************************/
 | 
					     *****************************************************************/
 | 
				
			||||||
@ -25,31 +26,56 @@ jq(document).ready(function() {
 | 
				
			|||||||
        var params = jq(this).serialize();
 | 
					        var params = jq(this).serialize();
 | 
				
			||||||
        var cell = jq(this).parent().get(0);
 | 
					        var cell = jq(this).parent().get(0);
 | 
				
			||||||
        var row = jq(cell).parent().get(0);
 | 
					        var row = jq(cell).parent().get(0);
 | 
				
			||||||
 | 
					        var currentFilter = jq(this).find("[name='form.button.Filter']").attr("value");
 | 
				
			||||||
 | 
					        var currentAction = jq(this).attr("class");
 | 
				
			||||||
        jq.post(target, params, function(data) {
 | 
					        jq.post(target, params, function(data) {
 | 
				
			||||||
 | 
								if (currentAction == 'background-form workflow_action' && currentFilter == '') {
 | 
				
			||||||
 | 
					                alert("NotImplementedError: AJAX switch workflow state")
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
								else {
 | 
				
			||||||
				jq(row).fadeOut("normal", function(){
 | 
									jq(row).fadeOut("normal", function(){
 | 
				
			||||||
					jq(this).remove();
 | 
										jq(this).remove();
 | 
				
			||||||
				});
 | 
									});
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
        });
 | 
					        });
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /*****************************************************************
 | 
					    /*****************************************************************
 | 
				
			||||||
     * Bulk actions
 | 
					     * Bulk actions (delete, publish)
 | 
				
			||||||
     *****************************************************************/
 | 
					     *****************************************************************/
 | 
				
			||||||
    jq('form.bulkactions').submit(function(e) {
 | 
					    jq('form.bulkactions').submit(function(e) {
 | 
				
			||||||
        e.preventDefault();
 | 
					        e.preventDefault();
 | 
				
			||||||
        var target = jq(this).attr('action');
 | 
					        var target = jq(this).attr('action');
 | 
				
			||||||
        var params = jq(this).serialize();
 | 
					        var params = jq(this).serialize();
 | 
				
			||||||
		var valArray = jq('input:checkbox:checked');
 | 
							var valArray = jq('input:checkbox:checked');
 | 
				
			||||||
 | 
					        var currentFilter = jq(this).find("[name='form.button.Filter']").attr("value");
 | 
				
			||||||
 | 
							var currentAction = jq(this).find("[name='form.select.BulkAction']").val();
 | 
				
			||||||
 | 
					        if (valArray.length) {
 | 
				
			||||||
            jq.post(target, params, function(data) {
 | 
					            jq.post(target, params, function(data) {
 | 
				
			||||||
                valArray.each(function () {
 | 
					                valArray.each(function () {
 | 
				
			||||||
 | 
										// if bulkaction is delete, or the current filter is
 | 
				
			||||||
 | 
										// pending (because then publish also removes the comment),
 | 
				
			||||||
 | 
										// remove all selected comments.
 | 
				
			||||||
 | 
					                    if (currentAction == 'delete' || currentFilter == 'pending') {
 | 
				
			||||||
                        row = jq(this).parent().parent();
 | 
					                        row = jq(this).parent().parent();
 | 
				
			||||||
                        row.fadeOut("normal", function() {
 | 
					                        row.fadeOut("normal", function() {
 | 
				
			||||||
                           row.remove();
 | 
					                           row.remove();
 | 
				
			||||||
                        });
 | 
					                        });
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
										// if bulkaction is publish and there is no current filter,
 | 
				
			||||||
 | 
										// change the workflow action
 | 
				
			||||||
 | 
										if (currentAction == 'publish') {
 | 
				
			||||||
 | 
					                        alert("NotImplementedError: AJAX switch workflow state")
 | 
				
			||||||
 | 
										}
 | 
				
			||||||
                });
 | 
					                });
 | 
				
			||||||
            });
 | 
					            });
 | 
				
			||||||
 | 
					        } else {
 | 
				
			||||||
 | 
								// The user has submitted a bulk action, but no comment
 | 
				
			||||||
 | 
								// was selected.
 | 
				
			||||||
 | 
								// Todo: nicer and translated message
 | 
				
			||||||
 | 
					            alert("You haven't selected anything for this bulk action.");
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
@ -13,7 +13,7 @@
 | 
				
			|||||||
                    filter view/filter|nothing;">
 | 
					                    filter view/filter|nothing;">
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        <h1 class="documentFirstHeading" i18n:translate="title_review">
 | 
					        <h1 class="documentFirstHeading" i18n:translate="title_review">
 | 
				
			||||||
            Review comments
 | 
					            Moderate comments
 | 
				
			||||||
        </h1>
 | 
					        </h1>
 | 
				
			||||||
        <ul class="filter">
 | 
					        <ul class="filter">
 | 
				
			||||||
            <li class="all">
 | 
					            <li class="all">
 | 
				
			||||||
 | 
				
			|||||||
@ -124,7 +124,7 @@ class BulkActionsView(BrowserView):
 | 
				
			|||||||
            bulkaction = self.request.get('form.select.BulkAction')
 | 
					            bulkaction = self.request.get('form.select.BulkAction')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            self.paths = self.request.get('paths')
 | 
					            self.paths = self.request.get('paths')
 | 
				
			||||||
 | 
					            if self.paths:
 | 
				
			||||||
                if bulkaction == '-1':
 | 
					                if bulkaction == '-1':
 | 
				
			||||||
                    # no bulk action was selected
 | 
					                    # no bulk action was selected
 | 
				
			||||||
                    pass
 | 
					                    pass
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user