Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Nov 1, 2021. It is now read-only.

Commitc87775f

Browse files
committed
refactor(normal-community): add jobsTable
1 parent92e6076 commitc87775f

File tree

9 files changed

+140
-11
lines changed

9 files changed

+140
-11
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
importReactfrom'react'
2+
3+
import{ICON_CMD}from'../../config'
4+
import{Popover,BannerCountBrief}from'../../components'
5+
6+
import{
7+
BannerContentWrapper,
8+
Operation,
9+
OperationItem,
10+
OperationDivider,
11+
OperationTitle,
12+
OperationIcon,
13+
OperationIconChart,
14+
}from'./styles/common_banner'
15+
16+
import*aslogicfrom'./logic'
17+
18+
constJobsBanner=({ filteredCount, totalCount})=>(
19+
<BannerContentWrapper>
20+
<BannerCountBrieffilteredCount={filteredCount}totalCount={totalCount}/>
21+
<Operation>
22+
<OperationItemonClick={console.log}>
23+
<OperationIconChartsrc={`${ICON_CMD}/refresh.svg`}/>
24+
刷新
25+
</OperationItem>
26+
<OperationDivider/>
27+
<OperationItem>
28+
<OperationIconsrc={`${ICON_CMD}/filter2.svg`}/>
29+
<Popover
30+
content={<div>兼容各个页面的 Filter 菜单</div>}
31+
trigger="hover"
32+
>
33+
<OperationTitle>过滤</OperationTitle>
34+
</Popover>
35+
</OperationItem>
36+
<OperationDivider/>
37+
<OperationItemonClick={logic.onAdd}>
38+
<OperationIconChartsrc={`${ICON_CMD}/plus.svg`}/>
39+
添加
40+
</OperationItem>
41+
<OperationDivider/>
42+
<OperationItem>
43+
<OperationIconsrc={`${ICON_CMD}/chart.svg`}/>
44+
图表
45+
</OperationItem>
46+
</Operation>
47+
</BannerContentWrapper>
48+
)
49+
50+
exportdefaultJobsBanner

‎containers/CommunityBanner/PostsBanner.js‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ class PostsBanner extends React.Component {
3030
totalCount={totalCount}
3131
/>
3232
<Operation>
33+
<OperationItemonClick={console.log}>
34+
<OperationIconChartsrc={`${ICON_CMD}/refresh.svg`}/>
35+
刷新
36+
</OperationItem>
37+
<OperationDivider/>
3338
<OperationItem>
3439
<OperationIconsrc={`${ICON_CMD}/filter2.svg`}/>
3540
<Popover

‎containers/CommunityBanner/index.js‎

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { makeDebugger, storePlug, stripMobx, ROUTE } from '../../utils'
1313
import*aslogicfrom'./logic'
1414

1515
importPostsBannerfrom'./PostsBanner'
16+
importJobsBannerfrom'./JobsBanner'
1617
importTagsBannerfrom'./TagsBanner'
1718
importThreadsBannerfrom'./ThreadsBanner'
1819
importSubscribersBannerfrom'./SubscribersBanner'
@@ -26,10 +27,11 @@ const debug = makeDebugger('C:CommunityBanner')
2627
constChildBanner=({
2728
curRoute,
2829
postsTotalCount,
30+
jobsTotalCount,
2931
tagsTotalCount,
3032
restProps,
3133
})=>{
32-
const{ filteredPostsCount}=restProps
34+
const{ filteredPostsCount, filteredJobsCount}=restProps
3335

3436
switch(curRoute.subPath){
3537
caseROUTE.POSTS:{
@@ -40,6 +42,14 @@ const ChildBanner = ({
4042
/>
4143
)
4244
}
45+
caseROUTE.JOBS:{
46+
return(
47+
<JobsBanner
48+
totalCount={jobsTotalCount}
49+
filteredCount={filteredJobsCount}
50+
/>
51+
)
52+
}
4353
caseROUTE.SUBSCRIBERS:{
4454
return<SubscribersBannertotalCount={100}filteredCount={10}/>
4555
}
@@ -68,13 +78,19 @@ class CommunityBannerContainer extends React.Component {
6878

6979
render(){
7080
const{ communityBanner}=this.props
71-
const{ route, postsTotalCount, tagsTotalCount}=communityBanner
81+
const{
82+
curRoute,
83+
postsTotalCount,
84+
jobsTotalCount,
85+
tagsTotalCount,
86+
}=communityBanner
7287

7388
return(
7489
<BannerContainer>
7590
<ChildBanner
76-
curRoute={route}
91+
curRoute={curRoute}
7792
postsTotalCount={postsTotalCount}
93+
jobsTotalCount={jobsTotalCount}
7894
tagsTotalCount={tagsTotalCount}
7995
restProps={stripMobx(communityBanner)}
8096
/>

‎containers/CommunityBanner/store.js‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ const CommunityBannerStore = t
1515
.model('CommunityBannerStore',{
1616
// postsTotalCount: t.optional(t.number, 0),
1717
filteredPostsCount:t.maybeNull(t.number),
18+
filteredJobsCount:t.maybeNull(t.number),
1819
// tagsTotalCount: t.optional(t.number, 0),
1920
})
2021
.views(self=>({
@@ -24,10 +25,13 @@ const CommunityBannerStore = t
2425
getpostsTotalCount(){
2526
returnself.root.communityContent.pagedPosts.totalCount
2627
},
28+
getjobsTotalCount(){
29+
returnself.root.communityContent.pagedJobs.totalCount
30+
},
2731
gettagsTotalCount(){
2832
returnself.root.communityContent.pagedTags.length
2933
},
30-
getroute(){
34+
getcurRoute(){
3135
const{ mainPath, subPath}=self.root.route
3236
return{
3337
mainPath,
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
importReactfrom'react'
2+
3+
importJobsTablefrom'../../components/JobsTable'
4+
import*aslogicfrom'./logic'
5+
6+
constJobsContent=({ data,restProps:{ jobsLoading}})=>(
7+
<JobsTable
8+
data={data}
9+
loading={jobsLoading}
10+
onDelete={logic.onDelete}
11+
onEdit={logic.onEdit}
12+
/>
13+
)
14+
15+
exportdefaultJobsContent

‎containers/CommunityContent/index.js‎

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { inject, observer } from 'mobx-react'
1212
import{makeDebugger,storePlug,ROUTE}from'../../utils'
1313

1414
importPostsContentfrom'./PostsContent'
15+
importJobsContentfrom'./JobsContent'
1516
importTagsContentfrom'./TagsContent'
1617

1718
import{Wrapper}from'./styles'
@@ -21,15 +22,19 @@ import * as logic from './logic'
2122
constdebug=makeDebugger('C:CommunityContent')
2223
/* eslint-enable no-unused-vars */
2324

24-
constrenderChildContent=(curRoute,store,restProps)=>{
25-
const{ pagedPostsData, pagedTagsData}=store
26-
25+
constChildContent=({
26+
curRoute,
27+
pagedPostsData,
28+
pagedJobsData,
29+
pagedTagsData,
30+
restProps,
31+
})=>{
2732
switch(curRoute.subPath){
2833
caseROUTE.POSTS:{
2934
return<PostsContentdata={pagedPostsData}restProps={restProps}/>
3035
}
3136
caseROUTE.JOBS:{
32-
return<h3>ROUTE.JOBS</h3>
37+
return<JobsContentdata={pagedJobsData}restProps={restProps}/>
3338
}
3439
caseROUTE.REPOS:{
3540
return<h3>ROUTE.REPOS</h3>
@@ -61,12 +66,23 @@ class CommunityContentContainer extends React.Component {
6166

6267
render(){
6368
const{ communityContent}=this.props
64-
const{ curRoute}=communityContent
69+
const{
70+
curRoute,
71+
pagedPostsData,
72+
pagedJobsData,
73+
pagedTagsData,
74+
}=communityContent
6575
constrestProps={ ...communityContent}
6676

6777
return(
6878
<Wrapper>
69-
{renderChildContent(curRoute,communityContent,restProps)}
79+
<ChildContent
80+
curRoute={curRoute}
81+
pagedPostsData={pagedPostsData}
82+
pagedJobsData={pagedJobsData}
83+
pagedTagsData={pagedTagsData}
84+
restProps={restProps}
85+
/>
7086
</Wrapper>
7187
)
7288
}

‎containers/CommunityContent/logic.js‎

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,13 @@ export function loadPosts(page = 1) {
4343
sr71$.query(S.pagedPosts,commonFilter(page,community))
4444
}
4545

46+
exportfunctionloadJobs(page=1){
47+
scrollIntoEle(TYPE.APP_HEADER_ID)
48+
store.markState({jobsLoading:true})
49+
const{mainPath:community}=store.curRoute
50+
sr71$.query(S.pagedJobs,commonFilter(page,community))
51+
}
52+
4653
exportfunctionloadTags(){
4754
scrollIntoEle(TYPE.APP_HEADER_ID)
4855
store.markState({tagsLoading:true})
@@ -61,6 +68,7 @@ const cancleLoading = () => {
6168
store.markState({
6269
// communitiesLoading: false,
6370
postsLoading:false,
71+
jobsLoading:false,
6472
tagsLoading:false,
6573
})
6674
}
@@ -73,6 +81,13 @@ const DataSolver = [
7381
store.markState({ pagedPosts})
7482
},
7583
},
84+
{
85+
match:asyncRes('pagedJobs'),
86+
action:({ pagedJobs})=>{
87+
cancleLoading()
88+
store.markState({ pagedJobs})
89+
},
90+
},
7691
{
7792
match:asyncRes('partialTags'),
7893
action:({ partialTags})=>{
@@ -100,7 +115,7 @@ const DataSolver = [
100115
returnloadPosts()
101116
}
102117
caseROUTE.JOBS:{
103-
returnconsole.log('todo')
118+
returnloadJobs()
104119
}
105120
caseROUTE.REPOS:{
106121
returnconsole.log('todo')

‎containers/CommunityContent/store.js‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ const CommunityContentStore = t
5454
getpagedPostsData(){
5555
returnstripMobx(self.pagedPosts)
5656
},
57+
getpagedJobsData(){
58+
returnstripMobx(self.pagedJobs)
59+
},
5760
getpagedTagsData(){
5861
return{entries:stripMobx(self.pagedTags)}
5962
},

‎utils/ssr_helper.js‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,11 @@ const ssrCommunityContents = (subPath, resp) => {
5454
communityContent:{pagedPosts:resp.pagedPosts},
5555
}
5656
}
57+
caseROUTE.JOBS:{
58+
return{
59+
communityContent:{pagedJobs:resp.pagedJobs},
60+
}
61+
}
5762
caseROUTE.TAGS:{
5863
return{
5964
communityContent:{pagedTags:resp.partialTags},

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp