file: honor server's remote-root option (remove root path from displayed path and returned value)
This commit is contained in:
parent
9ef97ca1c3
commit
4dbc572ea1
4 changed files with 17 additions and 7 deletions
|
|
@ -40,6 +40,7 @@ export default function UiFilebrowser(options, callback) {
|
|||
`
|
||||
|
||||
var files = [],
|
||||
root = '',
|
||||
path = ''
|
||||
|
||||
var extRe = options.extension ? new RegExp('.*\\.' + options.extension + '$') : /.*/
|
||||
|
|
@ -75,10 +76,10 @@ export default function UiFilebrowser(options, callback) {
|
|||
if (files.some(x=>x.name===saveInput.value)) {
|
||||
if (!confirm(locales('remotesave_overwrite'))) return
|
||||
}
|
||||
callback([path, saveInput.value])
|
||||
callback([path, saveInput.value], root)
|
||||
popup.close()
|
||||
} else {
|
||||
callback([path, choice ? choice.value : ''])
|
||||
callback([path, choice ? choice.value : ''], root)
|
||||
popup.close()
|
||||
}
|
||||
}
|
||||
|
|
@ -142,11 +143,13 @@ export default function UiFilebrowser(options, callback) {
|
|||
|
||||
ipc.on('listDir', (data)=>{
|
||||
|
||||
ariane.textContent = path = data.path
|
||||
path = data.path
|
||||
root = data.root
|
||||
|
||||
ariane.textContent = path.replace(root, '/')
|
||||
|
||||
files = data.files.filter(x=>x.folder || x.name.match(extRe))
|
||||
|
||||
|
||||
function alphaSort(a, b){
|
||||
// convert to strings and force lowercase
|
||||
a = typeof a.name === 'string' ? a.name.toLowerCase() : a.name.toString()
|
||||
|
|
|
|||
|
|
@ -58,9 +58,13 @@ export default class File extends Widget {
|
|||
directory: this.getProp('directory') === 'auto' ? undefined : this.getProp('directory'),
|
||||
loadDir: this.getProp('allowDir'),
|
||||
save: this.getProp('mode') === 'save'
|
||||
}, (path)=>{
|
||||
}, (path, root)=>{
|
||||
|
||||
this.setValue(path.join(path[0][0] === '/' ? '/' : '\\'), {
|
||||
var sep = path[0][0] === '/' ? '/' : '\\',
|
||||
val = path.join(sep)
|
||||
if (root) val = val.replace(root, sep).replace(sep + sep, sep)
|
||||
|
||||
this.setValue(val, {
|
||||
sync: true,
|
||||
send: true
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue