Fix change email & reset password buttons. Fix sorting of lists. Fixed admin checkbox bug

This commit is contained in:
John Lyon-Smith
2018-05-14 15:13:48 -07:00
parent 5b4798b196
commit f88bcbdf92
13 changed files with 60 additions and 45 deletions

View File

@@ -16,7 +16,7 @@ export class MasterDetail extends Component {
updateItem: PropTypes.func.isRequired,
createItem: PropTypes.func.isRequired,
deleteItem: PropTypes.func.isRequired,
sort: PropTypes.func.isRequired,
listSort: PropTypes.func.isRequired,
detailCallbacks: PropTypes.object,
listData: PropTypes.func,
children: PropTypes.element,
@@ -44,7 +44,7 @@ export class MasterDetail extends Component {
this.props
.listItems()
.then((list) => {
this.setState({ items: list.items })
this.setState({ items: list.items.sort(this.props.listSort) })
const { history } = this.props
const search = new URLSearchParams(history.location.search)
@@ -68,10 +68,6 @@ export class MasterDetail extends Component {
})
}
get selectedItem() {
return this.state.selectedItem
}
@autobind
showWait(message) {
this.setState({
@@ -91,18 +87,22 @@ export class MasterDetail extends Component {
@autobind
showMessage(message, detail) {
this.setState({
icon: "thumb",
message,
detail,
messageModal: {
icon: "thumb",
message,
detail,
},
})
}
@autobind
showErrorMessage(message, detail) {
this.setState({
icon: "hand",
message,
detail,
messageModal: {
icon: "hand",
message,
detail,
},
})
}
@@ -116,6 +116,18 @@ export class MasterDetail extends Component {
})
}
@autobind
hideYesNo() {
this.setState({
yesNoModal: null,
})
}
@autobind
getSelectedItem() {
return this.state.selectedItem
}
@autobind
removeUnfinishedNewItem() {
let items = this.state.items
@@ -178,7 +190,7 @@ export class MasterDetail extends Component {
this.setState({
items: this.state.items
.map((item) => (!item._id ? createdItem : item))
.sort(this.props.sort),
.sort(this.props.listSort),
modified: false,
selectedItem: createdItem,
})
@@ -231,9 +243,7 @@ export class MasterDetail extends Component {
}
}
this.setState({
yesNoModal: null,
})
this.hideYesNo()
}
@autobind
@@ -247,9 +257,7 @@ export class MasterDetail extends Component {
delete this.nextSelectedItem
}
this.setState({
yesNoModal: null,
})
this.hideYesNo()
}
@autobind
@@ -312,7 +320,7 @@ export class MasterDetail extends Component {
color: colorInfo.headerBorder,
}}
radius={sizeInfo.formBoxRadius}>
{this.state.selectedItem ? (
{selectedItem ? (
React.createElement(this.props.form, {
item: selectedItem,
onSave: this.handleSave,