MOBILE-4318 reportbuilder: Create report builder link handler
parent
affcf93df8
commit
c92fbe380f
|
@ -14,9 +14,11 @@
|
|||
|
||||
import { APP_INITIALIZER, NgModule } from '@angular/core';
|
||||
import { Routes } from '@angular/router';
|
||||
import { CoreContentLinksDelegate } from '@features/contentlinks/services/contentlinks-delegate';
|
||||
import { CoreMainMenuRoutingModule } from '@features/mainmenu/mainmenu-routing.module';
|
||||
import { CoreMainMenuTabRoutingModule } from '@features/mainmenu/mainmenu-tab-routing.module';
|
||||
import { CoreUserDelegate } from '@features/user/services/user-delegate';
|
||||
import { CoreReportBuilderLinkHandler } from './services/handlers/reportbuilder-link';
|
||||
import { CoreReportBuilderHandler, CoreReportBuilderHandlerService } from './services/handlers/reportbuilder';
|
||||
|
||||
const routes: Routes = [
|
||||
|
@ -37,6 +39,7 @@ const routes: Routes = [
|
|||
multi: true,
|
||||
useValue: () => {
|
||||
CoreUserDelegate.registerHandler(CoreReportBuilderHandler.instance);
|
||||
CoreContentLinksDelegate.registerHandler(CoreReportBuilderLinkHandler.instance);
|
||||
},
|
||||
},
|
||||
],
|
||||
|
|
|
@ -0,0 +1,54 @@
|
|||
// (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 { Params } from '@angular/router';
|
||||
import { CoreContentLinksHandlerBase } from '@features/contentlinks/classes/base-handler';
|
||||
import { CoreContentLinksAction } from '@features/contentlinks/services/contentlinks-delegate';
|
||||
import { CoreNavigator } from '@services/navigator';
|
||||
import { makeSingleton } from '@singletons';
|
||||
import { CoreReportBuilder } from '../reportbuilder';
|
||||
import { CoreReportBuilderHandlerService } from './reportbuilder';
|
||||
|
||||
/**
|
||||
* Content links handler for report builder
|
||||
* Match reportbuilder/view.php?id=6 with a valid data and report id.
|
||||
*/
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class CoreReportBuilderLinkHandlerService extends CoreContentLinksHandlerBase {
|
||||
|
||||
name = 'CoreReportBuilderLinkHandler';
|
||||
pattern = /\/reportbuilder\/view\.php.*([?&]id=\d+)/;
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
getActions(siteIds: string[], url: string, params: Params): CoreContentLinksAction[] {
|
||||
return [{
|
||||
action: async (siteId): Promise<void> => {
|
||||
CoreNavigator.navigateToSitePath(`${CoreReportBuilderHandlerService.PAGE_NAME}/${params.id || ''}`, { siteId });
|
||||
},
|
||||
}];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
async isEnabled(): Promise<boolean> {
|
||||
return await CoreReportBuilder.isEnabled();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export const CoreReportBuilderLinkHandler = makeSingleton(CoreReportBuilderLinkHandlerService);
|
Loading…
Reference in New Issue