diff --git a/src/actions/GenericActions.js b/src/actions/GenericActions.js index cded0a06f..bc022bd6c 100644 --- a/src/actions/GenericActions.js +++ b/src/actions/GenericActions.js @@ -188,12 +188,14 @@ export function actionsRequest(entity, type, id, selected){ ); } -export function referencesRequest(entity, type, id){ +export function referencesRequest(entity, type, docId, tabId, rowId){ return axios.get( config.API_URL + '/' + entity + '/' + type + '/' + - id + + docId + + (tabId ? '/' + tabId : '') + + (rowId ? '/' + rowId : '') + '/references' ); } diff --git a/src/assets/css/styles.css b/src/assets/css/styles.css index 510442482..574cd2dcb 100644 --- a/src/assets/css/styles.css +++ b/src/assets/css/styles.css @@ -107,7 +107,7 @@ body { .context-menu { position: fixed; display: none; - width: 150px; + width: 180px; background-color: #fff; left: 0; top: 0; diff --git a/src/components/table/TableContextMenu.js b/src/components/table/TableContextMenu.js index cb3cdd480..a8977a24c 100644 --- a/src/components/table/TableContextMenu.js +++ b/src/components/table/TableContextMenu.js @@ -1,6 +1,14 @@ import React, { Component } from 'react'; import PropTypes from 'prop-types'; import { connect } from 'react-redux'; +import { + referencesRequest +} from '../../actions/GenericActions'; + +import { + setFilter +} from '../../actions/ListActions'; +import {push} from 'react-router-redux'; import keymap from '../../keymap.js'; @@ -11,13 +19,15 @@ class TableContextMenu extends Component { contextMenu:{ x:0, y:0 - } + }, + references: [] } } componentDidMount() { - const {x, y, fieldName} = this.props; + const {x, y, fieldName, docId} = this.props; this.setPosition(x, y, fieldName, this.contextMenu); + docId && this.getReferences(); } getPosition = (dir, pos, element) => { @@ -45,14 +55,39 @@ class TableContextMenu extends Component { }); } + getReferences = () => { + const {docId, tabId, type, selected} = this.props; + + referencesRequest('window', type, docId, tabId, selected[0]) + .then(response => { + this.setState({ + references: response.data.references + + }); + }); + } + + handleReferenceClick = (refType, filter) => { + const { + dispatch, type, docId + } = this.props; + dispatch(setFilter(filter, refType)); + dispatch(push( + '/window/' + refType + + '?refType=' + type + + '&refId=' + docId + )); + } + render() { const { blur, selected, mainTable, handleAdvancedEdit, handleOpenNewTab, handleDelete, handleZoomInto } = this.props; - const {contextMenu} = this.state; + const {contextMenu, references} = this.state; const isSelectedOne = selected.length === 1; + return (