MOBILE-3454 filters: Support disabling check text filters
parent
6fa5578b53
commit
2a7f7e8977
|
@ -1914,6 +1914,7 @@
|
||||||
"core.openmodinbrowser": "Open {{$a}} in browser",
|
"core.openmodinbrowser": "Open {{$a}} in browser",
|
||||||
"core.othergroups": "Other groups",
|
"core.othergroups": "Other groups",
|
||||||
"core.pagea": "Page {{$a}}",
|
"core.pagea": "Page {{$a}}",
|
||||||
|
"core.parentlanguage": "",
|
||||||
"core.paymentinstant": "Use the button below to pay and be enrolled within minutes!",
|
"core.paymentinstant": "Use the button below to pay and be enrolled within minutes!",
|
||||||
"core.percentagenumber": "{{$a}}%",
|
"core.percentagenumber": "{{$a}}%",
|
||||||
"core.phone": "Phone",
|
"core.phone": "Phone",
|
||||||
|
|
|
@ -65,10 +65,10 @@ export class CoreFilterProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns whether or not WS get available in context is avalaible.
|
* Returns whether or not WS get available in context is available.
|
||||||
*
|
*
|
||||||
* @param siteId Site ID. If not defined, current site.
|
* @param siteId Site ID. If not defined, current site.
|
||||||
* @return Promise resolved with true if ws is avalaible, false otherwise.
|
* @return Promise resolved with true if ws is available, false otherwise.
|
||||||
* @since 3.4
|
* @since 3.4
|
||||||
*/
|
*/
|
||||||
canGetAvailableInContext(siteId?: string): Promise<boolean> {
|
canGetAvailableInContext(siteId?: string): Promise<boolean> {
|
||||||
|
@ -78,10 +78,10 @@ export class CoreFilterProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns whether or not WS get available in context is avalaible in a certain site.
|
* Returns whether or not WS get available in context is available in a certain site.
|
||||||
*
|
*
|
||||||
* @param site Site. If not defined, current site.
|
* @param site Site. If not defined, current site.
|
||||||
* @return Promise resolved with true if ws is avalaible, false otherwise.
|
* @return Promise resolved with true if ws is available, false otherwise.
|
||||||
* @since 3.4
|
* @since 3.4
|
||||||
*/
|
*/
|
||||||
canGetAvailableInContextInSite(site?: CoreSite): boolean {
|
canGetAvailableInContextInSite(site?: CoreSite): boolean {
|
||||||
|
@ -90,6 +90,53 @@ export class CoreFilterProvider {
|
||||||
return site.wsAvailable('core_filters_get_available_in_context');
|
return site.wsAvailable('core_filters_get_available_in_context');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether or not we can get the available filters: the WS is available and the feature isn't disabled.
|
||||||
|
*
|
||||||
|
* @param siteId Site ID. If not defined, current site.
|
||||||
|
* @return Promise resolved with boolean: whethe can get filters.
|
||||||
|
*/
|
||||||
|
async canGetFilters(siteId?: string): Promise<boolean> {
|
||||||
|
const wsAvailable = await this.canGetAvailableInContext(siteId);
|
||||||
|
const disabled = await this.checkFiltersDisabled(siteId);
|
||||||
|
|
||||||
|
return wsAvailable && !disabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether or not we can get the available filters: the WS is available and the feature isn't disabled.
|
||||||
|
*
|
||||||
|
* @param site Site. If not defined, current site.
|
||||||
|
* @return Promise resolved with boolean: whethe can get filters.
|
||||||
|
*/
|
||||||
|
canGetFiltersInSite(site?: CoreSite): boolean {
|
||||||
|
return this.canGetAvailableInContextInSite(site) && this.checkFiltersDisabledInSite(site);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether or not checking the available filters is disabled in the site.
|
||||||
|
*
|
||||||
|
* @param siteId Site ID. If not defined, current site.
|
||||||
|
* @return Promise resolved with boolean: whether it's disabled.
|
||||||
|
*/
|
||||||
|
async checkFiltersDisabled(siteId?: string): Promise<boolean> {
|
||||||
|
const site = await this.sitesProvider.getSite(siteId);
|
||||||
|
|
||||||
|
return this.checkFiltersDisabledInSite(site);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether or not checking the available filters is disabled in the site.
|
||||||
|
*
|
||||||
|
* @param site Site. If not defined, current site.
|
||||||
|
* @return Whether it's disabled.
|
||||||
|
*/
|
||||||
|
checkFiltersDisabledInSite(site?: CoreSite): boolean {
|
||||||
|
site = site || this.sitesProvider.getCurrentSite();
|
||||||
|
|
||||||
|
return site.isFeatureDisabled('CoreFilterDelegate');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Given some HTML code, this function returns the text as safe HTML.
|
* Given some HTML code, this function returns the text as safe HTML.
|
||||||
*
|
*
|
||||||
|
|
|
@ -173,7 +173,7 @@ export class CoreFilterHelperProvider {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the filters in a certain context, performing some checks like the site version.
|
* Get the filters in a certain context, performing some checks like the site version.
|
||||||
* It's recommended to use this function instead of canGetAvailableInContext because this function will check if
|
* It's recommended to use this function instead of canGetFilters + getEnabledFilters because this function will check if
|
||||||
* it's really needed to call the WS.
|
* it's really needed to call the WS.
|
||||||
*
|
*
|
||||||
* @param contextLevel The context level.
|
* @param contextLevel The context level.
|
||||||
|
@ -193,7 +193,7 @@ export class CoreFilterHelperProvider {
|
||||||
return this.sitesProvider.getSite(siteId).then((site) => {
|
return this.sitesProvider.getSite(siteId).then((site) => {
|
||||||
siteId = site.getId();
|
siteId = site.getId();
|
||||||
|
|
||||||
return this.filterProvider.canGetAvailableInContext(siteId).then((canGet) => {
|
return this.filterProvider.canGetFilters(siteId).then((canGet) => {
|
||||||
if (!canGet) {
|
if (!canGet) {
|
||||||
options.filter = true;
|
options.filter = true;
|
||||||
|
|
||||||
|
|
|
@ -471,7 +471,7 @@ export class CorePushNotificationsProvider {
|
||||||
extraFeatures = this.utils.isTrueOrOne(data.extrafeatures);
|
extraFeatures = this.utils.isTrueOrOne(data.extrafeatures);
|
||||||
|
|
||||||
// Get the filters to apply to text and message. Don't use FIlterHelper to prevent circular dependencies.
|
// Get the filters to apply to text and message. Don't use FIlterHelper to prevent circular dependencies.
|
||||||
this.filterProvider.canGetAvailableInContext(site.getId()).then((canGet) => {
|
this.filterProvider.canGetFilters(site.getId()).then((canGet) => {
|
||||||
if (!canGet) {
|
if (!canGet) {
|
||||||
// We cannot check which filters are available, apply them all.
|
// We cannot check which filters are available, apply them all.
|
||||||
return this.filterDelegate.getEnabledFilters(options.contextLevel, options.instanceId);
|
return this.filterDelegate.getEnabledFilters(options.contextLevel, options.instanceId);
|
||||||
|
|
Loading…
Reference in New Issue