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,104 @@
|
|||
class LawBookLaws{
|
||||
constructor(){
|
||||
this.name = "lawbooklaws";
|
||||
}
|
||||
|
||||
static isCustom(){
|
||||
return true;
|
||||
}
|
||||
|
||||
static allowEdit(){
|
||||
return userrights.has("lawbooks.edit");
|
||||
}
|
||||
static allowDelete(){
|
||||
return userrights.has("lawbooks.delete");
|
||||
}
|
||||
|
||||
static GetColumns(isEditList){
|
||||
if(!isEditList){
|
||||
return ["paragraph","crime","minimum_penalty","detention_time","others","id"]
|
||||
}
|
||||
else{
|
||||
return ["paragraph","crime","minimum_penalty","detention_time","others","id"]
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static TableDataCreate(row, key, isEditList){
|
||||
if(!isEditList){
|
||||
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 == "crime") {
|
||||
return `<td class="whitespace-normal">${row[key]}</td>`;
|
||||
}
|
||||
else if(key == "others") {
|
||||
return `<td class="whitespace-normal">${row[key]}</td>`;
|
||||
}
|
||||
else {
|
||||
return `<td>${row[key]}</td>`;
|
||||
}
|
||||
}
|
||||
else{
|
||||
|
||||
if(key == "id"){
|
||||
return `<td class="edittable_row" id = "edittable_row_${row.id}">
|
||||
${Form.NumberField(false, "lawbook_laws_amount_" + row.id, "0", "lawbook_laws_calc_penalty", false, false)}
|
||||
${Form.Hidden("lawbook_laws_id_" + row.id, row[key])}
|
||||
${Form.Hidden("lawbook_laws_minimum_penalty_" + row.id, row["minimum_penalty"])}
|
||||
${Form.Hidden("lawbook_laws_detention_time_" + row.id, row["detention_time"])}
|
||||
</td>`;
|
||||
}
|
||||
else if(key == "crime") {
|
||||
return `<td class="whitespace-normal">${row[key]}</td>`;
|
||||
}
|
||||
else if(key == "others") {
|
||||
return `<td class="whitespace-normal">${row[key]}</td>`;
|
||||
}
|
||||
else {
|
||||
return `<td>${row[key]}</td>`;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static GetEdit(data={}){
|
||||
return {
|
||||
"lawbook_id": {
|
||||
"val" : data.lawbook_id ?? "-1"
|
||||
,"type" : "hidden"
|
||||
},
|
||||
"crime": {
|
||||
"val" : data.crime ?? ""
|
||||
,"type" : "text"
|
||||
,"mandatory":true
|
||||
}
|
||||
,"paragraph": {
|
||||
"val" : data.paragraph ?? ""
|
||||
,"type" : (HandleParagraphsAsNumber ? "float" : "text")
|
||||
,"mandatory":true
|
||||
}
|
||||
,"minimum_penalty": {
|
||||
"val" : data.minimum_penalty ?? 0
|
||||
,"type" : "number"
|
||||
,"mandatory":true
|
||||
}
|
||||
,"detention_time": {
|
||||
"val" : data.detention_time ?? 0
|
||||
,"type" : "number"
|
||||
,"mandatory":true
|
||||
}
|
||||
,"others": {
|
||||
"val" : data.others ?? ""
|
||||
,"type" : "textarea"
|
||||
,autogrow : true
|
||||
,"mandatory":false
|
||||
,"isRow":true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue