2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-04-16 10:46:03 +00:00

01_FHEMWEB.pm/fhemweb.js: confirmDelete Attribute (Forum #55905)

git-svn-id: https://svn.fhem.de/fhem/trunk@11924 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
rudolfkoenig 2016-08-08 16:31:21 +00:00
parent 72cffd1e0c
commit 1511936bd5
2 changed files with 71 additions and 8 deletions

View File

@ -145,6 +145,7 @@ FHEMWEB_Initialize($)
basicAuthMsg
closeConn:1,0
column
confirmDelete
defaultRoom
deviceOverview:always,iconOnly,onClick,never
editConfig:1,0
@ -1171,7 +1172,9 @@ FW_doDetail($)
my $h = $defs{$d};
my $t = $h->{TYPE};
$t = "MISSING" if(!defined($t));
FW_pO "<div id=\"content\">";
my $cd = AttrVal($FW_wname, "confirmDelete", 1);
FW_pO "<div id=\"content\" data-confirmDelete=\"$cd\" ".
"data-webName=\"$FW_wname\">";
if($FW_ss) { # FS20MS2 special: on and off, is not the same as toggle
my $webCmd = AttrVal($d, "webCmd", undef);
@ -3077,6 +3080,21 @@ FW_widgetOverride($$)
Space in the room and group name has to be written as %20 for this
attribute.
</li>
<br>
<a name="confirmDelete"></a>
<li>confirmDelete<br>
confirm delete actions with a dialog. Default is 1, set it to 0 to
disable the feature.
</li>
<br>
<a name="CORS"></a>
<li>CORS<br>
If set to 1, FHEMWEB will supply a "Cross origin resource sharing"
header, see the wikipedia for details.
</li>
<br>
<a name="csrfToken"></a>
<li>csrfToken<br>
@ -3107,13 +3125,6 @@ FW_widgetOverride($$)
</ul>
</li><br>
<a name="CORS"></a>
<li>CORS<br>
If set to 1, FHEMWEB will supply a "Cross origin resource sharing"
header, see the wikipedia for details.
</li>
<br>
<a name="defaultRoom"></a>
<li>defaultRoom<br>
show the specified room if no room selected, e.g. on execution of some
@ -3782,6 +3793,13 @@ FW_widgetOverride($$)
%20 zu schreiben.
</li><br>
<a name="confirmDelete"></a>
<li>confirmDelete<br>
L&ouml;schaktionen weden mit einem Dialog best&auml;tigt.
Falls dieses Attribut auf 0 gesetzt ist, entf&auml;llt das.
</li>
<br>
<a name="CORS"></a>
<li>CORS<br>
Wenn auf 1 gestellt, wird FHEMWEB einen "Cross origin resource sharing"

View File

@ -88,6 +88,7 @@ FW_jqueryReadyFn()
FW_root = r;
FW_replaceWidgets($("html"));
FW_confirmDelete();
// Fix the td count by setting colspan on the last column
$("table.block.wide").each(function(){ // table
@ -214,6 +215,50 @@ FW_jqueryReadyFn()
FW_inlineModify();
}
function
FW_confirmDelete()
{
var d = $("div#content");
var cd = $(d).attr("data-confirmDelete");
if(!cd || cd == 0)
return;
var wn = $(d).attr("data-webName");
$(d).find("a").each(function(){
var href = $(this).attr("href");
if(!href)
return;
var ma = $(this).attr("href").match(/.*cmd[^=]*=(delete[^&]*)&.*$/);
if(!ma || ma.length != 2)
return;
$(this).attr("href", "#");
$(this).unbind("click");
$(this).click(function(e){
e.preventDefault();
var div = $("<div id='FW_okDialog'>");
$(div).html("Do you really want to "+ma[1]+"?<br><br>"+
"<input type='checkbox' name='noconf'> Skip this dialog in the future");
$("body").append(div);
function
doClose()
{
if($(div).find("input:checked").length)
FW_cmd(FW_root+"?cmd=attr "+wn+" confirmDelete 0&XHR=1");
$(this).dialog("close"); $(div).remove();
}
$(div).dialog({
dialogClass:"no-close", modal:true, width:"auto", closeOnEscape:true,
maxWidth:$(window).width()*0.9, maxHeight:$(window).height()*0.9,
buttons: [
{text:"Yes", click:function(){ location.href = ma[0]; doClose(); }},
{text:"No", click:function(){ doClose(); }}]
});
});
});
}
// Show the webCmd list in a dialog if: smallScreen & hiddenroom=detail & room
function
FW_smallScreenCommands()