From 6b32f2b933557cd04be4cdc32b2d60d1f5a54894 Mon Sep 17 00:00:00 2001 From: Pavel Petrovich Date: Tue, 30 Jun 2020 01:03:35 +0300 Subject: [PATCH] save entity fix --- client/src/Components/Comments/Comments.jsx | 26 +++++++-- .../Components/ModalWindow/ModalWindow.jsx | 31 ++++++++--- .../TaskModule/TaskView/DescriptionTask.jsx | 2 + .../Modules/TaskModule/TaskView/TaskView.jsx | 9 ++-- .../actions/publicActions/middleware/index.js | 4 ++ .../reducers/routerStateReducer/index.js | 53 +++++++++++++------ client/src/Utils/Hooks/coreHook/coreHook.js | 3 +- logger.error-audit.json | 17 +++--- 8 files changed, 102 insertions(+), 43 deletions(-) diff --git a/client/src/Components/Comments/Comments.jsx b/client/src/Components/Comments/Comments.jsx index 19654c99..9dfde8b7 100644 --- a/client/src/Components/Comments/Comments.jsx +++ b/client/src/Components/Comments/Comments.jsx @@ -8,6 +8,8 @@ import { Button, Empty, message, notification } from 'antd'; import Textarea from 'Components/Textarea'; import Comment from './Comment'; +import actionsTypes from 'actions.types'; +import { routeParser } from 'Utils'; class Comments extends React.PureComponent { state = { @@ -29,6 +31,7 @@ class Comments extends React.PureComponent { onUpdate, data: { key = '', comments = [], _id: id = '' } = {}, data = {}, + path, udata: { displayName = '', _id: uId = '' } = {}, } = this.props; @@ -50,10 +53,17 @@ class Comments extends React.PureComponent { this.setState({ ...this.state, onUpdateDisabled: true, value: '' }); + const parsedRoutePath = routeParser({ + pageType: 'moduleItem', + path, + }); + await onUpdate({ + actionType: actionsTypes.$UPDATE_SINGLE, + parsedRoutePath, key, id, - updateBy: 'key', + updateBy: '_id', updateItem: [...comments, comment], updateField: 'comments', store: 'tasks', @@ -84,15 +94,22 @@ class Comments extends React.PureComponent { }; onDelete = async (event, idComment) => { - const { onUpdate, data: { _id: id = '', key = '', comments = [] } = {}, data = {} } = this.props; + const { path, onUpdate, data: { _id: id = '', key = '', comments = [] } = {}, data = {} } = this.props; const filterComments = comments.filter((it) => it.id !== idComment); try { + const parsedRoutePath = routeParser({ + pageType: 'moduleItem', + path, + }); + await onUpdate({ + actionType: actionsTypes.$UPDATE_SINGLE, + parsedRoutePath, id, key, item: data, store: 'tasks', - updateBy: 'key', + updateBy: '_id', updateItem: filterComments, updateField: 'comments', }); @@ -122,11 +139,12 @@ class Comments extends React.PureComponent { try { await onUpdate({ + actionType: actionsTypes.$UPDATE_SINGLE, id, key, item: data, store: 'tasks', - updateBy: 'key', + updateBy: '_id', updateItem: newCommentsArray, updateField: 'comments', }); diff --git a/client/src/Components/ModalWindow/ModalWindow.jsx b/client/src/Components/ModalWindow/ModalWindow.jsx index 7bc15e8a..1a68a0c1 100644 --- a/client/src/Components/ModalWindow/ModalWindow.jsx +++ b/client/src/Components/ModalWindow/ModalWindow.jsx @@ -4,7 +4,7 @@ import _ from 'lodash'; import moment from 'moment'; import { Modal, Button, message, Select } from 'antd'; import { TASK_CONTROLL_JURNAL_SCHEMA } from 'Models/Schema/const'; -import { createNotification, isTimeLostValue } from 'Utils'; +import { createNotification, isTimeLostValue, routeParser } from 'Utils'; import SimpleEditableModal from './SimpleEditableModal'; import RegistrationModal from './RegistrationModal'; import ActionList from 'Components/ActionList'; @@ -154,10 +154,19 @@ class ModalWindow extends React.PureComponent { routeDataActive = {}, routeDataActive: { key = null } = {}, onCancelEditModeContent, + path, } = this.props; + + const parsedRoutePath = routeParser({ + pageType: 'moduleItem', + path, + }); + onUpdate({ + actionType: actionsTypes.$UPDATE_MANY, + parsedRoutePath, key, - updateBy: 'key', + updateBy: '_id', id: routeDataActive?._id, updateItem: valueDescription, updateField: 'description', @@ -248,11 +257,18 @@ class ModalWindow extends React.PureComponent { }); try { + const parsedRoutePath = routeParser({ + pageType: 'moduleItem', + path, + }); + await onUpdate({ + actionType: actionsTypes.$UPDATE_SINGLE, + parsedRoutePath, path, id: routeDataActive?._id, key, - updateBy: 'key', + updateBy: '_id', updateItem: _.isString(customStatus) ? customStatus : taskStatus, updateField: 'status', item: { ...routeDataActive }, @@ -416,6 +432,7 @@ class ModalWindow extends React.PureComponent { const { statusTaskValue, accessStatus } = this.props; const { type = '' } = this.state; const { [type]: visible = false } = this.state; + return (
@@ -427,13 +444,13 @@ class ModalWindow extends React.PureComponent { title="Смена статуса" >