Fixed createButton disabling bug

This commit is contained in:
Maximilian P. Käfer 2020-08-23 20:59:25 +02:00
parent 14ccf4ce58
commit 72ffa71d6b
2 changed files with 12 additions and 1 deletions

View File

@ -61,7 +61,9 @@ public class GroupCreationTab {
userList.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE); userList.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
eventBus.register(LoadGroupCreationEvent.class, e -> { eventBus.register(LoadGroupCreationEvent.class, e -> {
createButton.setDisable(true);
this.localDB = e.get(); this.localDB = e.get();
userList.getItems().clear();
Platform.runLater(() -> userList.getItems() Platform.runLater(() -> userList.getItems()
.addAll(localDB.getChats() .addAll(localDB.getChats()
.stream() .stream()
@ -90,7 +92,7 @@ public class GroupCreationTab {
* @since Envoy Client v0.1-beta * @since Envoy Client v0.1-beta
*/ */
@FXML @FXML
private void textUpdated() { createButton.setDisable(groupNameField.getText().isBlank()); } private void textUpdated() { createButton.setDisable(userList.getSelectionModel().isEmpty() || groupNameField.getText().isBlank()); }
/** /**
* Sends a {@link GroupCreation} to the server and closes this scene. * Sends a {@link GroupCreation} to the server and closes this scene.
@ -114,6 +116,7 @@ public class GroupCreationTab {
new Alert(AlertType.INFORMATION, String.format("Group '%s' successfully created.", name)).showAndWait(); new Alert(AlertType.INFORMATION, String.format("Group '%s' successfully created.", name)).showAndWait();
createGroup(name); createGroup(name);
} }
eventBus.dispatch(new BackEvent());
} }
/** /**

View File

@ -49,6 +49,14 @@
<Insets bottom="17.0" top="5.0" /> <Insets bottom="17.0" top="5.0" />
</padding> </padding>
</HBox> </HBox>
<Label text="Select Group Members" textAlignment="CENTER" textFill="WHITE">
<font>
<Font size="15.0" />
</font>
<VBox.margin>
<Insets top="5" bottom="5.0" />
</VBox.margin>
</Label>
<ListView id="chatList" fx:id="userList" focusTraversable="false" onMouseClicked="#userListClicked" prefWidth="316.0" VBox.vgrow="ALWAYS"> <ListView id="chatList" fx:id="userList" focusTraversable="false" onMouseClicked="#userListClicked" prefWidth="316.0" VBox.vgrow="ALWAYS">
<contextMenu> <contextMenu>
<ContextMenu anchorLocation="CONTENT_TOP_LEFT" /> <ContextMenu anchorLocation="CONTENT_TOP_LEFT" />