160 lines
No EOL
3.7 KiB
JavaScript
160 lines
No EOL
3.7 KiB
JavaScript
class RegVehicle_NoMOT{
|
|
constructor(){
|
|
this.name = "regvehicle_nomot";
|
|
}
|
|
|
|
static allowView(){
|
|
return userrights.has("regvehicles.view");
|
|
}
|
|
static allowAddNew(){
|
|
return false;
|
|
}
|
|
static allowEdit(){
|
|
return userrights.has("regvehicles.edit");
|
|
}
|
|
static allowDelete(){
|
|
return false;
|
|
}
|
|
|
|
static GetColumns(){
|
|
return ["plate","veh_type","veh_model","owner","mot","state","id"]
|
|
}
|
|
|
|
static GetExtraForView(data){
|
|
let retval = {
|
|
top:"",
|
|
bottom:""
|
|
}
|
|
|
|
return retval;
|
|
}
|
|
|
|
static TableDataCreate(row, key){
|
|
if(key == "state"){
|
|
|
|
let badges = ""
|
|
|
|
return `
|
|
<td>
|
|
${badges}
|
|
</td>`;
|
|
}
|
|
|
|
else if(key == "id"){
|
|
return `
|
|
<td>
|
|
${Form.getViewButtonIcon(row[key], "regvehicle.view")}
|
|
${Form.getEditButtonIcon(row[key] , "regvehicle.edit", this.allowEdit())}
|
|
</td>`;
|
|
}
|
|
else if(key == "owner"){
|
|
let val = row[key];
|
|
if(val == ""){
|
|
val = getTranslation("unknown");
|
|
}
|
|
|
|
return `
|
|
<td>
|
|
${val}
|
|
</td>`;
|
|
}
|
|
else if(key == "mot"){
|
|
if(row[key] == ""){
|
|
return `<td></td>`;
|
|
}
|
|
|
|
if(new Date(row[key]) < new Date()){
|
|
return `
|
|
<td>
|
|
<div class="badge badge-error font-bold">${System.formatDate(row[key])}</div>
|
|
</td>`
|
|
;
|
|
}
|
|
else{
|
|
return `
|
|
<td>
|
|
<div class="badge badge-success font-bold">${System.formatDate(row[key])}</div>
|
|
</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")}
|
|
];
|
|
}
|
|
|
|
filesOptions = [...filesOptions, ...data.extraData.files];
|
|
|
|
return {
|
|
"plate": {
|
|
"val" : data.plate ?? ""
|
|
,"type" : "text"
|
|
,"mandatory":true
|
|
}
|
|
,"owner": {
|
|
"val" : data.owner_id ?? "-1"
|
|
,"type" : "searchdropdown"
|
|
,"mandatory":false
|
|
,options:filesOptions
|
|
}
|
|
,"veh_type": {
|
|
"val" : data.veh_type ?? ""
|
|
,"type" : "text"
|
|
,"mandatory":false
|
|
}
|
|
,"mot": {
|
|
"val" : data.mot ?? ""
|
|
,"type" : "date"
|
|
,"mandatory":false
|
|
}
|
|
,"veh_model": {
|
|
"val" : data.veh_model ?? ""
|
|
,"type" : "text"
|
|
,"mandatory":false
|
|
}
|
|
,"color": {
|
|
"val" : data.color ?? ""
|
|
,"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
|
|
}
|
|
}
|
|
}
|
|
} |