class RadioState{ constructor(){ this.name = "radio_state"; } static allowAddNew(){ return userrights.has("radiostate.edit") } static allowEdit(){ return userrights.has("radiostate.edit") } static allowDelete(){ return userrights.has("radiostate.delete") } static GetExtraForOverview(data){ let retval = { top:"", bottom:"" } let buttons = ``; let radioDetails = System.getRadioState(data.current_state_vehicle, data.current_state_person); let currentRadio = radioDetails.radio_default; if(radioDetails.vehicle == null){ if(radioDetails.radio !== null){ currentRadio = data.current_state_person[0].state_name buttons = ` ` } } else{ currentRadio = currentRadio + " (" + radioDetails.vehicle + ")" if(radioDetails.radio !== null){ currentRadio = radioDetails.radio + " (" + radioDetails.vehicle + ")" buttons = ` ` } else{ buttons = ` ` } } retval.top = `
${getTranslation("current_state")}: ${currentRadio}
${buttons}
`; return retval; } static GetColumns(){ return ["name","short_name","setstate","id"] } static TableDataCreate(row, key){ let FgColor = System.GetFgColorByBgColor(row["color"]); if(key == "id"){ return ` ${Form.getEditButtonIcon(row[key] , this.name + ".edit", this.allowEdit())} ${Form.getDeleteButtonIcon(row[key], this.name, this.allowDelete())} `; } else if(key == "setstate"){ return ` `; } else if(key != "id"){ return `${row[key]}`; } else{ return `${row[key]}`; } } static GetEdit(data = {}){ return { "name": { "val" : data.name ?? "" ,"type" : "text" ,"isRow": true ,"mandatory":true } ,"short_name": { "val" : data.short_name ?? "" ,"type" : "text" ,"isRow": true ,"mandatory":true } ,"color": { "val" : data.color ?? "" ,"type" : "dropdown" ,"isRow": true ,"mandatory":true ,options:System.GetColorOptions() } } } }