MOBILE-4573 forum: Hide search when disabled
parent
a03937d4fe
commit
ce86bb42f1
|
@ -1,6 +1,6 @@
|
||||||
<!-- Buttons to add to the header. -->
|
<!-- Buttons to add to the header. -->
|
||||||
<core-navbar-buttons slot="end">
|
<core-navbar-buttons slot="end">
|
||||||
<ion-button fill="clear" (click)="openSearch()" [attr.aria-label]="'core.search' | translate">
|
<ion-button fill="clear" *ngIf="showSearch" (click)="openSearch()" [attr.aria-label]="'core.search' | translate">
|
||||||
<ion-icon name="fas-magnifying-glass" slot="icon-only" aria-hidden="true" />
|
<ion-icon name="fas-magnifying-glass" slot="icon-only" aria-hidden="true" />
|
||||||
</ion-button>
|
</ion-button>
|
||||||
<ion-button fill="clear" (click)="openModuleSummary()" aria-haspopup="true" [attr.aria-label]="'core.info' | translate">
|
<ion-button fill="clear" (click)="openModuleSummary()" aria-haspopup="true" [attr.aria-label]="'core.info' | translate">
|
||||||
|
|
|
@ -59,6 +59,7 @@ import { CoreRoutedItemsManagerSourcesTracker } from '@classes/items-management/
|
||||||
import { CorePromisedValue } from '@classes/promised-value';
|
import { CorePromisedValue } from '@classes/promised-value';
|
||||||
import { CoreNavigator } from '@services/navigator';
|
import { CoreNavigator } from '@services/navigator';
|
||||||
import { ADDON_MOD_FORUM_SEARCH_PAGE_NAME } from '@addons/mod/forum/constants';
|
import { ADDON_MOD_FORUM_SEARCH_PAGE_NAME } from '@addons/mod/forum/constants';
|
||||||
|
import { CoreSearchGlobalSearch } from '@features/search/services/global-search';
|
||||||
/**
|
/**
|
||||||
* Component that displays a forum entry page.
|
* Component that displays a forum entry page.
|
||||||
*/
|
*/
|
||||||
|
@ -85,6 +86,7 @@ export class AddonModForumIndexComponent extends CoreCourseModuleMainActivityCom
|
||||||
hasOfflineRatings = false;
|
hasOfflineRatings = false;
|
||||||
showQAMessage = false;
|
showQAMessage = false;
|
||||||
isSetPinAvailable = false;
|
isSetPinAvailable = false;
|
||||||
|
showSearch = false;
|
||||||
sortOrderSelectorModalOptions: ModalOptions = {
|
sortOrderSelectorModalOptions: ModalOptions = {
|
||||||
component: AddonModForumSortOrderSelectorComponent,
|
component: AddonModForumSortOrderSelectorComponent,
|
||||||
};
|
};
|
||||||
|
@ -306,6 +308,9 @@ export class AddonModForumIndexComponent extends CoreCourseModuleMainActivityCom
|
||||||
this.hasOffline = this.hasOffline || this.hasOfflineRatings;
|
this.hasOffline = this.hasOffline || this.hasOfflineRatings;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Initialize search.
|
||||||
|
this.showSearch = await this.isSearchEnabled();
|
||||||
}
|
}
|
||||||
|
|
||||||
async ngAfterViewInit(): Promise<void> {
|
async ngAfterViewInit(): Promise<void> {
|
||||||
|
@ -690,6 +695,21 @@ export class AddonModForumIndexComponent extends CoreCourseModuleMainActivityCom
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if forum search is available.
|
||||||
|
*
|
||||||
|
* @returns Whether forum search is available.
|
||||||
|
*/
|
||||||
|
protected async isSearchEnabled(): Promise<boolean> {
|
||||||
|
if (!CoreSearchGlobalSearch.isEnabled()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const searchAreas = await CoreSearchGlobalSearch.getSearchAreas();
|
||||||
|
|
||||||
|
return !!searchAreas.find(({ id }) => id === 'mod_forum-post');
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue