Remove some event dispatchers
This commit is contained in:
@@ -58,6 +58,22 @@ export class FSNode {
|
||||
(this.user_permissions !== undefined && Object.keys(this.user_permissions).length > 0) ||
|
||||
(this.password_permissions !== undefined && Object.keys(this.password_permissions).length > 0)
|
||||
}
|
||||
|
||||
download = () => {
|
||||
const a = document.createElement("a")
|
||||
|
||||
if (this.type === "file") {
|
||||
a.href = fs_path_url(this.path) + "?attach"
|
||||
a.download = this.name
|
||||
} else if (this.type === "dir") {
|
||||
a.href = fs_path_url(this.path) + "?bulk_download"
|
||||
a.download = this.name + ".zip"
|
||||
}
|
||||
|
||||
// You can't call .click() on an element that is not in the DOM. But
|
||||
// emitting a click event works
|
||||
a.dispatchEvent(new MouseEvent("click"))
|
||||
}
|
||||
}
|
||||
|
||||
export type FSNodeProperties = {
|
||||
@@ -400,19 +416,3 @@ export const fs_share_path = (path: FSNode[]): string => {
|
||||
|
||||
return share_url
|
||||
}
|
||||
|
||||
export const fs_download = (node: FSNode) => {
|
||||
const a = document.createElement("a")
|
||||
|
||||
if (node.type === "file") {
|
||||
a.href = fs_path_url(node.path) + "?attach"
|
||||
a.download = node.name
|
||||
} else if (node.type === "dir") {
|
||||
a.href = fs_path_url(node.path) + "?bulk_download"
|
||||
a.download = node.name + ".zip"
|
||||
}
|
||||
|
||||
// You can't call .click() on an element that is not in the DOM. But
|
||||
// emitting a click event works
|
||||
a.dispatchEvent(new MouseEvent("click"))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user