Skip to content
This repository has been archived by the owner on Jun 12, 2022. It is now read-only.

Commit

Permalink
Merge pull request #15 from AKolodeev/bugfix
Browse files Browse the repository at this point in the history
Fixed modals status field
  • Loading branch information
AKolodeev committed Sep 27, 2017
2 parents 51fab35 + 8369b60 commit 92f1467
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 14 deletions.
10 changes: 4 additions & 6 deletions example/src/App.js
Expand Up @@ -29,21 +29,19 @@ class App extends Component {

handleEditFileBtnClick() {
this.props.pushModalWindow(EDIT_FILE_DIALOG, { initialFileName: 'my_file.txt' })
.then(({ type, newFileName }) => {
// got modal exit status as *type* and newFileName
.then(({ status, newFileName }) => {
// ToDo: ajax request and processing
if (type === MODAL_TYPE_CONFIRM) {
if (status === MODAL_TYPE_CONFIRM) {
console.log('OK. New name: %s', newFileName);
}
});
}

handleRemoveFileBtnClick() {
this.props.pushModalWindow(REMOVE_FILE_DIALOG, { fileName: 'my_file.txt' })
.then(({ type }) => {
// got modal exit status as *type*
.then(({ status }) => {
// ToDo: ajax request and processing
if (type === MODAL_TYPE_CONFIRM) {
if (status === MODAL_TYPE_CONFIRM) {
console.log('OK, file removed');
}
});
Expand Down
10 changes: 5 additions & 5 deletions example/src/components/EditFileDialog.js
Expand Up @@ -38,17 +38,17 @@ export default class EditFileDialog extends Component {
}

handleConfirmBtnClick() {
const { resultTypes: { CONFIRM }, popModalWindow } = this.props;
const { resultTypes: { MODAL_TYPE_CONFIRM }, popModalWindow } = this.props;
const { newFileName } = this.state;

// Close the modal with "CONFIRM" status and provide new file name
popModalWindow({ status: CONFIRM, newFileName });
// Close the modal with confirm status and provide new file name
popModalWindow({ status: MODAL_TYPE_CONFIRM, newFileName });
}

handleCancelBtnClick() {
const { resultTypes: { CANCEL }, popModalWindow } = this.props;
const { resultTypes: { MODAL_TYPE_CANCEL }, popModalWindow } = this.props;

// Just closing the modal
popModalWindow({ status: CANCEL });
popModalWindow({ status: MODAL_TYPE_CANCEL });
}
}
6 changes: 3 additions & 3 deletions example/src/components/RemoveFileDialog.js
Expand Up @@ -2,13 +2,13 @@ import React from 'react';
import PropTypes from 'prop-types';

const RemoveFileDialog = props => {
const { fileName, resultTypes: { CONFIRM, CANCEL }, popModalWindow } = props;
const { fileName, resultTypes: { MODAL_TYPE_CONFIRM, MODAL_TYPE_CANCEL }, popModalWindow } = props;

return (
<div>
<p>Remove {fileName}?</p>
<button type="button" onClick={() => popModalWindow({ type: CONFIRM })}>Confirm</button>
<button type="button" onClick={() => popModalWindow({ type: CANCEL })}>Cancel</button>
<button type="button" onClick={() => popModalWindow({ status: MODAL_TYPE_CONFIRM })}>Confirm</button>
<button type="button" onClick={() => popModalWindow({ status: MODAL_TYPE_CANCEL })}>Cancel</button>
</div>
);
};
Expand Down

0 comments on commit 92f1467

Please sign in to comment.