class LawBookLaws{ constructor(){ this.name = "lawbooklaws"; } static isCustom(){ return true; } static allowEdit(){ return userrights.has("lawbooks.edit"); } static allowDelete(){ return userrights.has("lawbooks.delete"); } static GetColumns(isEditList){ if(!isEditList){ return ["paragraph","crime","minimum_penalty","detention_time","others","id"] } else{ return ["paragraph","crime","minimum_penalty","detention_time","others","id"] } } static TableDataCreate(row, key, isEditList){ if(!isEditList){ if(key == "id"){ return ` ${Form.getEditButtonIcon(row[key], this.name + ".edit", this.allowEdit())} ${Form.getDeleteButtonIcon(row[key], this.name ,this.allowDelete())} `; } else if(key == "crime") { return `${row[key]}`; } else if(key == "others") { return `${row[key]}`; } else { return `${row[key]}`; } } else{ if(key == "id"){ return ` ${Form.NumberField(false, "lawbook_laws_amount_" + row.id, "0", "lawbook_laws_calc_penalty", false, false)} ${Form.Hidden("lawbook_laws_id_" + row.id, row[key])} ${Form.Hidden("lawbook_laws_minimum_penalty_" + row.id, row["minimum_penalty"])} ${Form.Hidden("lawbook_laws_detention_time_" + row.id, row["detention_time"])} `; } else if(key == "crime") { return `${row[key]}`; } else if(key == "others") { return `${row[key]}`; } else { return `${row[key]}`; } } } static GetEdit(data={}){ return { "lawbook_id": { "val" : data.lawbook_id ?? "-1" ,"type" : "hidden" }, "crime": { "val" : data.crime ?? "" ,"type" : "text" ,"mandatory":true } ,"paragraph": { "val" : data.paragraph ?? "" ,"type" : (HandleParagraphsAsNumber ? "float" : "text") ,"mandatory":true } ,"minimum_penalty": { "val" : data.minimum_penalty ?? 0 ,"type" : "number" ,"mandatory":true } ,"detention_time": { "val" : data.detention_time ?? 0 ,"type" : "number" ,"mandatory":true } ,"others": { "val" : data.others ?? "" ,"type" : "textarea" ,autogrow : true ,"mandatory":false ,"isRow":true } } } }