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 = forms.ModelChoiceField(Category.objects, required=False, label="Study")
category_name = forms.CharField(required=False, label="Create New 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): class FileFilterForm(forms.Form):
category = forms.ModelChoiceField(Category.objects, required=False, label="Study") 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) search = forms.CharField(required=False)
@login_required @login_required

View File

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