diff --git a/src/api/expression.js b/src/api/expression.js index 2b7e85bb6..64bb61c30 100644 --- a/src/api/expression.js +++ b/src/api/expression.js @@ -11,11 +11,14 @@ export const createCalculationMutation = { } export const updateCalculationMutation = { - type: 'update', + type: 'json-patch', resource: 'expressionDimensionItems', - partial: true, id: ({ id }) => id, - data: ({ name, expression }) => ({ name, shortName: name, expression }), + data: ({ name, expression }) => [ + { op: 'add', path: '/name', value: name }, + { op: 'add', path: '/shortName', value: name }, + { op: 'add', path: '/expression', value: expression }, + ], } export const deleteCalculationMutation = { diff --git a/src/components/FileMenu/RenameDialog.js b/src/components/FileMenu/RenameDialog.js index 9692e5838..fe8f64328 100644 --- a/src/components/FileMenu/RenameDialog.js +++ b/src/components/FileMenu/RenameDialog.js @@ -19,12 +19,25 @@ import { labelForFileType, } from './utils.js' +const formatPayload = (name, description) => { + const payload = [{ op: 'add', path: '/name', value: name }] + + if (description) { + payload.push({ + op: 'add', + path: '/description', + value: description, + }) + } + + return payload +} + const getMutation = (type) => ({ resource: endpointFromFileType(type), id: ({ id }) => id, - type: 'update', - partial: true, - data: ({ name, description }) => ({ name, description }), + type: 'json-patch', + data: ({ name, description }) => formatPayload(name, description), }) export const RenameDialog = ({ type, object, onClose, onRename, onError }) => { @@ -52,7 +65,7 @@ export const RenameDialog = ({ type, object, onClose, onRename, onError }) => { } return ( - + {i18n.t('Rename {{fileType}}', { @@ -67,6 +80,7 @@ export const RenameDialog = ({ type, object, onClose, onRename, onError }) => { required value={name} onChange={({ value }) => setName(value)} + dataTest="file-menu-rename-modal-name" /> { value={description} rows={3} onChange={({ value }) => setDescription(value)} + dataTest="file-menu-rename-modal-description" /> - -