mirror of
https://git.rwth-aachen.de/acs/public/villas/web/
synced 2025-03-09 00:00:01 +01:00
Ensure unique node and simulator names in dialogs
Node names are checked to be unique in dialogs Simulator names are checked to be unique in dialogs on one node
This commit is contained in:
parent
e390776480
commit
47570d74d0
5 changed files with 10 additions and 10 deletions
|
@ -60,11 +60,11 @@ class NewNodeDialog extends React.Component {
|
|||
var endpoint = true;
|
||||
var name = true;
|
||||
|
||||
if (this.state.name === '') {
|
||||
if (this.state.name === '' || this.props.nodes.find(node => node._id !== this.state._id && node.name === this.state.name) !== undefined) {
|
||||
name = false;
|
||||
}
|
||||
|
||||
if (this.state.endpoint === '') {
|
||||
if (this.state.endpoint === '' || this.props.nodes.find(node => node._id !== this.state._id && node.endpoint === this.state.endpoint) !== undefined) {
|
||||
endpoint = false;
|
||||
}
|
||||
|
||||
|
|
|
@ -63,7 +63,7 @@ class EditSimulatorDialog extends Component {
|
|||
// check all controls
|
||||
var name = true;
|
||||
|
||||
if (this.state.name === '') {
|
||||
if (this.state.name === '' || this.props.node.simulators.find(simulator => this.props.simulator.name !== this.state.name && simulator.name === this.state.name) !== undefined) {
|
||||
name = false;
|
||||
}
|
||||
|
||||
|
|
|
@ -59,11 +59,11 @@ class NewNodeDialog extends React.Component {
|
|||
var endpoint = true;
|
||||
var name = true;
|
||||
|
||||
if (this.state.name === '') {
|
||||
if (this.state.name === '' || this.props.nodes.find(node => node.name === this.state.name) !== undefined) {
|
||||
name = false;
|
||||
}
|
||||
|
||||
if (this.state.endpoint === '') {
|
||||
if (this.state.endpoint === '' || this.props.nodes.find(node => node.endpoint === this.state.endpoint) !== undefined) {
|
||||
endpoint = false;
|
||||
}
|
||||
|
||||
|
|
|
@ -60,7 +60,7 @@ class NewSimulatorDialog extends Component {
|
|||
// check all controls
|
||||
var name = true;
|
||||
|
||||
if (this.state.name === '') {
|
||||
if (this.state.name === '' || this.props.node.simulators.find(simulator => simulator.name === this.state.name) !== undefined) {
|
||||
name = false;
|
||||
}
|
||||
|
||||
|
|
|
@ -200,12 +200,12 @@ class Simulators extends Component {
|
|||
|
||||
<NodeTree data={this.state.nodes} onDataChange={(treeData) => this.onTreeDataChange(treeData)} onNodeDelete={(node) => this.showDeleteNodeModal(node)} onNodeEdit={(node) => this.showEditNodeModal(node)} onNodeAdd={(node) => this.showAddSimulatorModal(node)} onSimulatorEdit={(node, index) => this.showEditSimulatorModal(node, index)} onSimulatorDelete={(node, index) => this.showDeleteSimulatorModal(node, index)} />
|
||||
|
||||
<NewNodeDialog show={this.state.newNodeModal} onClose={(data) => this.closeNewNodeModal(data)} />
|
||||
<EditNodeDialog node={this.state.modalData} show={this.state.editNodeModal} onClose={(data) => this.closeEditNodeModal(data)} />
|
||||
<NewSimulatorDialog show={this.state.addSimulatorModal} onClose={(data) => this.closeAddSimulatorModal(data)} />
|
||||
<NewNodeDialog show={this.state.newNodeModal} onClose={(data) => this.closeNewNodeModal(data)} nodes={this.state.nodes} />
|
||||
<EditNodeDialog node={this.state.modalData} show={this.state.editNodeModal} onClose={(data) => this.closeEditNodeModal(data)} nodes={this.state.nodes} />
|
||||
<NewSimulatorDialog show={this.state.addSimulatorModal} onClose={(data) => this.closeAddSimulatorModal(data)} node={this.state.modalData}/>
|
||||
|
||||
{this.state.editSimulatorModal &&
|
||||
<EditSimulatorDialog simulator={this.state.modalData.simulators[this.state.modalIndex]} show={this.state.editSimulatorModal} onClose={(data) => this.closeEditSimulatorModal(data)} />
|
||||
<EditSimulatorDialog simulator={this.state.modalData.simulators[this.state.modalIndex]} show={this.state.editSimulatorModal} onClose={(data) => this.closeEditSimulatorModal(data)} node={this.state.modalData} />
|
||||
}
|
||||
|
||||
<Modal show={this.state.deleteNodeModal}>
|
||||
|
|
Loading…
Add table
Reference in a new issue