Skip to content
This repository has been archived by the owner on Dec 13, 2020. It is now read-only.

Commit

Permalink
Included row: show row's references in context menu #801
Browse files Browse the repository at this point in the history
  • Loading branch information
Dunkat committed May 29, 2017
1 parent cbb63b2 commit 773e30d
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 7 deletions.
6 changes: 4 additions & 2 deletions src/actions/GenericActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,12 +186,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'
);
}
Expand Down
2 changes: 1 addition & 1 deletion src/assets/css/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ body {
.context-menu {
position: fixed;
display: none;
width: 150px;
width: 180px;
background-color: #fff;
left: 0;
top: 0;
Expand Down
61 changes: 58 additions & 3 deletions src/components/table/TableContextMenu.js
Original file line number Diff line number Diff line change
@@ -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';

Expand All @@ -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) => {
Expand Down Expand Up @@ -45,14 +55,40 @@ class TableContextMenu extends Component {
});
}

getReferences = () => {
const {dispatch, docId, tabId, type, selected} = this.props;

dispatch(
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 (
<div
className="context-menu context-menu-open panel-bordered panel-primary"
Expand Down Expand Up @@ -106,6 +142,25 @@ class TableContextMenu extends Component {
</span>
</div>
}

{references &&
<hr className="context-menu-separator" />
}

{references && references.map((item, index)=>
<div
className="context-menu-item"
key={index}
onClick={() => {
this.handleReferenceClick(item.documentType,
item.filter
)
}}
>
<i className="meta-icon-share" /> {item.caption}
</div>
)
}
</div>
)
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/widget/Lookup/Lookup.js
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ class Lookup extends Component {
validLocal: response.data.values.length === 0 &&
handleChangeOnFocus!==true ? false : true
});
}).catch((err) => {
}).catch(() => {
this.setState({
list: [],
loading: false
Expand Down

0 comments on commit 773e30d

Please sign in to comment.