commit
0c49a451f7
|
@ -34,26 +34,28 @@ export class AddonBlockSearchForumsHandlerService extends CoreBlockBaseHandler {
|
||||||
* @inheritdoc
|
* @inheritdoc
|
||||||
*/
|
*/
|
||||||
async isEnabled(): Promise<boolean> {
|
async isEnabled(): Promise<boolean> {
|
||||||
const enabled = await CoreSearchGlobalSearch.isEnabled();
|
return CoreSearchGlobalSearch.isEnabled();
|
||||||
|
|
||||||
if (!enabled) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
const forumSearchAreas = ['mod_forum-activity', 'mod_forum-post'];
|
|
||||||
const searchAreas = await CoreSearchGlobalSearch.getSearchAreas();
|
|
||||||
|
|
||||||
return searchAreas.some(({ id }) => forumSearchAreas.includes(id));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritdoc
|
* @inheritdoc
|
||||||
*/
|
*/
|
||||||
getDisplayData(block: CoreCourseBlock, contextLevel: string, instanceId: number): CoreBlockHandlerData | undefined {
|
async getDisplayData(
|
||||||
|
block: CoreCourseBlock,
|
||||||
|
contextLevel: string,
|
||||||
|
instanceId: number,
|
||||||
|
): Promise<undefined | CoreBlockHandlerData> {
|
||||||
if (contextLevel !== 'course') {
|
if (contextLevel !== 'course') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const forumSearchAreas = ['mod_forum-activity', 'mod_forum-post'];
|
||||||
|
const searchAreas = await CoreSearchGlobalSearch.getSearchAreas();
|
||||||
|
|
||||||
|
if (!searchAreas.some(({ id }) => forumSearchAreas.includes(id))) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
title: 'addon.block_searchforums.pluginname',
|
title: 'addon.block_searchforums.pluginname',
|
||||||
class: 'addon-block-search-forums',
|
class: 'addon-block-search-forums',
|
||||||
|
|
|
@ -47,7 +47,7 @@ export class CoreBlockBaseHandler implements CoreBlockHandler {
|
||||||
block: CoreCourseBlock, // eslint-disable-line @typescript-eslint/no-unused-vars
|
block: CoreCourseBlock, // eslint-disable-line @typescript-eslint/no-unused-vars
|
||||||
contextLevel: string, // eslint-disable-line @typescript-eslint/no-unused-vars
|
contextLevel: string, // eslint-disable-line @typescript-eslint/no-unused-vars
|
||||||
instanceId: number, // eslint-disable-line @typescript-eslint/no-unused-vars
|
instanceId: number, // eslint-disable-line @typescript-eslint/no-unused-vars
|
||||||
): undefined | CoreBlockHandlerData | Promise<CoreBlockHandlerData> {
|
): undefined | CoreBlockHandlerData | Promise<undefined | CoreBlockHandlerData> {
|
||||||
// To be overridden.
|
// To be overridden.
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,7 +45,7 @@ export interface CoreBlockHandler extends CoreDelegateHandler {
|
||||||
block: CoreCourseBlock,
|
block: CoreCourseBlock,
|
||||||
contextLevel: string,
|
contextLevel: string,
|
||||||
instanceId: number,
|
instanceId: number,
|
||||||
): undefined | CoreBlockHandlerData | Promise<CoreBlockHandlerData>;
|
): undefined | CoreBlockHandlerData | Promise<undefined | CoreBlockHandlerData>;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue