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,111 @@
|
|||
class Investigation{
|
||||
constructor(){
|
||||
this.name = "investigation";
|
||||
}
|
||||
|
||||
static allowAddNew(){
|
||||
return userrights.has("investigation.edit");
|
||||
}
|
||||
static allowEdit(){
|
||||
return userrights.has("investigation.edit");
|
||||
}
|
||||
static allowDelete(){
|
||||
return userrights.has("investigation.delete");
|
||||
}
|
||||
static allowClose(){
|
||||
return userrights.has("investigation.close");
|
||||
}
|
||||
|
||||
static GetExtraForView(data){
|
||||
let retval = {
|
||||
top:"",
|
||||
bottom:""
|
||||
}
|
||||
|
||||
let closeTxt = getTranslation("close");
|
||||
let closedValueNew = 1;
|
||||
if(data.closed){
|
||||
closeTxt = getTranslation("reopen");
|
||||
closedValueNew = 0;
|
||||
}
|
||||
|
||||
let buttons = ``;
|
||||
|
||||
if(this.allowAddNew()){
|
||||
buttons += `<button type="button" class="btn btn-sm btn-success" onclick="loadPage('investigationentry.add',-1,'false',{data:{investigation_id:'${data.id}'}})">${getTranslation("add_entry")}</button>`;
|
||||
}
|
||||
if(this.allowClose()){
|
||||
buttons += `<button type="button" class="btn btn-sm btn-primary" onclick="changeDataInColumn('investigation','closed','${data.id}','${closedValueNew}')">${closeTxt}</button>`;
|
||||
}
|
||||
|
||||
|
||||
retval.bottom += `
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-4 pt-6 pb-6">
|
||||
${buttons}
|
||||
</div>
|
||||
`;
|
||||
|
||||
|
||||
if(data.extraData.entries !== undefined && data.extraData.entries !== null && data.extraData.entries.length > 0){
|
||||
retval.bottom += System.GetTable(InvestigationEntry, data.extraData.entries);
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
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 == "reason"){
|
||||
|
||||
let txt = row[key];
|
||||
|
||||
if(txt.length > 30){
|
||||
txt = txt.substr(0,30) + "..";
|
||||
}
|
||||
return `
|
||||
<td>
|
||||
${txt}
|
||||
</td>`;
|
||||
}
|
||||
else if(key == "state"){
|
||||
if(row.closed){
|
||||
return `<td><div class="badge badge-info font-bold">${getTranslation("tag_closed")}</div></td>`;
|
||||
}
|
||||
else{
|
||||
return `<td><div class="badge badge-warning font-bold">${getTranslation("state_open")}</div></td>`;
|
||||
}
|
||||
}
|
||||
else{
|
||||
return `<td>${row[key]}</td>`;
|
||||
}
|
||||
}
|
||||
|
||||
static GetColumns(){
|
||||
return ["name","reason","state","id"]
|
||||
}
|
||||
static GetEdit(data={}){
|
||||
return {
|
||||
"name": {
|
||||
"val" : data.name ?? ""
|
||||
,"type" : "text"
|
||||
,"isRow": true
|
||||
,"mandatory":true
|
||||
}
|
||||
,"reason": {
|
||||
"val" : data.reason ?? ""
|
||||
,"type" : "textarea"
|
||||
,"isRow": true
|
||||
,"mandatory":true
|
||||
,autogrow: true
|
||||
,rows:3
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue