Merge pull request #3184 from dpalou/MOBILE-3930

Mobile 3930
main
Pau Ferrer Ocaña 2022-03-16 15:16:49 +01:00 committed by GitHub
commit 3b7e6426e0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 20 additions and 9 deletions

View File

@ -1,4 +1,4 @@
<ion-card *ngIf="module.handlerData && module.visibleoncoursepage !== 0">
<ion-card *ngIf="module.handlerData && module.visibleoncoursepage !== 0" [class.core-course-module-with-view]="moduleHasView">
<ng-container *ngIf="!module.handlerData.loading">
<ion-item id="core-course-module-{{module.id}}" detail="false"
class="ion-text-wrap core-course-module-handler core-module-main-item {{module.handlerData.class}}"

View File

@ -93,7 +93,7 @@
display: none;
}
&.core-course-module-not-viewed {
&.core-course-module-not-viewed ion-card.core-course-module-with-view {
--ion-card-border-color: var(--core-course-module-not-viewed-border-color);
}

View File

@ -57,6 +57,7 @@ export class CoreCourseModuleComponent implements OnInit, OnDestroy {
prefetchStatusIcon = ''; // Module prefetch status icon.
prefetchStatusText = ''; // Module prefetch status text.
autoCompletionTodo = false;
moduleHasView = true;
protected prefetchHandler?: CoreCourseModulePrefetchHandler;
@ -77,6 +78,7 @@ export class CoreCourseModuleComponent implements OnInit, OnDestroy {
}
this.module.handlerData.a11yTitle = this.module.handlerData.a11yTitle ?? this.module.handlerData.title;
this.moduleHasView = CoreCourse.moduleHasView(this.module);
const completionStatus = this.showCompletionConditions && this.module.completiondata?.isautomatic &&
this.module.completiondata.tracking == CoreCourseModuleCompletionTracking.COMPLETION_TRACKING_AUTOMATIC

View File

@ -21,6 +21,7 @@ import {
CoreCourseModuleSummaryResult,
CoreCourseModuleSummaryComponent,
} from '@features/course/components/module-summary/module-summary';
import { CoreCourse } from '@features/course/services/course';
import { CoreCourseHelper, CoreCourseModuleData } from '@features/course/services/course-helper';
import {
CoreCourseModuleDelegate,
@ -35,7 +36,7 @@ import {
import { IonRefresher } from '@ionic/angular';
import { CoreDomUtils } from '@services/utils/dom';
import { CoreUtils } from '@services/utils/utils';
import { CoreSitePluginsPluginContentComponent } from '../plugin-content/plugin-content';
import { CoreSitePluginsPluginContentComponent, CoreSitePluginsPluginContentLoadedData } from '../plugin-content/plugin-content';
/**
* Component that displays the index of a module site plugin.
@ -161,9 +162,12 @@ export class CoreSitePluginsModuleIndexComponent implements OnInit, OnDestroy, C
/**
* Function called when the data of the site plugin content is loaded.
*/
// eslint-disable-next-line @typescript-eslint/no-unused-vars
contentLoaded(refresh: boolean): void {
return;
contentLoaded(data: CoreSitePluginsPluginContentLoadedData): void {
if (data.success) {
CoreCourse.storeModuleViewed(this.courseId, this.module.id, {
sectionId: this.module.section,
});
}
}
/**

View File

@ -43,7 +43,7 @@ export class CoreSitePluginsPluginContentComponent implements OnInit, DoCheck {
@Input() data?: Record<string, unknown>; // Data to pass to the component.
@Input() preSets?: CoreSiteWSPreSets; // The preSets for the WS call.
@Input() pageTitle?: string; // Current page title. It can be used by the "new-content" directives.
@Output() onContentLoaded = new EventEmitter<boolean>(); // Emits an event when the content is loaded.
@Output() onContentLoaded = new EventEmitter<CoreSitePluginsPluginContentLoadedData>(); // Emits event when content is loaded.
@Output() onLoadingContent = new EventEmitter<boolean>(); // Emits an event when starts to load the content.
content?: string; // Content.
@ -114,11 +114,11 @@ export class CoreSitePluginsPluginContentComponent implements OnInit, DoCheck {
this.jsData.updateContent = this.updateContent.bind(this);
this.jsData.updateModuleCourseContent = this.updateModuleCourseContent.bind(this);
this.onContentLoaded.emit(refresh);
this.onContentLoaded.emit({ refresh: !!refresh, success: true });
} catch (error) {
// Make it think it's loaded - otherwise it sticks on 'loading' and stops navigation working.
this.content = '<div></div>';
this.onContentLoaded.emit(refresh);
this.onContentLoaded.emit({ refresh: !!refresh, success: false });
CoreDomUtils.showErrorModalDefault(error, 'core.errorloadingcontent', true);
} finally {
@ -237,3 +237,8 @@ export class CoreSitePluginsPluginContentComponent implements OnInit, DoCheck {
}
}
export type CoreSitePluginsPluginContentLoadedData = {
refresh: boolean;
success: boolean;
};