Skip to content

Commit

Permalink
Updated Settings UI
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonbarba19 committed Jun 5, 2024
2 parents b76d0a3 + 0e34e38 commit 6436e37
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 30 deletions.
2 changes: 2 additions & 0 deletions app/femr/business/services/system/UserService.java
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ public ServiceResponse<UserItem> updateUser(UserItem userItem, String newPasswor
user.setRoles(newRoles);
user.setPasswordReset(userItem.isPasswordReset());
user.setPasswordCreatedDate(DateTime.now());
user.setLanguageCode(userItem.getLanguageCode());
user = userRepository.updateUser(user);
response.setResponseObject(itemModelMapper.createUserItem(user));
} catch (Exception ex) {
Expand All @@ -249,6 +250,7 @@ public ServiceResponse<UserItem> updateUser(UserItem userItem, String newPasswor
return response;
}


/**
* {@inheritDoc}
*/
Expand Down
4 changes: 0 additions & 4 deletions app/femr/common/models/UserItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,6 @@ public class UserItem {
private Integer CreatedBy; //Sam Zanni
private String languageCode;

public UserItem() {
this.roles = new ArrayList<>();
}

public String getFirstName() {
return firstName;
}
Expand Down
2 changes: 1 addition & 1 deletion app/femr/ui/controllers/SettingsController.java
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,4 @@ private EditViewModel convertToEditViewModel(UserItem userItem) {
return editViewModel;
}

}
}
1 change: 0 additions & 1 deletion app/femr/ui/views/partials/authenticated.scala.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
@import femr.ui.controllers.SettingsController
@(currentUser: femr.common.dtos.CurrentUser, assets: AssetsFinder)

@import femr.ui.views.partials.helpers.AuthenticatedPartialHelper
Expand Down
78 changes: 55 additions & 23 deletions app/femr/ui/views/triage/index.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,6 @@
function updateGenderLabels(languageData, language) {
// Check if the language data exists for the selected language
if(languageData[language]) {
// Update the Male button
// if(languageData[language]['triage_index_Gender']) {
// const genderLabelElement = document.querySelector("label[for='genderBtns']");
// if (genderLabelElement) {
// genderLabelElement.textContent = languageData[language]['triage_index_Gender'] + " ";
// }
// }
if(languageData[language]['triage_index_Male']) {
const maleBtn = document.getElementById('maleBtn');
if (maleBtn) {
Expand All @@ -115,24 +108,44 @@
}
}
}
function updateFileInputText(languageData, language) {
const fileInputLabel = document.getElementById('chooseFileLabel');
const fileChosenText = document.getElementById('fileChosenText');

if (fileInputLabel && languageData[language] && languageData[language]['triage_index_choose']) {
fileInputLabel.textContent = languageData[language]['triage_index_choose'];
}
function updateAgeClassificationLabels(languageData, language) {
const classifications = document.querySelectorAll('#classificationRadioWrap label');
classifications.forEach(label => {
// Extracting the key from the label's ID (label_infant -> infant)
const classification = label.id.replace('label_', '');
const span = label.querySelector('span'); // Finds the span inside the current label
const translationKey = "ageClassification_" + classification; // Constructs the translation key

if (fileChosenText && languageData[language] && languageData[language]['triage_index_No']) {
fileChosenText.textContent = languageData[language]['triage_index_No'];
}
// Check if the translation exists for the given key and language
if(languageData[language] && languageData[language][translationKey]) {
const labelText = languageData[language][translationKey];
// Updating the text inside the span
if (span) {
span.textContent = labelText;
}
}
});
}
document.getElementById('photoInput').addEventListener('change', function() {
const fileChosenText = document.getElementById('fileChosenText');
fileChosenText.textContent = this.files.length ? this.files[0].name : languageData[currentLanguage]['triage_index_No'];
});

function updateAgeClassificationLabels(languageData, language) {
function updateLabels(languageData, language) {
// Update gender labels
if (languageData[language]) {
// Update the Male button
if (languageData[language]['triage_index_Male']) {
const maleBtn = document.getElementById('maleBtn');
if (maleBtn) {
maleBtn.nextSibling.textContent = languageData[language]['triage_index_Male'];
}
}
// Update the Female button
if (languageData[language]['triage_index_Female']) {
const femaleBtn = document.getElementById('femaleBtn');
if (femaleBtn) {
femaleBtn.nextSibling.textContent = languageData[language]['triage_index_Female'];
}
}
}
// Update age classification labels
const classifications = document.querySelectorAll('#classificationRadioWrap label');
classifications.forEach(label => {
// Extracting the key from the label's ID (label_infant -> infant)
Expand All @@ -141,7 +154,7 @@
const translationKey = "ageClassification_" + classification; // Constructs the translation key

// Check if the translation exists for the given key and language
if(languageData[language] && languageData[language][translationKey]) {
if (languageData[language] && languageData[language][translationKey]) {
const labelText = languageData[language][translationKey];
// Updating the text inside the span
if (span) {
Expand All @@ -150,6 +163,25 @@
}
});
}

function updateFileInputText(languageData, language) {
const fileInputLabel = document.getElementById('chooseFileLabel');
const fileChosenText = document.getElementById('fileChosenText');

if (fileInputLabel && languageData[language] && languageData[language]['triage_index_choose']) {
fileInputLabel.textContent = languageData[language]['triage_index_choose'];
}

if (fileChosenText && languageData[language] && languageData[language]['triage_index_No']) {
fileChosenText.textContent = languageData[language]['triage_index_No'];
}
}
document.getElementById('photoInput').addEventListener('change', function() {
const fileChosenText = document.getElementById('fileChosenText');
fileChosenText.textContent = this.files.length ? this.files[0].name : languageData[currentLanguage]['triage_index_No'];
});


function updateAgeInputPlaceholders(languageCode) {
// Update placeholders
const yearsInput = document.getElementById('yearsInput'); // You need to ensure this is the correct ID
Expand Down
5 changes: 4 additions & 1 deletion conf/routes
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,10 @@ GET /search/typeahead/medicationsWithID @femr.ui.controll
GET /search/typeahead/medicationAdministrations @femr.ui.controllers.SearchController.typeaheadMedicationAdministrationsJSONGet()

#Settings
GET /settings @femr.ui.controllers.SettingsController.index()
GET /settings @femr.ui.controllers.SettingsController.index()
POST /settings/update @femr.ui.controllers.SettingsController.update()


#Photo
GET /photo/patient/:id @femr.ui.controllers.PhotoController.GetPatientPhoto(id: Integer, showDefault: Boolean ?= false)
GET /photo/encounter/:id @femr.ui.controllers.PhotoController.GetPhoto(id: Int)
Expand Down

0 comments on commit 6436e37

Please sign in to comment.