forked from Simnation/Main
ed
This commit is contained in:
parent
48a36209b5
commit
884f3df7cf
262 changed files with 223207 additions and 2 deletions
122
resources/[jobs]/[mdt]/myEmergency/html/js/modules/Trainings.js
Normal file
122
resources/[jobs]/[mdt]/myEmergency/html/js/modules/Trainings.js
Normal file
|
@ -0,0 +1,122 @@
|
|||
class Trainings{
|
||||
constructor(){
|
||||
this.name = "trainings";
|
||||
}
|
||||
|
||||
static allowAddNew(){
|
||||
return userrights.has("trainings.edit")
|
||||
}
|
||||
static allowEdit(){
|
||||
return userrights.has("trainings.edit")
|
||||
}
|
||||
static allowDelete(){
|
||||
return userrights.has("trainings.delete")
|
||||
}
|
||||
static allowViewEmployeeTrainings(){
|
||||
return userrights.has("trainingsemployees.view")
|
||||
}
|
||||
|
||||
static GetExtraForView(data){
|
||||
let retval = {
|
||||
top:"",
|
||||
bottom:""
|
||||
}
|
||||
|
||||
if(this.allowViewEmployeeTrainings){
|
||||
retval.bottom += `
|
||||
<div class="collapse collapse-open border border-base-300 bg-base-100 rounded-box mt-4">
|
||||
<div class="collapse-title text-xl font-medium">
|
||||
${getTranslation("trainingsparticipants.overview")}
|
||||
</div>
|
||||
<div class="collapse-content">
|
||||
${System.GetTable(TrainingsParticipants, data.extraData.participants)}
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
static GetColumns(){
|
||||
return ["name","short_name","action","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 == "action"){
|
||||
|
||||
let content = "";
|
||||
if(row.allow_self_entry){
|
||||
let disabled = "";
|
||||
if(row.entered > 0){
|
||||
disabled = " disabled"
|
||||
}
|
||||
content = `<button type="button" class="btn btn-sm btn-primary" onclick="participateForTraining(${row["id"]})" ${disabled}>${getTranslation("participate")}</button>`
|
||||
}
|
||||
|
||||
return `
|
||||
<td>
|
||||
${content}
|
||||
</td>`;
|
||||
}
|
||||
else{
|
||||
return `<td>${row[key]}</td>`;
|
||||
}
|
||||
}
|
||||
|
||||
static GetEdit(data={}){
|
||||
for(let i=0; i<data.extraData.trainees.length; i++){
|
||||
data.extraData.trainees[i].name = System.buildEmployeeName(data.extraData.trainees[i].name)
|
||||
}
|
||||
|
||||
return {
|
||||
"name": {
|
||||
"val" : data.name ?? ""
|
||||
,"type" : "text"
|
||||
,"isRow": true
|
||||
,"mandatory":true
|
||||
}
|
||||
,"short_name": {
|
||||
"val" : data.short_name ?? ""
|
||||
,"type" : "text"
|
||||
,"isRow": true
|
||||
,"mandatory":true
|
||||
}
|
||||
,"content": {
|
||||
"val" : data.content ?? ""
|
||||
,"type" : "textarea"
|
||||
,"isRow": true
|
||||
,"mandatory":true
|
||||
,autogrow: true
|
||||
,rows:3
|
||||
}
|
||||
,"allow_self_entry": {
|
||||
"val" : data.allow_self_entry ?? ""
|
||||
,"type" : "dropdown"
|
||||
,"mandatory":true
|
||||
,options:System.GetBooleanOptions()
|
||||
}
|
||||
,"min_rank_id": {
|
||||
"val" : data.min_rank_id ?? ""
|
||||
,"type" : "dropdown"
|
||||
,"mandatory":true
|
||||
,options:System.getRankOptions()
|
||||
}
|
||||
,"trainee": {
|
||||
"val" : data.trainee ?? ""
|
||||
,"type" : "dropdown"
|
||||
,"isRow": true
|
||||
,"mandatory":true
|
||||
,options:data.extraData.trainees
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue