Skip to content

Commit

Permalink
feat(Stock MVC): 'Sell in portfolio' button functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
pawelsa committed May 25, 2026
1 parent 3d4fc0d commit d7d92fd
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import edu.ntnu.idi.idatt.model.transaction.Purchase;
import edu.ntnu.idi.idatt.service.transaction.PurchaseCalculator;
import edu.ntnu.idi.idatt.session.UserSession;
import edu.ntnu.idi.idatt.view.SceneFactory;
import edu.ntnu.idi.idatt.view.SceneManager;
import edu.ntnu.idi.idatt.view.components.AbstractController;
import edu.ntnu.idi.idatt.view.components.elements.RecieptComponent;
import edu.ntnu.idi.idatt.view.components.ui.UIAlert;
Expand Down Expand Up @@ -169,6 +171,16 @@ public void buyButtonClicked() {
showReciept(purchase);
}

/**
* Method to execute on portfolio button clicked.
* <p>
* Navigates to portfolio with this stock as deafult search.
* </p>
*/
public void portfolioButtonClicked() {
SceneManager.switchTo(SceneFactory.createPortfolioView(getSymbol()));
}

/**
* Method for showing transaction reciept.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public Parent createNavigation() {
List.of(
"Home",
" • Newspaper"),
() -> SceneManager.switchTo(SceneFactory.createExchangeView(false)),
() -> SceneManager.switchTo(SceneFactory.createExchangeView(true)),
() -> SceneManager.switchTo(SceneFactory.createNewspaperView(stockSymbol)));
}

Expand Down Expand Up @@ -188,6 +188,7 @@ public void setController(StockController controller) {
title.setText(controller.getSymbol());
stockSymbol = controller.getSymbol();
tradeSection.getBuyButton().setOnAction((e) -> controller.buyButtonClicked());
tradeSection.getPortfolioButton().setOnAction((e) -> controller.portfolioButtonClicked());
}

}

0 comments on commit d7d92fd

Please sign in to comment.