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

Commit

Permalink
Revert "Send editable fields' values to backend before view is deleted"
Browse files Browse the repository at this point in the history
Issue #1361

This reverts commit 2cff8b5.
  • Loading branch information
pablosichert committed Jan 11, 2018
1 parent 531ade5 commit d4e6e37
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 76 deletions.
24 changes: 0 additions & 24 deletions src/actions/WindowActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -506,30 +506,6 @@ export function initWindow(windowType, docId, tabId, rowId = null, isAdvanced) {
};
}

export function patchAll(entity, windowType, viewId, rows) {
return dispatch => {
dispatch(indicatorState("pending"));
let patchRequests = [];
const isEdit = true;

rows.map(row => {
patchRequests.push(
patchRequest({
entity,
docType: windowType,
viewId,
isEdit,
...row
})
);
});

axios.all(patchRequests).then(() => {
dispatch(indicatorState("saved"));
});
};
}

/*
* Wrapper for patch request of widget elements
* when responses should merge store
Expand Down
4 changes: 0 additions & 4 deletions src/components/Container.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,13 +144,9 @@ class Container extends Component {
windowType={rawModal.type}
viewId={rawModal.viewId}
masterDocumentList={masterDocumentList}
childRef={this.documentListComponent}
>
<div className="document-lists-wrapper">
<DocumentList
ref={c => {
this.documentListComponent = c && c.getWrappedInstance();
}}
type="grid"
windowType={rawModal.type}
defaultViewId={rawModal.viewId}
Expand Down
5 changes: 0 additions & 5 deletions src/components/app/DocumentList.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ class DocumentList extends Component {
const { defaultViewId, defaultPage, defaultSort } = props;

this.pageLength = 20;
this.table = null;
this.supportAttribute = false;

this.state = {
Expand Down Expand Up @@ -642,10 +641,6 @@ class DocumentList extends Component {
}
};

handlePatchAllEditFields = () => {
this.table && this.table.patchAllEditFields();
};

render() {
const {
windowType,
Expand Down
28 changes: 11 additions & 17 deletions src/components/app/RawModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ import Indicator from "./Indicator";
class RawModal extends Component {
state = {
scrolled: false,
isTooltipShow: false,
closeModal: false
isTooltipShow: false
};

componentDidMount() {
Expand All @@ -39,16 +38,6 @@ class RawModal extends Component {
this.removeEventListeners();
}

componentDidUpdate() {
if (this.state.closeModal) {
const { closeCallback, viewId, windowType } = this.props;
const { isNew } = this.state;
closeCallback && closeCallback(isNew);
deleteView(windowType, viewId);
this.removeModal();
}
}

toggleTooltip = visible => {
this.setState({
isTooltipShow: visible
Expand Down Expand Up @@ -80,11 +69,16 @@ class RawModal extends Component {
};

handleClose = () => {
const { childRef } = this.props;
childRef && childRef.handlePatchAllEditFields();
this.setState({
closeModal: true
});
const { closeCallback, viewId, windowType } = this.props;
const { isNew } = this.state;

if (closeCallback) {
closeCallback(isNew);
}

deleteView(windowType, viewId);

this.removeModal();
};

removeModal = () => {
Expand Down
26 changes: 0 additions & 26 deletions src/components/table/Table.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,8 @@ import {
getZoomIntoWindow,
mapIncluded,
openModal,
patchAll,
selectTableItems
} from "../../actions/WindowActions";
import { VIEW_EDITOR_RENDER_MODES_NEVER } from "../../constants/Constants";
import Prompt from "../app/Prompt";
import DocumentListContextShortcuts from "../shortcuts/DocumentListContextShortcuts";
import TableContextShortcuts from "../shortcuts/TableContextShortcuts";
Expand Down Expand Up @@ -178,30 +176,6 @@ class Table extends Component {
}
};

patchAllEditFields = () => {
const { dispatch, cols, entity, windowType, viewId } = this.props;
const { rows } = this.state;
let editableRows = [];
rows.map(row => {
cols.map(col => {
const property = col.fields[0].field;
const field = row.fieldsByName[property];
const value = field ? field.value : "";
const viewEditorRenderMode =
(field && field.viewEditorRenderMode) || col.viewEditorRenderMode;
if (viewEditorRenderMode !== VIEW_EDITOR_RENDER_MODES_NEVER) {
editableRows.push({
rowId: row.id,
property,
value
});
}
});
});

dispatch(patchAll(entity, windowType, viewId, editableRows));
};

getIndentData = selectFirst => {
const {
rowData,
Expand Down

0 comments on commit d4e6e37

Please sign in to comment.