forked from Simnation/Main
ed
This commit is contained in:
parent
48a36209b5
commit
884f3df7cf
262 changed files with 223207 additions and 2 deletions
|
@ -0,0 +1,94 @@
|
|||
class EmergencyVehicle{
|
||||
constructor(){
|
||||
this.name = "emergencyvehicle";
|
||||
}
|
||||
|
||||
static allowAddNew(){
|
||||
return userrights.has("emergencyvehicle.edit")
|
||||
}
|
||||
static allowEdit(){
|
||||
return userrights.has("emergencyvehicle.edit")
|
||||
}
|
||||
static allowDelete(){
|
||||
return userrights.has("emergencyvehicle.delete")
|
||||
}
|
||||
|
||||
|
||||
static GetExtraForOverview(data){
|
||||
let retval = {
|
||||
top:"",
|
||||
bottom:""
|
||||
}
|
||||
|
||||
let buttons = ``;
|
||||
let currentVehicle = getTranslation("no_current_vehicle");
|
||||
|
||||
if(data.current_vehicle!== undefined && data.current_vehicle.length > 0 && data.current_vehicle[0].id !== undefined && data.current_vehicle[0].id > -1){
|
||||
currentVehicle = data.current_vehicle[0].short_name + " - " + data.current_vehicle[0].name
|
||||
|
||||
buttons = `
|
||||
<button type="button" class="btn btn-sm btn-primary" onclick="SetVehicle(-1,'emergencyvehicle.overview')">${getTranslation("leave_patrol")}</button>
|
||||
`
|
||||
}
|
||||
|
||||
retval.top = `
|
||||
<div class="alert alert-info shadow-lg mb-4">
|
||||
<div>
|
||||
<div>${getTranslation("current_vehicle")}: <strong>${currentVehicle}</strong></div>
|
||||
<div>
|
||||
${buttons}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
static GetColumns(){
|
||||
return ["name","short_name","vehicle","action","id"]
|
||||
}
|
||||
|
||||
static TableDataCreate(row, key){
|
||||
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 == "action"){
|
||||
return `
|
||||
<td>
|
||||
<button type="button" class="btn btn-primary btn-sm" onclick="SetVehicle(${row["id"]}, 'emergencyvehicle.overview')">${getTranslation("set_state")}</button>
|
||||
</td>`;
|
||||
}
|
||||
else{
|
||||
return `<td>${row[key]}</td>`;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static GetEdit(data = {}){
|
||||
return {
|
||||
"name": {
|
||||
"val" : data.name ?? ""
|
||||
,"type" : "text"
|
||||
,"isRow": true
|
||||
,"mandatory":true
|
||||
}
|
||||
,"short_name": {
|
||||
"val" : data.short_name ?? ""
|
||||
,"type" : "text"
|
||||
,"isRow": true
|
||||
,"mandatory":true
|
||||
}
|
||||
,"vehicle": {
|
||||
"val" : data.vehicle ?? ""
|
||||
,"type" : "text"
|
||||
,"isRow": true
|
||||
,"mandatory":true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue