Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for #206, show authors, issues & articles editors in Dialog boxes on admin site #217

Merged
merged 9 commits into from
Oct 5, 2017
24 changes: 21 additions & 3 deletions src/components/editor/EditorArticleController.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from 'react';
import FalcorController from 'lib/falcor/FalcorController';
import { browserHistory } from 'react-router';
import _ from 'lodash';
import EditAuthorsForm from './EditAuthorsForm';
import { debounce } from 'lib/utilities';
Expand All @@ -8,6 +9,7 @@ import moment from 'moment';
import { updateFieldValue } from 'components/editor/lib/form-field-updaters';

// material-ui
import Dialog from 'material-ui/Dialog';
import CircularProgress from 'material-ui/CircularProgress';
import RaisedButton from 'material-ui/RaisedButton';
import Divider from 'material-ui/Divider';
Expand All @@ -21,6 +23,7 @@ const MAX_TEASER_LENGTH = 156;
export default class EditorArticleController extends FalcorController {
constructor(props) {
super(props);
this.handleDialogClose = this.handleDialogClose.bind(this);
this.isFormChanged = this.isFormChanged.bind(this);
this.handleSaveChanges = this.handleSaveChanges.bind(this);
this.handleAddAuthor = this.handleAddAuthor.bind(this);
Expand All @@ -36,6 +39,7 @@ export default class EditorArticleController extends FalcorController {
image: updateFieldValue.bind(this, 'image', undefined),
};
this.safeSetState({
open: true,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's remove this as described below.

changed: false,
saving: false,
authors: [],
Expand Down Expand Up @@ -121,6 +125,14 @@ export default class EditorArticleController extends FalcorController {
}
}

handleDialogClose() {
if (this.state.saving) return;

const page = this.props.params.page;
const path = `/articles/page/${page}`;
browserHistory.push(path);
}

handleSaveChanges(event) {
event.preventDefault();

Expand Down Expand Up @@ -349,8 +361,14 @@ export default class EditorArticleController extends FalcorController {
}

return (
<div style={styles.innerPaper}>
<h2>Article Editor: {article.title}</h2>
<Dialog
title="Article Editor"
open={this.state.open}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's just change this to just open (the implicit way of writing open={true}) since we never change this, we "close" this by routing away.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh I kinda overlooked this.. will change it now!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and thanks for bringing me onboard :D

modal={false}
autoScrollBodyContent
onRequestClose={this.handleDialogClose}
>
<h2>{article.title}</h2>
<Divider />
<TextField
disabled
Expand Down Expand Up @@ -435,7 +453,7 @@ export default class EditorArticleController extends FalcorController {
onClick={this.unpublish}
icon={<Warning />}
/>
</div>
</Dialog>
);
}
return (
Expand Down