mirror of
https://github.com/45Drives/cockpit-navigator.git
synced 2025-07-27 23:54:20 +02:00
rename file after timeout for double click
This commit is contained in:
parent
f94dbdfed1
commit
7d4616a229
@ -18,7 +18,7 @@
|
||||
*/
|
||||
|
||||
import {NavWindow} from "./NavWindow.js";
|
||||
import {format_bytes, property_entry_html, format_time} from "../functions.js";
|
||||
import {format_bytes, property_entry_html, format_time, check_if_exists} from "../functions.js";
|
||||
|
||||
export class NavEntry {
|
||||
/**
|
||||
@ -98,7 +98,13 @@ export class NavEntry {
|
||||
if (this.nav_window_ref.selected_entries.size === 1 && this.nav_window_ref.selected_entries.has(this)) {
|
||||
switch (e.target) {
|
||||
case this.dom_element.nav_item_title:
|
||||
this.show_edit(e.target);
|
||||
this.double_click = true;
|
||||
if(this.timeout)
|
||||
clearTimeout(this.timeout)
|
||||
this.timeout = setTimeout(() => {
|
||||
this.double_click = false;
|
||||
this.show_edit(e.target);
|
||||
}, 500);
|
||||
e.stopPropagation();
|
||||
break;
|
||||
default:
|
||||
@ -259,7 +265,10 @@ export class NavEntry {
|
||||
if (new_name === this.filename)
|
||||
return;
|
||||
if (new_name.includes("/")) {
|
||||
this.nav_window_ref.modal_prompt.alert("File name can't contain `/`.");
|
||||
this.nav_window_ref.modal_prompt.alert(
|
||||
"File name can't contain `/`.",
|
||||
"If you want to move the file, right click > cut then right click > paste."
|
||||
);
|
||||
return;
|
||||
} else if (new_name === "..") {
|
||||
this.nav_window_ref.modal_prompt.alert(
|
||||
@ -268,6 +277,14 @@ export class NavEntry {
|
||||
);
|
||||
return;
|
||||
}
|
||||
let new_path = [this.nav_window_ref.pwd().path_str(), new_name].join("/");
|
||||
if (await check_if_exists(new_path)) {
|
||||
this.nav_window_ref.modal_prompt.alert(
|
||||
"Failed to rename.",
|
||||
"File exists: " + new_path
|
||||
);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
await this.mv(new_name);
|
||||
} catch(e) {
|
||||
|
@ -44,6 +44,9 @@ export class NavFile extends NavEntry {
|
||||
switch(e.type){
|
||||
case "click":
|
||||
if (this.double_click) {
|
||||
if(this.timeout)
|
||||
clearTimeout(this.timeout);
|
||||
this.double_click = false;
|
||||
this.open();
|
||||
return;
|
||||
} else { // single click
|
||||
|
Loading…
x
Reference in New Issue
Block a user