Added delete confirmation using NagView.
This commit is contained in:
parent
a4d5622eda
commit
afa0c175e8
|
@ -480,7 +480,23 @@ command.add(nil, {
|
|||
|
||||
["treeview:delete"] = function()
|
||||
local filename = view.hovered_item.abs_filename
|
||||
local relfilename = view.hovered_item.filename
|
||||
local file_info = system.get_file_info(filename)
|
||||
local file_type = file_info.type == "dir" and "Directory" or "File"
|
||||
-- Ask before deleting
|
||||
local opt = {
|
||||
{ font = style.font, text = "Yes", default_yes = true },
|
||||
{ font = style.font, text = "No" , default_no = true }
|
||||
}
|
||||
core.nag_view:show(
|
||||
string.format("Delete %s", file_type),
|
||||
string.format(
|
||||
"Are you sure you want to delete the %s?\n%s: %s",
|
||||
file_type:lower(), file_type, relfilename
|
||||
),
|
||||
opt,
|
||||
function(item)
|
||||
if item.text == "Yes" then
|
||||
if file_info.type == "dir" then
|
||||
local deleted, error, path = common.rm(filename, true)
|
||||
if not deleted then
|
||||
|
@ -496,6 +512,9 @@ command.add(nil, {
|
|||
end
|
||||
core.reschedule_project_scan()
|
||||
core.log("Deleted \"%s\"", filename)
|
||||
end
|
||||
end
|
||||
)
|
||||
end,
|
||||
|
||||
["treeview:open-in-system"] = function()
|
||||
|
|
Loading…
Reference in New Issue