confirm deletes and moves; add 'All' option to filter fields

This commit is contained in:
Sanj 2011-07-01 20:23:17 +05:30
parent 06a52d5793
commit 14d1955bb3
2 changed files with 18 additions and 2 deletions

View File

@ -82,9 +82,18 @@ class CategoryForm(forms.Form):
category = forms.ModelChoiceField(Category.objects, required=False, label="Study")
category_name = forms.CharField(required=False, label="Create New Study")
FILE_FILTER_CHOICES = (
('', 'All'),
('image', 'Image'),
('audio', 'Audio'),
('text', 'Text'),
('video', 'Video'),
('other', 'Other'),
)
class FileFilterForm(forms.Form):
category = forms.ModelChoiceField(Category.objects, required=False, label="Study")
fileType = forms.ChoiceField(TYPE_CHOICES, required=False, label="File Type")
fileType = forms.ChoiceField(FILE_FILTER_CHOICES, required=False, label="File Type")
search = forms.CharField(required=False)
@login_required

View File

@ -2,6 +2,7 @@ $(function() {
// alert("hi");
var selectHTML = $('#id_category').html();
$('#id_category').children().eq(0).text("All");
$('#moveSelectedSelect').html(selectHTML);
$('#filterForm').submit(function(e) {
@ -47,6 +48,9 @@ $(function() {
var $this = $(this);
$this.attr("disabled", "disabled");
var ids = getSelectedIds();
if (!confirm("Are you sure you want to delete " + ids.length + " items?")) {
return false;
}
var url = "/files/deleteFiles/";
var params = {'ids': JSON.stringify(ids)};
$.post(url, params, function(response) {
@ -61,6 +65,9 @@ $(function() {
$this.attr("disabled", "disabled");
var ids = getSelectedIds();
var url = "/files/moveFiles/";
if (!confirm("Are you sure you wish to move " + ids.length + " items?")) {
return false;
}
var study_id = $('#moveSelectedSelect').val();
var params = {
'ids': JSON.stringify(ids),
@ -71,9 +78,9 @@ $(function() {
$this.removeAttr("disabled");
$('#filterForm').submit();
}, "json");
});
$(window).resize(function() {
var minuser = 400;
var winHeight = $(window).height();