Feature/finished/iia 2353 retrieve list of author concepts to select during login to komet#657
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR implements a login author feature that allows users to select from a list of author concepts during login to Komet. The implementation replaces a mock user selection system with a dynamic retrieval of author concepts from the system.
- Replaces hardcoded fake users with dynamic retrieval of author concepts from the USER concept hierarchy
- Implements proper MVVM pattern for the login author functionality with validation
- Updates UI event handlers from
signupActiontosignInActionfor consistency
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| JournalWindowPreferences.java | Adds constant for author login window preferences |
| loginAuthor.fxml | Updates action method names from signup to sign-in for consistency |
| LoginAuthorViewModel.java | New view model implementing validation and data binding for author login |
| LoginAuthorController.java | Refactored to use MVVM pattern with dynamic author concept retrieval |
| AppPages.java | Updated to use proper MVVM loader and pass view properties to login controller |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
kview/src/main/java/dev/ikm/komet/kview/mvvm/view/loginauthor/LoginAuthorViewModel.java
Outdated
Show resolved
Hide resolved
kview/src/main/java/dev/ikm/komet/kview/mvvm/view/loginauthor/LoginAuthorViewModel.java
Show resolved
Hide resolved
kview/src/main/java/dev/ikm/komet/kview/mvvm/view/loginauthor/LoginAuthorController.java
Outdated
Show resolved
Hide resolved
…st-of-Author-Concepts-to-select-during-login-to-Komet
| public static final String AUTHORS = "authors"; | ||
| public static final String SELECTED_AUTHOR = "selected-author"; | ||
| public static final String LOGIN_ERROR = "login-error"; | ||
| public static final String PASSWORD = "password"; |
There was a problem hiding this comment.
Can you make an enum here?
public enum LoginProperties {
AUTHORS("authors"),
SELECTED_AUTHOR("selected author"),
...
public final String name;
LoginProperties(String name){
this.name = name;
}
LoginProperties(){
this.name = this.name();
}
}Please create a constructor to add a friendly name. An example is shown here:
https://github.com/carldea/cognitive/blob/main/src/test/java/org/carlfx/cognitive/test/demo/AccountViewModel.java#L33-L50
Friendly error messages used in validation messages can use string interpolation if needed.
For example: validationResult.error("${%s} first character must be upper case.".formatted(FIRST_NAME));
kview/src/main/java/dev/ikm/komet/kview/mvvm/view/loginauthor/LoginAuthorViewModel.java
Outdated
Show resolved
Hide resolved
kview/src/main/java/dev/ikm/komet/kview/mvvm/view/loginauthor/LoginAuthorViewModel.java
Outdated
Show resolved
Hide resolved
| .addProperty(PASSWORD, "") | ||
| .addProperty(LOGIN_ERROR, ""); | ||
|
|
||
| addValidator(SELECTED_AUTHOR, "selected-author", (ReadOnlyObjectProperty prop, ValidationResult validationResult, ViewModel viewModel) -> { |
There was a problem hiding this comment.
Can the second parameter make use of the enum for SELECTED_AUTHOR.name()?
|
|
||
| passwordTextField.setVisible(false); | ||
| loginButton.setDisable(true); | ||
| loginErrorLabel.textProperty().bindBidirectional(loginAuthorViewModel.getProperty(LOGIN_ERROR)); |
There was a problem hiding this comment.
Can we just do a unidirectional bind?
| passwordField.textProperty().bindBidirectional(loginAuthorViewModel.getProperty(PASSWORD)); | ||
|
|
||
| passwordTextField.setVisible(false); | ||
| loginButton.setDisable(true); |
There was a problem hiding this comment.
Can we bind disableProperty() to view model's is
loginButton.disableProperty().bind(loginAuthorViewModel.invalidProperty());|
|
||
| userChooser.valueProperty().bindBidirectional(loginAuthorViewModel.getProperty(SELECTED_AUTHOR)); | ||
| passwordField.textProperty().bindBidirectional(loginAuthorViewModel.getProperty(PASSWORD)); | ||
|
|
There was a problem hiding this comment.
Can we add the following?
loginAuthorViewModel.doOnChange(()->{
loginAuthorViewModel.validate();
}, SELECTED_AUTHOR, PASSWORD);A view model contain validators will be update the validation messages.
Assuming the submit or login button is bound to the view model's invalidProperty().
No description provided.