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,138 @@
|
|||
class EvidenceRoomArticles{
|
||||
constructor(){
|
||||
this.name = "evidenceroomarticles";
|
||||
}
|
||||
|
||||
static isCustom(){
|
||||
return true;
|
||||
}
|
||||
|
||||
static allowEdit(){
|
||||
return userrights.has("evidencerooms.edit");
|
||||
}
|
||||
static allowDelete(){
|
||||
return userrights.has("evidencerooms.delete");
|
||||
}
|
||||
|
||||
static GetColumns(isReadOnly){
|
||||
if(isReadOnly == true){
|
||||
return ["name","amount","file_name","state","changedate"]
|
||||
}
|
||||
else{
|
||||
return ["name","amount","file_name","state","changedate","id"]
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static TableDataCreate(row, key,isReadOnly){
|
||||
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 == "changedate") {
|
||||
return `<td>${row[key]}<br>${System.buildEmployeeName(row.changedby)}</td>`;
|
||||
}
|
||||
else if(key == "state"){
|
||||
let state = this.GetStateByID(row[key]);
|
||||
|
||||
|
||||
return `
|
||||
<td>
|
||||
<div class="badge font-bold ${state.color ?? ""}">${state.name ?? ""}</div>
|
||||
</td>`;
|
||||
}
|
||||
else if(key == "file_name"){
|
||||
let val = row[key];
|
||||
if(val == ""){
|
||||
val = getTranslation("unknown");
|
||||
}
|
||||
|
||||
return `
|
||||
<td>
|
||||
${val}
|
||||
</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")}
|
||||
];
|
||||
}
|
||||
|
||||
let files = [...filesOptions, ...data.extraData.files];
|
||||
|
||||
return {
|
||||
"evidenceroom_id": {
|
||||
"val" : data.evidenceroom_id ?? "-1"
|
||||
,"type" : "hidden"
|
||||
},
|
||||
"name": {
|
||||
"val" : data.name ?? ""
|
||||
,"type" : "text"
|
||||
,"isRow":true
|
||||
,"mandatory":true
|
||||
}
|
||||
,"amount": {
|
||||
"val" : data.amount ?? ""
|
||||
,"type" : "number"
|
||||
,"isRow":true
|
||||
,"mandatory":true
|
||||
}
|
||||
,"state": {
|
||||
"val" : data.state ?? 0
|
||||
,"type" : "dropdown"
|
||||
,"isRow":true
|
||||
,"mandatory":true
|
||||
,options:this.GetStateOptions()
|
||||
}
|
||||
,"file_id": {
|
||||
"val" : data.file_id ?? -1
|
||||
,"type" : "searchdropdown"
|
||||
,"mandatory":true
|
||||
,"isRow":true
|
||||
,options:files
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static GetStateOptions(){
|
||||
let retval = [];
|
||||
|
||||
let json = this.GetStates();
|
||||
Object.keys(json).forEach(function(key){
|
||||
retval.push({"id": key, "name":json[key].name })
|
||||
});
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
static GetStates(){
|
||||
return {
|
||||
"0" : {name:getTranslation("state_new"), "color":"badge-primary"},
|
||||
"1" : {name:getTranslation("state_inprogress"), "color":"badge-warning"},
|
||||
"2" : {name:getTranslation("state_stored"), "color":"badge-success"},
|
||||
"3" : {name:getTranslation("state_destoyed"), "color":"badge-error"}
|
||||
}
|
||||
}
|
||||
|
||||
static GetStateByID(id){
|
||||
return this.GetStates()[id] ?? {}
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue