mirror of
https://github.com/astuto/astuto.git
synced 2025-12-15 19:27:52 +01:00
Improve Roadmap and Board components
This commit is contained in:
@@ -102,10 +102,16 @@ class NewPost extends React.Component<Props, State> {
|
|||||||
});
|
});
|
||||||
this.setState({isLoading: false});
|
this.setState({isLoading: false});
|
||||||
|
|
||||||
if (res.status === 204) this.setState({success: 'Your post has been published!'});
|
if (res.status === 204) {
|
||||||
else {
|
this.setState({
|
||||||
|
success: 'Your post has been published!',
|
||||||
|
|
||||||
|
title: '',
|
||||||
|
description: '',
|
||||||
|
});
|
||||||
|
} else {
|
||||||
let data = await res.json();
|
let data = await res.json();
|
||||||
this.setState({error: data.message});
|
this.setState({error: data.error});
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|||||||
@@ -28,15 +28,20 @@ const PostList = ({ posts, areLoading, error, handleLoadMore, page, hasMore }: P
|
|||||||
loader={<Spinner key={0} />}
|
loader={<Spinner key={0} />}
|
||||||
useWindow={true}
|
useWindow={true}
|
||||||
>
|
>
|
||||||
{posts.map((post, i) => (
|
{
|
||||||
<PostListItem
|
posts.length > 0 ?
|
||||||
title={post.title}
|
posts.map((post, i) => (
|
||||||
description={post.description}
|
<PostListItem
|
||||||
postStatus={post.postStatus}
|
title={post.title}
|
||||||
|
description={post.description}
|
||||||
|
postStatus={post.postStatus}
|
||||||
|
|
||||||
key={i}
|
key={i}
|
||||||
/>
|
/>
|
||||||
))}
|
))
|
||||||
|
:
|
||||||
|
!areLoading ? <span className="infoText text-muted">There are no posts.</span> : null
|
||||||
|
}
|
||||||
</InfiniteScroll>
|
</InfiniteScroll>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ const SearchFilter = ({ searchQuery, handleChange }: Props) => (
|
|||||||
<div className="box sidebar-box">
|
<div className="box sidebar-box">
|
||||||
<label htmlFor="searchPostInput" className="smallTitle">Search:</label>
|
<label htmlFor="searchPostInput" className="smallTitle">Search:</label>
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="search"
|
||||||
onChange={e => handleChange(e.target.value)}
|
onChange={e => handleChange(e.target.value)}
|
||||||
id="searchPostInput"
|
id="searchPostInput"
|
||||||
className="form-control"
|
className="form-control"
|
||||||
|
|||||||
@@ -9,8 +9,6 @@ import IBoard from '../../interfaces/IBoard';
|
|||||||
import IPost from '../../interfaces/IPost';
|
import IPost from '../../interfaces/IPost';
|
||||||
import IPostStatus from '../../interfaces/IPostStatus';
|
import IPostStatus from '../../interfaces/IPostStatus';
|
||||||
|
|
||||||
import debounce from '../../helpers/debounce.js';
|
|
||||||
|
|
||||||
import '../../stylesheets/components/Board.scss';
|
import '../../stylesheets/components/Board.scss';
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
@@ -40,6 +38,8 @@ interface State {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class Board extends React.Component<Props, State> {
|
class Board extends React.Component<Props, State> {
|
||||||
|
searchFilterTimeoutId: number;
|
||||||
|
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
|
|
||||||
@@ -145,11 +145,13 @@ class Board extends React.Component<Props, State> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
setSearchFilter(searchQuery: string) {
|
setSearchFilter(searchQuery: string) {
|
||||||
debounce(() => (
|
if (this.searchFilterTimeoutId) clearInterval(this.searchFilterTimeoutId);
|
||||||
|
|
||||||
|
this.searchFilterTimeoutId = setTimeout(() => (
|
||||||
this.setState({
|
this.setState({
|
||||||
filters: { ...this.state.filters, searchQuery },
|
filters: { ...this.state.filters, searchQuery },
|
||||||
}, this.requestPosts)
|
}, this.requestPosts)
|
||||||
), 1000)();
|
), 500);
|
||||||
}
|
}
|
||||||
|
|
||||||
setPostStatusFilter(postStatusId: number) {
|
setPostStatusFilter(postStatusId: number) {
|
||||||
|
|||||||
@@ -12,14 +12,19 @@ interface Props {
|
|||||||
|
|
||||||
const PostList = ({ posts, boards }: Props) => (
|
const PostList = ({ posts, boards }: Props) => (
|
||||||
<div className="postList">
|
<div className="postList">
|
||||||
{posts.map((post, i) => (
|
{
|
||||||
<PostListItem
|
posts.length > 0 ?
|
||||||
title={post.title}
|
posts.map((post, i) => (
|
||||||
boardName={boards.find(board => board.id === post.board_id).name}
|
<PostListItem
|
||||||
|
title={post.title}
|
||||||
|
boardName={boards.find(board => board.id === post.board_id).name}
|
||||||
|
|
||||||
key={i}
|
key={i}
|
||||||
/>
|
/>
|
||||||
))}
|
))
|
||||||
|
:
|
||||||
|
<span className="infoText text-muted">There are no posts that have this status.</span>
|
||||||
|
}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +0,0 @@
|
|||||||
// https://toughcompetent.com/blog/es5-es6-debounce-react-events-on-inputs/
|
|
||||||
function debounce(a,b,c){var d,e;return function(){function h(){d=null,c||(e=a.apply(f,g))}var f=this,g=arguments;return clearTimeout(d),d=setTimeout(h,b),c&&!d&&(e=a.apply(f,g)),e}}
|
|
||||||
|
|
||||||
export default debounce;
|
|
||||||
@@ -39,7 +39,6 @@
|
|||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
align-items: flex-start;
|
align-items: flex-start;
|
||||||
flex-wrap: nowrap;
|
flex-wrap: nowrap;
|
||||||
|
|
||||||
|
|
||||||
.sidebar {
|
.sidebar {
|
||||||
.sidebar-box {
|
.sidebar-box {
|
||||||
@@ -208,4 +207,10 @@
|
|||||||
margin-top: auto;
|
margin-top: auto;
|
||||||
margin-bottom: auto;
|
margin-bottom: auto;
|
||||||
margin-right: 4px;
|
margin-right: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.infoText {
|
||||||
|
display: block;
|
||||||
|
text-align: center;
|
||||||
|
font-style: italic;
|
||||||
}
|
}
|
||||||
@@ -40,6 +40,11 @@
|
|||||||
height: 16px;
|
height: 16px;
|
||||||
border-radius: 100%;
|
border-radius: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.infoText {
|
||||||
|
text-align: center;
|
||||||
|
font-style: italic;
|
||||||
|
}
|
||||||
|
|
||||||
.columnTitle {
|
.columnTitle {
|
||||||
margin: 0 8px;
|
margin: 0 8px;
|
||||||
|
|||||||
Reference in New Issue
Block a user