diff --git a/src/main/java/edit_flashcard_set_use_case/function_testing/InMemoryFlashcardSet.java b/src/main/java/edit_flashcard_set_use_case/function_testing/InMemoryFlashcardSet.java index 0c651f83..df8e9534 100644 --- a/src/main/java/edit_flashcard_set_use_case/function_testing/InMemoryFlashcardSet.java +++ b/src/main/java/edit_flashcard_set_use_case/function_testing/InMemoryFlashcardSet.java @@ -55,15 +55,17 @@ public void editTitleAndDescription(FlashcardSetDsRequestModel flashcardSet) { @Override public void saveFlashcardID(int flashcardSetId, int flashcardId) { FlashcardSetDsRequestModel oldFlashcardSet = flashcardSets.get(flashcardSetId); - String title = oldFlashcardSet.getTitle(); - String description = oldFlashcardSet.getDescription(); - boolean isPrivate = oldFlashcardSet.getIsPrivate(); List flashcardIds = oldFlashcardSet.getFlashcardIds(); - String owner = oldFlashcardSet.getOwnerUsername(); ArrayList newFlashcardIds = new ArrayList<>(flashcardIds); newFlashcardIds.add(flashcardId); - FlashcardSetDsRequestModel newFlashcardSet = new FlashcardSetDsRequestModel(title, description, isPrivate, flashcardSetId, owner, newFlashcardIds); + FlashcardSetDsRequestModel newFlashcardSet = new FlashcardSetDsRequestModel( + oldFlashcardSet.getTitle(), + oldFlashcardSet.getDescription(), + oldFlashcardSet.getIsPrivate(), + flashcardSetId, + oldFlashcardSet.getOwnerUsername(), + newFlashcardIds); flashcardSets.put(flashcardSetId, newFlashcardSet); } @@ -77,15 +79,16 @@ public void saveFlashcardID(int flashcardSetId, int flashcardId) { @Override public void removeFlashcardId(int flashcardSetId, int flashcardId) { FlashcardSetDsRequestModel oldFlashcardSet = flashcardSets.get(flashcardSetId); - String title = oldFlashcardSet.getTitle(); - String description = oldFlashcardSet.getDescription(); - boolean isPrivate = oldFlashcardSet.getIsPrivate(); List flashcardIds = oldFlashcardSet.getFlashcardIds(); - String owner = oldFlashcardSet.getOwnerUsername(); - ArrayList newFlashcardIds = new ArrayList<>(flashcardIds); newFlashcardIds.remove(flashcardId); - FlashcardSetDsRequestModel newFlashcardSet = new FlashcardSetDsRequestModel(title, description, isPrivate, flashcardSetId, owner, newFlashcardIds); + FlashcardSetDsRequestModel newFlashcardSet = new FlashcardSetDsRequestModel( + oldFlashcardSet.getTitle(), + oldFlashcardSet.getDescription(), + oldFlashcardSet.getIsPrivate(), + flashcardSetId, + oldFlashcardSet.getOwnerUsername(), + newFlashcardIds); flashcardSets.put(flashcardSetId, newFlashcardSet); } diff --git a/src/main/java/frameworks_and_drivers/components/ListOfFlashcardsDataPanel.java b/src/main/java/frameworks_and_drivers/components/ListOfFlashcardsDataPanel.java index 371e0c61..d440fb7d 100644 --- a/src/main/java/frameworks_and_drivers/components/ListOfFlashcardsDataPanel.java +++ b/src/main/java/frameworks_and_drivers/components/ListOfFlashcardsDataPanel.java @@ -64,8 +64,6 @@ public ListOfFlashcardsDataPanel(DBGateway dbGateway, List new EditorMainScreen(responseModel.getResult_set().get(tempX) - .getFlashcardSetId())); + edit.addActionListener((e) -> { + EditorMainScreen editor = new EditorMainScreen(responseModel.getResult_set().get(tempX).getFlashcardSetId()); + editor.addWindowListener(new WindowAdapter() {}); + }); JButton delete = new JButton("Delete"); delete.addActionListener(e -> { DeleteFlashcardSetOutputBoundary presenter = new DeleteFlashcardSetPresenter();