Skip to content

Commit

Permalink
Merge pull request #4266 from crazyserver/MOBILE-3063
Browse files Browse the repository at this point in the history
Mobile 3063
  • Loading branch information
dpalou authored Dec 18, 2024
2 parents a2d4936 + 170817e commit 0af6865
Show file tree
Hide file tree
Showing 24 changed files with 780 additions and 108 deletions.
13 changes: 13 additions & 0 deletions scripts/langindex.json
Original file line number Diff line number Diff line change
Expand Up @@ -2680,6 +2680,19 @@
"core.viewcode": "local_moodlemobileapp",
"core.vieweditor": "local_moodlemobileapp",
"core.viewembeddedcontent": "local_moodlemobileapp",
"core.viewer.decreasetextsize": "local_moodlemobileapp",
"core.viewer.default": "moodle",
"core.viewer.enterreadingmode": "local_moodlemobileapp",
"core.viewer.exitreadingmode": "local_moodlemobileapp",
"core.viewer.increasetextsize": "local_moodlemobileapp",
"core.viewer.openreadingmodesettings": "local_moodlemobileapp",
"core.viewer.readingthemeauto": "local_moodlemobileapp",
"core.viewer.readingthemedark": "local_moodlemobileapp/core.settings.colorscheme-dark",
"core.viewer.readingthemehcm": "local_moodlemobileapp",
"core.viewer.readingthemelight": "local_moodlemobileapp/core.settings.colorscheme-light",
"core.viewer.readingthemesepia": "local_moodlemobileapp",
"core.viewer.showmedia": "zoom",
"core.viewer.theme": "moodle",
"core.viewprofile": "moodle",
"core.wanttochangesite": "local_moodlemobileapp",
"core.warningofflinedatadeleted": "local_moodlemobileapp",
Expand Down
2 changes: 1 addition & 1 deletion src/addons/mod/book/pages/contents/contents.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ <h1>
<div class="safe-area-padding-horizontal core-swipe-slides-container">
<core-swipe-slides [manager]="manager" [options]="swiperOpts">
<ng-template let-chapter="item" let-active="active">
<div class="ion-padding">
<div class="ion-padding" core-reading-mode>
<core-format-text [component]="component" [componentId]="cmId" [text]="chapter.content" contextLevel="module"
[contextInstanceId]="cmId" [courseId]="courseId" [disabled]="!active" />
<div class="ion-margin-top" *ngIf="chapter.tags?.length > 0">
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
136 changes: 71 additions & 65 deletions src/addons/mod/glossary/pages/entry/entry.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ <h1 *ngIf="entry">
<core-format-text [text]="entry.concept" contextLevel="module" [contextInstanceId]="componentId" [courseId]="courseId" />
</h1>
</ion-title>
<ion-buttons slot="end" />
</ion-toolbar>
</ion-header>
<ion-content [core-swipe-navigation]="entries" class="limited-width">
Expand All @@ -23,72 +24,77 @@ <h1 *ngIf="entry">
<ion-label>{{ 'core.hasdatatosync' | translate: { $a: 'addon.mod_glossary.entry' | translate } }}</ion-label>
</ion-item>
</ion-card>
<ion-item class="ion-text-wrap" *ngIf="showAuthor">
<core-user-avatar [user]="entry" slot="start" />
<ion-label>
<h2>
<core-format-text [text]="entry.concept" contextLevel="module" [contextInstanceId]="componentId"
[courseId]="courseId" />
</h2>
<p *ngIf="onlineEntry">{{ onlineEntry.userfullname }}</p>
</ion-label>
<ion-note slot="end" *ngIf="showDate && onlineEntry">{{ onlineEntry.timemodified | coreDateDayOrTime }}</ion-note>
</ion-item>
<ion-item class="ion-text-wrap" *ngIf="!showAuthor">
<ion-label>
<p class="item-heading">
<core-format-text [text]="entry.concept" contextLevel="module" [contextInstanceId]="componentId" />
</p>
</ion-label>
<ion-note slot="end" *ngIf="showDate && onlineEntry">{{ onlineEntry.timemodified | coreDateDayOrTime }}</ion-note>
</ion-item>
<ion-item class="ion-text-wrap">
<ion-label>
<core-format-text [component]="component" [componentId]="componentId" [text]="entry.definition" contextLevel="module"
[contextInstanceId]="componentId" [courseId]="courseId" />
</ion-label>
</ion-item>
<div *ngIf="onlineEntry && onlineEntry.attachment">
<core-file *ngFor="let file of onlineEntry.attachments" [file]="file" [component]="component" [componentId]="componentId" />
</div>
<div *ngIf="offlineEntry && offlineEntry.attachments">
<core-file *ngFor="let file of offlineEntry.attachments.online" [file]="file" [component]="component"
[componentId]="componentId" />
</div>
<div *ngIf="offlineEntry && offlineEntryFiles">
<core-local-file *ngFor="let file of offlineEntryFiles" [file]="file" />
</div>
<ion-item class="ion-text-wrap" *ngIf="onlineEntry && tagsEnabled && entry && onlineEntry.tags && onlineEntry.tags.length > 0">
<ion-label>
<div slot="start">{{ 'core.tag.tags' | translate }}:</div>
<core-tag-list [tags]="onlineEntry.tags" />
</ion-label>
</ion-item>
<ion-item *ngIf="canDelete || canEdit">
<div slot="end">
<ion-button *ngIf="canDelete" fill="clear" color="danger" (click)="deleteEntry()"
[ariaLabel]="'addon.mod_glossary.deleteentry' | translate">
<ion-icon slot="icon-only" name="fas-trash" aria-hidden="true" />
</ion-button>
<ion-button *ngIf="canEdit" fill="clear" (click)="editEntry()" [ariaLabel]="'addon.mod_glossary.editentry' | translate">
<ion-icon slot="icon-only" name="fas-pen" aria-hidden="true" />
</ion-button>
<div core-reading-mode>
<ion-item class="ion-text-wrap" *ngIf="showAuthor">
<core-user-avatar [user]="entry" slot="start" />
<ion-label>
<h2>
<core-format-text [text]="entry.concept" contextLevel="module" [contextInstanceId]="componentId"
[courseId]="courseId" />
</h2>
<p *ngIf="onlineEntry">{{ onlineEntry.userfullname }}</p>
</ion-label>
<ion-note slot="end" *ngIf="showDate && onlineEntry">{{ onlineEntry.timemodified | coreDateDayOrTime }}</ion-note>
</ion-item>
<ion-item class="ion-text-wrap" *ngIf="!showAuthor">
<ion-label>
<p class="item-heading">
<core-format-text [text]="entry.concept" contextLevel="module" [contextInstanceId]="componentId" />
</p>
</ion-label>
<ion-note slot="end" *ngIf="showDate && onlineEntry">{{ onlineEntry.timemodified | coreDateDayOrTime }}</ion-note>
</ion-item>
<ion-item class="ion-text-wrap">
<ion-label>
<core-format-text [component]="component" [componentId]="componentId" [text]="entry.definition"
contextLevel="module" [contextInstanceId]="componentId" [courseId]="courseId" />
</ion-label>
</ion-item>
<div *ngIf="onlineEntry && onlineEntry.attachment">
<core-file *ngFor="let file of onlineEntry.attachments" [file]="file" [component]="component"
[componentId]="componentId" />
</div>
</ion-item>
<ion-item class="ion-text-wrap" *ngIf="onlineEntry && !onlineEntry.approved">
<ion-label>
<p><em>{{ 'addon.mod_glossary.entrypendingapproval' | translate }}</em></p>
</ion-label>
</ion-item>
<core-comments *ngIf="glossary && glossary.allowcomments && onlineEntry && onlineEntry.id > 0 && commentsEnabled"
contextLevel="module" [instanceId]="glossary.coursemodule" component="mod_glossary" [itemId]="onlineEntry.id"
area="glossary_entry" [courseId]="glossary.course" [showItem]="true" />
<core-rating-rate *ngIf="glossary && ratingInfo && onlineEntry" [ratingInfo]="ratingInfo" contextLevel="module"
[instanceId]="glossary.coursemodule" [itemId]="onlineEntry.id" [itemSetId]="0" [courseId]="glossary.course"
[aggregateMethod]="glossary.assessed" [scaleId]="glossary.scale" [userId]="entry.userid" (onUpdate)="ratingUpdated()" />
<core-rating-aggregate *ngIf="glossary && ratingInfo && onlineEntry" [ratingInfo]="ratingInfo" contextLevel="module"
[instanceId]="glossary.coursemodule" [itemId]="onlineEntry.id" [courseId]="glossary.course"
[aggregateMethod]="glossary.assessed" [scaleId]="glossary.scale" />
<div *ngIf="offlineEntry && offlineEntry.attachments">
<core-file *ngFor="let file of offlineEntry.attachments.online" [file]="file" [component]="component"
[componentId]="componentId" />
</div>
<div *ngIf="offlineEntry && offlineEntryFiles">
<core-local-file *ngFor="let file of offlineEntryFiles" [file]="file" />
</div>
<ion-item class="ion-text-wrap"
*ngIf="onlineEntry && tagsEnabled && entry && onlineEntry.tags && onlineEntry.tags.length > 0">
<ion-label>
<div slot="start">{{ 'core.tag.tags' | translate }}:</div>
<core-tag-list [tags]="onlineEntry.tags" />
</ion-label>
</ion-item>
<ion-item *ngIf="canDelete || canEdit">
<div slot="end">
<ion-button *ngIf="canDelete" fill="clear" color="danger" (click)="deleteEntry()"
[ariaLabel]="'addon.mod_glossary.deleteentry' | translate">
<ion-icon slot="icon-only" name="fas-trash" aria-hidden="true" />
</ion-button>
<ion-button *ngIf="canEdit" fill="clear" (click)="editEntry()"
[ariaLabel]="'addon.mod_glossary.editentry' | translate">
<ion-icon slot="icon-only" name="fas-pen" aria-hidden="true" />
</ion-button>
</div>
</ion-item>
<ion-item class="ion-text-wrap" *ngIf="onlineEntry && !onlineEntry.approved">
<ion-label>
<p><em>{{ 'addon.mod_glossary.entrypendingapproval' | translate }}</em></p>
</ion-label>
</ion-item>
<core-comments *ngIf="glossary && glossary.allowcomments && onlineEntry && onlineEntry.id > 0 && commentsEnabled"
contextLevel="module" [instanceId]="glossary.coursemodule" component="mod_glossary" [itemId]="onlineEntry.id"
area="glossary_entry" [courseId]="glossary.course" [showItem]="true" />
<core-rating-rate *ngIf="glossary && ratingInfo && onlineEntry" [ratingInfo]="ratingInfo" contextLevel="module"
[instanceId]="glossary.coursemodule" [itemId]="onlineEntry.id" [itemSetId]="0" [courseId]="glossary.course"
[aggregateMethod]="glossary.assessed" [scaleId]="glossary.scale" [userId]="entry.userid" (onUpdate)="ratingUpdated()" />
<core-rating-aggregate *ngIf="glossary && ratingInfo && onlineEntry" [ratingInfo]="ratingInfo" contextLevel="module"
[instanceId]="glossary.coursemodule" [itemId]="onlineEntry.id" [courseId]="glossary.course"
[aggregateMethod]="glossary.assessed" [scaleId]="glossary.scale" />
</div>
</ng-container>

<ion-card *ngIf="!entry" class="core-warning-card">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<core-course-module-info [module]="module" [description]="displayDescription && description" [component]="component"
[componentId]="componentId" [courseId]="courseId" (completionChanged)="onCompletionChange()" />

<div class="ion-padding">
<div class="ion-padding" core-reading-mode>
<core-format-text [component]="component" [componentId]="componentId" [text]="contents" contextLevel="module"
[contextInstanceId]="module.id" [courseId]="courseId" />

Expand Down
39 changes: 1 addition & 38 deletions src/core/components/navbar-buttons/navbar-buttons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export class CoreNavBarButtonsComponent implements OnInit, OnDestroy {
*/
async ngOnInit(): Promise<void> {
try {
const header = await this.searchHeader();
const header = await CoreDom.findIonHeaderFromElement(this.element);
if (header) {
// Search the right buttons container (start, end or any).
let selector = 'ion-buttons';
Expand Down Expand Up @@ -192,43 +192,6 @@ export class CoreNavBarButtonsComponent implements OnInit, OnDestroy {
return componentRef.instance;
}

/**
* Search the ion-header where the buttons should be added.
*
* @returns Promise resolved with the header element.
*/
protected async searchHeader(): Promise<HTMLIonHeaderElement> {
await CoreDom.waitToBeInDOM(this.element);
let parentPage: HTMLElement | null = this.element;

while (parentPage && parentPage.parentElement) {
const content = parentPage.closest<HTMLIonContentElement>('ion-content');
if (content) {
// Sometimes ion-page class is not yet added by the ViewController, wait for content to render.
await content.componentOnReady();
}

parentPage = parentPage.parentElement.closest('.ion-page, .ion-page-hidden, .ion-page-invisible');

// Check if the page has a header. If it doesn't, search the next parent page.
let header = parentPage?.querySelector<HTMLIonHeaderElement>(':scope > ion-header');

if (header && getComputedStyle(header).display !== 'none') {
return header;
}

// Find using content if any.
header = content?.parentElement?.querySelector<HTMLIonHeaderElement>(':scope > ion-header');

if (header && getComputedStyle(header).display !== 'none') {
return header;
}
}

// Header not found, reject.
throw Error('Header not found.');
}

/**
* Show or hide all the elements.
*/
Expand Down
1 change: 1 addition & 0 deletions src/core/directives/collapsible-header.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ export class CoreCollapsibleHeaderDirective implements OnInit, OnChanges, OnDest

constructor(el: ElementRef) {
this.collapsedHeader = el.nativeElement;
CoreDirectivesRegistry.register(this.collapsedHeader, this);
}

/**
Expand Down
3 changes: 3 additions & 0 deletions src/core/directives/directives.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import { CoreContentDirective } from './content';
import { CoreUpdateNonReactiveAttributesDirective } from './update-non-reactive-attributes';
import { CoreUserTourDirective } from './user-tour';
import { CoreIonDatetimeDirective } from './datetime';
import { CoreReadingModeDirective } from './reading-mode';

@NgModule({
declarations: [
Expand All @@ -59,6 +60,7 @@ import { CoreIonDatetimeDirective } from './datetime';
CoreUpdateNonReactiveAttributesDirective,
CoreUserTourDirective,
CoreIonDatetimeDirective,
CoreReadingModeDirective,
],
exports: [
CoreAutoFocusDirective,
Expand All @@ -82,6 +84,7 @@ import { CoreIonDatetimeDirective } from './datetime';
CoreUpdateNonReactiveAttributesDirective,
CoreUserTourDirective,
CoreIonDatetimeDirective,
CoreReadingModeDirective,
],
})
export class CoreDirectivesModule {}
2 changes: 1 addition & 1 deletion src/core/directives/format-text.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ import { CorePromiseUtils } from '@singletons/promise-utils';
* Please use this directive if your text needs to be filtered or it can contain links or media (images, audio, video).
*
* Example usage:
* <core-format-text [text]="myText" [component]="component" [componentId]="componentId"></core-format-text>
* <core-format-text [text]="myText" [component]="component" [componentId]="componentId" />
*/
@Directive({
selector: 'core-format-text',
Expand Down
Loading

0 comments on commit 0af6865

Please sign in to comment.