-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix modal upload validation and tests
- Loading branch information
1 parent
9ade652
commit 2738567
Showing
10 changed files
with
96 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
$('#file_upload_modal').remove(); | ||
$('body').append('<%= j render "modal" %>'); | ||
$('#file_upload_modal .invalid-feedback').empty().hide(); | ||
(new bootstrap.Modal($('#file_upload_modal'))).show(); | ||
|
||
$(document).on('click', '#file_upload_button', function(e) { | ||
file = $(this).parents('form:first').find('input:file'); | ||
if (file.val()) { | ||
var allowed = file.data('ext').split(','); | ||
var ext = '.' + file.val().split('.').pop().toLowerCase(); | ||
if($.inArray(ext, allowed) == -1) { | ||
div = $(this).parents('form:first').find('div.invalid-feedback'); | ||
var error = '<p>File extension ' + ext + ' is not allowed.</p>'; | ||
div.empty().append(error); | ||
div.show(); | ||
} else { | ||
return true; | ||
} | ||
} | ||
e.preventDefault(); | ||
return false; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1 @@ | ||
$('body').append('<%= j render "modal" %>'); | ||
(new bootstrap.Modal($('#file_upload_modal'))).show(); | ||
|
||
$('form.file-upload input.file').change ( function() { | ||
if ($(this).val()) { | ||
$(this).parents('form:first').find('input:submit').removeAttr('disabled'); | ||
} | ||
}); | ||
<%= render partial: 'upload_modal', formats: :js %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1 @@ | ||
$('body').append('<%= j render "modal" %>'); | ||
(new bootstrap.Modal($('#file_upload_modal'))).show(); | ||
|
||
$('form.file-upload input.file').change ( function() { | ||
if ($(this).val()) { | ||
$(this).parents('form:first').find('input:submit').removeAttr('disabled'); | ||
} | ||
}); | ||
<%= render partial: 'upload_modal', formats: :js %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters