From d3ffc45be334637dd65faef48f8967576b3b5eb8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Pau=20Ferrer=20Oca=C3=B1a?=
Date: Fri, 29 Oct 2021 12:36:42 +0200
Subject: [PATCH] MOBILE-3807 usermenu: Change UI and texts
---
scripts/langindex.json | 1 +
.../login/components/sites/sites.html | 5 +-
.../features/login/pages/sites/sites.html | 2 +-
.../features/login/services/login-helper.ts | 19 +++---
.../components/user-menu/user-menu.html | 37 ++++-------
.../components/user-menu/user-menu.scss | 16 -----
.../pages/space-usage/space-usage.html | 2 +-
.../synchronization/synchronization.html | 2 +-
src/core/features/user/pages/about/about.html | 63 +++++++++++--------
src/core/services/sites.ts | 12 ++--
10 files changed, 71 insertions(+), 88 deletions(-)
diff --git a/scripts/langindex.json b/scripts/langindex.json
index 093646fcf..b269f6b62 100644
--- a/scripts/langindex.json
+++ b/scripts/langindex.json
@@ -2255,6 +2255,7 @@
"core.user.participants": "moodle",
"core.user.phone1": "moodle",
"core.user.phone2": "moodle",
+ "core.user.profile": "moodle",
"core.user.roles": "moodle",
"core.user.sendemail": "local_moodlemobileapp",
"core.user.student": "moodle/defaultcoursestudent",
diff --git a/src/core/features/login/components/sites/sites.html b/src/core/features/login/components/sites/sites.html
index 20ee59b87..5cf1c7fae 100644
--- a/src/core/features/login/components/sites/sites.html
+++ b/src/core/features/login/components/sites/sites.html
@@ -26,7 +26,8 @@
- {{ accountsList.currentSite.siteUrl }}
+
{{
+ accountsList.currentSite.siteUrlWithoutProtocol }}
@@ -52,7 +53,7 @@
- {{ sites[0].siteUrl }}
+ {{ sites[0].siteUrlWithoutProtocol }}
diff --git a/src/core/features/login/pages/sites/sites.html b/src/core/features/login/pages/sites/sites.html
index b9d3ed2b7..a47a65f2f 100644
--- a/src/core/features/login/pages/sites/sites.html
+++ b/src/core/features/login/pages/sites/sites.html
@@ -26,7 +26,7 @@
- {{ sites[0].siteUrl }}
+ {{ sites[0].siteUrlWithoutProtocol }}
diff --git a/src/core/features/login/services/login-helper.ts b/src/core/features/login/services/login-helper.ts
index 545898b2b..627547671 100644
--- a/src/core/features/login/services/login-helper.ts
+++ b/src/core/features/login/services/login-helper.ts
@@ -1357,25 +1357,23 @@ export class CoreLoginHelperProvider {
const index = sites.findIndex((site) => site.id == currentSiteId);
accountsList.currentSite = sites.splice(index, 1)[0];
- siteUrl = accountsList.currentSite.siteUrl.replace(/^https?:\/\//, '').toLowerCase();
- accountsList.currentSite.siteUrl = siteUrl;
+ siteUrl = accountsList.currentSite.siteUrlWithoutProtocol;
}
const otherSites: Record = {};
// Add site counter and classify sites.
await Promise.all(sites.map(async (site) => {
- site.siteUrl = site.siteUrl.replace(/^https?:\/\//, '').toLowerCase();
site.badge = await CoreUtils.ignoreErrors(CorePushNotifications.getSiteCounter(site.id)) || 0;
- if (site.siteUrl == siteUrl) {
+ if (site.siteUrlWithoutProtocol == siteUrl) {
accountsList.sameSite.push(site);
} else {
- if (!otherSites[site.siteUrl]) {
- otherSites[site.siteUrl] = [];
+ if (!otherSites[site.siteUrlWithoutProtocol]) {
+ otherSites[site.siteUrlWithoutProtocol] = [];
}
- otherSites[site.siteUrl].push(site);
+ otherSites[site.siteUrlWithoutProtocol].push(site);
}
return;
@@ -1396,11 +1394,11 @@ export class CoreLoginHelperProvider {
async deleteAccountFromList(accountsList: CoreAccountsList, site: CoreSiteBasicInfo): Promise {
await CoreSites.deleteSite(site.id);
- const siteUrl = site.siteUrl;
+ const siteUrl = site.siteUrlWithoutProtocol;
let index = 0;
// Found on same site.
- if (accountsList.sameSite.length > 0 && accountsList.sameSite[0].siteUrl == siteUrl) {
+ if (accountsList.sameSite.length > 0 && accountsList.sameSite[0].siteUrlWithoutProtocol == siteUrl) {
index = accountsList.sameSite.findIndex((listedSite) => listedSite.id == site.id);
if (index >= 0) {
accountsList.sameSite.splice(index, 1);
@@ -1410,7 +1408,8 @@ export class CoreLoginHelperProvider {
return;
}
- const otherSiteIndex = accountsList.otherSites.findIndex((sites) => sites.length > 0 && sites[0].siteUrl == siteUrl);
+ const otherSiteIndex = accountsList.otherSites.findIndex((sites) =>
+ sites.length > 0 && sites[0].siteUrlWithoutProtocol == siteUrl);
if (otherSiteIndex < 0) {
// Site Url not found.
return;
diff --git a/src/core/features/mainmenu/components/user-menu/user-menu.html b/src/core/features/mainmenu/components/user-menu/user-menu.html
index 4cb01be69..c36894446 100644
--- a/src/core/features/mainmenu/components/user-menu/user-menu.html
+++ b/src/core/features/mainmenu/components/user-menu/user-menu.html
@@ -8,32 +8,19 @@
{{'core.user.account' | translate}}
-
-
-
-
-
-
-
-
-
-
+
+
{{ siteInfo.fullname }}
-
@@ -41,7 +28,7 @@
[attr.aria-label]="'core.user.details' | translate" detail="true" lines="none">
- {{ 'core.user.details' | translate }}
+ {{ 'core.user.profile' | translate }}
@@ -51,17 +38,17 @@
-
+
{{ handler.title | translate }}
-
-
+
{{ 'core.mainmenu.logout' | translate }}
diff --git a/src/core/features/mainmenu/components/user-menu/user-menu.scss b/src/core/features/mainmenu/components/user-menu/user-menu.scss
index bae1b1d30..74e3b93a4 100644
--- a/src/core/features/mainmenu/components/user-menu/user-menu.scss
+++ b/src/core/features/mainmenu/components/user-menu/user-menu.scss
@@ -1,22 +1,6 @@
@import "~theme/globals";
:host {
- .core-user-profile-maininfo::part(native) {
- flex-direction: column;
- }
-
- ::ng-deep {
- core-user-avatar {
- display: block;
- --core-avatar-size: var(--core-large-avatar-size);
- height: calc(var(--core-avatar-size) + 16px);
-
- img {
- margin: 8px auto;
- }
- }
- }
-
.core-user-menu-preferences {
--inner-border-width: 0;
--border-width: 1px 0 0 0;
diff --git a/src/core/features/settings/pages/space-usage/space-usage.html b/src/core/features/settings/pages/space-usage/space-usage.html
index aa17b099a..6d1343a40 100644
--- a/src/core/features/settings/pages/space-usage/space-usage.html
+++ b/src/core/features/settings/pages/space-usage/space-usage.html
@@ -25,7 +25,7 @@
{{ site.fullName }}
- {{ site.siteUrl }}
+ {{ site.siteUrlWithoutProtocol }}
{{ site.spaceUsage | coreBytesToSize }}
diff --git a/src/core/features/settings/pages/synchronization/synchronization.html b/src/core/features/settings/pages/synchronization/synchronization.html
index 625d67b88..31fe30857 100644
--- a/src/core/features/settings/pages/synchronization/synchronization.html
+++ b/src/core/features/settings/pages/synchronization/synchronization.html
@@ -37,7 +37,7 @@
{{ site.fullName }}
- {{ site.siteUrl }}
+ {{ site.siteUrlWithoutProtocol }}
- {{ 'core.user.details' | translate }}
+ {{ 'core.user.profile' | translate }}
@@ -14,56 +14,55 @@
-
+
{{ user.fullname }}
- {{ user.address }}
+
+ {{ user.address }}
+
- {{ 'core.user.contact' | translate}}
+
+
+ {{ 'core.user.contact' | translate}}
+
+
{{ 'core.user.email' | translate }}
-
- {{ user.email }}
-
+
+ {{ user.email }}
+
{{ 'core.user.phone1' | translate}}
- {{ user.phone1 }}
-
+ {{ user.phone1 }}
+
{{ 'core.user.phone2' | translate}}
- {{ user.phone2 }}
-
+ {{ user.phone2 }}
+
{{ 'core.user.address' | translate}}
- {{ formattedAddress }}
-
+ {{ formattedAddress }}
+
@@ -80,13 +79,17 @@
- {{ 'core.userdetails' | translate}}
+
+
+ {{ 'core.userdetails' | translate}}
+
+
{{ 'core.user.webpage' | translate}}
- {{ user.url }}
-
+ {{ user.url }}
+
@@ -100,11 +103,17 @@
- {{ 'core.user.description' | translate}}
+
+
+ {{ 'core.user.description' | translate}}
+
+
-
-
+
+
+
+
diff --git a/src/core/services/sites.ts b/src/core/services/sites.ts
index 3b77bf38b..abbcc0de6 100644
--- a/src/core/services/sites.ts
+++ b/src/core/services/sites.ts
@@ -1052,8 +1052,10 @@ export class CoreSitesProvider {
* @param siteId The site ID. If not defined, current site (if available).
* @return Promise resolved with site home ID.
*/
- getSiteHomeId(siteId?: string): Promise {
- return this.getSite(siteId).then((site) => site.getSiteHomeId());
+ async getSiteHomeId(siteId?: string): Promise {
+ const site = await this.getSite(siteId);
+
+ return site.getSiteHomeId();
}
/**
@@ -1074,6 +1076,7 @@ export class CoreSitesProvider {
const basicInfo: CoreSiteBasicInfo = {
id: site.id,
siteUrl: site.siteUrl,
+ siteUrlWithoutProtocol: site.siteUrl.replace(/^https?:\/\//, '').toLowerCase(),
fullName: siteInfo?.fullname,
siteName: CoreConstants.CONFIG.sitename == '' ? siteInfo?.sitename: CoreConstants.CONFIG.sitename,
avatar: siteInfo?.userpictureurl,
@@ -1098,9 +1101,7 @@ export class CoreSitesProvider {
// Sort sites by url and fullname.
sites.sort((a, b) => {
// First compare by site url without the protocol.
- const urlA = a.siteUrl.replace(/^https?:\/\//, '').toLowerCase();
- const urlB = b.siteUrl.replace(/^https?:\/\//, '').toLowerCase();
- const compare = urlA.localeCompare(urlB);
+ const compare = a.siteUrlWithoutProtocol.localeCompare(b.siteUrlWithoutProtocol);
if (compare !== 0) {
return compare;
@@ -1756,6 +1757,7 @@ export type CoreSiteUserTokenResponse = {
export type CoreSiteBasicInfo = {
id: string; // Site ID.
siteUrl: string; // Site URL.
+ siteUrlWithoutProtocol: string; // Site URL without protocol.
fullName?: string; // User's full name.
siteName?: string; // Site's name.
avatar?: string; // User's avatar.