From 926e786688cfd1cea7d13ddb50001a31034a8fed Mon Sep 17 00:00:00 2001 From: Dani Palou Date: Wed, 9 Oct 2019 15:02:53 +0200 Subject: [PATCH] MOBILE-2491 filter: Implement algebra filter --- src/addon/filter/algebra/algebra.module.ts | 34 ++++++++++++++ src/addon/filter/algebra/providers/handler.ts | 45 +++++++++++++++++++ src/addon/filter/filter.module.ts | 2 + 3 files changed, 81 insertions(+) create mode 100644 src/addon/filter/algebra/algebra.module.ts create mode 100644 src/addon/filter/algebra/providers/handler.ts diff --git a/src/addon/filter/algebra/algebra.module.ts b/src/addon/filter/algebra/algebra.module.ts new file mode 100644 index 000000000..8b34d7afb --- /dev/null +++ b/src/addon/filter/algebra/algebra.module.ts @@ -0,0 +1,34 @@ +// (C) Copyright 2015 Moodle Pty Ltd. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +import { NgModule } from '@angular/core'; +import { IonicModule } from 'ionic-angular'; +import { CoreFilterDelegate } from '@core/filter/providers/delegate'; +import { AddonFilterAlgebraHandler } from './providers/handler'; + +@NgModule({ + declarations: [ + ], + imports: [ + IonicModule + ], + providers: [ + AddonFilterAlgebraHandler + ] +}) +export class AddonFilterAlgebraModule { + constructor(filterDelegate: CoreFilterDelegate, handler: AddonFilterAlgebraHandler) { + filterDelegate.registerHandler(handler); + } +} diff --git a/src/addon/filter/algebra/providers/handler.ts b/src/addon/filter/algebra/providers/handler.ts new file mode 100644 index 000000000..5079ff659 --- /dev/null +++ b/src/addon/filter/algebra/providers/handler.ts @@ -0,0 +1,45 @@ + +// (C) Copyright 2015 Moodle Pty Ltd. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +import { Injectable } from '@angular/core'; +import { CoreFilterDefaultHandler } from '@core/filter/providers/default-filter'; +import { CoreFilterFormatTextOptions } from '@core/filter/providers/filter'; +import { CoreSite } from '@classes/site'; + +/** + * Handler to support the Algebra notation filter. + */ +@Injectable() +export class AddonFilterAlgebraHandler extends CoreFilterDefaultHandler { + name = 'AddonFilterAlgebraHandler'; + filterName = 'algebra'; + + constructor() { + super(); + + // This filter is handled by Moodle, nothing to do in the app. + } + + /** + * Check if the filter should be applied in a certain site based on some filter options. + * + * @param options Options. + * @param site Site. + * @return Whether filter should be applied. + */ + shouldBeApplied(options: CoreFilterFormatTextOptions, site?: CoreSite): boolean { + return false; + } +} diff --git a/src/addon/filter/filter.module.ts b/src/addon/filter/filter.module.ts index 617f623c6..f2646d346 100644 --- a/src/addon/filter/filter.module.ts +++ b/src/addon/filter/filter.module.ts @@ -14,6 +14,7 @@ import { NgModule } from '@angular/core'; import { AddonFilterActivityNamesModule } from './activitynames/activitynames.module'; +import { AddonFilterAlgebraModule } from './algebra/algebra.module'; import { AddonFilterCensorModule } from './censor/censor.module'; import { AddonFilterDataModule } from './data/data.module'; import { AddonFilterEmailProtectModule } from './emailprotect/emailprotect.module'; @@ -29,6 +30,7 @@ import { AddonFilterUrlToLinkModule } from './urltolink/urltolink.module'; declarations: [], imports: [ AddonFilterActivityNamesModule, + AddonFilterAlgebraModule, AddonFilterCensorModule, AddonFilterDataModule, AddonFilterEmailProtectModule,