luci-base: ui.js: UIFileUpload fixes
- Introduce a new option `initial_directory` which describes the initial directory to display when nothing is selected, default to the root directory - Prevent stray legacy cbi reloads when deselecting files - Fix within-root-directory-check for initial rendering Signed-off-by: Jo-Philipp Wich <jo@mein.io>
This commit is contained in:
parent
9fd7e9fc23
commit
136b965b25
1 changed files with 4 additions and 2 deletions
|
@ -1919,6 +1919,8 @@ var UIFileUpload = UIElement.extend({
|
|||
button.style.display = '';
|
||||
|
||||
this.node.dispatchEvent(new CustomEvent('cbi-fileupload-cancel', {}));
|
||||
|
||||
ev.preventDefault();
|
||||
},
|
||||
|
||||
handleReset: function(ev) {
|
||||
|
@ -1962,9 +1964,9 @@ var UIFileUpload = UIElement.extend({
|
|||
handleFileBrowser: function(ev) {
|
||||
var button = ev.target,
|
||||
browser = button.nextElementSibling,
|
||||
path = this.stat ? this.stat.path.replace(/\/[^\/]+$/, '') : this.options.root_directory;
|
||||
path = this.stat ? this.stat.path.replace(/\/[^\/]+$/, '') : (this.options.initial_directory || this.options.root_directory);
|
||||
|
||||
if (this.options.root_directory.indexOf(path) != 0)
|
||||
if (path.indexOf(this.options.root_directory) != 0)
|
||||
path = this.options.root_directory;
|
||||
|
||||
ev.preventDefault();
|
||||
|
|
Loading…
Reference in a new issue