Skip to content

Commit

Permalink
OurLandHK#361 show mission summary in user profile
Browse files Browse the repository at this point in the history
  • Loading branch information
khmak3 committed Sep 26, 2018
1 parent 6bc90ae commit 3baf165
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 28 deletions.
2 changes: 1 addition & 1 deletion src/LocationDrawer.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ class LocationDrawer extends React.Component {
for(address of addressBook.publicAddresses) {
if(address.type !== addressEnum.home && address.type !== addressEnum.office) {
let newAddress = Object.create(address);
newAddress.text = `十八社區/${address.text}`;
newAddress.text = `${constant.regionEventLabel}/${address.text}`;
newAddress.geolocation = address.geolocation;
//console.log(newAddress.text);
addressList.push(newAddress)
Expand Down
16 changes: 1 addition & 15 deletions src/MessageView.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,21 +127,7 @@ class MessageView extends Component {
className={classes.urgentEventTag}
/>
}
/*
return(<GridListTile key={imageUrl} onClick={() => this.handleClick()}>
<img height={128} src={imageUrl} alt={text} />
<GridListTileBar
title={text}
subtitle={subtitle}
classes={{
root: classes.titleBar,
title: classes.tileTitle,
}}
>
{urgentEventTag}
</GridListTileBar>
</GridListTile>);
*/

return (<Card className={classes.tileCard} onClick={() => this.handleClick()}>
<CardMedia className={classes.tileMedia} image={imageUrl} title={auther}/>
<CardContent>
Expand Down
7 changes: 6 additions & 1 deletion src/Person.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import AddressDialog from './address/AddressDialog';
import FocusDialog from './admin/FocusDialog';
import {connect} from "react-redux";
import {checkImageExists} from './util/http';
import MissionView from './mission/MissionView';
import Divider from '@material-ui/core/Divider';
import {
toggleAddressDialog,
Expand Down Expand Up @@ -64,6 +65,7 @@ class Person extends Component {
let adminButton = null;
let publishMessage = null;
let completeMessage = null;
let missionHtml = null;
let focusButton = null;
let userProfileView = <UserProfileView ref={(userProfileView) => {this.userProfileView = userProfileView;}} openDialog={openDialog => this.openUserProfileDialog = openDialog}/>;
const { user } = this.props;
Expand All @@ -90,6 +92,7 @@ class Person extends Component {
</ListItem></span>);
publishMessage = <EventListDialog title="發表事件: " messageIds={user.userProfile.publishMessages}/>
completeMessage = <EventListDialog title="完成事件: " messageIds={user.userProfile.completeMessages}/>
missionHtml = <MissionView user={user.user} userProfile={user.userProfile} addressList={addressBook.addresses} bookmarkList={user.bookmarkList} publicProfileView={true}/>
if (user.userProfile != null & (user.userProfile.role === RoleEnum.admin || user.userProfile.role === RoleEnum.monitor)) {
focusButton = <FocusDialog/>;
}
Expand Down Expand Up @@ -118,6 +121,7 @@ class Person extends Component {
<Divider/>
<List disablePadding>
{userLoginDisplay}
{missionHtml}
{publishMessage}
{completeMessage}
<ListItem button>
Expand All @@ -137,7 +141,8 @@ class Person extends Component {

const mapStateToProps = (state, ownProps) => {
return {
user: state.user
user: state.user,
addressBook: state.addressBook,
};
}

Expand Down
5 changes: 3 additions & 2 deletions src/UserProfileView.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ class UserProfileView extends React.Component {
this.setState({interestedTags});
}
render() {
const { classes, user } = this.props;
const { classes, user, addressBook } = this.props;
var imgURL = '/images/profile_placeholder.png';
var publish = 0;
var concern = 0;
Expand Down Expand Up @@ -325,7 +325,8 @@ UserProfileView.propTypes = {
const mapStateToProps = (state, ownProps) => {
return {
user: state.user,
suggestions: state.suggestions
suggestions: state.suggestions,
addressBook: state.addressBook,
};
}

Expand Down
3 changes: 2 additions & 1 deletion src/config/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ let constant = {
bookmarkTitleLabel: "關注分類",
updateBookmarkLabel: "更新關注分類",
nearbyEventLabel: "我的社區",
regionEventLabel: "十八社區",
regionEventLabel: "我地正區",
recentEventLabel: "最近查看",
leaderBoardLabel: "排名榜",
noTagLabel: "所有事件",
Expand All @@ -61,6 +61,7 @@ let constant = {
missionDone: "大成功",
secretMission: "秘密任務",
mission: "任務",
missionComplete: "完成任務",
recentUpdate: "最近更新",
homeLabel: "主頁",
userLabel: "我的",
Expand Down
44 changes: 36 additions & 8 deletions src/mission/MissionView.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import { withStyles } from '@material-ui/core/styles';
import AppBar from '@material-ui/core/AppBar';
import Toolbar from '@material-ui/core/Toolbar';
import Typography from '@material-ui/core/Typography';
import Card from '@material-ui/core/Card';
import ListItem from '@material-ui/core/ListItem';
import CardMedia from '@material-ui/core/CardMedia';
import CardHeader from '@material-ui/core/CardHeader';
import ListItemText from '@material-ui/core/ListItemText';
import CloseIcon from '@material-ui/icons/Close';
import Slide from '@material-ui/core/Slide';
import Grid from '@material-ui/core/Grid'
Expand Down Expand Up @@ -74,8 +74,6 @@ function Transition(props) {
return fn.apply(window, userProfile, bookmarkList, addressLis);
}

const taskCheckingFunction = ['singleInput', 'fiveInput', 'tenInput']; //, 'fiveInput', 'tenInput'];

const taskCriterias = [
{
taskname: "第一次",
Expand Down Expand Up @@ -110,6 +108,17 @@ function Transition(props) {
badgeName: "一打",
badgeImage: "/images/squareLogo.jpg",
},
{
taskname: "一路發",
desc: "報料168次",
checkObjectinUserPorilfe: "publishMessages",
checkField: "length",
passCritera: "greater",
threshold: 168,
hideBeforeDone: true,
badgeName: "一路發",
badgeImage: "/images/squareLogo.jpg",
},
{
taskname: "八元位",
desc: "報料256次",
Expand All @@ -120,7 +129,7 @@ function Transition(props) {
hideBeforeDone: false,
badgeName: "8-Bit",
badgeImage: "/images/squareLogo.jpg",
}
},
];

function addressInputed(userProfile, bookmarkList, addressLis) {
Expand All @@ -133,6 +142,11 @@ class MissionView extends React.Component {
let userProfile = null;
let bookmarkList = [];
let addressList = [];
if(this.props.publicProfileView) {
this.publicProfileView = true;
} else {
this.publicProfileView = false;
}
if(this.props.userProfile) {
userProfile = this.props.userProfile;
}
Expand Down Expand Up @@ -176,6 +190,12 @@ class MissionView extends React.Component {
}
}

handleRequestOpen = () => {
if(this.state.userProfile) {
trackEvent('Mission', this.state.userProfile.displayName);
}
this.setState({open: true});
}

handleRequestClose = () => {
// window.history.pushState("", "", `/`)
Expand All @@ -187,15 +207,23 @@ class MissionView extends React.Component {
renderHighlightMission(taskList) {
const { classes } = this.props;
let rv = null;
let done = 0;
if(this.state.userProfile) {
taskList.map((task) => {
if(task.status != constant.missionDone) {
if(!rv) {
rv = this.renderTaskCard(task);
}
} else {
done++;
}
})
}
if(this.publicProfileView) {
rv = <ListItem >
<ListItemText primary={`${constant.missionComplete}: ${done}`} />
</ListItem>
}
return rv;
}

Expand Down Expand Up @@ -262,8 +290,8 @@ class MissionView extends React.Component {
badgeImage = "/images/secret.png"
badgeName = constant.secretMission;
if(taskCriteria.hideBeforeDone) {
let taskname = constant.secretMission;
let desc = constant.secretMission;
taskname = constant.secretMission;
desc = constant.secretMission;
}
}
let task = {
Expand Down Expand Up @@ -301,7 +329,7 @@ class MissionView extends React.Component {
}
return (
<React.Fragment>
<div onClick={() => this.setState({open: true})}>
<div onClick={this.handleRequestOpen}>
{card}
</div>
<Dialog fullScreen open={dialogOpen} onRequestClose={this.handleRequestClose} transition={Transition} unmountOnExit>
Expand Down

0 comments on commit 3baf165

Please sign in to comment.