Skip to content

Commit

Permalink
Feat: Attempt to use said base controller
Browse files Browse the repository at this point in the history
  • Loading branch information
AdrianBalunan committed Apr 15, 2026
1 parent 8315fcf commit c348161
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
import javafx.scene.Parent;
import javafx.scene.control.TextField;
import javafx.scene.layout.FlowPane;
import ntnu.systemutvikling.team6.controller.components.BaseController;
import ntnu.systemutvikling.team6.controller.components.LoaderScene;
import ntnu.systemutvikling.team6.controller.components.NavbarFooterController;
import ntnu.systemutvikling.team6.controller.components.OrganizationCardController;
import ntnu.systemutvikling.team6.database.DatabaseConnection;
import ntnu.systemutvikling.team6.database.Readers.CharitySelect;
import ntnu.systemutvikling.team6.models.Charity;
Expand All @@ -22,7 +26,7 @@
* on the featured charity to see more details about it. The user can also switch to the charity
* page or donation page for the selected charity.
*/
public class AvailableOrganizationController {
public class AvailableOrganizationController extends BaseController implements NavbarFooterController {

@FXML private TextField searchField;
@FXML private FlowPane cardsContainer;
Expand Down Expand Up @@ -88,7 +92,7 @@ private void displayCharities(List<Charity> charities) {

for (Charity charity : charities) {
try {
FXMLLoader loader = new FXMLLoader(getClass().getResource("/fxml/organizationCard.fxml"));
FXMLLoader loader = new FXMLLoader(getClass().getResource("/fxml/components/organizationCard.fxml"));
Parent card = loader.load();

OrganizationCardController cardController = loader.getController();
Expand All @@ -115,15 +119,6 @@ public void setInitialSearch(String query) {
searchField.setText(query);
}

/**
* This method is used to switch to the front page.
*
* @param event action event from button click
*/
@FXML
public void switchToFrontPage(ActionEvent event) {
LoaderScene.LoadScene("FrontPage", event, charity, null);
}

/**
* This method is used to switch to the charity page for the selected charity.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import javafx.fxml.FXML;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import ntnu.systemutvikling.team6.controller.components.LoaderScene;
import ntnu.systemutvikling.team6.models.Charity;

/**
Expand Down Expand Up @@ -40,16 +41,6 @@ public void setCharity(Charity charity) {
CharityName.setText(charity.getName());
}

/**
* This method is used to switch to the front page.
*
* @param event
*/
@FXML
public void switchToFrontPage(ActionEvent event) {
System.out.println("Click");
LoaderScene.LoadScene("FrontPage", event, charity, null);
}

/**
* This method is used to switch to the donation page.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.scene.layout.FlowPane;
import ntnu.systemutvikling.team6.controller.components.BaseController;
import ntnu.systemutvikling.team6.controller.components.LoaderScene;
import ntnu.systemutvikling.team6.controller.components.NavbarFooterController;
import ntnu.systemutvikling.team6.controller.components.OrganizationCardController;
import ntnu.systemutvikling.team6.database.DatabaseConnection;
import ntnu.systemutvikling.team6.database.Readers.CharitySelect;
import ntnu.systemutvikling.team6.database.Readers.DonationSelect;
Expand All @@ -27,7 +31,7 @@
* it, or click on the featured charity to see more details about it. It also has buttons to switch
* to the charity page and the donation page for the featured charity
*/
public class FrontpageController {
public class FrontpageController extends BaseController implements NavbarFooterController {
@FXML private Charity featuredCharity;
@FXML private FlowPane cardsContainer;
@FXML private Label Carosel_Organisasjon;
Expand All @@ -43,6 +47,11 @@ public class FrontpageController {

private List<Charity> allCharities = new ArrayList<>();

@Override
protected void authTokenisSet(){

}

/**
* Initialize method for the front page. This method is called when the front page is loaded. It
* retrieves the list of charities and donations from the database. The list of charities is
Expand Down Expand Up @@ -88,6 +97,7 @@ public void initialize() {
}
}


/**
* This method is used to switch to the charity page for the selected charity
*
Expand Down Expand Up @@ -210,7 +220,7 @@ private void displayCharities(List<Charity> charities) {

for (Charity charity : charities) {
try {
FXMLLoader loader = new FXMLLoader(getClass().getResource("/fxml/organizationCard.fxml"));
FXMLLoader loader = new FXMLLoader(getClass().getResource("/fxml/components/organizationCard.fxml"));
Parent card = loader.load();
OrganizationCardController cardController = loader.getController();
cardController.setOrganization(charity);
Expand Down

0 comments on commit c348161

Please sign in to comment.