Added work item details to activity
This commit is contained in:
@@ -27,10 +27,11 @@ import { reactAutoBind } from "auto-bind2"
|
|||||||
import KeyboardSpacer from "react-native-keyboard-spacer"
|
import KeyboardSpacer from "react-native-keyboard-spacer"
|
||||||
import { isIphoneX } from "react-native-iphone-x-helper"
|
import { isIphoneX } from "react-native-iphone-x-helper"
|
||||||
import { api } from "../API"
|
import { api } from "../API"
|
||||||
import { formatLatLng } from "../util"
|
import { formatLatLng, workItemTypeEnum } from "../util"
|
||||||
import moment from "moment"
|
import moment from "moment"
|
||||||
import "url-search-params-polyfill"
|
import "url-search-params-polyfill"
|
||||||
import { config } from "../config"
|
import { config } from "../config"
|
||||||
|
import { FormStaticOptionStrip } from "../ui/FormStaticOptionStrip"
|
||||||
|
|
||||||
const styles = StyleSheet.create({
|
const styles = StyleSheet.create({
|
||||||
container: {
|
container: {
|
||||||
@@ -124,6 +125,8 @@ export class Activity extends React.Component {
|
|||||||
),
|
),
|
||||||
location: formatLatLng(lat, lng),
|
location: formatLatLng(lat, lng),
|
||||||
dateTime: moment().format(),
|
dateTime: moment().format(),
|
||||||
|
details: workItem.details,
|
||||||
|
workItemType: workItem.workItemType,
|
||||||
})
|
})
|
||||||
|
|
||||||
this.region = {
|
this.region = {
|
||||||
@@ -288,6 +291,8 @@ export class Activity extends React.Component {
|
|||||||
waitModal,
|
waitModal,
|
||||||
dateTime,
|
dateTime,
|
||||||
location,
|
location,
|
||||||
|
details,
|
||||||
|
workItemType,
|
||||||
uploadPercent,
|
uploadPercent,
|
||||||
} = this.state
|
} = this.state
|
||||||
|
|
||||||
@@ -301,14 +306,6 @@ export class Activity extends React.Component {
|
|||||||
rightButton={{ icon: "done", onPress: this.handleDonePress }}
|
rightButton={{ icon: "done", onPress: this.handleDonePress }}
|
||||||
/>
|
/>
|
||||||
<ScrollView style={styles.container}>
|
<ScrollView style={styles.container}>
|
||||||
<View style={styles.panel}>
|
|
||||||
<BoundInput
|
|
||||||
binder={binder}
|
|
||||||
name="resolution"
|
|
||||||
label="Resolution:"
|
|
||||||
message="You must supply a resolution for the activity"
|
|
||||||
/>
|
|
||||||
</View>
|
|
||||||
<View style={styles.panel}>
|
<View style={styles.panel}>
|
||||||
<BoundOptionStrip
|
<BoundOptionStrip
|
||||||
binder={binder}
|
binder={binder}
|
||||||
@@ -322,17 +319,34 @@ export class Activity extends React.Component {
|
|||||||
name="status"
|
name="status"
|
||||||
message="You must supply a status for the activity"
|
message="You must supply a status for the activity"
|
||||||
/>
|
/>
|
||||||
</View>
|
<BoundInput
|
||||||
<View style={styles.panel}>
|
binder={binder}
|
||||||
|
name="resolution"
|
||||||
|
label="Resolution:"
|
||||||
|
message="You must supply a resolution for the activity"
|
||||||
|
/>
|
||||||
<BoundInput
|
<BoundInput
|
||||||
binder={binder}
|
binder={binder}
|
||||||
name="notes"
|
name="notes"
|
||||||
label="Notes:"
|
label="Notes:"
|
||||||
message="You must supply notes for the activity"
|
message="You must supply notes for the activity"
|
||||||
/>
|
/>
|
||||||
|
<FormStaticInput label="Date & Time:" value={dateTime} />
|
||||||
|
<BoundPhotoPanel
|
||||||
|
name="photos"
|
||||||
|
binder={binder}
|
||||||
|
onUploadStarted={this.handleUploadStarted}
|
||||||
|
onUploadProgress={this.handleUploadProgress}
|
||||||
|
onUploadEnded={this.handleUploadEnded}
|
||||||
|
/>
|
||||||
</View>
|
</View>
|
||||||
<View style={styles.panel}>
|
<View style={styles.panel}>
|
||||||
<FormStaticInput label="Date & Time:" value={dateTime} />
|
<FormStaticOptionStrip
|
||||||
|
label="Work Item Type:"
|
||||||
|
options={workItemTypeEnum}
|
||||||
|
value={workItemType}
|
||||||
|
/>
|
||||||
|
<FormStaticInput label="Details:" value={details} />
|
||||||
<FormStaticInput label="Location:" value={location} />
|
<FormStaticInput label="Location:" value={location} />
|
||||||
<View style={{ flexDirection: "column", justifyContent: "center" }}>
|
<View style={{ flexDirection: "column", justifyContent: "center" }}>
|
||||||
<MapView
|
<MapView
|
||||||
@@ -369,15 +383,6 @@ export class Activity extends React.Component {
|
|||||||
/>
|
/>
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
<View style={styles.panel}>
|
|
||||||
<BoundPhotoPanel
|
|
||||||
name="photos"
|
|
||||||
binder={binder}
|
|
||||||
onUploadStarted={this.handleUploadStarted}
|
|
||||||
onUploadProgress={this.handleUploadProgress}
|
|
||||||
onUploadEnded={this.handleUploadEnded}
|
|
||||||
/>
|
|
||||||
</View>
|
|
||||||
{isIphoneX ? <View style={{ height: 30, width: "100%" }} /> : null}
|
{isIphoneX ? <View style={{ height: 30, width: "100%" }} /> : null}
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
<ProgressModal
|
<ProgressModal
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ export default class App extends React.Component {
|
|||||||
<Switch>
|
<Switch>
|
||||||
<Route exact path="/login" component={Login} />
|
<Route exact path="/login" component={Login} />
|
||||||
<Route exact path="/logout" component={Logout} />
|
<Route exact path="/logout" component={Logout} />
|
||||||
<ProtectedRoute exact path="/home" component={Home} />
|
{/* <ProtectedRoute exact path="/home" component={Home} /> */}
|
||||||
<ProtectedRoute
|
<ProtectedRoute
|
||||||
exact
|
exact
|
||||||
path="/arviewer"
|
path="/arviewer"
|
||||||
@@ -69,7 +69,8 @@ export default class App extends React.Component {
|
|||||||
path="/workItemList"
|
path="/workItemList"
|
||||||
component={WorkItemList}
|
component={WorkItemList}
|
||||||
/>
|
/>
|
||||||
<DefaultRoute redirect="/home" />
|
{/* <DefaultRoute redirect="/home" /> */}
|
||||||
|
<DefaultRoute redirect="/activity?workItemId=5b0c85995ebbed31c323cdf6" />
|
||||||
</Switch>
|
</Switch>
|
||||||
</View>
|
</View>
|
||||||
</NativeRouter>
|
</NativeRouter>
|
||||||
|
|||||||
@@ -100,6 +100,7 @@ export class WorkItem extends React.Component {
|
|||||||
messageModal: null,
|
messageModal: null,
|
||||||
waitModal: null,
|
waitModal: null,
|
||||||
progressModal: null,
|
progressModal: null,
|
||||||
|
allowLocationUpdates: false,
|
||||||
}
|
}
|
||||||
this.region = null
|
this.region = null
|
||||||
this.isMapReady = false
|
this.isMapReady = false
|
||||||
@@ -151,6 +152,8 @@ export class WorkItem extends React.Component {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
} else {
|
||||||
|
this.setState({ allowLocationUpdates: true })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -221,7 +224,7 @@ export class WorkItem extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
handleRegionChange(region) {
|
handleRegionChange(region) {
|
||||||
if (this.state.binder._id || !this.isMapReady) {
|
if (!this.state.allowLocationUpdates || !this.isMapReady) {
|
||||||
// On iOS we get this after setting the initial region, before the map declared as ready!
|
// On iOS we get this after setting the initial region, before the map declared as ready!
|
||||||
// Also, if we are only viewing the work item, then don't allow region changes
|
// Also, if we are only viewing the work item, then don't allow region changes
|
||||||
return
|
return
|
||||||
@@ -349,8 +352,6 @@ export class WorkItem extends React.Component {
|
|||||||
options={workItemTypeEnum}
|
options={workItemTypeEnum}
|
||||||
message="Select a work item type"
|
message="Select a work item type"
|
||||||
/>
|
/>
|
||||||
</View>
|
|
||||||
<View style={styles.panel}>
|
|
||||||
<BoundInput
|
<BoundInput
|
||||||
binder={binder}
|
binder={binder}
|
||||||
name="details"
|
name="details"
|
||||||
@@ -358,8 +359,6 @@ export class WorkItem extends React.Component {
|
|||||||
label="Details:"
|
label="Details:"
|
||||||
message="You must supply details for the work item"
|
message="You must supply details for the work item"
|
||||||
/>
|
/>
|
||||||
</View>
|
|
||||||
<View style={styles.panel}>
|
|
||||||
<View style={{ flexDirection: "column", justifyContent: "center" }}>
|
<View style={{ flexDirection: "column", justifyContent: "center" }}>
|
||||||
<MapView
|
<MapView
|
||||||
ref={(ref) => (this.mapView = ref)}
|
ref={(ref) => (this.mapView = ref)}
|
||||||
@@ -406,8 +405,6 @@ export class WorkItem extends React.Component {
|
|||||||
name="address"
|
name="address"
|
||||||
label="Address:"
|
label="Address:"
|
||||||
/>
|
/>
|
||||||
</View>
|
|
||||||
<View style={styles.panel}>
|
|
||||||
<BoundPhotoPanel
|
<BoundPhotoPanel
|
||||||
name="photos"
|
name="photos"
|
||||||
binder={binder}
|
binder={binder}
|
||||||
@@ -429,7 +426,7 @@ export class WorkItem extends React.Component {
|
|||||||
)}
|
)}
|
||||||
{isIphoneX ? <View style={{ height: 30, width: "100%" }} /> : null}
|
{isIphoneX ? <View style={{ height: 30, width: "100%" }} /> : null}
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
{!this.state.binder._id && (
|
{!this.state.allowLocationUpdates && (
|
||||||
<Geolocation onUpdate={this.handlePositionUpdate} watch={false} />
|
<Geolocation onUpdate={this.handlePositionUpdate} watch={false} />
|
||||||
)}
|
)}
|
||||||
<ProgressModal
|
<ProgressModal
|
||||||
|
|||||||
@@ -85,10 +85,9 @@ export class BoundInput extends React.Component {
|
|||||||
<Text
|
<Text
|
||||||
style={{
|
style={{
|
||||||
fontSize: 12,
|
fontSize: 12,
|
||||||
display: valid ? "none" : "flex",
|
|
||||||
color: "red",
|
color: "red",
|
||||||
}}>
|
}}>
|
||||||
{message}
|
{valid ? " " : message}
|
||||||
</Text>
|
</Text>
|
||||||
</View>
|
</View>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -55,10 +55,9 @@ export class BoundOptionStrip extends React.Component {
|
|||||||
<Text
|
<Text
|
||||||
style={{
|
style={{
|
||||||
fontSize: 12,
|
fontSize: 12,
|
||||||
display: valid ? "none" : "flex",
|
|
||||||
color: "red",
|
color: "red",
|
||||||
}}>
|
}}>
|
||||||
{message}
|
{valid ? " " : message}
|
||||||
</Text>
|
</Text>
|
||||||
</View>
|
</View>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ export class FormStaticInput extends React.Component {
|
|||||||
underlineColorAndroid="white"
|
underlineColorAndroid="white"
|
||||||
value={value}
|
value={value}
|
||||||
/>
|
/>
|
||||||
|
<Text> </Text>
|
||||||
</View>
|
</View>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
33
mobile/src/ui/FormStaticOptionStrip.js
Normal file
33
mobile/src/ui/FormStaticOptionStrip.js
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
import React from "react"
|
||||||
|
import PropTypes from "prop-types"
|
||||||
|
import { Text, View, Platform } from "react-native"
|
||||||
|
import { OptionStrip } from "."
|
||||||
|
|
||||||
|
export class FormStaticOptionStrip extends React.Component {
|
||||||
|
static propTypes = {
|
||||||
|
label: PropTypes.string,
|
||||||
|
options: PropTypes.arrayOf(
|
||||||
|
PropTypes.shape({ value: PropTypes.string, text: PropTypes.string })
|
||||||
|
).isRequired,
|
||||||
|
value: PropTypes.string,
|
||||||
|
}
|
||||||
|
|
||||||
|
render() {
|
||||||
|
const { label, value, options } = this.props
|
||||||
|
|
||||||
|
return (
|
||||||
|
<View style={{ width: "100%" }}>
|
||||||
|
<Text
|
||||||
|
style={{
|
||||||
|
color: "black",
|
||||||
|
fontSize: 14,
|
||||||
|
marginBottom: 5,
|
||||||
|
}}>
|
||||||
|
{label}
|
||||||
|
</Text>
|
||||||
|
<OptionStrip value={value} readOnly options={options} />
|
||||||
|
<Text> </Text>
|
||||||
|
</View>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -9,6 +9,7 @@ export class OptionStrip extends Component {
|
|||||||
PropTypes.shape({ value: PropTypes.string, text: PropTypes.string })
|
PropTypes.shape({ value: PropTypes.string, text: PropTypes.string })
|
||||||
).isRequired,
|
).isRequired,
|
||||||
value: PropTypes.string,
|
value: PropTypes.string,
|
||||||
|
readOnly: PropTypes.bool,
|
||||||
onValueChanged: PropTypes.func,
|
onValueChanged: PropTypes.func,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -41,14 +42,15 @@ export class OptionStrip extends Component {
|
|||||||
handlePress(option) {
|
handlePress(option) {
|
||||||
const { onValueChanged } = this.props
|
const { onValueChanged } = this.props
|
||||||
|
|
||||||
this.setState({ selectedOption: option })
|
|
||||||
if (onValueChanged) {
|
if (onValueChanged) {
|
||||||
onValueChanged(option.value)
|
onValueChanged(option.value)
|
||||||
|
} else if (!this.props.readOnly) {
|
||||||
|
this.setState({ selectedOption: option })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { style, options, value } = this.props
|
const { style, options, value, readOnly } = this.props
|
||||||
const { selectedOption } = this.state
|
const { selectedOption } = this.state
|
||||||
|
|
||||||
// TODO: Handle visible, disabled & read-only
|
// TODO: Handle visible, disabled & read-only
|
||||||
@@ -58,6 +60,7 @@ export class OptionStrip extends Component {
|
|||||||
{options.map((option, index) => (
|
{options.map((option, index) => (
|
||||||
<TouchableHighlight
|
<TouchableHighlight
|
||||||
key={index}
|
key={index}
|
||||||
|
disabled={readOnly}
|
||||||
underlayColor="#3BB0FD"
|
underlayColor="#3BB0FD"
|
||||||
style={[
|
style={[
|
||||||
{
|
{
|
||||||
@@ -65,7 +68,11 @@ export class OptionStrip extends Component {
|
|||||||
flexBasis: 0,
|
flexBasis: 0,
|
||||||
height: 40,
|
height: 40,
|
||||||
backgroundColor:
|
backgroundColor:
|
||||||
option === selectedOption ? "#3BB0FD" : "#EEEEEE",
|
option !== selectedOption
|
||||||
|
? "#EEEEEE"
|
||||||
|
: readOnly
|
||||||
|
? "#AAAAAA"
|
||||||
|
: "#3BB0FD",
|
||||||
},
|
},
|
||||||
index === 0 && {
|
index === 0 && {
|
||||||
borderTopLeftRadius: 6,
|
borderTopLeftRadius: 6,
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ export { Geolocation } from "./Geolocation"
|
|||||||
export { BoundSwitch } from "./BoundSwitch"
|
export { BoundSwitch } from "./BoundSwitch"
|
||||||
export { BoundInput } from "./BoundInput"
|
export { BoundInput } from "./BoundInput"
|
||||||
export { FormStaticInput } from "./FormStaticInput"
|
export { FormStaticInput } from "./FormStaticInput"
|
||||||
|
export { FormStaticOptionStrip } from "./FormStaticOptionStrip"
|
||||||
export { BoundButton } from "./BoundButton"
|
export { BoundButton } from "./BoundButton"
|
||||||
export { BoundOptionStrip } from "./BoundOptionStrip"
|
export { BoundOptionStrip } from "./BoundOptionStrip"
|
||||||
export { BoundHeader } from "./BoundHeader"
|
export { BoundHeader } from "./BoundHeader"
|
||||||
|
|||||||
Reference in New Issue
Block a user