mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-22 06:30:59 +01:00
Et2VfsSelectDialog
- Remember last used path, start there next time if path was not provided - Single click now opens sub-dir. Current path is used for select-dir mode - Fix Copy To in Et2LinkList context menu
This commit is contained in:
parent
844f64fffa
commit
7eee15c980
@ -17,8 +17,8 @@ import {egw} from "../../jsapi/egw_global";
|
||||
import {Et2LinkString} from "./Et2LinkString";
|
||||
import {egwMenu} from "../../egw_action/egw_menu";
|
||||
import {Et2Dialog} from "../Et2Dialog/Et2Dialog";
|
||||
import {et2_vfsSelect} from "../et2_widget_vfs";
|
||||
import {et2_createWidget} from "../et2_core_widget";
|
||||
import {loadWebComponent} from "../Et2Widget/Et2Widget";
|
||||
import {Et2VfsSelectButton} from "../Et2Vfs/Et2VfsSelectButton";
|
||||
|
||||
/**
|
||||
* Display a list of entries in a comma separated list
|
||||
@ -478,7 +478,7 @@ export class Et2LinkList extends Et2LinkString
|
||||
});
|
||||
|
||||
// Only allow this option if the entry has been saved, and has a real ID
|
||||
if(this.to_id && typeof this.to_id != 'object')
|
||||
if(this.to_id && typeof this.to_id != 'object' || this.entryId && this.application)
|
||||
{
|
||||
this.context.addItem("copy_to", this.egw().lang("Copy to"), this.egw().image('copy'), () =>
|
||||
{
|
||||
@ -488,19 +488,19 @@ export class Et2LinkList extends Et2LinkString
|
||||
// Get target
|
||||
let select_attrs : any = {
|
||||
mode: "select-dir",
|
||||
button_caption: '',
|
||||
button_icon: 'copy',
|
||||
button_label: egw.lang("copy"),
|
||||
image: 'copy',
|
||||
buttonLabel: egw.lang("copy"),
|
||||
//extra_buttons: [{text: egw.lang("link"), id:"link", image: "link"}],
|
||||
dialog_title: egw.lang('Copy to'),
|
||||
method: "EGroupware\\Api\\Etemplate\\Widget\\Link::ajax_copy_to",
|
||||
method_id: this.context.data
|
||||
};
|
||||
let vfs_select = <et2_vfsSelect>et2_createWidget("vfs-select", select_attrs, self);
|
||||
let vfs_select = <Et2VfsSelectButton>loadWebComponent("et2-vfs-select", select_attrs, this);
|
||||
vfs_select.methodId = this.context.data;
|
||||
document.body.append(vfs_select);
|
||||
|
||||
// No button, just open it
|
||||
vfs_select.button.hide();
|
||||
vfs_select.click(null);
|
||||
vfs_select.click();
|
||||
vfs_select.addEventListener("change", (e) => {vfs_select.remove()});
|
||||
});
|
||||
}
|
||||
this.context.addItem("-", "-");
|
||||
|
@ -29,17 +29,6 @@ export class Et2LinkPasteDialog extends Et2VfsSelectDialog
|
||||
this._appList = [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Override double-click on directory, can't go into it
|
||||
*
|
||||
* @param {MouseEvent} event
|
||||
*/
|
||||
handleFileDoubleClick(event : MouseEvent)
|
||||
{
|
||||
// just select it
|
||||
this.handleFileClick(event);
|
||||
}
|
||||
|
||||
protected async localSearch<DataType extends SearchResult>(search : string, searchOptions : object, localOptions : DataType[] = []) : Promise<DataType[]>
|
||||
{
|
||||
const files = await getClipboardFiles();
|
||||
|
@ -93,7 +93,10 @@ export class Et2VfsSelectButton extends Et2InputWidget(LitElement)
|
||||
/** Programmatically trigger the dialog */
|
||||
public click()
|
||||
{
|
||||
this.handleClick(new Event("click"));
|
||||
this.updateComplete.then(() =>
|
||||
{
|
||||
this.handleClick(new Event("click"));
|
||||
})
|
||||
}
|
||||
|
||||
protected handleClick(event)
|
||||
|
@ -208,7 +208,9 @@ export class Et2VfsSelectDialog
|
||||
|
||||
if(this.path == "")
|
||||
{
|
||||
this.path = <string>this.egw()?.preference("startfolder", "filemanager") || "~";
|
||||
this.path = this.egw().getLocalStorageItem(this.egw().appName, this.constructor.name + "Path") ||
|
||||
<string>this.egw()?.preference("startfolder", "filemanager") ||
|
||||
"~";
|
||||
}
|
||||
}
|
||||
|
||||
@ -443,6 +445,9 @@ export class Et2VfsSelectDialog
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
// Save path for next time
|
||||
this.egw().setLocalStorageItem(this.egw().appName, this.constructor.name + "Path", this.path);
|
||||
this.dispatchEvent(new Event("change", {bubbles: true}));
|
||||
}
|
||||
|
||||
@ -600,8 +605,9 @@ export class Et2VfsSelectDialog
|
||||
if(file && !file.disabled)
|
||||
{
|
||||
// Can't select a directory normally
|
||||
if(file.value.isDir && this.mode != "select-dir")
|
||||
if(file.value.isDir)
|
||||
{
|
||||
this.setPath(file.value.path);
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
return;
|
||||
@ -620,30 +626,6 @@ export class Et2VfsSelectDialog
|
||||
}
|
||||
}
|
||||
|
||||
handleFileDoubleClick(event : MouseEvent)
|
||||
{
|
||||
const target = event.target as HTMLElement;
|
||||
const file : Et2VfsSelectRow = target.closest('et2-vfs-select-row');
|
||||
|
||||
if(file.value.isDir)
|
||||
{
|
||||
this.toggleResultSelection(file, false);
|
||||
const oldPath = this.path;
|
||||
this.setPath(file.value.path);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Not a dir, just select it
|
||||
this.handleFileClick(event);
|
||||
|
||||
// If we only want one, we've got it. Close by clicking the primary button
|
||||
if(!this.multiple)
|
||||
{
|
||||
this.shadowRoot.querySelector('et2-button[variant="primary"]')?.click();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
handleKeyDown(event)
|
||||
{
|
||||
// Ignore selects
|
||||
@ -701,7 +683,7 @@ export class Et2VfsSelectDialog
|
||||
}
|
||||
else if(["Enter"].includes(event.key) && this.currentResult && !this.currentResult.disabled)
|
||||
{
|
||||
return this.handleFileDoubleClick(event);
|
||||
return this.handleFileClick(event);
|
||||
}
|
||||
else if(["Escape"].includes(event.key))
|
||||
{
|
||||
@ -799,7 +781,6 @@ export class Et2VfsSelectDialog
|
||||
.selected=${this.value.includes(file.path)}
|
||||
.value=${file}
|
||||
@mouseup=${this.handleFileClick}
|
||||
@dblclick=${this.handleFileDoubleClick}
|
||||
></et2-vfs-select-row>`;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user