fileInput JS: Allow uploading the same file. (#1719)

* tools README: notes about entr + grunt

* fileInput JS: Allow uploading the same file. Fixes #1508

* Grunt

* Added note to NEWS.

* tools README: add Linux section, fix formatting
This commit is contained in:
Alan Dipert
2017-06-15 13:09:37 -07:00
committed by Winston Chang
parent c29846a9da
commit 3817370d4e
7 changed files with 33 additions and 3 deletions

View File

@@ -9,6 +9,8 @@ shiny 1.0.3.9000
### Minor new features and improvements
* Addressed [#1508](https://github.com/rstudio/shiny/issues/1508): `fileInput` now permits the same file to be uploaded multiple times. ([#1719](https://github.com/rstudio/shiny/pull/1719))
* Addressed [#1501](https://github.com/rstudio/shiny/issues/1501): The `fileInput` control now retains uploaded file extensions on the server. This fixes [readxl](https://github.com/tidyverse/readxl)'s `readxl::read_excel` and other functions that must recognize a file's extension in order to work. ([#1706](https://github.com/rstudio/shiny/pull/1706))
* For `conditionalPanel`s, Shiny now gives more informative messages if there are errors evaluating or parsing the JavaScript conditional expression. ([#1727](https://github.com/rstudio/shiny/pull/1727))

View File

@@ -4843,6 +4843,9 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
// invalidated reactives, but observers don't actually execute.
self.shinyapp.makeRequest('uploadieFinish', [], function () {}, function () {});
$(self.iframe).remove();
// Reset the file input's value to "". This allows the same file to be
// uploaded again. https://stackoverflow.com/a/22521275
$(self.fileEl).val("");
};
if (this.iframe.attachEvent) {
this.iframe.attachEvent('onload', iframeDestroy);
@@ -4958,6 +4961,9 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
self.$setActive(false);
self.onProgress(null, 1);
self.$bar().text('Upload complete');
// Reset the file input's value to "". This allows the same file to be
// uploaded again. https://stackoverflow.com/a/22521275
$(evt.el).val("");
}, function (error) {
self.onError(error);
});

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -19,6 +19,9 @@ var IE8FileUploader = function(shinyapp, id, fileEl) {
// invalidated reactives, but observers don't actually execute.
self.shinyapp.makeRequest('uploadieFinish', [], function(){}, function(){});
$(self.iframe).remove();
// Reset the file input's value to "". This allows the same file to be
// uploaded again. https://stackoverflow.com/a/22521275
$(self.fileEl).val("");
};
if (this.iframe.attachEvent) {
this.iframe.attachEvent('onload', iframeDestroy);
@@ -142,6 +145,9 @@ $.extend(FileUploader.prototype, FileProcessor.prototype);
self.$setActive(false);
self.onProgress(null, 1);
self.$bar().text('Upload complete');
// Reset the file input's value to "". This allows the same file to be
// uploaded again. https://stackoverflow.com/a/22521275
$(evt.el).val("");
},
function(error) {
self.onError(error);

View File

@@ -84,7 +84,23 @@ One of the tasks concatenates all the .js files in `/srcjs` together into `/inst
During development of Shiny's Javascript code, it's best to use `grunt watch` so that the minified file will get updated whenever you make changes the Javascript sources.
#### Auto build and browser refresh
An alternative to `grunt watch` is to use `entr` to trigger `grunt` when sources change. `entr` can be installed with `brew install entr` on a Mac, or on Linux using your distribution's package manager. Using this technique, it's possible to both automatically rebuild sources and reload Chrome at the same time:
*macOS*:
```
find ../srcjs/ | entr bash -c './node_modules/grunt/bin/grunt && osascript -e "tell application \"Google Chrome\" to reload active tab of window 1"'
```
*Linux*:
For this to work you must first install `xdotool` using your distribution's package manager.
```
find ../srcjs/ | entr bash -c './node_modules/grunt/bin/grunt && xdotool search --onlyvisible --class Chrome windowfocus key ctrl+r'
```
Updating web libraries
======================