",{}).bind('contextmenu', mlcContextMenuOpen).addClass("contextMenu").attr("xKey",idx).attr("xSet",isset(json.data.values[idx]));
$("",{class: "idx", text: i}).appendTo(row);
$(" | ",{class: "", text: idx}).appendTo(row);
$(" | ",{class: "", text: mod}).appendTo(row);
$(" | ",{class: "", text: json.data.values[idx]}).appendTo(row);
$(" | ",{class: "button", style: "text-align: center", append: $("",{class: "fas fa-ellipsis-h"})})
.click(mlcContextMenuOpen)
.appendTo(row);
$("",{append: row}).appendTo(tx);
});
});
}
function reloadFeatures () {
API.exec("GET","core/moduleInfo/"+UI.parceURL().id+"/features",{},function(json) {
$("div.widget.features").empty();
let tx = $("",{class: "datatable sel"});
$("",{class: "idx", text: "#"}).appendTo(tx);
$(" | ",{class: "", text: langPack.core.iface.title}).appendTo(tx);
$(" | ",{class: "", text: langPack.core.iface.active}).appendTo(tx);
$(" | ",{class: "button", style: "text-align: center", append: $("",{class: "fas fa-ellipsis-h"})}).appendTo(tx);
tx.appendTo("div.widget.features");
let i=0;
$.each(json.data, function(idx, mod) {
i++;
let row=$("",{}).bind('contextmenu', mlfContextMenuOpen).addClass("contextMenu").attr("xFeature",idx).attr("xActive",mod);
$("",{class: "idx", text: i}).appendTo(row);
$(" | ",{class: "", text: idx}).appendTo(row);
$(" | ",{class: "", text: mod}).appendTo(row);
$(" | ",{class: "button", style: "text-align: center", append: $("",{class: "fas fa-ellipsis-h"})})
.click(mlfContextMenuOpen)
.appendTo(row);
$("",{append: row}).appendTo(tx);
});
});
}
function mlfContextMenuOpen(el) {
let feature=$(el.target).closest("tr").attr("xFeature");
let active=$(el.target).closest("tr").attr("xActive")=="true";
let menuItems=[];
if (active) {
menuItems.push({title: langPack.core.iface.delete, onClick: function() {
let buttons={};
buttons[langPack.core.iface.dialodDelButton]=function() {
$("#dialogInfo").dialog("close");
API.exec({
requestType: "DELETE",
method: "core/moduleInfo/"+UI.parceURL().id+"/features",
data: {feature: feature},
onSuccess: function(json) {
reloadFeatures();
},
errDict: langPack.core.iface.modules.errors,
});
};
buttons[langPack.core.iface.dialodCloseButton]=function() { $("#dialogInfo").dialog("close"); }
UI.showInfoDialog(langPack.core.iface.modules.delFeatureDialogText+" #"+feature+"?",langPack.core.iface.dialodDelButton,buttons);
}},
);
} else {
menuItems.push({title: langPack.core.iface.add, onClick: function() {
let buttons={};
buttons[langPack.core.iface.dialodAddButton]=function() {
$("#dialogInfo").dialog("close");
API.exec({
requestType: "PUT",
method: "core/moduleInfo/"+UI.parceURL().id+"/features",
data: {feature: feature},
onSuccess: function(json) {
reloadFeatures();
},
errDict: langPack.core.iface.modules.errors,
});
};
buttons[langPack.core.iface.dialodCloseButton]=function() { $("#dialogInfo").dialog("close"); }
UI.showInfoDialog(langPack.core.iface.modules.addFeatureDialogText+" #"+feature+"?",langPack.core.iface.dialodDelButton,buttons);
}},
);
}
UI.contextMenuOpen(el,menuItems,feature);
return false;
}
function mlcContextMenuOpen(el) {
let key=$(el.target).closest("tr").attr("xKey");
let active=$(el.target).closest("tr").attr("xSet")=="true";
let menuItems=[];
if (active) {
menuItems.push({title: langPack.core.iface.delete, onClick: function() {
let buttons={};
buttons[langPack.core.iface.dialodDelButton]=function() {
$("#dialogInfo").dialog("close");
API.exec({
requestType: "DELETE",
method: "core/moduleInfo/"+UI.parceURL().id+"/config",
data: {key: key},
onSuccess: function(json) {
reloadConfig();
},
errDict: langPack.core.iface.modules.errors,
});
};
buttons[langPack.core.iface.dialodCloseButton]=function() { $("#dialogInfo").dialog("close"); }
UI.showInfoDialog(langPack.core.iface.modules.delConfigDialogText+" #"+key+"?",langPack.core.iface.dialodDelButton,buttons);
}});
}
menuItems.push({title: langPack.core.iface.set, onClick: function() {
var buttons={};
buttons[langPack.core.iface.dialodAddButton]=function() {
let fdata=UI.collectForm("addcfg", true,false, false,true);
if (fdata.validateErrCount==0) {
API.exec({
errDict: langPack.core.iface.groups.errors,
requestType: "PUT",
data: {
value: fdata.val.val,
key: key,
},
method: "core/moduleInfo/"+UI.parceURL().id+"/config",
onSuccess: function(json) {
UI.closeDialog('addcfg');
reloadConfig();
}
});
}
};
buttons[langPack.core.iface.dialodCloseButton]=function() { UI.closeDialog('addcfg'); }
UI.createDialog(
UI.addFieldGroup([
UI.addField({title: langPack.core.iface.title, val: key}),
UI.addField({item: "cfg_val", title: langPack.core.iface.title, type: "input", reqx: "true"}),
]),
langPack.core.iface.dialodAddButton,
buttons,
245,1,'addcfg');
UI.openDialog('addcfg')
}});
UI.contextMenuOpen(el,menuItems,key);
return false;
}
| | |