forked from Simnation/Main
102 lines
No EOL
2.7 KiB
JavaScript
102 lines
No EOL
2.7 KiB
JavaScript
class RankManagementRights{
|
|
static isCustom(){
|
|
return true;
|
|
}
|
|
|
|
static allowAddNew(){
|
|
return false;
|
|
}
|
|
|
|
static CreateCustom(data){
|
|
let thead = `
|
|
<tr>
|
|
<th>
|
|
<input type="checkbox" id="toggle-all-checkboxes" class="toggle toggle-success"/>
|
|
</th>
|
|
<th>
|
|
${getTranslation("name")}
|
|
</th>
|
|
</tr>
|
|
`
|
|
|
|
let tbody = ``;
|
|
for(let i=0; i<data.data.rights.length; i++){
|
|
tbody += `
|
|
<tr>
|
|
${this.TableDataCreate(data.data.rights[i],"id")}
|
|
${this.TableDataCreate(data.data.rights[i],"right_key")}
|
|
</tr>
|
|
`;
|
|
}
|
|
|
|
document.getElementById("currentpage-content").innerHTML = `
|
|
<div class="card w-full p-2 bg-base-100 shadow-xl mt-2 mb-6">
|
|
<div class="h-full w-full bg-base-100">
|
|
<div class="overflow-x-auto w-full">
|
|
<table class="table table-compact w-full">
|
|
<thead>
|
|
${thead}
|
|
</thead>
|
|
<tbody>
|
|
${tbody}
|
|
</tbody>
|
|
</table>
|
|
<div class="grid grid-cols-1 md:grid-cols-2 gap-4 pt-6">
|
|
<button id="input-cancel-button" class="btn btn-sm btn-error">${getTranslation("cancel")}</button>
|
|
<button id="input-save-button" data-rankid="${data.data.id}" class="btn btn-sm btn-primary">${getTranslation("save")}</button>
|
|
</div">
|
|
</div>
|
|
</div>
|
|
</div>
|
|
`;
|
|
|
|
document.getElementById("toggle-all-checkboxes").onclick=function(){
|
|
let check = this.checked;
|
|
|
|
Array.from(document.getElementById("currentpage-content").querySelectorAll(".toggler-input")).forEach(function(item){
|
|
item.checked = check ?? false;
|
|
});
|
|
}
|
|
|
|
|
|
document.getElementById("input-cancel-button").onclick=function(){
|
|
loadPage("rankmanagement.dataload",-1)
|
|
}
|
|
document.getElementById("input-save-button").onclick=function(){
|
|
|
|
let temp = Form.getFormData();
|
|
delete temp["toggle-all-checkboxes"];
|
|
|
|
let formData = {
|
|
rank_id: this.getAttribute("data-rankid"),
|
|
data:temp
|
|
}
|
|
|
|
sendDataToAPI("rankmanagementrights", "rankmanagement.dataload",-1, -1, formData);
|
|
}
|
|
}
|
|
|
|
|
|
static GetColumns(){
|
|
return ["name", "id"]
|
|
}
|
|
static TableDataCreate(row, key){
|
|
if(key == "id"){
|
|
let checked = "";
|
|
if(row.active){
|
|
checked = " checked";
|
|
}
|
|
|
|
return `<td><input id="input-${row.right_key}" data-id="${row[key]}" type="checkbox" class="toggle toggle-success toggler-input" ${checked} /></td>`
|
|
}
|
|
else if(key == "right_key"){
|
|
return `<td>${getTranslation(row[key])}</td>`;
|
|
}
|
|
else{
|
|
return `<td>${row[key]}</td>`;
|
|
}
|
|
}
|
|
|
|
static GetEdit(data={}){
|
|
}
|
|
} |