1
0
Fork 0
forked from Simnation/Main
Main/resources/[jobs]/[mdt]/myEmergency/html/js/modules/LawBookLaws.js
2025-08-14 13:21:51 +02:00

104 lines
No EOL
2.9 KiB
JavaScript

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 `
<td>
${Form.getEditButtonIcon(row[key], this.name + ".edit", this.allowEdit())}
${Form.getDeleteButtonIcon(row[key], this.name ,this.allowDelete())}
</td>`;
}
else if(key == "crime") {
return `<td class="whitespace-normal">${row[key]}</td>`;
}
else if(key == "others") {
return `<td class="whitespace-normal">${row[key]}</td>`;
}
else {
return `<td>${row[key]}</td>`;
}
}
else{
if(key == "id"){
return `<td class="edittable_row" id = "edittable_row_${row.id}">
${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"])}
</td>`;
}
else if(key == "crime") {
return `<td class="whitespace-normal">${row[key]}</td>`;
}
else if(key == "others") {
return `<td class="whitespace-normal">${row[key]}</td>`;
}
else {
return `<td>${row[key]}</td>`;
}
}
}
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
}
}
}
}