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

Commit

Permalink
create patchViewAttributes in generic
Browse files Browse the repository at this point in the history
  • Loading branch information
wiadev committed Dec 2, 2017
1 parent 0ca894d commit 92678ed
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions src/actions/GenericActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,48 @@ export function getViewAttributes (
);
}

function getPathRequestPayload(property, value) {
let payload = [];
if (Array.isArray(property) && value !== undefined) {
payload = property.map(item => ({
op: 'replace',
path: item.field,
value
}));
} else if (property && value !== undefined) {
payload = [{
op: 'replace',
path: property,
value
}];
}

return payload;
}

export function patchViewAttributes(
windowId,
viewId,
rowId,
property,
value
) {
console.log(windowId,
viewId,
rowId,
property,
value);
const payload = getPathRequestPayload(property, value);

return axios.patch(
config.API_URL +
'/documentView'+
'/' + windowId +
'/' + viewId +
'/' + rowId +
'/attributes', payload);
}

export function createInstance(entity, docType, docId, tabId, subentity) {
return axios.post(
config.API_URL +
Expand Down

1 comment on commit 92678ed

@teosarca
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

task #1357

Please sign in to comment.