177 lines
No EOL
4.5 KiB
JavaScript
177 lines
No EOL
4.5 KiB
JavaScript
class Files{
|
|
constructor(){
|
|
this.name = "files";
|
|
}
|
|
static allowAddNew(){
|
|
return userrights.has("files.edit") && !sync.isActive("files");
|
|
}
|
|
static allowEdit(){
|
|
return userrights.has("files.edit");
|
|
}
|
|
static allowDelete(ingoreSync=false){
|
|
return userrights.has("files.delete") && (!sync.isActive("files") || ingoreSync);
|
|
}
|
|
static allowClose(){
|
|
return userrights.has("files.close");
|
|
}
|
|
static allowBlacken(){
|
|
return userrights.has("files.blacken");
|
|
}
|
|
static allowShare(){
|
|
return userrights.has("files.share");
|
|
}
|
|
static allowFinishmanhunt(){
|
|
return userrights.has("manhunt.finish");
|
|
}
|
|
static allowFinishEntry(){
|
|
return userrights.has("filesentry.finish");
|
|
}
|
|
|
|
|
|
static GetColumns(){
|
|
return ["name","alias","phone","id"];
|
|
}
|
|
|
|
static GetPropertyHTML(data){
|
|
if(data.extraData.properties == null || data.extraData.properties == undefined){
|
|
return "";
|
|
}
|
|
else{
|
|
let tbody = ``;
|
|
for(let i=0; i<data.extraData.properties.length; i++){
|
|
let row = data.extraData.properties[i];
|
|
|
|
tbody += `
|
|
<tr>
|
|
<td>
|
|
${row.label}
|
|
</td>
|
|
<td>
|
|
<button type="button" class="btn btn-primary btn-sm" data-entering='${row.entering}' onclick="GenerateRoute(this)">
|
|
<i class="fa-solid fa-location-dot"></i>
|
|
<button>
|
|
</td>
|
|
</tr>
|
|
`;
|
|
}
|
|
|
|
return `
|
|
<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("properties")}
|
|
</div>
|
|
<div class="collapse-content">
|
|
<table class="table table-compact w-full">
|
|
<thead>
|
|
<tr>
|
|
<th>
|
|
${getTranslation("name")}
|
|
</th>
|
|
<th>
|
|
</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
${tbody}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
`
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
static GetExtraForView(data){
|
|
let retval = {
|
|
top:"",
|
|
bottom:"",
|
|
initTableButtons:false,
|
|
}
|
|
|
|
if(RegVehicle.allowView()){
|
|
|
|
if(data.extraData.vehicles !== undefined){
|
|
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("regvehicle.overview")}
|
|
</div>
|
|
<div class="collapse-content">
|
|
${System.GetTable(RegVehicle, data.extraData.vehicles)}
|
|
</div>
|
|
</div>
|
|
`;
|
|
|
|
retval.initTableButtons = true
|
|
}
|
|
}
|
|
|
|
return retval;
|
|
}
|
|
|
|
static TableDataCreate(row, key){
|
|
if(key == "state"){
|
|
|
|
let badges = ``;
|
|
|
|
if(row[key] != ""){
|
|
badges += `<div class="badge badge-error font-bold">${getTranslation("tag_" + row[key])}</div>`;
|
|
}
|
|
if(row.blackend){
|
|
badges += `<div class="badge badge-warning font-bold">${getTranslation("tag_blackend")}</div>`;
|
|
}
|
|
if(row.closed){
|
|
badges += `<div class="badge badge-info font-bold">${getTranslation("tag_closed")}</div>`;
|
|
}
|
|
return `<td>${badges}</td>`;
|
|
}
|
|
else if(key == "id"){
|
|
return `
|
|
<td>
|
|
${Form.getViewButtonIcon(row[key], this.name + ".view")}
|
|
${Form.getEditButtonIcon(row[key] , this.name + ".edit", this.allowEdit())}
|
|
</td>`;
|
|
}
|
|
else if(key == "shared"){
|
|
if(row[key]){
|
|
return `
|
|
<td class="font-bold">
|
|
<i class="fa-solid fa-check"></i>
|
|
</td>
|
|
`;
|
|
}
|
|
else{
|
|
return `<td></td>`;
|
|
}
|
|
}
|
|
else{
|
|
return `<td>${row[key]}</td>`;
|
|
}
|
|
}
|
|
|
|
static GetEdit(data = {}){
|
|
|
|
return {
|
|
"name": {
|
|
"val" : data.name ?? ""
|
|
,"type" : "text"
|
|
,"mandatory":true
|
|
}
|
|
,"alias": {
|
|
"val" : data.alias ?? ""
|
|
,"type" : "text"
|
|
,"mandatory":false
|
|
}
|
|
,"phone": {
|
|
"val" : data.phone ?? ""
|
|
,"type" : "text"
|
|
,"mandatory":false
|
|
}
|
|
};
|
|
}
|
|
}
|
|
|