Skip to content

Commit

Permalink
clear the input after a forbiden file
Browse files Browse the repository at this point in the history
  • Loading branch information
wellingguzman committed Nov 9, 2016
1 parent 7e5eee4 commit 24d0ae0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
8 changes: 6 additions & 2 deletions app/core/uis/single_file.js
Expand Up @@ -21,12 +21,13 @@ define([
'underscore',
'backbone',
'core/t',
'utils',
'core/UIComponent',
'core/UIView',
'core/table/table.view',
'core/overlays/overlays'
],
function(app, _, Backbone, __t, UIComponent, UIView, TableView, Overlays) {
function(app, _, Backbone, __t, Utils, UIComponent, UIView, TableView, Overlays) {

'use strict';

Expand Down Expand Up @@ -181,7 +182,10 @@ define([
var target = $(event.target);
var file = target[0].files[0];
var model = this.fileModel;
model.setFile(file, this.options.settings.get('allowed_filetypes'));
var allowed = model.setFile(file, this.options.settings.get('allowed_filetypes'));
if (allowed === false) {
Utils.clearElement(target);
}
},
'click button[data-action="computer"], .ui-thumbnail-dropzone, .single-image-thumbnail img': function(e) {
this.$el.find('#fileAddInput').click();
Expand Down
5 changes: 5 additions & 0 deletions app/utils.js
Expand Up @@ -125,5 +125,10 @@ define(function() {
return value == null || value === '';
};

Utils.clearElement = function(element) {
element.wrap('<form>').closest('form').get(0).reset();
element.unwrap();
};

return Utils;
});

0 comments on commit 24d0ae0

Please sign in to comment.