mirror of
https://git.rwth-aachen.de/acs/public/villas/web/
synced 2025-03-09 00:00:01 +01:00
disable showing of edit and delete button through additional table column parameter
This commit is contained in:
parent
27c3b2dffa
commit
1c0a2403d2
3 changed files with 53 additions and 32 deletions
|
@ -23,7 +23,9 @@ class TableColumn extends Component {
|
|||
modifier: null,
|
||||
width: null,
|
||||
editButton: false,
|
||||
showEditButton: null,
|
||||
deleteButton: false,
|
||||
showDeleteButton: null,
|
||||
exportButton: false,
|
||||
duplicateButton: false,
|
||||
link: '/',
|
||||
|
|
|
@ -124,26 +124,34 @@ class CustomTable extends Component {
|
|||
}
|
||||
|
||||
// add buttons
|
||||
if (child.props.editButton === true) {
|
||||
cell.push(
|
||||
<OverlayTrigger
|
||||
key={0}
|
||||
placement={'bottom'}
|
||||
overlay={<Tooltip id={`tooltip-${"edit"}`}> Edit </Tooltip>}>
|
||||
<Button
|
||||
variant='table-control-button'
|
||||
onClick={() => child.props.onEdit(index)}
|
||||
disabled={child.props.onEdit == null} >
|
||||
<Icon icon='edit' />
|
||||
</Button>
|
||||
</OverlayTrigger>);
|
||||
let showEditButton = true
|
||||
if (child.props.showEditButton !== null)
|
||||
{
|
||||
showEditButton = child.props.showEditButton(index)
|
||||
}
|
||||
if(showEditButton){
|
||||
if (child.props.editButton) {
|
||||
cell.push(
|
||||
<OverlayTrigger
|
||||
key={0}
|
||||
placement={'bottom'}
|
||||
overlay={<Tooltip id={`tooltip-${"edit"}`}> Edit </Tooltip>}>
|
||||
<Button
|
||||
variant='table-control-button'
|
||||
onClick={() => child.props.onEdit(index)}
|
||||
disabled={child.props.onEdit == null} >
|
||||
<Icon icon='edit' />
|
||||
</Button>
|
||||
</OverlayTrigger>);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (child.props.checkbox) {
|
||||
const checkboxKey = child.props.checkboxKey;
|
||||
let isDisabled = false;
|
||||
if (child.props.checkboxDisabled != null){
|
||||
isDisabled = !child.props.checkboxDisabled(index)
|
||||
isDisabled = child.props.checkboxDisabled(index)
|
||||
}
|
||||
cell.push(
|
||||
<FormCheck
|
||||
|
@ -215,21 +223,30 @@ class CustomTable extends Component {
|
|||
</OverlayTrigger>);
|
||||
}
|
||||
|
||||
if (child.props.deleteButton === true) {
|
||||
cell.push(
|
||||
<OverlayTrigger
|
||||
key={5}
|
||||
placement={'bottom'}
|
||||
overlay={<Tooltip id={`tooltip-${"delete"}`}> Delete </Tooltip>} >
|
||||
<Button
|
||||
variant='table-control-button'
|
||||
onClick={() => child.props.onDelete(index)}
|
||||
disabled={child.props.onDelete == null}>
|
||||
<Icon icon='trash' />
|
||||
</Button>
|
||||
</OverlayTrigger>);
|
||||
let showDeleteButton = true;
|
||||
if (child.props.showDeleteButton !== null){
|
||||
showDeleteButton = child.props.showDeleteButton(index)
|
||||
}
|
||||
|
||||
if (showDeleteButton){
|
||||
if (child.props.deleteButton) {
|
||||
cell.push(
|
||||
<OverlayTrigger
|
||||
key={5}
|
||||
placement={'bottom'}
|
||||
overlay={<Tooltip id={`tooltip-${"delete"}`}> Delete </Tooltip>} >
|
||||
<Button
|
||||
variant='table-control-button'
|
||||
onClick={() => child.props.onDelete(index)}
|
||||
disabled={child.props.onDelete == null}>
|
||||
<Icon icon='trash' />
|
||||
</Button>
|
||||
</OverlayTrigger>);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
return cell;
|
||||
} // addCell
|
||||
|
||||
|
|
|
@ -393,9 +393,9 @@ class InfrastructureComponents extends Component {
|
|||
}
|
||||
}
|
||||
|
||||
isExternalIC(index, ics){
|
||||
isLocalIC(index, ics){
|
||||
let ic = ics[index]
|
||||
return ic.managedexternally
|
||||
return !ic.managedexternally
|
||||
}
|
||||
|
||||
getICCategoryTable(ics, editable, title){
|
||||
|
@ -405,7 +405,7 @@ class InfrastructureComponents extends Component {
|
|||
<Table data={ics}>
|
||||
<TableColumn
|
||||
checkbox
|
||||
checkboxDisabled={(index) => this.isExternalIC(index, ics) === true}
|
||||
checkboxDisabled={(index) => this.isLocalIC(index, ics) === true}
|
||||
onChecked={(ic, event) => this.onICChecked(ic, event)}
|
||||
width='30'
|
||||
/>
|
||||
|
@ -438,9 +438,11 @@ class InfrastructureComponents extends Component {
|
|||
{this.state.currentUser.role === "Admin" ?
|
||||
<TableColumn
|
||||
width='150'
|
||||
editButton = {(index) => this.isExternalIC(index, ics) !== true}
|
||||
editButton
|
||||
showEditButton ={(index) => this.isLocalIC(index, ics)}
|
||||
exportButton
|
||||
deleteButton = {(index) => this.isExternalIC(index, ics) !== true}
|
||||
deleteButton
|
||||
showDeleteButton = {(index) => this.isLocalIC(index, ics)}
|
||||
onEdit={index => this.setState({editModal: true, modalIC: ics[index], modalIndex: index})}
|
||||
onExport={index => this.exportIC(index)}
|
||||
onDelete={index => this.setState({deleteModal: true, modalIC: ics[index], modalIndex: index})}
|
||||
|
|
Loading…
Add table
Reference in a new issue