From 6eebd9cc5e30de27e22d6a9b3768caa2439579a3 Mon Sep 17 00:00:00 2001 From: Luke Berndt Date: Mon, 25 Jan 2021 22:46:28 -0500 Subject: [PATCH] Fixed group modal --- README.md | 3 +++ admin/src/Group/GroupModal.js | 41 +++++++++++++++++++++++++++++------ admin/src/System/System.js | 2 +- 3 files changed, 38 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 0c5b16f..f9d4703 100644 --- a/README.md +++ b/README.md @@ -97,6 +97,9 @@ CNAMEs need to be created for the various services. Create the CNAMEs below with After doing this, you should have the following domains: api.domain.com, account.domain.com, media.domain.com, admin.domain.compose +openmhz.test:3000 + + ### Mailjet Sign up for MailJet! https://www.mailjet.com diff --git a/admin/src/Group/GroupModal.js b/admin/src/Group/GroupModal.js index 4f79c58..e84a330 100644 --- a/admin/src/Group/GroupModal.js +++ b/admin/src/Group/GroupModal.js @@ -65,18 +65,21 @@ class GroupModal extends Component { // we want to remove that are part of the Group from the list on the Left const group = { name: editGroup.groupName, items: items } this.setState({ group: group, talkgroups: talkgroups, groupName: editGroup.groupName }); - } else { - // If we are not editing, make sure there is the full list on the left. - this.setState({ talkgroups: this.props.talkgroups }) } - + + if (this.props.talkgroups && !prevProps.talkgroups) { + // If we are not editing, make sure there is the full list on the left. + this.setState({ talkgroups: [...this.props.talkgroups] }) + } + // If we are done editing, clear out the modal if (!this.props.editGroupId && (this.props.editGroupId !== prevProps.editGroupId)) { this.setState({ groupName: "", group: { name: "", items: [] - } + }, + talkgroups: [...this.props.talkgroups] }); } } @@ -120,10 +123,19 @@ class GroupModal extends Component { .concat(this.state.talkgroups.slice(index + 1)) }); } - handleClose = () => this.props.onClose(false); + handleClose = () => { + this.setState({ + groupName: "", group: { + name: "", + items: [] + }, + talkgroups: [...this.props.talkgroups] + }); + this.props.onClose(false); + } handleSubmit() { var talkgroupNums = this.state.group.items.map(a => a.num); - + if (this.props.editGroupId) { const data = { _id: this.props.editGroupId, @@ -132,6 +144,13 @@ class GroupModal extends Component { talkgroups: JSON.stringify(talkgroupNums) }; + this.setState({ + groupName: "", group: { + name: "", + items: [] + }, + talkgroups: [...this.props.talkgroups] + }); this.props.groupActions.updateGroup(data).then(requestMessage => { if (requestMessage) { // report to the user is there was a problem during registration @@ -150,6 +169,14 @@ class GroupModal extends Component { talkgroups: JSON.stringify(talkgroupNums) }; + this.setState({ + groupName: "", group: { + name: "", + items: [] + }, + talkgroups: [...this.props.talkgroups] + }); + this.props.groupActions.createGroup(data).then(requestMessage => { if (requestMessage) { // report to the user is there was a problem during registration diff --git a/admin/src/System/System.js b/admin/src/System/System.js index be69b1d..a15cc32 100644 --- a/admin/src/System/System.js +++ b/admin/src/System/System.js @@ -163,7 +163,7 @@ class System extends Component { } } - componentDidReceiveProps(prevProp) { + componentDidUpdate(prevProp) { // If we just received the error statistics for a system, for the first time, proccess them. if (this.props.errors && !prevProp.errors) {