Skip to content

Commit

Permalink
fixed feedback submission and added user feedback on succession or fa…
Browse files Browse the repository at this point in the history
…ilure (#750)
  • Loading branch information
thekevinWHYuan authored Dec 5, 2024
1 parent 45bb490 commit 17ed530
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 21 deletions.
6 changes: 5 additions & 1 deletion app/femr/business/services/system/UserService.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,11 @@ public ServiceResponse<Boolean> createFeedback(String feedback) {
newFeedback.setDate(dateUtils.getCurrentDateTime());
newFeedback.setFeedback(feedback);

feedbackRepository.create(newFeedback);
if (feedbackRepository.create(newFeedback) != null){
response.setResponseObject(true);
}else{
response.setResponseObject(false);
}

return response;
}
Expand Down
4 changes: 2 additions & 2 deletions app/femr/data/models/core/IFeedback.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public interface IFeedback {
void setDate (DateTime theDate);
void setFeedback (String theFeedback);

String getLanguageCode();
void setLanguageCode(String languageCode);
// String getLanguageCode();
// void setLanguageCode(String languageCode);

}
22 changes: 11 additions & 11 deletions app/femr/data/models/mysql/Feedback.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ public class Feedback implements IFeedback {
@Column(name = "feedback", nullable = false)
private String feedback;

@Column(name="language_code", nullable=true, length=5)
private String languageCode;
// @Column(name="language_code", nullable=true, length=5)
// private String languageCode;



Expand Down Expand Up @@ -55,14 +55,14 @@ public void setFeedback (String theFeedback) {
feedback = theFeedback;
}

@Override
public String getLanguageCode() {
return this.languageCode;
}

@Override
public void setLanguageCode(String languageCode) {
this.languageCode = languageCode;
}
// @Override
// public String getLanguageCode() {
// return this.languageCode;
// }
//
// @Override
// public void setLanguageCode(String languageCode) {
// this.languageCode = languageCode;
// }

}
15 changes: 10 additions & 5 deletions app/femr/ui/controllers/FeedbackController.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import femr.business.services.core.ISessionService;
import femr.business.services.core.IUserService;
import femr.common.dtos.CurrentUser;
import femr.common.dtos.ServiceResponse;
import femr.data.models.mysql.Roles;
import femr.ui.helpers.security.AllowedRoles;
import femr.ui.helpers.security.FEMRAuthenticated;
Expand All @@ -28,6 +29,7 @@ public class FeedbackController extends Controller {
private final ISessionService sessionService;
private final FormFactory formFactory;
private final IUserService userService;
private String SuccessMessage = "";


@Inject
Expand All @@ -47,7 +49,7 @@ public FeedbackController( AssetsFinder assetsFinder,
// GET
public Result indexGet() {
CurrentUser currentUser = sessionService.retrieveCurrentUserSession();
return ok(feedback.render(currentUser, assetsFinder));
return ok(feedback.render(currentUser, assetsFinder, SuccessMessage));
}

// POST
Expand All @@ -57,11 +59,14 @@ public Result indexPost() {
CurrentUser currentUser = sessionService.retrieveCurrentUserSession();

if(!viewModel.getFeedbackMsg().equals("")){
userService.createFeedback(viewModel.getFeedbackMsg());
return redirect("/");
ServiceResponse<Boolean> success = userService.createFeedback(viewModel.getFeedbackMsg());
if (success.getResponseObject()){
SuccessMessage = "Successfully sent feedback!";
return ok(feedback.render(currentUser, assetsFinder, SuccessMessage));
}
}

return redirect("/feedback");
SuccessMessage = "Failed to send feedback. Please try again or contact a nerd!";
return ok(feedback.render(currentUser, assetsFinder, SuccessMessage));
}


Expand Down
4 changes: 2 additions & 2 deletions app/femr/ui/views/feedback/feedback.scala.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@(currentUser: femr.common.dtos.CurrentUser, assets: AssetsFinder)
@(currentUser: femr.common.dtos.CurrentUser, assets: AssetsFinder, successMessage: java.lang.String)

@import femr.ui.views.html.layouts.main
@import femr.ui.controllers.routes.FeedbackController
Expand Down Expand Up @@ -53,7 +53,7 @@ <h2 id="feedback_header">Give Feedback</h2>
<textarea class="fTextArea" name="feedbackMsg" id="usrFeedback" cols="50" rows="10" maxlength="10000" required></textarea>
<button type="submit" class="fButton fSubmitButton" id="feedback_submit">Submit</button>
}

<span id="feedback_success_message">@successMessage</span>
<p id="feedback_disclaimer">Your feedback is completely anonymous and will only be used to produce a better fEMR product.</p>
</div>
}
3 changes: 3 additions & 0 deletions public/css/feedback.css
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,6 @@ button#feedbackSubmit {
margin: 10px 0;
}

span{
font-weight: bold;
}

0 comments on commit 17ed530

Please sign in to comment.