diff --git a/src/actions/GenericActions.js b/src/actions/GenericActions.js index 8fe31076a..86e57c856 100644 --- a/src/actions/GenericActions.js +++ b/src/actions/GenericActions.js @@ -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 +