Skip to content

Commit

Permalink
Working w/Settings tab - Local Storage
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonbarba19 committed Jun 10, 2024
1 parent e9ada88 commit 4483246
Show file tree
Hide file tree
Showing 12 changed files with 45 additions and 55 deletions.
15 changes: 2 additions & 13 deletions app/femr/ui/controllers/SettingsController.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,7 @@ public SettingsController(AssetsFinder assetsFinder,

public Result index() {
CurrentUser currentUser = sessionService.retrieveCurrentUserSession();
System.out.println("Test");
/*ServiceResponse<UserItem> userServiceResponse = userService.retrieveUser(currentUser.getId());
if (userServiceResponse.hasErrors()){
System.out.println("Test1333");
throw new RuntimeException();
}*/
System.out.println("Test1");
IndexViewModelGet viewModelGet = new IndexViewModelGet();
System.out.println("Test2");
Form<EditViewModel> editViewModelForm = formFactory.form(EditViewModel.class).bindFromRequest();
System.out.println("Test3");
return ok(femr.ui.views.html.settings.index.render(currentUser, viewModelGet, editViewModelForm, assetsFinder));
return ok(femr.ui.views.html.settings.index.render(currentUser, assetsFinder));
}

public Result update() {
Expand All @@ -67,7 +56,7 @@ public Result update() {
IndexViewModelGet viewModelGet = new IndexViewModelGet();
Form<EditViewModel> editViewModelForm = formFactory.form(EditViewModel.class).bindFromRequest();
if (editViewModelForm.hasErrors()) {
return badRequest(index.render(currentUser, viewModelGet, editViewModelForm, assetsFinder));
return badRequest(index.render(currentUser, assetsFinder));
}

EditViewModel viewModel = editViewModelForm.get();
Expand Down
4 changes: 2 additions & 2 deletions app/femr/ui/views/admin/index.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
.then(response => response.json())
.then(data => {
languageData = data;
//const initialLanguage = localStorage.getItem('languageCode') || 'en';
const initialLanguage = @currentUser.getLanguageCode();
const initialLanguage = localStorage.getItem('languageCode') || 'en';
//const initialLanguage = @currentUser.getLanguageCode();
updateLanguage(initialLanguage);
document.getElementById('languageSelect').value = initialLanguage;
});
Expand Down
7 changes: 5 additions & 2 deletions app/femr/ui/views/home/index.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@
.then(response => response.json())
.then(data => {
languageData = data;
updateLanguage();
const initialLanguage = localStorage.getItem('languageCode') || 'en';
//const initialLanguage = currentUser.getLanguageCode();
updateLanguage(initialLanguage);
document.getElementById('languageSelect').value = initialLanguage;
});

document.getElementById('languageSelect').addEventListener('change', function() {
Expand All @@ -34,7 +37,7 @@
}
}

function updateLanguage(languageCode = "en", currUser = " Admin!") {
function updateLanguage(languageCode, currUser = " Admin!") {
const language = languageCode;
updateTextContent("home_index_h2_Welcome", languageData[language].home_index_h2_Welcome + currUser);
updateTextContent("home_index_div_Your", languageData[language].home_index_div_Your);
Expand Down
4 changes: 2 additions & 2 deletions app/femr/ui/views/layouts/admin.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
.then(response => response.json())
.then(data => {
languageData = data;
//const initialLanguage = localStorage.getItem('languageCode') || 'en';
const initialLanguage = @currentUser.getLanguageCode();
const initialLanguage = localStorage.getItem('languageCode') || 'en';
//const initialLanguage = @currentUser.getLanguageCode();
updateLanguage(initialLanguage);
document.getElementById('languageSelect').value = initialLanguage;
});
Expand Down
22 changes: 7 additions & 15 deletions app/femr/ui/views/layouts/settings.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
.then(response => response.json())
.then(data => {
languageData = data;
//const initialLanguage = localStorage.getItem('languageCode') || 'en';
const initialLanguage = @currentUser.getLanguageCode();
const initialLanguage = localStorage.getItem('languageCode') || 'en';
//const initialLanguage = currentUser.getLanguageCode();
updateLanguage(initialLanguage);
document.getElementById('languageSelect').value = initialLanguage;
});
Expand Down Expand Up @@ -53,12 +53,6 @@

function updateLanguage(languageCode = "en") {
localStorage.setItem('languageCode', languageCode);
updateChildTextContent("admin_configure", languageData[languageCode].admin_configure);
updateChildTextContent("admin_inventory", languageData[languageCode].admin_inventory);
updateChildTextContent("admin_trips", languageData[languageCode].admin_trips);
updateChildTextContent("admin_users", languageData[languageCode].admin_users);
updateChildTextContent("admin_updates", languageData[languageCode].admin_updates);
//updateTextContent("admin_title", languageData[languageCode].admin_title);
}
});
</script>
Expand All @@ -72,16 +66,14 @@

@main(title, currentUser, adminStyles, assets = assets) {
<div id="admin-panels">
<div id="admin-left-panel">
<a id="settings_profile" href="@UsersController.manageGet()" class="fButton fOtherButton fAdminButton userBtns fAdminButtonLeftTextAlign"><span class="glyphicon glyphicon-cog"></span>
Profile</a>
<a id="settings_language" href="@InventoryController.manageGet(0)" class="fButton fOtherButton fAdminButton userBtns fAdminButtonLeftTextAlign"><span class="glyphicon glyphicon-briefcase"></span>
Language</a>
</div>
<div id="admin-right-panel">
<div id="title">
<h2 id="admin_title">Settings Panel</h2>
<h2 id="settings_title">Settings Panel</h2>
</div>
<div id="info">
<h3 id="settings_language">Language Preference.</h3>
</div>

@message
<div id="adminContent">
@content
Expand Down
4 changes: 2 additions & 2 deletions app/femr/ui/views/manager/index.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
.then(response => response.json())
.then(data => {
languageData = data;
//const initialLanguage = localStorage.getItem('languageCode') || 'en';
const initialLanguage = @currentUser.getLanguageCode();
const initialLanguage = localStorage.getItem('languageCode') || 'en';
//const initialLanguage = @currentUser.getLanguageCode();
updateLanguage(initialLanguage);
document.getElementById('languageSelect').value = initialLanguage;
});
Expand Down
4 changes: 2 additions & 2 deletions app/femr/ui/views/medical/index.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
.then(response => response.json())
.then(data => {
languageData = data;
//const initialLanguage = localStorage.getItem('languageCode') || 'en';
const initialLanguage = @currentUser.getLanguageCode();
const initialLanguage = localStorage.getItem('languageCode') || 'en';
//const initialLanguage = @currentUser.getLanguageCode();
updateLanguage(initialLanguage);
document.getElementById('languageSelect').value = initialLanguage;
});
Expand Down
3 changes: 2 additions & 1 deletion app/femr/ui/views/partials/authenticated.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
.then(data => {
languageData = data;
const initialLanguage = localStorage.getItem('languageCode') || 'en';
//const initialLanguage = @currentUser.getLanguageCode();
//const initialLanguage = currentUser.getLanguageCode();
updateLanguage(initialLanguage);
document.getElementById('languageSelect').value = initialLanguage;
});
Expand All @@ -47,6 +47,7 @@
updateTextContent("langCode_admin", languageData[languageCode].langCode_admin);
updateTextContent("langCode_superUser", languageData[languageCode].langCode_superUser);
updateTextContent("langCode_reference", languageData[languageCode].langCode_reference);
updateTextContent("langCode_settings", languageData[languageCode].langCode_settings);
}
});
</script>
Expand Down
4 changes: 2 additions & 2 deletions app/femr/ui/views/partials/footer.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
.then(response => response.json())
.then(data => {
languageData = data;
//const initialLanguage = localStorage.getItem('languageCode') || 'en';
const initialLanguage = @currentUser.getLanguageCode();
const initialLanguage = localStorage.getItem('languageCode') || 'en';
//currentUser.getLanguageCode();
updateLanguage(initialLanguage);
document.getElementById('languageSelect').value = initialLanguage;
});
Expand Down
4 changes: 2 additions & 2 deletions app/femr/ui/views/pharmacies/index.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
.then(response => response.json())
.then(data => {
languageData = data;
//const initialLanguage = localStorage.getItem('languageCode') || 'en';
const initialLanguage = @currentUser.getLanguageCode();
const initialLanguage = localStorage.getItem('languageCode') || 'en';
//const initialLanguage = @currentUser.getLanguageCode();
updateLanguage(initialLanguage);
document.getElementById('languageSelect').value = initialLanguage;
});
Expand Down
17 changes: 7 additions & 10 deletions app/femr/ui/views/settings/index.scala.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@(currentUser: femr.common.dtos.CurrentUser,
viewModelGet: femr.ui.models.settings.IndexViewModelGet,
form: play.data.Form[femr.ui.models.settings.EditViewModel],
//viewModelGet: femr.ui.models.settings.IndexViewModelGet,
//form: play.data.Form[femr.ui.models.settings.EditViewModel],
assets: AssetsFinder)

@import femr.ui.views.html.layouts.settings
Expand All @@ -17,10 +17,8 @@
.then(response => response.json())
.then(data => {
languageData = data;
let initialLanguage = @currentUser.getLanguageCode();
if (initialLanguage == null) {
initialLanguage = "en";
}
const initialLanguage = localStorage.getItem('languageCode') || 'en';
//const initialLanguage = currentUser.getLanguageCode();
updateLanguage(initialLanguage);
document.getElementById('languageSelect').value = initialLanguage;
});
Expand All @@ -36,16 +34,15 @@
}
}

function updateLanguage(languageCode = "en") {
function updateLanguage(languageCode) {
localStorage.setItem('languageCode', languageCode);
//updateTextContent("admin_welcome", languageData[languageCode].admin_welcome);
updateTextContent("settings_title", languageData[languageCode].settings_title);
updateTextContent("settings_language", languageData[languageCode].settings_language);
}
});
</script>

@settings("Settings Panel", currentUser, assets = assets) {
<h3 id="settings_welcome">Welcome, User. Please select a language.</h3>

<p class="userStatus">
<select id="languageSelect" style="margin-left: 10px">
<option value="en">English</option>
Expand Down
12 changes: 10 additions & 2 deletions public/json/languages.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"langCode_admin": "Admin",
"langCode_superUser": "SuperUser",
"langCode_reference": "Reference",
"langCode_settings": "Settings",
"langCode_feedbackBtn": "Leave Feedback",
"langCode_googleChrome": "Designed for use in Google Chrome",
"triage_index_p_That": "That patient could not be found.",
Expand Down Expand Up @@ -265,7 +266,9 @@
"no_trip_assigned_title": "Your account is not assigned to a trip",
"no_trip_assigned_text": "In order to manage your formulary, you must be assigned to a trip. Please assign yourself to a trip before using the inventory feature.",
"manage_trip_users": "Manage Trip Users »",
"formulary_view_info": "You are viewing the formulary for"
"formulary_view_info": "You are viewing the formulary for",
"settings_title": "Settings Panel",
"settings_language": "Language Preference"
},
"es": {
"home_index_h2_Welcome": "Bienvenido a fEMR 2.4.1-beta,",
Expand All @@ -282,6 +285,7 @@
"langCode_admin": "Administración",
"langCode_superUser": "Superusuario",
"langCode_reference": "Referencia",
"langCode_settings": "Configuración",
"triage_index_infant": "Infante",
"langCode_feedbackBtn": "Dejar Comentarios",
"langCode_googleChrome": "Diseñado para usar en Google Chrome",
Expand Down Expand Up @@ -543,7 +547,9 @@
"about": "Acerca de",
"role": "Rol",
"last_login": "Último acceso",
"toggle": "Alternar"
"toggle": "Alternar",
"settings_title": "Panel de configuración",
"settings_language": "Preferencia de idioma"
},
"fr": {
"home_index_h2_Welcome": "Bienvenue sur fEMR 2.4.1-beta,",
Expand All @@ -560,6 +566,7 @@
"langCode_admin": "Admin",
"langCode_superUser": "SuperUtilisateur",
"langCode_reference": "Référence",
"langCode_settings": "Paramètres",
"langCode_feedbackBtn": "Laisser un retour",
"langCode_googleChrome": "Conçu pour être utilisé dans Google Chrome",
"triage_index_p_That": "Ce patient n'a pas pu être trouvé.",
Expand Down Expand Up @@ -2973,6 +2980,7 @@
"langCode_admin": "Administrator",
"langCode_superUser": "SuperUser",
"langCode_reference": "Referenz",
"langCode_settings": "Einstellungen",
"langCode_feedbackBtn": "Hinterlasse Kommentar",
"langCode_googleChrome": "Entwickelt für die Verwendung in Google Chrome",
"triage_index_p_That": "Dieser Patient konnte nicht gefunden werden.",
Expand Down

0 comments on commit 4483246

Please sign in to comment.