Skip to content

Commit

Permalink
update version
Browse files Browse the repository at this point in the history
  • Loading branch information
jkingster committed Mar 21, 2024
1 parent 7a040c2 commit 91b3143
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,12 @@ public class EmployeeManagerController extends Controller {
@FXML private TextField titleField;
@FXML private TextField departmentField;
@FXML private TextField emailField;
@FXML private TextField searchField;
@FXML private Button createButton;
@FXML private Button deleteButton;
@FXML private Button updateButton;
@FXML private Button searchButton;


@Override public void initialize(URL url, ResourceBundle resourceBundle) {
configureEmployeeList();
Expand Down Expand Up @@ -61,8 +64,15 @@ public class EmployeeManagerController extends Controller {
Notify.showError("Failed to delete.", "No employee was deleted.", "You must select an employee first.");
return;
}
employee.remove(selected.getId());
clearFields();

Notify.showConfirmation("Are you sure you want to delete this employee?", "This action cannot be undone.")
.ifPresent(type -> {
if (type == ButtonType.YES) {
employee.remove(selected.getId());
clearFields();
}
});

}

@FXML private void onUpdate() {
Expand All @@ -82,11 +92,57 @@ public class EmployeeManagerController extends Controller {
clearFields();
}

@FXML private void onSearch() {
final String text = searchField.getText();
for (final EmployeeModel model : employeeList.getItems()) {
final String name = model.getFullName();
if (containsIgnoreCase(name, text)) {
selectEmployee(model);
break;
}

final String email = model.getEmail();
if (containsIgnoreCase(email, text)) {
selectEmployee(model);
break;
}

final String title = model.getTitle();
if (containsIgnoreCase(title, text)) {
selectEmployee(model);
break;
}
}
}

private void selectEmployee(final EmployeeModel employee) {
employeeList.getSelectionModel().select(employee);
populateFields(employee);
}

// https://stackoverflow.com/questions/14018478/string-contains-ignore-case
private boolean containsIgnoreCase(String str, String searchStr) {
if (str == null || searchStr == null) return false;

final int length = searchStr.length();
if (length == 0)
return true;

for (int i = str.length() - length; i >= 0; i--) {
if (str.regionMatches(true, i, searchStr, 0, length))
return true;
}
return false;
}

private void configureButtons() {
createButton.disableProperty().bind(firstNameField.textProperty().isEmpty().or(lastNameField.textProperty().isEmpty()).or(employeeList.getSelectionModel().selectedItemProperty().isNotNull()));

deleteButton.disableProperty().bind(employeeList.getSelectionModel().selectedItemProperty().isNull());
updateButton.disableProperty().bind(employeeList.getSelectionModel().selectedItemProperty().isNull());

searchButton.disableProperty().bind(searchField.textProperty().isEmpty());
searchButton.setGraphic(FALoader.createDefault(FontAwesome.Glyph.SEARCH));
}

private void configureEmployeeList() {
Expand Down
11 changes: 10 additions & 1 deletion src/main/resources/io/jacobking/quickticket/changelog.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
[
{
"version": "2.1.0-beta",
"changes": [
"Fixed bug: malformed changelog.json",
"UI update: Increased width of ticket box for employees.",
"New feature: Added confirmation box when deleting employees.",
"New feature: You can now search for employees by name, email or title."
]
},
{
"version": "2.0.7-beta",
"changes": [
Expand All @@ -8,7 +17,7 @@
"Fixed bug: No longer receiving an error pop-up about multiple instances. (v2.0.4-beta)",
"Fixed bug: Updating a ticket user adds a improperly placed comment. (v2.0.5-beta)",
"Fixed bug: Updating the SMTP settings reflects in the UI now. (v2.0.6-beta)",
"Fixed bug: When creating a ticket, the text area would horizontally scroll. Now it auto-wraps. (v2.0.7-beta)",
"Fixed bug: When creating a ticket, the text area would horizontally scroll. Now it auto-wraps. (v2.0.7-beta)"
]
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
<?import javafx.scene.control.Separator?>
<?import javafx.scene.control.TextField?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.BorderPane?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.VBox?>

Expand Down Expand Up @@ -40,14 +39,20 @@
<TextField fx:id="titleField" prefHeight="25.0" prefWidth="165.0" promptText="Title" />
</children>
</HBox>
<BorderPane prefHeight="200.0" prefWidth="200.0">
<left>
<ListView fx:id="ticketListView" maxWidth="-Infinity" minWidth="-Infinity" prefHeight="200.0" prefWidth="188.0" styleClass="ticket-list-view" stylesheets="@../css/core/list.css" BorderPane.alignment="CENTER" />
</left>
</BorderPane>
<ListView fx:id="ticketListView" maxWidth="-Infinity" minWidth="-Infinity" prefHeight="200.0" prefWidth="348.0" styleClass="ticket-list-view" stylesheets="@../css/core/list.css" />
</children>
</VBox>
<VBox alignment="CENTER" layoutX="14.0" prefHeight="400.0" prefWidth="199.0" spacing="5.0">
<children>
<HBox alignment="CENTER" prefHeight="36.0" prefWidth="200.0" spacing="5.0">
<children>
<TextField fx:id="searchField" prefHeight="25.0" prefWidth="172.0" />
<Button fx:id="searchButton" mnemonicParsing="false" onAction="#onSearch" prefHeight="25.0" prefWidth="26.0" />
</children>
</HBox>
<ListView fx:id="employeeList" prefHeight="340.0" prefWidth="201.0" styleClass="ticket-list-view" stylesheets="@../css/core/list.css" />
</children>
</VBox>
<ListView fx:id="employeeList" layoutX="6.0" layoutY="11.0" prefHeight="378.0" prefWidth="207.0" styleClass="ticket-list-view" stylesheets="@../css/core/list.css" />
</children>
<stylesheets>
<URL value="@../css/screen/employee.css" />
Expand Down

0 comments on commit 91b3143

Please sign in to comment.