Skip to content

Commit

Permalink
Merge pull request #123 from ChrisHo1341/branch-email-template-button
Browse files Browse the repository at this point in the history
Add email template button
  • Loading branch information
ChrisHo1341 authored Apr 4, 2024
2 parents 5177107 + 20ff856 commit 8ff05d9
Show file tree
Hide file tree
Showing 5 changed files with 290 additions and 0 deletions.
150 changes: 150 additions & 0 deletions src/main/java/seedu/address/ui/EmailWindow.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
package seedu.address.ui;

import java.util.logging.Logger;

import javafx.fxml.FXML;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.input.Clipboard;
import javafx.scene.input.ClipboardContent;
import javafx.stage.Stage;
import seedu.address.commons.core.LogsCenter;

/**
* Controller for email page
*/
public class EmailWindow extends UiPart<Stage> {

private static final Logger logger = LogsCenter.getLogger(EmailWindow.class);
private static final String FXML = "EmailWindow.fxml";

private static final String INITIAL = "Initial";
private static final String TECHNICAL_ASSESSMENT = "Technical Assessment";
private static final String INTERVIEW = "Interview";
private static final String DECISION_AND_OFFER = "Decision and Offer";

private static final String INITIAL_TEMPLATE = "Initial Application Template Placeholder";
private static final String TA_TEMPLATE = "Technical Assessment Template Placeholder";
private static final String INTERVIEW_TEMPLATE = "Interview Template Placeholder";
private static final String DO_TEMPLATE = "Decision and Offer Template Placeholder";

private static final String INITIAL_MESSAGE = "Initial Application Email Template";
private static final String TA_MESSAGE = "Technical Assessment Email Template";
private static final String INTERVIEW_MESSAGE = "Interview Email Template";
private static final String DO_MESSAGE = "Decision and Offer Template";

private String emailTemplateMessage = "";
private String message = "";

@FXML
private Button copyButton;

@FXML
private Label emailTemplate;

/**
* Creates a new EmailWindow
*
* @param root Stage to use as the root of the EmailWindow
*/
public EmailWindow(Stage root) {
super(FXML, root);
emailTemplate.setText(message);
}

/**
* Creates a new EmailWindow
*/
public EmailWindow() {
this(new Stage());
}

/**
* Sets the emailTemplateMessage depending on which email type is selected
* @param templateType The type of email selected by user
*/
public void setTemplate(String templateType) {

if (templateType.equals(INITIAL)) {
this.emailTemplateMessage = INITIAL_TEMPLATE;
this.message = INITIAL_MESSAGE;

} else if (templateType.equals(TECHNICAL_ASSESSMENT)) {
this.emailTemplateMessage = TA_TEMPLATE;
this.message = TA_MESSAGE;

} else if (templateType.equals(INTERVIEW)) {
this.emailTemplateMessage = INTERVIEW_TEMPLATE;
this.message = INTERVIEW_MESSAGE;

} else {
this.emailTemplateMessage = DO_TEMPLATE;
this.emailTemplateMessage = DO_MESSAGE;
}

emailTemplate.setText(message);
}

/**
* Shows the email window.
* @throws IllegalStateException
* <ul>
* <li>
* if this method is called on a thread other than the JavaFX Application Thread.
* </li>
* <li>
* if this method is called during animation or layout processing.
* </li>
* <li>
* if this method is called on the primary stage.
* </li>
* <li>
* if {@code dialogStage} is already showing.
* </li>
* </ul>
*/
public void show() {
logger.fine("Showing email template");
getRoot().show();
getRoot().centerOnScreen();
}

/**
* Returns true if the email window is currently being shown.
*/
public boolean isShowing() {
return getRoot().isShowing();
}

/**
* Hides the help window.
*/
public void hide() {
getRoot().hide();
}

/**
* Close the help window.
*/
public void close() {
getRoot().close();
}

/**
* Focuses on the help window.
*/
public void focus() {
getRoot().requestFocus();
}

/**
* Copies the URL to the user guide to the clipboard.
*/
@FXML
private void copyEmailTemplate() {
final Clipboard clipboard = Clipboard.getSystemClipboard();
final ClipboardContent emailTemplate = new ClipboardContent();
emailTemplate.putString(emailTemplateMessage);
clipboard.setContent(emailTemplate);
}
}
67 changes: 67 additions & 0 deletions src/main/java/seedu/address/ui/MainWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,20 @@ public class MainWindow extends UiPart<Stage> {
private ResultDisplay resultDisplay;
private HelpWindow helpWindow;
private ImportWindow importWindow;
private EmailWindow emailTemplateWindow;

@FXML
private StackPane commandBoxPlaceholder;

@FXML
private MenuItem helpMenuItem;

@FXML
private MenuItem emailTemplateItem;

@FXML
private StackPane personListPanelPlaceholder;

@FXML
private StackPane roleListPanelPlaceholder;

Expand Down Expand Up @@ -103,6 +108,7 @@ public MainWindow(Stage primaryStage, Logic logic) {

helpWindow = new HelpWindow();
importWindow = new ImportWindow();
emailTemplateWindow = new EmailWindow();

// Configure import window to be a modal (inspired by AI)
importWindow.getRoot().initModality(Modality.APPLICATION_MODAL);
Expand Down Expand Up @@ -189,6 +195,67 @@ public void handleHelp() {
helpWindow.focus();
}
}

/**
* Opens the email window and sets it to the initial application email type
*/
@FXML
public void handleInitialTemplate() {

emailTemplateWindow.setTemplate("Initial");

if (!emailTemplateWindow.isShowing()) {
emailTemplateWindow.show();
} else {
emailTemplateWindow.focus();
}
}

/**
* Opens the email window and sets it to the technical assessment email type
*/
@FXML
public void handleTechnialAssessmentTemplate() {

emailTemplateWindow.setTemplate("Technical Assessment");

if (!emailTemplateWindow.isShowing()) {
emailTemplateWindow.show();
} else {
emailTemplateWindow.focus();
}
}

/**
* Opens the email window and sets it to the interview email type
*/
@FXML
public void handleInterviewTemplate() {

emailTemplateWindow.setTemplate("Interview");

if (!emailTemplateWindow.isShowing()) {
emailTemplateWindow.show();
} else {
emailTemplateWindow.focus();
}
}

/**
* Opens the email window and sets it to the decision and offer email type
*/
@FXML
public void handleDecisionAndOfferTemplate() {

emailTemplateWindow.setTemplate("Decision and Offer");

if (!emailTemplateWindow.isShowing()) {
emailTemplateWindow.show();
} else {
emailTemplateWindow.focus();
}
}

/**
* Opens the import window or focuses on it if it's already opened.
*/
Expand Down
23 changes: 23 additions & 0 deletions src/main/resources/view/EmailWindow.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#selectButton, #importMessage {
-fx-text-fill: white;
}

#selectButton {
-fx-background-color: dimgray;
}

#selectButton:hover {
-fx-background-color: gray;
}

#selectButton:armed {
-fx-background-color: darkgray;
}

#importMessageContainer {
-fx-background-color: derive(#1d1d1d, 20%);
}

#buttonBar {
-fx-background-color: derive(#1d1d1d, 20%);
}
44 changes: 44 additions & 0 deletions src/main/resources/view/EmailWindow.fxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?xml version="1.0" encoding="UTF-8"?>

<?import java.net.URL?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.Scene?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.image.Image?>
<?import javafx.scene.layout.HBox?>
<?import javafx.stage.Stage?>

<fx:root resizable="false" title="Help" type="javafx.stage.Stage" xmlns="http://javafx.com/javafx/17" xmlns:fx="http://javafx.com/fxml/1">
<icons>
<Image url="@/images/help_icon.png" />
</icons>
<scene>
<Scene>
<stylesheets>
<URL value="@EmailWindow.css" />
</stylesheets>

<HBox alignment="CENTER" fx:id="emailTemplateMessageContainer">
<children>
<Label fx:id="emailTemplate" text="Label">
<HBox.margin>
<Insets right="5.0" />
</HBox.margin>
</Label>
<Button fx:id="copyButton" mnemonicParsing="false" onAction="#copyEmailTemplate" text="Copy Email Template">
<HBox.margin>
<Insets left="5.0" />
</HBox.margin>
</Button>
</children>
<opaqueInsets>
<Insets bottom="10.0" left="5.0" right="10.0" top="5.0" />
</opaqueInsets>
<padding>
<Insets bottom="10.0" left="5.0" right="10.0" top="5.0" />
</padding>
</HBox>
</Scene>
</scene>
</fx:root>
6 changes: 6 additions & 0 deletions src/main/resources/view/MainWindow.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@
<MenuItem mnemonicParsing="false" onAction="#handleShowAll"
text="Show All" />
</Menu>
<Menu mnemonicParsing="false" text="Email">
<MenuItem fx:id="emailTemplateItem" mnemonicParsing="false" onAction="#handleInitialTemplate" text="Initial Application Email" />
<MenuItem fx:id="emailTemplateItem" mnemonicParsing="false" onAction="#handleTechnialAssessmentTemplate" text="Technical Assessment Email" />
<MenuItem fx:id="emailTemplateItem" mnemonicParsing="false" onAction="#handleInterviewTemplate" text="Interview Email" />
<MenuItem fx:id="emailTemplateItem" mnemonicParsing="false" onAction="#handleDecisionAndOfferTemplate" text="Decision and Offer Email" />
</Menu>
</MenuBar>
<HBox VBox.vgrow="ALWAYS">
<VBox>
Expand Down

0 comments on commit 8ff05d9

Please sign in to comment.