Enabling test server and bug fixes

This commit is contained in:
John Lyon-Smith
2018-04-20 17:40:55 -07:00
parent acfbc52cf9
commit f7c73ee277
15 changed files with 399 additions and 126 deletions

View File

@@ -51,24 +51,26 @@ const styles = StyleSheet.create({
export class Activity extends React.Component {
static bindings = {
dateTime: {
isValid: true,
header: {
noValue: true,
isDisabled: (r) => !(r.anyModified && r.allValid),
},
location: {
dateTime: {
isValid: (r, v) => v !== "",
isReadOnly: true,
},
details: {
isValid: true,
isValid: (r, v) => v !== "",
},
resolution: {
isValid: true,
isValid: (r, v) => v !== "",
},
notes: {
isValid: true,
isValid: (r, v) => v !== "",
},
status: {
isValid: true,
isValid: (r, v) => v !== "",
alwaysGet: true,
},
}
@@ -136,14 +138,55 @@ export class Activity extends React.Component {
}
}
@autobind
handleDonePress() {
const { binder } = this.state
let obj = binder.getModifiedFieldValues()
if (!obj._id) {
api
.createActivity(obj)
.then((activity) => {
this.handleBackPress()
})
.catch((error) => {
this.setState({
messageModal: {
icon: "hand",
message: "Unable to create activity",
detail: error.message,
},
})
})
} else {
api
.updateActivity(obj)
.then((activity) => {
this.handleBackPress()
})
.catch((error) => {
this.setState({
messageModal: {
icon: "hand",
message: "Unable to update activity",
detail: error.message,
},
})
})
}
}
render() {
const { binder, messageModal, region } = this.state
return (
<View style={{ width: "100%", height: "100%" }}>
<Header
title="Activity"
<BoundHeader
binder={binder}
name="header"
title="Work Item"
leftButton={{ icon: "back", onPress: this.handleBackPress }}
rightButton={{ icon: "done", onPress: this.handleDonePress }}
/>
<ScrollView style={styles.container}>
<View style={styles.panel}>