MOBILE-3807 more: Remove unused items on more menu and styling

main
Pau Ferrer Ocaña 2021-10-22 12:24:05 +02:00
parent 0bbfb898d1
commit 1adda456c9
11 changed files with 69 additions and 112 deletions

View File

@ -1923,10 +1923,8 @@
"core.login.yourenteredsite": "local_moodlemobileapp",
"core.lostconnection": "local_moodlemobileapp",
"core.mainmenu.changesite": "local_moodlemobileapp",
"core.mainmenu.help": "moodle",
"core.mainmenu.home": "moodle",
"core.mainmenu.logout": "moodle",
"core.mainmenu.website": "local_moodlemobileapp",
"core.maxfilesize": "moodle",
"core.maxsizeandattachments": "moodle",
"core.min": "moodle",
@ -1960,7 +1958,7 @@
"core.mod_wiki": "wiki/pluginname",
"core.mod_workshop": "workshop/pluginname",
"core.moduleintro": "moodle",
"core.more": "moodle",
"core.more": "moodle/moremenu",
"core.mygroups": "group",
"core.name": "moodle",
"core.needhelp": "local_moodlemobileapp",

View File

@ -13,7 +13,7 @@
<ion-content>
<core-loading [hideUntil]="true">
<ion-list>
<ion-item class="ion-text-center core-user-profile-maininfo" *ngIf="siteInfo">
<ion-item class="ion-text-center core-user-profile-maininfo" *ngIf="siteInfo" lines="none">
<core-user-avatar [user]="siteInfo" [userId]="siteInfo.userid" [linkProfile]="false"></core-user-avatar>
<ion-label>
<h2>{{ siteInfo.fullname }}</h2>
@ -21,32 +21,35 @@
<core-format-text [text]="siteName" contextLevel="system" [contextInstanceId]="0" [wsNotFiltered]="true">
</core-format-text>
</p>
<p class="core-usermenu-siteinfo core-usermenu-siteurl">{{ siteUrl }}</p>
<p class="core-usermenu-siteinfo core-usermenu-siteurl">
<a [href]="siteUrl" core-link autoLogin="yes">{{ siteUrl }}</a>
</p>
</ion-label>
</ion-item>
<ion-item button class="ion-text-wrap core-usermenu-handler" (click)="openUserProfile($event)"
[attr.aria-label]="'core.user.details' | translate" detail="true">
[attr.aria-label]="'core.user.details' | translate" detail="true" lines="none">
<ion-icon name="fas-user" slot="start" aria-hidden="true"></ion-icon>
<ion-label>
<p class="item-heading">{{ 'core.user.details' | translate }}</p>
</ion-label>
</ion-item>
<ion-item class="ion-text-center" *ngIf="(!handlers || !handlers.length) && !handlersLoaded">
<ion-item class="ion-text-center" *ngIf="(!handlers || !handlers.length) && !handlersLoaded" lines="none">
<ion-label><ion-spinner [attr.aria-label]="'core.loading' | translate"></ion-spinner></ion-label>
</ion-item>
<ion-item button *ngFor="let handler of handlers" class="ion-text-wrap" (click)="handlerClicked($event, handler)"
[ngClass]="['core-user-menu-handler', handler.class || '']" [hidden]="handler.hidden"
[attr.aria-label]="handler.title | translate" detail="true">
[attr.aria-label]="handler.title | translate" detail="true" lines="none">
<ion-icon *ngIf="handler.icon" [name]="handler.icon" slot="start" aria-hidden="true"></ion-icon>
<ion-label>
<p class="item-heading">{{ handler.title | translate }}</p>
</ion-label>
</ion-item>
<ion-item button (click)="openPreferences($event)" [attr.aria-label]="'core.settings.preferences' | translate" detail="true">
<ion-item button (click)="openPreferences($event)" [attr.aria-label]="'core.settings.preferences' | translate" detail="true"
class="core-user-menu-preferences">
<ion-icon name="fas-wrench" slot="start" aria-hidden="true"></ion-icon>
<ion-label>
<p class="item-heading">{{ 'core.settings.preferences' | translate }}</p>

View File

@ -16,6 +16,11 @@
}
}
}
.core-user-menu-preferences {
--inner-border-width: 0;
--border-width: 1px 0 0 0;
}
}
@if ($core-user-hide-siteinfo) {

View File

@ -1,7 +1,5 @@
{
"changesite": "Change site",
"help": "Help",
"home": "Home",
"logout": "Log out",
"website": "Website"
"logout": "Log out"
}

View File

@ -4,7 +4,7 @@
<ion-back-button [text]="'core.back' | translate"></ion-back-button>
</ion-buttons>
<h1><core-format-text [text]="siteName" contextLevel="system" [contextInstanceId]="0"></core-format-text></h1>
<h1>{{ 'core.more' | translate }}</h1>
<ion-buttons slot="end">
<core-user-menu-button></core-user-menu-button>
@ -54,20 +54,6 @@
<p class="item-heading">{{ 'core.scanqr' | translate }}</p>
</ion-label>
</ion-item>
<ion-item button *ngIf="showWeb && siteInfo" [href]="siteInfo.siteurl" core-link autoLogin="yes"
[attr.aria-label]="'core.mainmenu.website' | translate" detail="true" detailIcon="open-outline">
<ion-icon name="fas-globe" slot="start" aria-hidden="true"></ion-icon>
<ion-label>
<p class="item-heading">{{ 'core.mainmenu.website' | translate }}</p>
</ion-label>
</ion-item>
<ion-item button *ngIf="showHelp" [href]="docsUrl" core-link autoLogin="no"
[attr.aria-label]="'core.mainmenu.help' | translate" detail="true" detailIcon="open-outline">
<ion-icon name="far-life-ring" slot="start" aria-hidden="true"></ion-icon>
<ion-label>
<p class="item-heading">{{ 'core.mainmenu.help' | translate }}</p>
</ion-label>
</ion-item>
</ion-list>
</ion-content>
<ion-footer>

View File

@ -17,7 +17,6 @@ import { Subscription } from 'rxjs';
import { CoreSites } from '@services/sites';
import { CoreUtils } from '@services/utils/utils';
import { CoreSiteInfo } from '@classes/site';
import { CoreMainMenuDelegate, CoreMainMenuHandlerData } from '../../services/mainmenu-delegate';
import { CoreMainMenu, CoreMainMenuCustomItem } from '../../services/mainmenu';
import { CoreEventObserver, CoreEvents } from '@singletons/events';
@ -28,7 +27,7 @@ import { CoreTextUtils } from '@services/utils/text';
import { Translate } from '@singletons';
/**
* Page that displays the main menu of the app.
* Page that displays the more page of the app.
*/
@Component({
selector: 'page-core-mainmenu-more',
@ -39,12 +38,7 @@ export class CoreMainMenuMorePage implements OnInit, OnDestroy {
handlers?: CoreMainMenuHandlerData[];
handlersLoaded = false;
siteInfo?: CoreSiteInfo;
siteName?: string;
showScanQR: boolean;
showWeb?: boolean;
showHelp?: boolean;
docsUrl?: string;
customItems?: CoreMainMenuCustomItem[];
protected allHandlers?: CoreMainMenuHandlerData[];
@ -53,14 +47,14 @@ export class CoreMainMenuMorePage implements OnInit, OnDestroy {
protected updateSiteObserver: CoreEventObserver;
constructor() {
this.langObserver = CoreEvents.on(CoreEvents.LANGUAGE_CHANGED, this.loadCustomMenuItems.bind(this));
this.updateSiteObserver = CoreEvents.on(CoreEvents.SITE_UPDATED, async () => {
this.customItems = await CoreMainMenu.getCustomMenuItems();
}, CoreSites.getCurrentSiteId());
this.loadCustomMenuItems();
this.langObserver = CoreEvents.on(CoreEvents.LANGUAGE_CHANGED, this.loadSiteInfo.bind(this));
this.updateSiteObserver = CoreEvents.on(
CoreEvents.SITE_UPDATED,
this.loadSiteInfo.bind(this),
CoreSites.getCurrentSiteId(),
);
this.loadSiteInfo();
this.showScanQR = CoreUtils.canScanQR() &&
!CoreSites.getCurrentSite()?.isFeatureDisabled('CoreMainMenuDelegate_QrReader');
}
@ -109,18 +103,9 @@ export class CoreMainMenuMorePage implements OnInit, OnDestroy {
}
/**
* Load the site info required by the view.
* Load custom menu items.
*/
protected async loadSiteInfo(): Promise<void> {
const currentSite = CoreSites.getRequiredCurrentSite();
this.siteInfo = currentSite.getInfo();
this.siteName = currentSite.getSiteName();
this.showWeb = !currentSite.isFeatureDisabled('CoreMainMenuDelegate_website');
this.showHelp = !currentSite.isFeatureDisabled('CoreMainMenuDelegate_help');
this.docsUrl = await currentSite.getDocsUrl();
protected async loadCustomMenuItems(): Promise<void> {
this.customItems = await CoreMainMenu.getCustomMenuItems();
}

View File

@ -15,18 +15,6 @@
</ion-refresher>
<core-loading [hideUntil]="handlers.loaded">
<ion-list>
<ion-item *ngIf="siteInfo" class="ion-text-wrap">
<ion-label>
<p class="item-heading">{{siteInfo!.fullname}}</p>
<p>
<core-format-text [text]="siteName" contextLevel="system" [contextInstanceId]="0"
[wsNotFiltered]="true"></core-format-text>
</p>
<p>{{ siteUrl }}</p>
</ion-label>
</ion-item>
<core-spacer></core-spacer>
<ion-item *ngFor="let handler of handlers.items" [ngClass]="['core-settings-handler', handler.class]"
[attr.aria-label]="handler.title | translate" detail="true" (click)="handlers.select(handler)" button
[attr.aria-current]="handlers.getItemAriaCurrent(handler)">
@ -36,38 +24,37 @@
<p class="item-heading">{{ handler.title | translate}}</p>
</ion-label>
</ion-item>
<ion-card>
<ion-item class="ion-text-wrap" *ngIf="spaceUsage">
<ion-label>
<p class="item-heading ion-text-wrap">{{ 'core.settings.spaceusage' | translate }}</p>
<p *ngIf="spaceUsage.spaceUsage">{{ spaceUsage.spaceUsage | coreBytesToSize }}</p>
</ion-label>
<ion-button fill="clear" [attr.aria-label]="'core.info' | translate" (click)="showSpaceInfo()" slot="end">
<ion-icon name="fas-info-circle" color="info" slot="icon-only"></ion-icon>
</ion-button>
<ion-button fill="clear" color="danger" slot="end" (click)="deleteSiteStorage()"
[hidden]="spaceUsage.spaceUsage! + spaceUsage.cacheEntries! <= 0"
[attr.aria-label]="'core.settings.deletesitefilestitle' | translate">
<ion-icon name="fas-trash" slot="icon-only" aria-hidden="true"></ion-icon>
</ion-button>
</ion-item>
<ion-item class="ion-text-wrap">
<ion-label>
<p class="item-heading">{{ 'core.settings.synchronizenow' | translate }}</p>
</ion-label>
<ion-button fill="clear" [attr.aria-label]="'core.info' | translate" (click)="showSyncInfo()" slot="end">
<ion-icon name="fas-info-circle" color="info" slot="icon-only"></ion-icon>
</ion-button>
<core-button-with-spinner [loading]="isSynchronizing()" slot="end">
<ion-button fill="clear" (click)="synchronize()"
[attr.aria-label]="'core.settings.synchronizenow' | translate">
<ion-icon name="fas-sync-alt" slot="icon-only" aria-hidden="true"></ion-icon>
</ion-button>
</core-button-with-spinner>
</ion-item>
</ion-card>
</ion-list>
<ion-card>
<ion-item class="ion-text-wrap" *ngIf="spaceUsage">
<ion-label>
<p class="item-heading ion-text-wrap">{{ 'core.settings.spaceusage' | translate }}</p>
<p *ngIf="spaceUsage.spaceUsage">{{ spaceUsage.spaceUsage | coreBytesToSize }}</p>
</ion-label>
<ion-button fill="clear" [attr.aria-label]="'core.info' | translate" (click)="showSpaceInfo()" slot="end">
<ion-icon name="fas-info-circle" color="info" slot="icon-only"></ion-icon>
</ion-button>
<ion-button fill="clear" color="danger" slot="end" (click)="deleteSiteStorage()"
[hidden]="spaceUsage.spaceUsage! + spaceUsage.cacheEntries! <= 0"
[attr.aria-label]="'core.settings.deletesitefilestitle' | translate">
<ion-icon name="fas-trash" slot="icon-only" aria-hidden="true"></ion-icon>
</ion-button>
</ion-item>
<ion-item class="ion-text-wrap">
<ion-label>
<p class="item-heading">{{ 'core.settings.synchronizenow' | translate }}</p>
</ion-label>
<ion-button fill="clear" [attr.aria-label]="'core.info' | translate" (click)="showSyncInfo()" slot="end">
<ion-icon name="fas-info-circle" color="info" slot="icon-only"></ion-icon>
</ion-button>
<core-button-with-spinner [loading]="isSynchronizing()" slot="end">
<ion-button fill="clear" (click)="synchronize()"
[attr.aria-label]="'core.settings.synchronizenow' | translate">
<ion-icon name="fas-sync-alt" slot="icon-only" aria-hidden="true"></ion-icon>
</ion-button>
</core-button-with-spinner>
</ion-item>
</ion-card>
</core-loading>
</core-split-view>
</ion-content>

View File

@ -22,7 +22,6 @@ import { CoreSites } from '@services/sites';
import { CoreDomUtils } from '@services/utils/dom';
import { CoreSettingsHelper, CoreSiteSpaceUsage } from '../../services/settings-helper';
import { CoreApp } from '@services/app';
import { CoreSiteInfo } from '@classes/site';
import { Translate } from '@singletons';
import { CoreNavigator } from '@services/navigator';
import { CorePageItemsListManager } from '@classes/page-items-list-manager';
@ -43,9 +42,6 @@ export class CoreSitePreferencesPage implements AfterViewInit, OnDestroy {
isIOS: boolean;
siteId: string;
siteInfo?: CoreSiteInfo;
siteName?: string;
siteUrl?: string;
spaceUsage: CoreSiteSpaceUsage = {
cacheEntries: 0,
spaceUsage: 0,
@ -60,11 +56,9 @@ export class CoreSitePreferencesPage implements AfterViewInit, OnDestroy {
this.siteId = CoreSites.getCurrentSiteId();
this.handlers = new CoreSettingsSitePreferencesManager(CoreSitePreferencesPage);
this.sitesObserver = CoreEvents.on(CoreEvents.SITE_UPDATED, (data) => {
if (data.siteId == this.siteId) {
this.refreshData();
}
});
this.sitesObserver = CoreEvents.on(CoreEvents.SITE_UPDATED, () => {
this.refreshData();
}, this.siteId);
}
/**
@ -94,11 +88,6 @@ export class CoreSitePreferencesPage implements AfterViewInit, OnDestroy {
protected async fetchData(): Promise<void> {
this.handlers.setItems(CoreSettingsDelegate.getHandlers());
const currentSite = CoreSites.getCurrentSite();
this.siteInfo = currentSite!.getInfo();
this.siteName = currentSite!.getSiteName();
this.siteUrl = currentSite!.getURL();
this.spaceUsage = await CoreSettingsHelper.getSiteSpaceUsage(this.siteId);
}
@ -145,7 +134,9 @@ export class CoreSitePreferencesPage implements AfterViewInit, OnDestroy {
*/
async deleteSiteStorage(): Promise<void> {
try {
this.spaceUsage = await CoreSettingsHelper.deleteSiteStorage(this.siteName || '', this.siteId);
const siteName = CoreSites.getRequiredCurrentSite().getSiteName();
this.spaceUsage = await CoreSettingsHelper.deleteSiteStorage(siteName, this.siteId);
} catch {
// Ignore cancelled confirmation modal.
}

View File

@ -12,7 +12,7 @@
</ion-refresher>
<core-loading [hideUntil]="userLoaded">
<ion-list *ngIf="user">
<ion-item class="ion-text-center core-user-profile-maininfo">
<ion-item class="ion-text-center core-user-profile-maininfo" lines="full">
<core-user-avatar [user]="user" [userId]="user.id" [linkProfile]="false" [checkOnline]="true">
<ion-button
class="edit-avatar"

View File

@ -185,7 +185,7 @@
"mod_wiki": "Wiki",
"mod_workshop": "Workshop",
"moduleintro": "Description",
"more": "more",
"more": "More",
"mygroups": "My groups",
"name": "Name",
"needhelp": "Need help?",

View File

@ -1039,6 +1039,10 @@ ion-item.item-multiple-inputs.only-links {
}
}
a {
cursor: pointer;
}
// Case with ion-input + ion-select inside.
ion-item.item-input.item-multiple-inputs {
.flex-row {