ed
This commit is contained in:
parent
48a36209b5
commit
884f3df7cf
262 changed files with 223207 additions and 2 deletions
|
@ -0,0 +1,161 @@
|
|||
class RegVehicle_PartAcceptance{
|
||||
constructor(){
|
||||
this.name = "regvehicle_partacceptance";
|
||||
}
|
||||
|
||||
static GetCustomDestination(data, dest){
|
||||
return (data.vehicle_id ?? "" != "" ? "regvehicle.view" : "regvehicle.overview");
|
||||
}
|
||||
|
||||
static GetCustomDestID(data, destID){
|
||||
return data.vehicle_id ?? destID;
|
||||
}
|
||||
static allowView(){
|
||||
return userrights.has("regvehicles.view");
|
||||
}
|
||||
static allowAddNew(){
|
||||
return userrights.has("regvehicles.edit");
|
||||
}
|
||||
static allowEdit(){
|
||||
return userrights.has("regvehicles.edit");
|
||||
}
|
||||
static allowDelete(){
|
||||
return userrights.has("regvehicles.edit");
|
||||
}
|
||||
|
||||
static GetExtraForEdit(data){
|
||||
|
||||
let retval = {
|
||||
top:"",
|
||||
bottom:""
|
||||
}
|
||||
|
||||
let gridData = data.extraData.tuning_options;
|
||||
let html = "";
|
||||
|
||||
|
||||
if(gridData.length == 0 || gridData.length == undefined){
|
||||
html += `<h2>${getTranslation("no_data_found")}</h2>`;
|
||||
|
||||
retval.top = html;
|
||||
|
||||
return retval;
|
||||
|
||||
}
|
||||
|
||||
let columns = ["name", "price", "id"];
|
||||
|
||||
html = `<table class = "table table-compact w-full">`
|
||||
for(let i=0; i<gridData.length;i++){
|
||||
|
||||
let row = gridData[i];
|
||||
|
||||
if(i==0){
|
||||
|
||||
html += `<thead>`;
|
||||
html += `<tr>`;
|
||||
|
||||
for(let k=0; k<columns.length;k++){
|
||||
html += `<th>${getTranslation(columns[k])}</th>`;
|
||||
}
|
||||
|
||||
html += `</tr>`;
|
||||
html += `</thead>`;
|
||||
html += `<tbody>`;
|
||||
}
|
||||
|
||||
html+=`<tr>`;
|
||||
|
||||
for(let j=0; j<columns.length;j++){
|
||||
let key = columns[j];
|
||||
|
||||
if(key == "id"){
|
||||
html += `
|
||||
<td>
|
||||
<input onchange="RegVehicle_PartAcceptance.CustomValidation(this)" data-price="${row.price}" type="checkbox" id="input-part_accepted_${row.id}" class="toggle toggle-success ignore-validation part-accepted" />
|
||||
${Form.Hidden("input-part_accepted_price_" + row.id, row.price)}
|
||||
</td>
|
||||
`;
|
||||
}
|
||||
else if(key == "price"){
|
||||
html += `
|
||||
<td>
|
||||
${System.FormatNumber(row[key])}
|
||||
</td>
|
||||
`;
|
||||
}
|
||||
else{
|
||||
html += `
|
||||
<td>
|
||||
${row[key] ?? ""}
|
||||
</td>
|
||||
`;
|
||||
}
|
||||
}
|
||||
html+=`</tr>`;
|
||||
}
|
||||
|
||||
html += `
|
||||
<tr>
|
||||
<td class="text-right">
|
||||
<strong>${getTranslation("sum_total")}:</strong>
|
||||
</td>
|
||||
<td id="part_acceptance_total_price" class="font-bold">
|
||||
0
|
||||
</td>
|
||||
<td>
|
||||
</td>
|
||||
</tr>
|
||||
`;
|
||||
|
||||
html += `</tbody>`;
|
||||
html += `</table>`;
|
||||
|
||||
|
||||
|
||||
|
||||
retval.top = html;
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
static CustomValidation(){
|
||||
let elements = Array.from(document.querySelectorAll(".part-accepted"));
|
||||
let totalPrice = 0;
|
||||
|
||||
elements.forEach(function(checkbox){
|
||||
let price = parseInt(checkbox.getAttribute("data-price"));
|
||||
|
||||
|
||||
if(price > 0 && checkbox.checked){
|
||||
totalPrice += price;
|
||||
}
|
||||
});
|
||||
|
||||
document.getElementById("part_acceptance_total_price").innerHTML = System.FormatNumber(totalPrice);
|
||||
|
||||
|
||||
|
||||
Form.validate();
|
||||
}
|
||||
|
||||
static GetEdit(data={}){
|
||||
let retval = {
|
||||
"vehicle_id": {
|
||||
"val" : data.vehicle_id ?? -1
|
||||
,"type" : "hidden"
|
||||
,"mandatory":true
|
||||
,"isRow":true
|
||||
},
|
||||
"content": {
|
||||
"val" : data.content ?? ""
|
||||
,"type" : "textarea"
|
||||
,"mandatory":true
|
||||
,isRow:true
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue