Merge pull request #2829 from dpalou/MOBILE-3320

Mobile 3320
main
Pau Ferrer Ocaña 2021-06-15 08:49:57 +02:00 committed by GitHub
commit 345ff293c1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 49 additions and 32 deletions

View File

@ -56,11 +56,11 @@
"duration_finish": day.haslastdayofevent
}'
[class.addon-calendar-event-past-day]="isPastMonth || day.ispast"
role="button cell"
role="cell"
tabindex="0"
(ariaButtonClick)="dayClicked(day.mday)"
>
<p class="addon-calendar-day-number">
<p class="addon-calendar-day-number" role="button">
<span aria-hidden="true">{{ day.mday }}</span>
<span class="sr-only">{{ day.periodName | translate }}</span>
</p>

View File

@ -802,14 +802,14 @@ export class AddonModDataHelperProvider {
offline: boolean,
siteId?: string,
): Promise<number | CoreFileUploaderStoreFilesResult> {
if (!files.length) {
return 0;
}
if (offline) {
return this.storeFiles(dataId, entryId, fieldId, files, siteId);
}
if (!files.length) {
return 0;
}
return CoreFileUploader.uploadOrReuploadFiles(files, AddonModDataProvider.COMPONENT, itemId, siteId);
}

View File

@ -215,7 +215,6 @@ export class AddonModQuizPlayerPage implements OnInit, OnDestroy, CanLeave {
// Reload the current page.
const scrollElement = await this.content?.getScrollElement();
const scrollTop = scrollElement?.scrollTop || -1;
const scrollLeft = scrollElement?.scrollLeft || -1;
this.loaded = false;
this.content?.scrollToTop(); // Scroll top so the spinner is seen.
@ -224,8 +223,11 @@ export class AddonModQuizPlayerPage implements OnInit, OnDestroy, CanLeave {
await this.loadPage(this.attempt!.currentpage!);
} finally {
this.loaded = true;
if (scrollTop != -1 && scrollLeft != -1) {
this.content?.scrollToPoint(scrollLeft, scrollTop);
if (scrollTop != -1) {
// Wait for content to be rendered.
setTimeout(() => {
this.content?.scrollToPoint(0, scrollTop);
}, 50);
}
}
} catch (error) {

View File

@ -32,7 +32,12 @@ import {
} from '../../services/survey';
import { AddonModSurveyHelper, AddonModSurveyQuestionFormatted } from '../../services/survey-helper';
import { AddonModSurveyOffline } from '../../services/survey-offline';
import { AddonModSurveyAutoSyncData, AddonModSurveySync, AddonModSurveySyncResult } from '../../services/survey-sync';
import {
AddonModSurveyAutoSyncData,
AddonModSurveySync,
AddonModSurveySyncProvider,
AddonModSurveySyncResult,
} from '../../services/survey-sync';
/**
* Component that displays a survey.
@ -52,6 +57,7 @@ export class AddonModSurveyIndexComponent extends CoreCourseModuleMainActivityCo
answers: Record<string, string> = {};
protected currentUserId?: number;
protected syncEventName = AddonModSurveySyncProvider.AUTO_SYNCED;
constructor(
protected content?: IonContent,

View File

@ -590,7 +590,7 @@ export class AddonModWikiIndexComponent extends CoreCourseModuleMainActivityComp
if (modalData) {
if (modalData.home) {
// Go back to the initial page of the wiki.
CoreNavigator.navigateToSitePath(modalData.home);
CoreNavigator.navigateToSitePath(modalData.home, { animationDirection: 'back' });
} else if (modalData.page) {
this.goToPage(modalData.page);
}

View File

@ -37,7 +37,7 @@
elementId="content_editor" [draftExtraParams]="editorExtraParams"></core-rich-text-editor>
</ion-item>
<core-attachments *ngIf="fileAvailable" [files]="submission?.attachmentfiles || []" [maxSize]="workshop.maxbytes"
<core-attachments *ngIf="fileAvailable" [files]="attachments" [maxSize]="workshop.maxbytes"
[maxSubmissions]="workshop.nattachments" [component]="component" [componentId]="workshop.coursemodule"
allowOffline="true" [acceptedTypes]="workshop.submissionfiletypes" [required]="fileRequired">
</core-attachments>

View File

@ -20,7 +20,6 @@ import { CoreFileUploader, CoreFileUploaderStoreFilesResult } from '@features/fi
import { CanLeave } from '@guards/can-leave';
import { CoreFile } from '@services/file';
import { CoreFileEntry, CoreFileHelper } from '@services/file-helper';
import { CoreFileSession } from '@services/file-session';
import { CoreNavigator } from '@services/navigator';
import { CoreSites } from '@services/sites';
import { CoreSync } from '@services/sync';
@ -67,6 +66,7 @@ export class AddonModWorkshopEditSubmissionPage implements OnInit, OnDestroy, Ca
textRequired = false;
fileAvailable = false;
fileRequired = false;
attachments: CoreFileEntry[] = [];
protected workshopId!: number;
protected submissionId = 0;
@ -211,14 +211,9 @@ export class AddonModWorkshopEditSubmissionPage implements OnInit, OnDestroy, Ca
this.editForm.controls['title'].setValue(this.submission.title);
this.editForm.controls['content'].setValue(this.submission.content);
this.attachments = this.submission.attachmentfiles || [];
}
CoreFileSession.setFiles(
this.component,
this.getFilesComponentId(),
this.submission?.attachmentfiles || [],
);
this.loaded = true;
} catch (error) {
this.loaded = false;
@ -254,7 +249,7 @@ export class AddonModWorkshopEditSubmissionPage implements OnInit, OnDestroy, Ca
}
if (this.fileAvailable) {
values.attachmentfiles = CoreFileSession.getFiles(this.component, this.getFilesComponentId()) || [];
values.attachmentfiles = this.attachments;
}
return values;
@ -337,7 +332,9 @@ export class AddonModWorkshopEditSubmissionPage implements OnInit, OnDestroy, Ca
// Upload attachments first if any.
let allowOffline = !inputData.attachmentfiles.length;
try {
let attachmentsId: CoreFileUploaderStoreFilesResult | number | undefined;
let attachmentsId: number | undefined;
let storeFilesResult: CoreFileUploaderStoreFilesResult | undefined;
try {
attachmentsId = await AddonModWorkshopHelper.uploadOrStoreSubmissionFiles(
this.workshopId,
@ -349,7 +346,7 @@ export class AddonModWorkshopEditSubmissionPage implements OnInit, OnDestroy, Ca
saveOffline = true;
allowOffline = true;
attachmentsId = await AddonModWorkshopHelper.uploadOrStoreSubmissionFiles(
storeFilesResult = await AddonModWorkshopHelper.uploadOrStoreSubmissionFiles(
this.workshopId,
inputData.attachmentfiles,
true,
@ -369,7 +366,7 @@ export class AddonModWorkshopEditSubmissionPage implements OnInit, OnDestroy, Ca
this.courseId,
inputData.title,
inputData.content,
attachmentsId as CoreFileUploaderStoreFilesResult,
storeFilesResult,
submissionId,
AddonModWorkshopAction.UPDATE,
);
@ -396,7 +393,7 @@ export class AddonModWorkshopEditSubmissionPage implements OnInit, OnDestroy, Ca
this.courseId,
inputData.title,
inputData.content,
attachmentsId as CoreFileUploaderStoreFilesResult,
storeFilesResult,
undefined,
AddonModWorkshopAction.ADD,
);

View File

@ -17,7 +17,6 @@ import { CoreError } from '@classes/errors/error';
import { CoreSite, CoreSiteWSPreSets } from '@classes/site';
import { CoreCourseCommonModWSOptions } from '@features/course/services/course';
import { CoreCourseLogHelper } from '@features/course/services/log-helper';
import { CoreFileUploaderStoreFilesResult } from '@features/fileuploader/services/fileuploader';
import { CoreGradesMenuItem } from '@features/grades/services/grades-helper';
import { CoreApp } from '@services/app';
import { CoreSites, CoreSitesCommonWSOptions, CoreSitesReadingStrategy } from '@services/sites';
@ -718,7 +717,7 @@ export class AddonModWorkshopProvider {
courseId: number,
title: string,
content: string,
attachmentsId?: number | CoreFileUploaderStoreFilesResult,
attachmentsId?: number,
siteId?: string,
allowOffline: boolean = false,
): Promise<number | false> {
@ -731,7 +730,7 @@ export class AddonModWorkshopProvider {
courseId,
title,
content,
attachmentsId as CoreFileUploaderStoreFilesResult,
undefined,
undefined,
AddonModWorkshopAction.ADD,
siteId,
@ -814,7 +813,7 @@ export class AddonModWorkshopProvider {
courseId: number,
title: string,
content: string,
attachmentsId?: CoreFileUploaderStoreFilesResult | number | undefined,
attachmentsId?: number | undefined,
siteId?: string,
allowOffline: boolean = false,
): Promise<number | false> {
@ -827,7 +826,7 @@ export class AddonModWorkshopProvider {
courseId,
title,
content,
attachmentsId as CoreFileUploaderStoreFilesResult,
undefined,
submissionId,
AddonModWorkshopAction.UPDATE,
siteId,

View File

@ -188,7 +188,7 @@ export class CoreExternalContentDirective implements AfterViewInit, OnChanges {
if (tagName == 'VIDEO' && targetAttr != 'poster') {
const video = <HTMLVideoElement> this.element;
if (video.textTracks) {
// It's a video with subtitles. In iOS, subtitles position is wrong so it needs to be fixed.
// It's a video with subtitles. Fix some issues with subtitles.
video.textTracks.onaddtrack = (event): void => {
const track = <TextTrack> event.track;
if (track) {
@ -248,6 +248,11 @@ export class CoreExternalContentDirective implements AfterViewInit, OnChanges {
true,
downloadUnknown,
);
} else if (tagName === 'TRACK') {
// Download tracks right away. Using an online URL for tracks can give a CORS error in Android.
finalUrl = await CoreFilepool.downloadUrl(site.getId(), url, false, this.component, this.componentId);
finalUrl = CoreFile.convertFileSrc(finalUrl);
} else {
finalUrl = await CoreFilepool.getUrlByUrl(
site.getId(),
@ -277,6 +282,13 @@ export class CoreExternalContentDirective implements AfterViewInit, OnChanges {
this.loaded = false;
this.waitForLoad();
}
if (targetAttr == 'poster') {
// Setting the poster immediately doesn't display it in some cases. Set it to empty and then set the right one.
this.element.setAttribute(targetAttr, '');
await CoreUtils.nextTick();
}
this.element.setAttribute(targetAttr, finalUrl);
this.element.setAttribute('data-original-' + targetAttr, url);
}

View File

@ -44,8 +44,7 @@ export type CoreRedirectPayload = {
/**
* Navigation options.
*/
export type CoreNavigationOptions = {
animated?: boolean;
export type CoreNavigationOptions = Pick<NavigationOptions, 'animated'|'animation'|'animationDirection'> & {
params?: Params;
reset?: boolean;
preferCurrentTab?: boolean; // Default true.
@ -132,6 +131,8 @@ export class CoreNavigatorService {
const url: string[] = [/^[./]/.test(path) ? path : `./${path}`];
const navigationOptions: NavigationOptions = CoreObject.withoutEmpty({
animated: options.animated,
animation: options.animation,
animationDirection: options.animationDirection,
queryParams: CoreObject.isEmpty(options.params ?? {}) ? null : CoreObject.withoutEmpty(options.params),
relativeTo: path.startsWith('/') ? null : this.getCurrentRoute(),
});