diff --git a/src/addon/block/activitymodules/components/activitymodules/activitymodules.scss b/src/addon/block/activitymodules/components/activitymodules/activitymodules.scss new file mode 100644 index 000000000..cc70ceb22 --- /dev/null +++ b/src/addon/block/activitymodules/components/activitymodules/activitymodules.scss @@ -0,0 +1,26 @@ +ion-app.app-root.md addon-block-activitymodules { + .core-module-icon { + margin-top: $label-md-margin-top; + margin-bottom: $label-md-margin-bottom; + width: 24px; + height: 24px; + } +} + +ion-app.app-root.ios addon-block-activitymodules { + .core-module-icon { + margin-top: $label-ios-margin-top; + margin-bottom: $label-ios-margin-bottom; + width: 24px; + height: 24px; + } +} + +ion-app.app-root.wp addon-block-activitymodules { + .core-module-icon { + margin-top: $item-wp-padding-top; + margin-bottom: $item-wp-padding-bottom; + width: 24px; + height: 24px; + } +} diff --git a/src/addon/block/activitymodules/components/activitymodules/activitymodules.ts b/src/addon/block/activitymodules/components/activitymodules/activitymodules.ts index e85cee1e4..9e5519b4a 100644 --- a/src/addon/block/activitymodules/components/activitymodules/activitymodules.ts +++ b/src/addon/block/activitymodules/components/activitymodules/activitymodules.ts @@ -110,7 +110,7 @@ export class AddonBlockActivityModulesComponent extends CoreBlockBaseComponent i if (modName === 'resources') { icon = this.courseProvider.getModuleIconSrc('page'); } else { - icon = this.courseProvider.getModuleIconSrc(modName); + icon = this.moduleDelegate.getModuleIconSrc(modName); } this.entries.push({ diff --git a/src/core/course/components/module/module.scss b/src/core/course/components/module/module.scss index 41fabe184..fd7ec52e7 100644 --- a/src/core/course/components/module/module.scss +++ b/src/core/course/components/module/module.scss @@ -94,6 +94,8 @@ ion-app.app-root.ios core-course-module { a.core-course-module-handler .core-module-icon { margin-top: $label-ios-margin-top; margin-bottom: $label-ios-margin-bottom; + width: 24px; + height: 24px; } .core-module-title core-format-text { @@ -119,6 +121,8 @@ ion-app.app-root.wp core-course-module { a.core-course-module-handler .core-module-icon { margin-top: $item-wp-padding-top; margin-bottom: $item-wp-padding-bottom; + width: 24px; + height: 24px; } .core-module-title core-format-text { diff --git a/src/core/course/providers/module-delegate.ts b/src/core/course/providers/module-delegate.ts index 5a95209f7..52daed19e 100644 --- a/src/core/course/providers/module-delegate.ts +++ b/src/core/course/providers/module-delegate.ts @@ -71,6 +71,13 @@ export interface CoreCourseModuleHandler extends CoreDelegateHandler { */ displayRefresherInSingleActivity?(): boolean; + /** + * Get the icon src for the module. + * + * @return {string} The icon src. + */ + getIconSrc?(): string; + /** * Check if this type of module supports a certain feature. * If this function is implemented, the supportedFeatures object will be ignored. @@ -302,6 +309,16 @@ export class CoreCourseModuleDelegate extends CoreDelegate { return this.executeFunctionOnEnabled(modname, 'displayRefresherInSingleActivity'); } + /** + * Get the icon src for a certain type of module. + * + * @param {any} modname The name of the module type. + * @return {string} The icon src. + */ + getModuleIconSrc(modname: string): string { + return this.executeFunctionOnEnabled(modname, 'getIconSrc') || this.courseProvider.getModuleIconSrc(modname); + } + /** * Check if a certain type of module supports a certain feature. * diff --git a/src/core/siteplugins/classes/handlers/module-handler.ts b/src/core/siteplugins/classes/handlers/module-handler.ts index ffaf73af6..41cffe6c6 100644 --- a/src/core/siteplugins/classes/handlers/module-handler.ts +++ b/src/core/siteplugins/classes/handlers/module-handler.ts @@ -23,9 +23,18 @@ import { CoreSitePluginsModuleIndexComponent } from '../../components/module-ind */ export class CoreSitePluginsModuleHandler extends CoreSitePluginsBaseHandler implements CoreCourseModuleHandler { priority: number; + supportedFeatures: {[name: string]: any}; + supportsFeature: (feature: string) => any; - constructor(name: string, public modName: string, protected handlerSchema: any) { + constructor(name: string, public modName: string, protected handlerSchema: any, protected initResult: any) { super(name); + + this.supportedFeatures = handlerSchema.supportedfeatures; + + if (initResult && initResult.jsResult && initResult.jsResult.supportsFeature) { + // The init result defines a function to check if a feature is supported, use it. + this.supportsFeature = initResult.jsResult.supportsFeature.bind(initResult.jsResult); + } } /** @@ -58,6 +67,15 @@ export class CoreSitePluginsModuleHandler extends CoreSitePluginsBaseHandler imp }; } + /** + * Get the icon src for the module. + * + * @return {string} The icon src. + */ + getIconSrc(): string { + return this.handlerSchema.displaydata.icon; + } + /** * Get the component to render the module. This is needed to support singleactivity course format. * The component returned must implement CoreCourseModuleMainComponent. diff --git a/src/core/siteplugins/providers/helper.ts b/src/core/siteplugins/providers/helper.ts index 26124d2b6..666044bd0 100644 --- a/src/core/siteplugins/providers/helper.ts +++ b/src/core/siteplugins/providers/helper.ts @@ -443,7 +443,7 @@ export class CoreSitePluginsHelperProvider { break; case 'CoreCourseModuleDelegate': - promise = Promise.resolve(this.registerModuleHandler(plugin, handlerName, handlerSchema)); + promise = Promise.resolve(this.registerModuleHandler(plugin, handlerName, handlerSchema, result)); break; case 'CoreUserDelegate': @@ -720,9 +720,10 @@ export class CoreSitePluginsHelperProvider { * @param {any} plugin Data of the plugin. * @param {string} handlerName Name of the handler in the plugin. * @param {any} handlerSchema Data about the handler. + * @param {any} initResult Result of the init WS call. * @return {string} A string to identify the handler. */ - protected registerModuleHandler(plugin: any, handlerName: string, handlerSchema: any): string { + protected registerModuleHandler(plugin: any, handlerName: string, handlerSchema: any, initResult: any): string { if (!handlerSchema.displaydata) { // Required data not provided, stop. this.logger.warn('Ignore site plugin because it doesn\'t provide displaydata', plugin, handlerSchema); @@ -730,13 +731,13 @@ export class CoreSitePluginsHelperProvider { return; } - this.logger.debug('Register site plugin in module delegate:', plugin, handlerSchema); + this.logger.debug('Register site plugin in module delegate:', plugin, handlerSchema, initResult); // Create and register the handler. const uniqueName = this.sitePluginsProvider.getHandlerUniqueName(plugin, handlerName), modName = plugin.component.replace('mod_', ''); - this.moduleDelegate.registerHandler(new CoreSitePluginsModuleHandler(uniqueName, modName, handlerSchema)); + this.moduleDelegate.registerHandler(new CoreSitePluginsModuleHandler(uniqueName, modName, handlerSchema, initResult)); if (handlerSchema.offlinefunctions && Object.keys(handlerSchema.offlinefunctions).length) { // Register the prefetch handler.