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

Commit

Permalink
REST API FINALIZATION (quickfix #2)
Browse files Browse the repository at this point in the history
  • Loading branch information
damianprzygodzki committed Jan 11, 2017
1 parent 4617c11 commit ae4aec0
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 41 deletions.
20 changes: 20 additions & 0 deletions src/actions/GenericActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,3 +126,23 @@ export function deleteRequest(entity, docType, docId, tabId, rowId) {
(rowId ? "/" + rowId : "")
);
}

export function actionsRequest(entity, type, id){
return () => axios.get(
config.API_URL + '/' +
entity + '/' +
type + '/' +
id +
'/actions'
);
}

export function referencesRequest(entity, type, id){
return () => axios.get(
config.API_URL + '/' +
entity + '/' +
type + '/' +
id +
'/references'
);
}
19 changes: 0 additions & 19 deletions src/actions/MenuActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,25 +113,6 @@ export function getWindowBreadcrumb(id){
}
}

export function getRelatedDocuments(type, id){
return () => axios.get(
config.API_URL + '/window/' + type + '/' + id + '/references'
);
}

export function getDocumentActions(type, id){
return () => axios.get(
config.API_URL + '/window/' + type + '/' + id + '/actions'
);
}

export function getViewActions(type, viewId){
return () => axios.get(
config.API_URL + '/documentView/' + type + '/' + viewId + '/actions'
);
}


//END OF THUNK ACTIONS

// UTILITIES
Expand Down
13 changes: 10 additions & 3 deletions src/components/Container.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,18 @@ class Container extends Component {
constructor(props){
super(props);
}

render() {
const {
docActionElem, docStatusData, docNoElement, docNoData, docSummaryData,
dataId, windowType, breadcrumb, references, actions, showSidelist,
siteName, connectionError, noMargin
siteName, connectionError, noMargin, entity, children
} = this.props;

return (
<div>
<Header
entity={entity}
docStatus = {docActionElem}
docStatusData = {docStatusData}
docNo = {docNoElement}
Expand All @@ -32,8 +34,13 @@ class Container extends Component {
/>
{connectionError && <ErrorScreen />}
<NotificationHandler />
<div className={"header-sticky-distance js-unselect " + (!!noMargin ? "dashboard" : "container-fluid")}>
{this.props.children}
<div
className={
"header-sticky-distance js-unselect " +
(!!noMargin ? "dashboard" : "container-fluid")
}
>
{children}
</div>
</div>
);
Expand Down
3 changes: 2 additions & 1 deletion src/components/header/Header.js
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ class Header extends Component {
const {
docSummaryData, siteName, docNoData, docNo, docStatus, docStatusData,
windowType, dataId, breadcrumb, showSidelist, references, actions, indicator,
viewId, inbox, homemenu, selected
viewId, inbox, homemenu, selected, entity
} = this.props;

const {
Expand Down Expand Up @@ -414,6 +414,7 @@ class Header extends Component {
handleClone={this.handleClone}
redirect={this.redirect}
selected={selected}
entity={entity}
/>}

{showSidelist && <SideList
Expand Down
32 changes: 14 additions & 18 deletions src/components/header/SubHeader.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,16 @@ import {
import keymap from '../../keymap.js';

import {
getRelatedDocuments,
setReferences,
getDocumentActions,
setActions,
getViewActions
} from '../../actions/MenuActions';

import {
actionsRequest,
referencesRequest
} from '../../actions/GenericActions';

class Subheader extends Component {
constructor(props){
super(props);
Expand All @@ -28,30 +31,23 @@ class Subheader extends Component {
}

componentDidMount() {
const {dispatch, windowType, dataId, viewId, selected} = this.props;
const {
dispatch, windowType, dataId, viewId, selected, entity
} = this.props;

dispatch(setActions([]));

document.getElementsByClassName('js-subheader-column')[0].focus();

if(windowType && dataId){
dispatch(getRelatedDocuments(windowType, dataId)).then((response) => {
if(selected.length === 1 || dataId){
dispatch(referencesRequest("window", windowType, dataId ? dataId : selected[0])).then((response) => {
dispatch(setReferences(response.data.references));
});

dispatch(getDocumentActions(windowType,dataId)).then((response) => {
dispatch(setActions(response.data.actions));
});
}else if (viewId && !dataId){
dispatch(getViewActions(windowType, viewId)).then((response) => {
dispatch(setActions(response.data.actions));
});
if(selected && selected.length === 1){
dispatch(getRelatedDocuments(windowType, selected[0])).then((response) => {
dispatch(setReferences(response.data.references));
});
}
}

dispatch(actionsRequest(entity, windowType, dataId ? dataId : viewId)).then((response) => {
dispatch(setActions(response.data.actions));
});
}

handleReferenceClick = (type, filter) => {
Expand Down
1 change: 1 addition & 0 deletions src/containers/DocList.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class DocList extends Component {

return (
<Container
entity="documentView"
breadcrumb={breadcrumb}
windowType={windowType}
actions={actions}
Expand Down
1 change: 1 addition & 0 deletions src/containers/MasterWindow.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ class MasterWindow extends Component {

return (
<Container
entity="window"
docActionElem = {docActionElement}
docStatusData = {docStatusData}
docNoElement = {documentNoElement}
Expand Down

0 comments on commit ae4aec0

Please sign in to comment.