Changed name of variable element to requestElement and now the link name of a list item is generated by generateListElements and if this element is the one selected make it visually different
This commit is contained in:
@@ -3,12 +3,23 @@ import { Link } from 'react-router-dom';
|
|||||||
|
|
||||||
class SidebarComponent extends Component {
|
class SidebarComponent extends Component {
|
||||||
|
|
||||||
|
generateListElements(index, item) {
|
||||||
|
if (index == this.props.listItemSelected)
|
||||||
|
return (
|
||||||
|
<td>{item.name}</td>
|
||||||
|
)
|
||||||
|
else
|
||||||
|
return (
|
||||||
|
<td><Link to={{ pathname: '/admin/'+String(index)}}>{item.name}</Link></td>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
displayRequestedElementsInfo() {
|
displayRequestedElementsInfo() {
|
||||||
if (this.props.requested_objects) {
|
if (this.props.requested_objects) {
|
||||||
let element = this.props.requested_objects.map((item, index) => {
|
let requestedElement = this.props.requested_objects.map((item, index) => {
|
||||||
return (
|
return (
|
||||||
<tr key={index}>
|
<tr key={index}>
|
||||||
<td><Link to={{ pathname: '/admin/'+String(index)}}>{item.name}</Link></td>
|
{ this.generateListElements(index, item) }
|
||||||
<td>{item.status}</td>
|
<td>{item.status}</td>
|
||||||
<td>{item.requested_date}</td>
|
<td>{item.requested_date}</td>
|
||||||
</tr>
|
</tr>
|
||||||
@@ -25,7 +36,7 @@ class SidebarComponent extends Component {
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{element}
|
{requestedElement}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user