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

119 lines
No EOL
3 KiB
JavaScript

class CriminalComplaint{
constructor(){
this.name = "criminalcomplaint";
}
static allowAddNew(){
return userrights.has("criminalcomplaint.edit")
}
static allowEdit(){
return userrights.has("criminalcomplaint.edit")
}
static allowDelete(){
return userrights.has("criminalcomplaint.delete")
}
static GetColumns(){
return ["charge_from","perpetrator","state","id"]
}
static TableDataCreate(row, key){
if(key == "id"){
return `
<td>
${Form.getViewButtonIcon(row[key], this.name + ".view")}
${Form.getEditButtonIcon(row[key] , this.name + ".edit", this.allowEdit())}
${Form.getDeleteButtonIcon(row[key], this.name, this.allowDelete())}
</td>`;
}
else if(key == "state"){
let complaint = System.GetComplaintByID(row[key]);
return `
<td>
<div class="badge font-bold ${complaint.color ?? ""}">${complaint.name ?? ""}</div>
</td>`;
}
else if(key == "charge_from" || key == "perpetrator"){
let val = row[key];
if(val == ""){
val = getTranslation("unknown");
}
return `
<td>
${val}
</td>`;
}
else{
return `<td>${row[key]}</td>`;
}
}
static GetEdit(data={}){
let filesOptions = [
{"id":-1, "name":getTranslation("unknown")}
,{"id":-2, "name":getTranslation("new_file"), "show_extra_field":true}
];
if(sync.isActive("files")){
filesOptions = [
{"id":-1, "name":getTranslation("unknown")}
];
}
let perpetrators = [...filesOptions, ...data.extraData.perpetrators];
let charge_froms = [...filesOptions, ...data.extraData.charge_froms];
return {
"charge_from": {
"val" : data.charge_from_id ?? "-1"
,"type" : "searchdropdown"
,"mandatory":true
,options:charge_froms
}
,"perpetrator": {
"val" : data.perpetrator_id ?? "-1"
,"type" : "searchdropdown"
,"mandatory":true
,options:perpetrators
}
,"perpetrator_description":{
"val" : data.perpetrator_description ?? ""
,"type" : "textarea"
,"isRow": true
,"mandatory":true
,autogrow: false
,rows:3
}
,"state": {
"val" : data.state ?? ""
,"type" : "dropdown"
,"mandatory":true
,"isRow":true
,options:System.GetCompaintStateOptions()
}
,"act_of_crime":{
"val" : data.act_of_crime ?? ""
,"type" : "textarea"
,"isRow": true
,"mandatory":false
,autogrow: false
,rows:3
}
,"notes":{
"val" : data.notes ?? ""
,"type" : "textarea"
,"isRow": true
,"mandatory":false
,autogrow: false
,rows:3
}
}
}
}