class RegWeapons{ constructor(){ this.name = "regweapons"; } static allowAddNew(){ return userrights.has("regweapons.edit"); } static allowEdit(){ return userrights.has("regweapons.edit"); } static allowDelete(){ return userrights.has("regweapons.delete"); } static allowFinishmanhunt(){ return userrights.has("manhunt.finish"); } static allowSetManhunt(){ return userrights.has("manhunt.add"); } static GetColumns(){ return ["serialno","weapontype","weaponmodel","owner","state","id"] } static GetExtraForView(data){ let retval = { top:"", bottom:"" } if(data.is_wanted == 1){ let btn = ``; if(this.allowFinishmanhunt()){ btn = ``; } retval.top = `

${getTranslation("vehicle_wanted")}

${getTranslation("reason")}: ${data.is_wanted_reason}

${getTranslation("is_wanted_at_sight")}

${btn}
` } return retval; } static TableDataCreate(row, key){ if(key == "state"){ if(row[key] == true){ return `
${getTranslation("tag_is_wanted")}
`; } else{ return ``; } } else if(key == "id"){ let isWantedButton = ``; if(this.allowSetManhunt()){ isWantedButton = Form.getIsWantedButton(row[key], this.name, row.state == "1"); } return ` ${Form.getViewButtonIcon(row[key], this.name + ".view")} ${Form.getEditButtonIcon(row[key] , this.name + ".edit", this.allowEdit())} ${isWantedButton} ${Form.getDeleteButtonIcon(row[key], this.name, this.allowDelete())} `; } else if(key == "owner"){ let val = row[key]; if(val == ""){ val = getTranslation("unknown"); } return ` ${val} `; } else{ return `${row[key]}`; } } 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")} ]; } filesOptions = [...filesOptions, ...data.extraData.files]; return { "serialno": { "val" : data.serialno ?? "" ,"type" : "text" ,"mandatory":true } ,"owner": { "val" : data.owner_id ?? "-1" ,"type" : "searchdropdown" ,"mandatory":false ,options:filesOptions } ,"weapontype": { "val" : data.weapontype ?? "" ,"type" : "text" ,"mandatory":false } ,"weaponmodel": { "val" : data.weaponmodel ?? "" ,"type" : "text" ,"mandatory":false } ,"-": { "type" : "divider" } ,"others": { "val" : data.others ?? "" ,"type" : "textarea" ,"isRow": true ,"mandatory":false ,autogrow: true ,rows:3 } ,"is_wanted": { "val" : (data.is_wanted ?? false ? 1 : 0) ,"type" : (this.allowSetManhunt() ? "dropdown" : "hidden") ,"isRow": true ,"mandatory":false ,hideInViewMode:true ,"options":System.GetBooleanOptions() } ,"is_wanted_reason": { "val" : data.is_wanted_reason ?? "" ,"type" : (this.allowSetManhunt() ? "text" : "hidden") ,"isRow": true ,hideInViewMode:true ,"mandatory":false } } } }