mirror of
https://github.com/45Drives/cockpit-navigator.git
synced 2025-07-28 08:04:39 +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 {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 {
|
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)) {
|
if (this.nav_window_ref.selected_entries.size === 1 && this.nav_window_ref.selected_entries.has(this)) {
|
||||||
switch (e.target) {
|
switch (e.target) {
|
||||||
case this.dom_element.nav_item_title:
|
case this.dom_element.nav_item_title:
|
||||||
|
this.double_click = true;
|
||||||
|
if(this.timeout)
|
||||||
|
clearTimeout(this.timeout)
|
||||||
|
this.timeout = setTimeout(() => {
|
||||||
|
this.double_click = false;
|
||||||
this.show_edit(e.target);
|
this.show_edit(e.target);
|
||||||
|
}, 500);
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -259,7 +265,10 @@ export class NavEntry {
|
|||||||
if (new_name === this.filename)
|
if (new_name === this.filename)
|
||||||
return;
|
return;
|
||||||
if (new_name.includes("/")) {
|
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;
|
return;
|
||||||
} else if (new_name === "..") {
|
} else if (new_name === "..") {
|
||||||
this.nav_window_ref.modal_prompt.alert(
|
this.nav_window_ref.modal_prompt.alert(
|
||||||
@ -268,6 +277,14 @@ export class NavEntry {
|
|||||||
);
|
);
|
||||||
return;
|
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 {
|
try {
|
||||||
await this.mv(new_name);
|
await this.mv(new_name);
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
|
@ -44,6 +44,9 @@ export class NavFile extends NavEntry {
|
|||||||
switch(e.type){
|
switch(e.type){
|
||||||
case "click":
|
case "click":
|
||||||
if (this.double_click) {
|
if (this.double_click) {
|
||||||
|
if(this.timeout)
|
||||||
|
clearTimeout(this.timeout);
|
||||||
|
this.double_click = false;
|
||||||
this.open();
|
this.open();
|
||||||
return;
|
return;
|
||||||
} else { // single click
|
} else { // single click
|
||||||
|
Loading…
x
Reference in New Issue
Block a user