From 7dea9bf315c6402ace78f06352240224cd68bf8b Mon Sep 17 00:00:00 2001 From: Cynthia Date: Mon, 25 Sep 2017 17:53:40 -0400 Subject: [PATCH 1/9] fix for #206, add scroll to author & article pages --- src/components/editor/EditorArticleController.jsx | 13 ++++++++++++- .../editor/EditorArticleListController.jsx | 4 ++-- src/components/editor/EditorAuthorController.jsx | 13 ++++++++++++- .../editor/EditorAuthorListController.jsx | 2 +- 4 files changed, 27 insertions(+), 5 deletions(-) diff --git a/src/components/editor/EditorArticleController.jsx b/src/components/editor/EditorArticleController.jsx index add5e13f..c42a1268 100644 --- a/src/components/editor/EditorArticleController.jsx +++ b/src/components/editor/EditorArticleController.jsx @@ -119,6 +119,17 @@ export default class EditorArticleController extends FalcorController { // The update wasn't due to a change in article this.debouncedHandleFormStateChanges(); } + // scroll to article editor once page loads + const { hash } = window.location; + if (hash) { + setTimeout(() => { + const id = hash.replace('#', ''); + const element = document.getElementById(id); + if (element) { + element.scrollIntoView(); + } + }, 0); + } } handleSaveChanges(event) { @@ -349,7 +360,7 @@ export default class EditorArticleController extends FalcorController { } return ( -
+

Article Editor: {article.title}

+ { + const id = hash.replace('#', ''); + const element = document.getElementById(id); + if (element) { + element.scrollIntoView(); + } + }, 0); + } } handleSaveChanges(event) { @@ -245,7 +256,7 @@ export default class EditorAuthorController extends FalcorController { } return ( -
+

Author Profile: {this.state.name}

diff --git a/src/components/editor/EditorAuthorListController.jsx b/src/components/editor/EditorAuthorListController.jsx index 2bd04447..872d6ae3 100644 --- a/src/components/editor/EditorAuthorListController.jsx +++ b/src/components/editor/EditorAuthorListController.jsx @@ -60,7 +60,7 @@ export default class EditorAuthorListController extends FalcorController { } handleClickAuthor(author) { - browserHistory.push(`/authors/${author.slug}`); + browserHistory.push(`/authors/${author.slug}#author-profile`); } handleCreateAuthorChange() { From d3498a1028b85085b60b6e1b8e596793e60b245f Mon Sep 17 00:00:00 2001 From: Cynthia Date: Mon, 25 Sep 2017 23:50:40 -0400 Subject: [PATCH 2/9] move hash scroll to admin-client.js, add support for Issues page --- src/client-scripts/admin-client.js | 18 ++++++++++++++++++ .../editor/EditorArticleController.jsx | 11 ----------- .../editor/EditorAuthorController.jsx | 11 ----------- .../editor/EditorIssueListController.jsx | 10 +++++----- 4 files changed, 23 insertions(+), 27 deletions(-) diff --git a/src/client-scripts/admin-client.js b/src/client-scripts/admin-client.js index b53a9cd9..9dec7836 100644 --- a/src/client-scripts/admin-client.js +++ b/src/client-scripts/admin-client.js @@ -13,10 +13,28 @@ const clientModel = new falcor.Model({ source: new HttpDataSource('/model.json'), }); +function hashLinkScroll(retryCount = 0, retryLimit = 200) { + // scroll to the hash location once page loads, + // if element is not rendered yet, try again in 100ms + const { hash } = window.location; + if (hash) { + window.requestAnimationFrame(() => { + const id = hash.replace('#', ''); + const element = document.getElementById(id); + if (element) { + element.scrollIntoView(); + } else if (retryCount < retryLimit) { + setTimeout(hashLinkScroll(retryCount + 1), 100); + } + }, 0); + } +} + ReactDOM.render( , document.getElementById('main')); diff --git a/src/components/editor/EditorArticleController.jsx b/src/components/editor/EditorArticleController.jsx index c42a1268..0e888eb4 100644 --- a/src/components/editor/EditorArticleController.jsx +++ b/src/components/editor/EditorArticleController.jsx @@ -119,17 +119,6 @@ export default class EditorArticleController extends FalcorController { // The update wasn't due to a change in article this.debouncedHandleFormStateChanges(); } - // scroll to article editor once page loads - const { hash } = window.location; - if (hash) { - setTimeout(() => { - const id = hash.replace('#', ''); - const element = document.getElementById(id); - if (element) { - element.scrollIntoView(); - } - }, 0); - } } handleSaveChanges(event) { diff --git a/src/components/editor/EditorAuthorController.jsx b/src/components/editor/EditorAuthorController.jsx index 9d94e286..29da3b77 100644 --- a/src/components/editor/EditorAuthorController.jsx +++ b/src/components/editor/EditorAuthorController.jsx @@ -127,17 +127,6 @@ export default class EditorAuthorController extends FalcorController { // The update wasn't due to a change in article this.debouncedHandleFormStateChanges(); } - // scroll to author profile once page loads - const { hash } = window.location; - if (hash) { - setTimeout(() => { - const id = hash.replace('#', ''); - const element = document.getElementById(id); - if (element) { - element.scrollIntoView(); - } - }, 0); - } } handleSaveChanges(event) { diff --git a/src/components/editor/EditorIssueListController.jsx b/src/components/editor/EditorIssueListController.jsx index d0423e89..bc66393b 100644 --- a/src/components/editor/EditorIssueListController.jsx +++ b/src/components/editor/EditorIssueListController.jsx @@ -82,7 +82,7 @@ export default class EditorIssueListController extends FalcorController { if (issueNumber === 'none') { browserHistory.push('/issues'); } else { - browserHistory.push(`/issues/${issueNumber}/main`); + browserHistory.push(`/issues/${issueNumber}/main#issue-editor`); } } } @@ -227,7 +227,7 @@ export default class EditorIssueListController extends FalcorController { - + { currentIssueNumber ?
@@ -236,19 +236,19 @@ export default class EditorIssueListController extends FalcorController { label="MAIN" value="main" icon={} - containerElement={} + containerElement={} /> } - containerElement={} + containerElement={} /> } - containerElement={} + containerElement={} />
From 477d011da67eb70d65f3796beaa78e6e73d105c5 Mon Sep 17 00:00:00 2001 From: Cynthia Date: Wed, 27 Sep 2017 14:36:44 -0400 Subject: [PATCH 3/9] revert to 17c8d7a, cancel the scroll fix --- src/client-scripts/admin-client.js | 18 ------------------ .../editor/EditorArticleController.jsx | 2 +- .../editor/EditorArticleListController.jsx | 4 ++-- .../editor/EditorAuthorController.jsx | 2 +- .../editor/EditorAuthorListController.jsx | 2 +- .../editor/EditorIssueListController.jsx | 10 +++++----- 6 files changed, 10 insertions(+), 28 deletions(-) diff --git a/src/client-scripts/admin-client.js b/src/client-scripts/admin-client.js index 9dec7836..b53a9cd9 100644 --- a/src/client-scripts/admin-client.js +++ b/src/client-scripts/admin-client.js @@ -13,28 +13,10 @@ const clientModel = new falcor.Model({ source: new HttpDataSource('/model.json'), }); -function hashLinkScroll(retryCount = 0, retryLimit = 200) { - // scroll to the hash location once page loads, - // if element is not rendered yet, try again in 100ms - const { hash } = window.location; - if (hash) { - window.requestAnimationFrame(() => { - const id = hash.replace('#', ''); - const element = document.getElementById(id); - if (element) { - element.scrollIntoView(); - } else if (retryCount < retryLimit) { - setTimeout(hashLinkScroll(retryCount + 1), 100); - } - }, 0); - } -} - ReactDOM.render( , document.getElementById('main')); diff --git a/src/components/editor/EditorArticleController.jsx b/src/components/editor/EditorArticleController.jsx index 0e888eb4..add5e13f 100644 --- a/src/components/editor/EditorArticleController.jsx +++ b/src/components/editor/EditorArticleController.jsx @@ -349,7 +349,7 @@ export default class EditorArticleController extends FalcorController { } return ( -
+

Article Editor: {article.title}

+ +

Author Profile: {this.state.name}

diff --git a/src/components/editor/EditorAuthorListController.jsx b/src/components/editor/EditorAuthorListController.jsx index 872d6ae3..2bd04447 100644 --- a/src/components/editor/EditorAuthorListController.jsx +++ b/src/components/editor/EditorAuthorListController.jsx @@ -60,7 +60,7 @@ export default class EditorAuthorListController extends FalcorController { } handleClickAuthor(author) { - browserHistory.push(`/authors/${author.slug}#author-profile`); + browserHistory.push(`/authors/${author.slug}`); } handleCreateAuthorChange() { diff --git a/src/components/editor/EditorIssueListController.jsx b/src/components/editor/EditorIssueListController.jsx index bc66393b..d0423e89 100644 --- a/src/components/editor/EditorIssueListController.jsx +++ b/src/components/editor/EditorIssueListController.jsx @@ -82,7 +82,7 @@ export default class EditorIssueListController extends FalcorController { if (issueNumber === 'none') { browserHistory.push('/issues'); } else { - browserHistory.push(`/issues/${issueNumber}/main#issue-editor`); + browserHistory.push(`/issues/${issueNumber}/main`); } } } @@ -227,7 +227,7 @@ export default class EditorIssueListController extends FalcorController { - + { currentIssueNumber ?
@@ -236,19 +236,19 @@ export default class EditorIssueListController extends FalcorController { label="MAIN" value="main" icon={} - containerElement={} + containerElement={} /> } - containerElement={} + containerElement={} /> } - containerElement={} + containerElement={} />
From 6c19b951d1c33f7eaa9cd63efae435e85a617f6f Mon Sep 17 00:00:00 2001 From: Cynthia Date: Wed, 27 Sep 2017 16:17:44 -0400 Subject: [PATCH 4/9] add material ui Dialog to admin articles page --- .../editor/EditorArticleController.jsx | 178 ++++++++++-------- 1 file changed, 100 insertions(+), 78 deletions(-) diff --git a/src/components/editor/EditorArticleController.jsx b/src/components/editor/EditorArticleController.jsx index add5e13f..18be1ad9 100644 --- a/src/components/editor/EditorArticleController.jsx +++ b/src/components/editor/EditorArticleController.jsx @@ -8,6 +8,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'; @@ -21,6 +22,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); @@ -36,6 +38,7 @@ export default class EditorArticleController extends FalcorController { image: updateFieldValue.bind(this, 'image', undefined), }; this.safeSetState({ + open: true, changed: false, saving: false, authors: [], @@ -92,6 +95,7 @@ export default class EditorArticleController extends FalcorController { super.componentWillReceiveProps(nextProps, undefined, falcorCallback); this.safeSetState({ + open: true, changed: false, saving: false, authors: [], @@ -121,6 +125,10 @@ export default class EditorArticleController extends FalcorController { } } + handleDialogClose() { + this.safeSetState({ open: false }); + } + handleSaveChanges(event) { event.preventDefault(); @@ -348,93 +356,107 @@ export default class EditorArticleController extends FalcorController { } } + // Dialog action button + const actions = [ + , + ]; + return (
-

Article Editor: {article.title}

- - - - - { - _.map(categories, category => ( - - )) - } - +

{article.title}

+
-
- + + + { + _.map(categories, category => ( + + )) + } + +
+
+ + +
+ +
+ { + article.published_at + ? `This article was published on ${ + moment(article.published_at).format('MMMM DD, YYYY') + }.` + : 'The article has yet to be published. It will be published automatically ' + + 'when you publish the issue that contains it.' + }
} /> - -
- -
- { - article.published_at - ? `This article was published on ${ - moment(article.published_at).format('MMMM DD, YYYY') - }.` - : 'The article has yet to be published. It will be published automatically ' + - 'when you publish the issue that contains it.' - }
- } - /> +
); } From 804300f0d31b39a07a1704bfdad3fa6d5eb65c80 Mon Sep 17 00:00:00 2001 From: Cynthia Date: Sun, 1 Oct 2017 23:14:20 -0400 Subject: [PATCH 5/9] fix submit issue, enable page redirect in articles page --- .../editor/EditorArticleController.jsx | 188 +++++++++--------- 1 file changed, 92 insertions(+), 96 deletions(-) diff --git a/src/components/editor/EditorArticleController.jsx b/src/components/editor/EditorArticleController.jsx index 18be1ad9..65643783 100644 --- a/src/components/editor/EditorArticleController.jsx +++ b/src/components/editor/EditorArticleController.jsx @@ -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'; @@ -95,7 +96,6 @@ export default class EditorArticleController extends FalcorController { super.componentWillReceiveProps(nextProps, undefined, falcorCallback); this.safeSetState({ - open: true, changed: false, saving: false, authors: [], @@ -126,7 +126,11 @@ export default class EditorArticleController extends FalcorController { } handleDialogClose() { - this.safeSetState({ open: false }); + if (this.state.saving) return; + + const page = this.props.params.page; + const path = `/articles/page/${page}`; + browserHistory.push(path); } handleSaveChanges(event) { @@ -356,108 +360,100 @@ export default class EditorArticleController extends FalcorController { } } - // Dialog action button - const actions = [ - , - ]; - return ( -
- +

{article.title}

+ + +
-

{article.title}

- + + { + _.map(categories, category => ( + + )) + } + +

+ - - - { - _.map(categories, category => ( - - )) - } - -
-
- - -
- -
- { - article.published_at - ? `This article was published on ${ - moment(article.published_at).format('MMMM DD, YYYY') - }.` - : 'The article has yet to be published. It will be published automatically ' + - 'when you publish the issue that contains it.' - }
} + type="submit" + disabled={!this.state.changed || this.state.saving} /> -
-
+ +
+ +
+ { + article.published_at + ? `This article was published on ${ + moment(article.published_at).format('MMMM DD, YYYY') + }.` + : 'The article has yet to be published. It will be published automatically ' + + 'when you publish the issue that contains it.' + }
+ } + /> + ); } return ( From 651ec48c40c6294fbb12602aece0022cb197bfe2 Mon Sep 17 00:00:00 2001 From: Cynthia Date: Tue, 3 Oct 2017 21:47:51 -0400 Subject: [PATCH 6/9] fix small problems with Dialog and add to Authors & Issues page --- .../editor/EditorArticleController.jsx | 3 +- .../editor/EditorAuthorController.jsx | 121 ++++++++++-------- .../editor/EditorIssueListController.jsx | 24 +++- 3 files changed, 89 insertions(+), 59 deletions(-) diff --git a/src/components/editor/EditorArticleController.jsx b/src/components/editor/EditorArticleController.jsx index 65643783..fbff32c6 100644 --- a/src/components/editor/EditorArticleController.jsx +++ b/src/components/editor/EditorArticleController.jsx @@ -39,7 +39,6 @@ export default class EditorArticleController extends FalcorController { image: updateFieldValue.bind(this, 'image', undefined), }; this.safeSetState({ - open: true, changed: false, saving: false, authors: [], @@ -363,7 +362,7 @@ export default class EditorArticleController extends FalcorController { return ( -

Author Profile: {this.state.name}

- -
-
-
-
-
-
- - -
+ +
+

Author Profile: {this.state.name}

+ +
+
+
+
+
+
+ + +
+
); } return ( diff --git a/src/components/editor/EditorIssueListController.jsx b/src/components/editor/EditorIssueListController.jsx index d0423e89..56b9d9eb 100644 --- a/src/components/editor/EditorIssueListController.jsx +++ b/src/components/editor/EditorIssueListController.jsx @@ -6,6 +6,7 @@ import { updateFieldValue } from './lib/form-field-updaters'; import { stringToInt } from 'lib/utilities'; // material-ui +import Dialog from 'material-ui/Dialog'; import Paper from 'material-ui/Paper'; import Divider from 'material-ui/Divider'; import { Tabs, Tab } from 'material-ui/Tabs'; @@ -43,6 +44,7 @@ const styles = { export default class EditorIssueListController extends FalcorController { constructor(props) { super(props); + this.handleDialogClose = this.handleDialogClose.bind(this); this.addIssue = this.addIssue.bind(this); this.fieldUpdaters = { name: updateFieldValue.bind(this, 'name', undefined), @@ -87,6 +89,13 @@ export default class EditorIssueListController extends FalcorController { } } + handleDialogClose() { + if (this.state.saving) return; + + const path = '/issues'; + browserHistory.push(path); + } + addIssue(e) { e.preventDefault(); const issueName = this.state.name; @@ -227,10 +236,15 @@ export default class EditorIssueListController extends FalcorController {
- + +
{ currentIssueNumber ? -
+ Issue {currentIssueNumber}
-
+ {this.props.children} + : null } - {this.props.children} -
+
); } From dc3a2cc53181ee1016191dfcf980d91384bb89bf Mon Sep 17 00:00:00 2001 From: Emil Goldsmith Olesen Date: Wed, 4 Oct 2017 10:35:06 -0400 Subject: [PATCH 7/9] Removed redundant style object from EditorArticleController --- src/components/editor/EditorArticleController.jsx | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/components/editor/EditorArticleController.jsx b/src/components/editor/EditorArticleController.jsx index fbff32c6..bd0f8a52 100644 --- a/src/components/editor/EditorArticleController.jsx +++ b/src/components/editor/EditorArticleController.jsx @@ -318,11 +318,6 @@ export default class EditorArticleController extends FalcorController { marginTop: 24, marginBottom: 12, }, - innerPaper: { - paddingLeft: 30, - paddingRight: 30, - paddingBottom: 15, - }, }; if (this.state.ready) { From 081fefeafbbdc46de16f8dbee6d00aaaa486ab82 Mon Sep 17 00:00:00 2001 From: Cynthia Date: Thu, 5 Oct 2017 13:46:34 -0400 Subject: [PATCH 8/9] remove Dialog from Issues page --- .../editor/EditorIssueListController.jsx | 24 ++++--------------- 1 file changed, 5 insertions(+), 19 deletions(-) diff --git a/src/components/editor/EditorIssueListController.jsx b/src/components/editor/EditorIssueListController.jsx index 56b9d9eb..d0423e89 100644 --- a/src/components/editor/EditorIssueListController.jsx +++ b/src/components/editor/EditorIssueListController.jsx @@ -6,7 +6,6 @@ import { updateFieldValue } from './lib/form-field-updaters'; import { stringToInt } from 'lib/utilities'; // material-ui -import Dialog from 'material-ui/Dialog'; import Paper from 'material-ui/Paper'; import Divider from 'material-ui/Divider'; import { Tabs, Tab } from 'material-ui/Tabs'; @@ -44,7 +43,6 @@ const styles = { export default class EditorIssueListController extends FalcorController { constructor(props) { super(props); - this.handleDialogClose = this.handleDialogClose.bind(this); this.addIssue = this.addIssue.bind(this); this.fieldUpdaters = { name: updateFieldValue.bind(this, 'name', undefined), @@ -89,13 +87,6 @@ export default class EditorIssueListController extends FalcorController { } } - handleDialogClose() { - if (this.state.saving) return; - - const path = '/issues'; - browserHistory.push(path); - } - addIssue(e) { e.preventDefault(); const issueName = this.state.name; @@ -236,15 +227,10 @@ export default class EditorIssueListController extends FalcorController { - -
+ { currentIssueNumber ? - +
Issue {currentIssueNumber}
- {this.props.children} -
+
: null } -
+ {this.props.children} +
); } From 4b44343d6e171c6199c98a144aeec400d94cf072 Mon Sep 17 00:00:00 2001 From: Emil Goldsmith Olesen Date: Thu, 5 Oct 2017 16:15:53 -0400 Subject: [PATCH 9/9] Removed redundant Paper wrappers around modals --- src/components/editor/EditorArticleListController.jsx | 4 +--- src/components/editor/EditorAuthorListController.jsx | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/src/components/editor/EditorArticleListController.jsx b/src/components/editor/EditorArticleListController.jsx index 8a1fa10a..d3730199 100644 --- a/src/components/editor/EditorArticleListController.jsx +++ b/src/components/editor/EditorArticleListController.jsx @@ -147,9 +147,7 @@ export default class EditorArticleListController extends FalcorController { />
- - {this.props.children} - + {this.props.children}
); } diff --git a/src/components/editor/EditorAuthorListController.jsx b/src/components/editor/EditorAuthorListController.jsx index 2bd04447..15ac2390 100644 --- a/src/components/editor/EditorAuthorListController.jsx +++ b/src/components/editor/EditorAuthorListController.jsx @@ -161,9 +161,7 @@ export default class EditorAuthorListController extends FalcorController {
- - {this.props.children} - + {this.props.children}
);