class LawBooks{ constructor(){ this.name = "lawbooks"; } static allowAddNew(){ return userrights.has("lawbooks.edit"); } static allowEdit(){ return userrights.has("lawbooks.edit"); } static allowDelete(){ return userrights.has("lawbooks.delete"); } static isCustom(){ return true; } static CreateCustom(data, isEditMode = false){ let retval = ``; if(!isEditMode){ document.getElementById("currentpage-content").innerHTML = Form.overviewHeadline(this.name.toLowerCase() + ".add", false, this.allowAddNew()); } for(let i=0; i${getTranslation("add_crime")}`; } if(this.allowEdit()){ buttons += ``; } if(this.allowDelete()){ buttons += ``; } } if(buttons != ""){ mbClass = "mb-2"; } if(!isEditMode || row.laws.length > 0){ retval += `
${row.short_name} - ${row.name}
${buttons}
${System.GetTable(System.getClassByName("lawbooklaws"), row.laws, isEditMode)}
`; } } if(!isEditMode){ document.getElementById("currentpage-content").innerHTML += retval; Form.initTableButtons(); Array.from(document.querySelectorAll(".lawbooks-add-crime")).forEach(function(button){ button.onclick = function(){ let staticData = { data:{ lawbook_id:this.getAttribute("data-parentID") } } loadPage("lawbooklaws.add",-1,"false", staticData) } }); Array.from(document.querySelectorAll(".lawbooks-edit")).forEach(function(button){ button.onclick = function(){ loadPage("lawbooks.edit",this.getAttribute("data-parentID"),"false", {}) } }); } else{ return retval; } } static GetEdit(data={}){ return { "name": { "val" : data.name ?? "" ,"type" : "text" ,"mandatory":true ,"isRow":true } ,"short_name": { "val" : data.short_name ?? "" ,"type" : "text" ,"mandatory":true ,"isRow":true } } } }