Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Category Manager #52

Closed
11 tasks done
robkap94 opened this issue Mar 7, 2022 · 14 comments · Fixed by #55
Closed
11 tasks done

Category Manager #52

robkap94 opened this issue Mar 7, 2022 · 14 comments · Fixed by #55
Assignees
Labels
code code related enhancement upgrade related
Milestone

Comments

@robkap94
Copy link
Owner

robkap94 commented Mar 7, 2022

As we already have Category class (for orders), we need to create small pop-up window which will be Category Manager.
Hence, it is going to be list with simple buttons (add, edit, delete).

  • Create pop-up window for Category Manager in the toolbar,
  • Establish ObservableList of categories which will be populated by loaded categories from db (addCategory in loadedDB),
  • Establish button add category,
  • Establish add functionality with similar method as it was done with orders in Establish SQL Database #35 ,
  • Establish button edit category,
  • Establish button delete category,
  • Ensure that in the "Create Order" you can choose categories from the dropdown list, user should not type it manually since now (AddOrderDialogController),
  • Ensure that above is also applied for the Edit Order. (Will be applied in feature Edit Button #40 )

Additional tasks:

  • Adjust jUnit tests for Feature Establish SQL Database #35 ,
  • Change project's "Window" class into "AppWindow" to not collide with JavaFX's lib "Window" class,
  • From commentary below, check whether it's good idea, or not, to leave duplicated code.
@robkap94 robkap94 added enhancement upgrade related code code related labels Mar 7, 2022
@robkap94 robkap94 added this to the v.alpha milestone Mar 7, 2022
@robkap94 robkap94 self-assigned this Mar 7, 2022
@robkap94 robkap94 mentioned this issue Mar 7, 2022
11 tasks
@robkap94
Copy link
Owner Author

robkap94 commented Mar 8, 2022

I will start this task tomorrow, during the day :)

@robkap94
Copy link
Owner Author

robkap94 commented Mar 9, 2022

I'm handling this task right now.

@robkap94
Copy link
Owner Author

robkap94 commented Mar 9, 2022

I have adjusted jUnit tests for SQL db which was missing in feature #35

@robkap94
Copy link
Owner Author

robkap94 commented Mar 9, 2022

I have just created pop-up window for Category manager.

@robkap94
Copy link
Owner Author

robkap94 commented Mar 9, 2022

I have just refactored project's "Window" class into "AppWindow". Hence, it won't collide with standard library of JavaFX.

@robkap94
Copy link
Owner Author

I have added ObservableList of categories, which is populated by loaded db. Also, I have established "Add" button and implemented it's functionality to show small dialog window with name's field to add new category.

All works and tested on dummy data. Hence, I will proceed with the rest of tasks tomorrow.

@robkap94
Copy link
Owner Author

robkap94 commented Mar 10, 2022

For the duplicated code in controllers, check this - https://softwareengineering.stackexchange.com/questions/264392/is-a-good-practice-to-call-a-controller-function-from-another-controller

Also, consider this for MainApp/AppWindow duplicated code and take a decision if this is good to leave this duplicated code.

Potential solution: consider to create separated class which may be used to create dialogs.

@robkap94
Copy link
Owner Author

I have just reduced duplicated code by creating new class "DialogWindow" which is to create any dialog windows. It takes parameters of fxmlLoader, Window type object, title, header, required buttons etc.

@robkap94
Copy link
Owner Author

I have reduced duplicated code for ManagerController (File -> Close closure's confirmation code) and AppWindow.showExitConfirmationDialog() (which is now static method and is used in ManagerController).

@robkap94
Copy link
Owner Author

robkap94 commented Mar 10, 2022

Established "Delete button" for Manager View for orders (additionally, this will be confirmed in #42 ), will do the same for Category Manager.

Additionally, added listener for selected order, will do the same for Category Manager (Jeez, I have made such an offtopic here - need to focus on Category Manager :) )

@robkap94
Copy link
Owner Author

Established EDIT button, it is now working 👍

@robkap94
Copy link
Owner Author

I have established DELETE button + adjusted DELETE button in Order's list.
The main problem was literally order of code:

OLD VERSION:

  1. controller's internal list was updated by removing old position,
  2. orderData's observable list was updated by removing old position.

NEW VERSION:

  1. orderData's observable list was updated by removing old position,
  2. controller's internal list was updated by removing old position.

It was required because there were bugs in the Category Manager (and potential bug in the Order List) as first I was removing position from the list (which set up was based on orderData's observable list) and afterwards I was updating actual observable list from orderData's. This was causing that controller's list was updated twice (first when I removed old position, second when observableList was updated) and this causes a bug. It is fixed now so it should be ok :)

@robkap94
Copy link
Owner Author

I have changed category selection into ComboBox (dropdown list), populated by observable List.
Also, I have changed method to add order into the SQL DB as now it required order and category object of Category class.

So, Order class object is created with the STRING name of category but still, thru controllers, selected category's object is passed to addOrderToSqlDB and over there we are using category.getId() method to provide only id of the category. This will allow to keep consistent and clear data in SQL database where we are using category's ids for category field in orders table.

tldr: Handled dropdown list and adjusted SQL INSERT method for orders.

@robkap94
Copy link
Owner Author

Last task, to ensure that in Edit window the same dropdown list is going to be applied... Well, this is going to be handled in feature #40 .
Therefore, all done. Preparing pull request and closing this task 👍

@robkap94 robkap94 mentioned this issue Mar 11, 2022
robkap94 added a commit that referenced this issue Mar 11, 2022
@robkap94 robkap94 mentioned this issue Mar 11, 2022
5 tasks
@robkap94 robkap94 linked a pull request Mar 11, 2022 that will close this issue
@robkap94 robkap94 mentioned this issue Mar 11, 2022
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code code related enhancement upgrade related
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

1 participant