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 += ``; } if(this.allowClose()){ buttons += ``; } retval.bottom += `
${buttons}
`; 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 ` ${Form.getViewButtonIcon(row[key], this.name + ".view")} ${Form.getEditButtonIcon(row[key] , this.name + ".edit", this.allowEdit())} ${Form.getDeleteButtonIcon(row[key], this.name, this.allowDelete())} `; } else if(key == "reason"){ let txt = row[key]; if(txt.length > 30){ txt = txt.substr(0,30) + ".."; } return ` ${txt} `; } else if(key == "state"){ if(row.closed){ return `
${getTranslation("tag_closed")}
`; } else{ return `
${getTranslation("state_open")}
`; } } else{ return `${row[key]}`; } } 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 } } } }