forked from Simnation/Main
92 lines
No EOL
2.3 KiB
JavaScript
92 lines
No EOL
2.3 KiB
JavaScript
class MissionReport{
|
|
constructor(){
|
|
this.name = "missionreport";
|
|
}
|
|
|
|
static allowAddNew(){
|
|
return userrights.has("missionreport.edit");
|
|
}
|
|
static allowEdit(){
|
|
return userrights.has("missionreport.edit");
|
|
}
|
|
static allowDelete(){
|
|
return userrights.has("missionreport.delete");
|
|
}
|
|
|
|
static GetColumns(){
|
|
return ["name","mission_date","createddate","createdby","changeddate","changedby","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 == "mission_date"){
|
|
return `
|
|
<td>
|
|
${System.formatDate(row[key])}
|
|
|
|
</td>`;
|
|
}
|
|
else if(key == "name"){
|
|
return `
|
|
<td class="whitespace-normal">
|
|
${row[key]}
|
|
</td>`;
|
|
}
|
|
else if(key == "createddate" || key == "changeddate"){
|
|
return `
|
|
<td>
|
|
${System.formatTimestamp(row[key])}
|
|
</td>`;
|
|
}
|
|
else if(key == "createdby" || key == "changedby"){
|
|
return `
|
|
<td>
|
|
${System.buildEmployeeName(row[key])}
|
|
</td>`;
|
|
}
|
|
else{
|
|
return `<td>${row[key]}</td>`;
|
|
}
|
|
|
|
}
|
|
|
|
static GetEdit(data={}){
|
|
return {
|
|
"name": {
|
|
"val" : data.name ?? ""
|
|
,"type" : "text"
|
|
,"mandatory":true
|
|
}
|
|
,"mission_date": {
|
|
"val" : data.mission_date ?? new Date().toISOString().split('T')[0]
|
|
,"type" : "date"
|
|
,"mandatory":true
|
|
}
|
|
,"mission_location":{
|
|
"val" : data.mission_location ?? ""
|
|
,"type" : "text"
|
|
,"mandatory":true
|
|
}
|
|
,"involved_forces": {
|
|
"val" : data.involved_forces ?? ""
|
|
,"type" : "text"
|
|
,"mandatory":true
|
|
}
|
|
,"report":{
|
|
"val" : data.report ?? ""
|
|
,"type" : "textarea"
|
|
,"isRow": true
|
|
,"mandatory":true
|
|
,autogrow: true
|
|
,rows:3
|
|
}
|
|
}
|
|
}
|
|
} |