MOBILE-3320 siteplugins: Allow overriding FEATURE_NO_VIEW_LINK
parent
b8c37b63b4
commit
65e3d39991
|
@ -14,6 +14,7 @@
|
||||||
|
|
||||||
import { Type } from '@angular/core';
|
import { Type } from '@angular/core';
|
||||||
|
|
||||||
|
import { CoreConstants } from '@/core/constants';
|
||||||
import { CoreCourseAnyModuleData, CoreCourseWSModule } from '@features/course/services/course';
|
import { CoreCourseAnyModuleData, CoreCourseWSModule } from '@features/course/services/course';
|
||||||
import { CoreCourseModule } from '@features/course/services/course-helper';
|
import { CoreCourseModule } from '@features/course/services/course-helper';
|
||||||
import { CoreCourseModuleHandler, CoreCourseModuleHandlerData } from '@features/course/services/module-delegate';
|
import { CoreCourseModuleHandler, CoreCourseModuleHandlerData } from '@features/course/services/module-delegate';
|
||||||
|
@ -65,10 +66,7 @@ export class CoreSitePluginsModuleHandler extends CoreSitePluginsBaseHandler imp
|
||||||
sectionId?: number,
|
sectionId?: number,
|
||||||
forCoursePage?: boolean,
|
forCoursePage?: boolean,
|
||||||
): CoreCourseModuleHandlerData {
|
): CoreCourseModuleHandlerData {
|
||||||
const callMethod = forCoursePage && this.handlerSchema.coursepagemethod;
|
if ('description' in module && this.shouldOnlyDisplayDescription(module, forCoursePage)) {
|
||||||
|
|
||||||
if ('noviewlink' in module && module.noviewlink && !callMethod) {
|
|
||||||
// The module doesn't link to a new page (similar to label). Only display the description.
|
|
||||||
const title = module.description;
|
const title = module.description;
|
||||||
module.description = '';
|
module.description = '';
|
||||||
|
|
||||||
|
@ -105,7 +103,7 @@ export class CoreSitePluginsModuleHandler extends CoreSitePluginsBaseHandler imp
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (callMethod && module.visibleoncoursepage !== 0) {
|
if (forCoursePage && this.handlerSchema.coursepagemethod && module.visibleoncoursepage !== 0) {
|
||||||
// Call the method to get the course page template.
|
// Call the method to get the course page template.
|
||||||
this.loadCoursePageTemplate(module, courseId, handlerData);
|
this.loadCoursePageTemplate(module, courseId, handlerData);
|
||||||
}
|
}
|
||||||
|
@ -113,6 +111,32 @@ export class CoreSitePluginsModuleHandler extends CoreSitePluginsBaseHandler imp
|
||||||
return handlerData;
|
return handlerData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check whether the plugin should only display the description, similar to mod_label.
|
||||||
|
*
|
||||||
|
* @param module Module.
|
||||||
|
* @param forCoursePage Whether the data will be used to render the course page.
|
||||||
|
* @return Bool.
|
||||||
|
*/
|
||||||
|
protected shouldOnlyDisplayDescription(module: CoreCourseAnyModuleData, forCoursePage?: boolean): boolean {
|
||||||
|
if (forCoursePage && this.handlerSchema.coursepagemethod) {
|
||||||
|
// The plugin defines a method for course page, don't display just the description.
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if the plugin specifies if FEATURE_NO_VIEW_LINK is supported.
|
||||||
|
const noViewLink = <boolean | undefined> (this.supportsFeature ?
|
||||||
|
this.supportsFeature(CoreConstants.FEATURE_NO_VIEW_LINK) :
|
||||||
|
this.supportedFeatures?.[CoreConstants.FEATURE_NO_VIEW_LINK]);
|
||||||
|
|
||||||
|
if (noViewLink !== undefined) {
|
||||||
|
return noViewLink;
|
||||||
|
}
|
||||||
|
|
||||||
|
// The plugin doesn't specify it. Use the value returned by the site.
|
||||||
|
return 'noviewlink' in module && !!module.noviewlink;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load and use template for course page.
|
* Load and use template for course page.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue