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

Commit

Permalink
#355 changedIds ws event's parameter handling (wip)
Browse files Browse the repository at this point in the history
  • Loading branch information
damianprzygodzki committed Mar 24, 2017
1 parent e61b75c commit 294e74e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
11 changes: 11 additions & 0 deletions src/actions/GenericActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,17 @@ export function patchRequest(
(isAdvanced ? '?advanced=true' : ''), payload);
}

export function getDataByIds(entity, docType, viewId, docIds) {
return () => axios.get(
config.API_URL +
'/' + entity +
(docType ? '/' + docType : '') +
(viewId ? '/' + viewId : '') +
'/byIds' +
'?ids='+ docIds
)
}

export function completeRequest(
entity, docType, docId, tabId, rowId, subentity, subentityId
) {
Expand Down
13 changes: 11 additions & 2 deletions src/components/app/DocumentList.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ import SockJs from 'sockjs-client';
import Stomp from 'stompjs/lib/stomp.min.js';

import {
initLayout
initLayout,
getDataByIds
} from '../../actions/GenericActions';

import {
Expand Down Expand Up @@ -131,6 +132,7 @@ class DocumentList extends Component {
}

connectWS = (viewId) => {
const {dispatch, windowType} = this.props;
(this.sockClient && this.sockClient.connected) &&
this.sockClient.disconnect();

Expand All @@ -139,7 +141,14 @@ class DocumentList extends Component {
this.sockClient.debug = null;
this.sockClient.connect({}, () => {
this.sockClient.subscribe('/view/'+ viewId, msg => {
const {fullyChanged} = JSON.parse(msg.body);
const {fullyChanged, changedIds} = JSON.parse(msg.body);
if(changedIds){
dispatch(getDataByIds(
'documentView', windowType, viewId, changedIds.join()
)).then(response => {
console.log(response.data)
});
}
if(fullyChanged == true){
this.browseView(true);
}
Expand Down

0 comments on commit 294e74e

Please sign in to comment.