MOBILE-3108 siteplugins: Allow create only title and prerendered blocks

main
Dani Palou 2019-07-30 16:16:45 +02:00
parent 5b45d4a335
commit 767c0c19d4
17 changed files with 126 additions and 49 deletions

View File

@ -13,7 +13,6 @@
// limitations under the License. // limitations under the License.
import { Injectable, Injector } from '@angular/core'; import { Injectable, Injector } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
import { CoreBlockHandlerData } from '@core/block/providers/delegate'; import { CoreBlockHandlerData } from '@core/block/providers/delegate';
import { CoreBlockPreRenderedComponent } from '@core/block/components/pre-rendered-block/pre-rendered-block'; import { CoreBlockPreRenderedComponent } from '@core/block/components/pre-rendered-block/pre-rendered-block';
@ -27,7 +26,7 @@ export class AddonBlockBadgesHandler extends CoreBlockBaseHandler {
name = 'AddonBlockBadges'; name = 'AddonBlockBadges';
blockName = 'badges'; blockName = 'badges';
constructor(private translate: TranslateService) { constructor() {
super(); super();
} }
@ -44,7 +43,7 @@ export class AddonBlockBadgesHandler extends CoreBlockBaseHandler {
: CoreBlockHandlerData | Promise<CoreBlockHandlerData> { : CoreBlockHandlerData | Promise<CoreBlockHandlerData> {
return { return {
title: this.translate.instant('addon.block_badges.pluginname'), title: 'addon.block_badges.pluginname',
class: 'addon-block-badges', class: 'addon-block-badges',
component: CoreBlockPreRenderedComponent component: CoreBlockPreRenderedComponent
}; };

View File

@ -13,7 +13,6 @@
// limitations under the License. // limitations under the License.
import { Injectable, Injector } from '@angular/core'; import { Injectable, Injector } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
import { CoreBlockHandlerData } from '@core/block/providers/delegate'; import { CoreBlockHandlerData } from '@core/block/providers/delegate';
import { CoreBlockPreRenderedComponent } from '@core/block/components/pre-rendered-block/pre-rendered-block'; import { CoreBlockPreRenderedComponent } from '@core/block/components/pre-rendered-block/pre-rendered-block';
@ -27,7 +26,7 @@ export class AddonBlockBlogMenuHandler extends CoreBlockBaseHandler {
name = 'AddonBlockBlogMenu'; name = 'AddonBlockBlogMenu';
blockName = 'blog_menu'; blockName = 'blog_menu';
constructor(private translate: TranslateService) { constructor() {
super(); super();
} }
@ -44,7 +43,7 @@ export class AddonBlockBlogMenuHandler extends CoreBlockBaseHandler {
: CoreBlockHandlerData | Promise<CoreBlockHandlerData> { : CoreBlockHandlerData | Promise<CoreBlockHandlerData> {
return { return {
title: this.translate.instant('addon.block_blogmenu.pluginname'), title: 'addon.block_blogmenu.pluginname',
class: 'addon-block-blog-menu', class: 'addon-block-blog-menu',
component: CoreBlockPreRenderedComponent component: CoreBlockPreRenderedComponent
}; };

View File

@ -13,7 +13,6 @@
// limitations under the License. // limitations under the License.
import { Injectable, Injector } from '@angular/core'; import { Injectable, Injector } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
import { CoreBlockHandlerData } from '@core/block/providers/delegate'; import { CoreBlockHandlerData } from '@core/block/providers/delegate';
import { CoreBlockPreRenderedComponent } from '@core/block/components/pre-rendered-block/pre-rendered-block'; import { CoreBlockPreRenderedComponent } from '@core/block/components/pre-rendered-block/pre-rendered-block';
@ -27,7 +26,7 @@ export class AddonBlockBlogRecentHandler extends CoreBlockBaseHandler {
name = 'AddonBlockBlogRecent'; name = 'AddonBlockBlogRecent';
blockName = 'blog_recent'; blockName = 'blog_recent';
constructor(private translate: TranslateService) { constructor() {
super(); super();
} }
@ -44,7 +43,7 @@ export class AddonBlockBlogRecentHandler extends CoreBlockBaseHandler {
: CoreBlockHandlerData | Promise<CoreBlockHandlerData> { : CoreBlockHandlerData | Promise<CoreBlockHandlerData> {
return { return {
title: this.translate.instant('addon.block_blogrecent.pluginname'), title: 'addon.block_blogrecent.pluginname',
class: 'addon-block-blog-recent', class: 'addon-block-blog-recent',
component: CoreBlockPreRenderedComponent component: CoreBlockPreRenderedComponent
}; };

View File

@ -13,7 +13,6 @@
// limitations under the License. // limitations under the License.
import { Injectable, Injector } from '@angular/core'; import { Injectable, Injector } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
import { CoreBlockHandlerData } from '@core/block/providers/delegate'; import { CoreBlockHandlerData } from '@core/block/providers/delegate';
import { CoreBlockPreRenderedComponent } from '@core/block/components/pre-rendered-block/pre-rendered-block'; import { CoreBlockPreRenderedComponent } from '@core/block/components/pre-rendered-block/pre-rendered-block';
@ -27,7 +26,7 @@ export class AddonBlockBlogTagsHandler extends CoreBlockBaseHandler {
name = 'AddonBlockBlogTags'; name = 'AddonBlockBlogTags';
blockName = 'blog_tags'; blockName = 'blog_tags';
constructor(private translate: TranslateService) { constructor() {
super(); super();
} }
@ -44,7 +43,7 @@ export class AddonBlockBlogTagsHandler extends CoreBlockBaseHandler {
: CoreBlockHandlerData | Promise<CoreBlockHandlerData> { : CoreBlockHandlerData | Promise<CoreBlockHandlerData> {
return { return {
title: this.translate.instant('addon.block_blogtags.pluginname'), title: 'addon.block_blogtags.pluginname',
class: 'addon-block-blog-tags', class: 'addon-block-blog-tags',
component: CoreBlockPreRenderedComponent component: CoreBlockPreRenderedComponent
}; };

View File

@ -13,7 +13,6 @@
// limitations under the License. // limitations under the License.
import { Injectable, Injector } from '@angular/core'; import { Injectable, Injector } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
import { CoreBlockHandlerData } from '@core/block/providers/delegate'; import { CoreBlockHandlerData } from '@core/block/providers/delegate';
import { CoreBlockPreRenderedComponent } from '@core/block/components/pre-rendered-block/pre-rendered-block'; import { CoreBlockPreRenderedComponent } from '@core/block/components/pre-rendered-block/pre-rendered-block';
import { CoreBlockBaseHandler } from '@core/block/classes/base-block-handler'; import { CoreBlockBaseHandler } from '@core/block/classes/base-block-handler';
@ -26,7 +25,7 @@ export class AddonBlockGlossaryRandomHandler extends CoreBlockBaseHandler {
name = 'AddonBlockGlossaryRandom'; name = 'AddonBlockGlossaryRandom';
blockName = 'glossary_random'; blockName = 'glossary_random';
constructor(private translate: TranslateService) { constructor() {
super(); super();
} }
@ -42,7 +41,7 @@ export class AddonBlockGlossaryRandomHandler extends CoreBlockBaseHandler {
getDisplayData(injector: Injector, block: any, contextLevel: string, instanceId: number) getDisplayData(injector: Injector, block: any, contextLevel: string, instanceId: number)
: CoreBlockHandlerData | Promise<CoreBlockHandlerData> { : CoreBlockHandlerData | Promise<CoreBlockHandlerData> {
return { return {
title: block.contents.title || this.translate.instant('addon.block_glossaryrandom.pluginname'), title: block.contents.title || 'addon.block_glossaryrandom.pluginname',
class: 'addon-block-glossary-random', class: 'addon-block-glossary-random',
component: CoreBlockPreRenderedComponent component: CoreBlockPreRenderedComponent
}; };

View File

@ -13,7 +13,6 @@
// limitations under the License. // limitations under the License.
import { Injectable, Injector } from '@angular/core'; import { Injectable, Injector } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
import { CoreBlockHandlerData } from '@core/block/providers/delegate'; import { CoreBlockHandlerData } from '@core/block/providers/delegate';
import { CoreBlockPreRenderedComponent } from '@core/block/components/pre-rendered-block/pre-rendered-block'; import { CoreBlockPreRenderedComponent } from '@core/block/components/pre-rendered-block/pre-rendered-block';
import { CoreBlockBaseHandler } from '@core/block/classes/base-block-handler'; import { CoreBlockBaseHandler } from '@core/block/classes/base-block-handler';
@ -26,7 +25,7 @@ export class AddonBlockNewsItemsHandler extends CoreBlockBaseHandler {
name = 'AddonBlockNewsItems'; name = 'AddonBlockNewsItems';
blockName = 'news_items'; blockName = 'news_items';
constructor(private translate: TranslateService) { constructor() {
super(); super();
} }
@ -42,7 +41,7 @@ export class AddonBlockNewsItemsHandler extends CoreBlockBaseHandler {
getDisplayData(injector: Injector, block: any, contextLevel: string, instanceId: number) getDisplayData(injector: Injector, block: any, contextLevel: string, instanceId: number)
: CoreBlockHandlerData | Promise<CoreBlockHandlerData> { : CoreBlockHandlerData | Promise<CoreBlockHandlerData> {
return { return {
title: this.translate.instant('addon.block_newsitems.pluginname'), title: 'addon.block_newsitems.pluginname',
class: 'addon-block-news-items', class: 'addon-block-news-items',
component: CoreBlockPreRenderedComponent component: CoreBlockPreRenderedComponent
}; };

View File

@ -13,7 +13,6 @@
// limitations under the License. // limitations under the License.
import { Injectable, Injector } from '@angular/core'; import { Injectable, Injector } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
import { CoreBlockHandlerData } from '@core/block/providers/delegate'; import { CoreBlockHandlerData } from '@core/block/providers/delegate';
import { CoreBlockPreRenderedComponent } from '@core/block/components/pre-rendered-block/pre-rendered-block'; import { CoreBlockPreRenderedComponent } from '@core/block/components/pre-rendered-block/pre-rendered-block';
import { CoreBlockBaseHandler } from '@core/block/classes/base-block-handler'; import { CoreBlockBaseHandler } from '@core/block/classes/base-block-handler';
@ -26,7 +25,7 @@ export class AddonBlockOnlineUsersHandler extends CoreBlockBaseHandler {
name = 'AddonBlockOnlineUsers'; name = 'AddonBlockOnlineUsers';
blockName = 'online_users'; blockName = 'online_users';
constructor(private translate: TranslateService) { constructor() {
super(); super();
} }
@ -42,7 +41,7 @@ export class AddonBlockOnlineUsersHandler extends CoreBlockBaseHandler {
getDisplayData(injector: Injector, block: any, contextLevel: string, instanceId: number) getDisplayData(injector: Injector, block: any, contextLevel: string, instanceId: number)
: CoreBlockHandlerData | Promise<CoreBlockHandlerData> { : CoreBlockHandlerData | Promise<CoreBlockHandlerData> {
return { return {
title: this.translate.instant('addon.block_onlineusers.pluginname'), title: 'addon.block_onlineusers.pluginname',
class: 'addon-block-online-users', class: 'addon-block-online-users',
component: CoreBlockPreRenderedComponent component: CoreBlockPreRenderedComponent
}; };

View File

@ -13,7 +13,6 @@
// limitations under the License. // limitations under the License.
import { Injectable, Injector } from '@angular/core'; import { Injectable, Injector } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
import { CoreBlockHandlerData } from '@core/block/providers/delegate'; import { CoreBlockHandlerData } from '@core/block/providers/delegate';
import { CoreBlockPreRenderedComponent } from '@core/block/components/pre-rendered-block/pre-rendered-block'; import { CoreBlockPreRenderedComponent } from '@core/block/components/pre-rendered-block/pre-rendered-block';
@ -27,7 +26,7 @@ export class AddonBlockRecentActivityHandler extends CoreBlockBaseHandler {
name = 'AddonBlockRecentActivity'; name = 'AddonBlockRecentActivity';
blockName = 'recent_activity'; blockName = 'recent_activity';
constructor(private translate: TranslateService) { constructor() {
super(); super();
} }
@ -44,7 +43,7 @@ export class AddonBlockRecentActivityHandler extends CoreBlockBaseHandler {
: CoreBlockHandlerData | Promise<CoreBlockHandlerData> { : CoreBlockHandlerData | Promise<CoreBlockHandlerData> {
return { return {
title: this.translate.instant('addon.block_recentactivity.pluginname'), title: 'addon.block_recentactivity.pluginname',
class: 'addon-block-recent-activity', class: 'addon-block-recent-activity',
component: CoreBlockPreRenderedComponent component: CoreBlockPreRenderedComponent
}; };

View File

@ -13,7 +13,6 @@
// limitations under the License. // limitations under the License.
import { Injectable, Injector } from '@angular/core'; import { Injectable, Injector } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
import { CoreBlockHandlerData } from '@core/block/providers/delegate'; import { CoreBlockHandlerData } from '@core/block/providers/delegate';
import { CoreBlockPreRenderedComponent } from '@core/block/components/pre-rendered-block/pre-rendered-block'; import { CoreBlockPreRenderedComponent } from '@core/block/components/pre-rendered-block/pre-rendered-block';
@ -27,7 +26,7 @@ export class AddonBlockRssClientHandler extends CoreBlockBaseHandler {
name = 'AddonBlockRssClient'; name = 'AddonBlockRssClient';
blockName = 'rss_client'; blockName = 'rss_client';
constructor(private translate: TranslateService) { constructor() {
super(); super();
} }
@ -44,7 +43,7 @@ export class AddonBlockRssClientHandler extends CoreBlockBaseHandler {
: CoreBlockHandlerData | Promise<CoreBlockHandlerData> { : CoreBlockHandlerData | Promise<CoreBlockHandlerData> {
return { return {
title: block.contents.title || this.translate.instant('addon.block_rssclient.pluginname'), title: block.contents.title || 'addon.block_rssclient.pluginname',
class: 'addon-block-rss-client', class: 'addon-block-rss-client',
component: CoreBlockPreRenderedComponent component: CoreBlockPreRenderedComponent
}; };

View File

@ -13,7 +13,6 @@
// limitations under the License. // limitations under the License.
import { Injectable, Injector } from '@angular/core'; import { Injectable, Injector } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
import { CoreBlockHandlerData } from '@core/block/providers/delegate'; import { CoreBlockHandlerData } from '@core/block/providers/delegate';
import { CoreBlockPreRenderedComponent } from '@core/block/components/pre-rendered-block/pre-rendered-block'; import { CoreBlockPreRenderedComponent } from '@core/block/components/pre-rendered-block/pre-rendered-block';
@ -27,7 +26,7 @@ export class AddonBlockTagsHandler extends CoreBlockBaseHandler {
name = 'AddonBlockTags'; name = 'AddonBlockTags';
blockName = 'tags'; blockName = 'tags';
constructor(private translate: TranslateService) { constructor() {
super(); super();
} }
@ -44,7 +43,7 @@ export class AddonBlockTagsHandler extends CoreBlockBaseHandler {
: CoreBlockHandlerData | Promise<CoreBlockHandlerData> { : CoreBlockHandlerData | Promise<CoreBlockHandlerData> {
return { return {
title: this.translate.instant('addon.block_tags.pluginname'), title: 'addon.block_tags.pluginname',
class: 'addon-block-tags', class: 'addon-block-tags',
component: CoreBlockPreRenderedComponent component: CoreBlockPreRenderedComponent
}; };

View File

@ -1,5 +1,5 @@
<ion-item-divider text-wrap *ngIf="title"> <ion-item-divider text-wrap *ngIf="title">
<h2><core-format-text [text]="title"></core-format-text></h2> <h2><core-format-text [text]="title | translate"></core-format-text></h2>
</ion-item-divider> </ion-item-divider>
<core-loading [hideUntil]="loaded" class="core-loading-center"> <core-loading [hideUntil]="loaded" class="core-loading-center">
<ion-item *ngIf="block.contents.content" text-wrap class="core-block-content"> <ion-item *ngIf="block.contents.content" text-wrap class="core-block-content">

View File

@ -15,14 +15,17 @@
import { Injector } from '@angular/core'; import { Injector } from '@angular/core';
import { CoreSitePluginsBaseHandler } from './base-handler'; import { CoreSitePluginsBaseHandler } from './base-handler';
import { CoreBlockHandler, CoreBlockHandlerData } from '@core/block/providers/delegate'; import { CoreBlockHandler, CoreBlockHandlerData } from '@core/block/providers/delegate';
import { CoreBlockPreRenderedComponent } from '@core/block/components/pre-rendered-block/pre-rendered-block';
import { CoreSitePluginsBlockComponent } from '@core/siteplugins/components/block/block'; import { CoreSitePluginsBlockComponent } from '@core/siteplugins/components/block/block';
import { CoreSitePluginsOnlyTitleBlockComponent } from '@core/siteplugins/components/only-title-block/only-title-block';
/** /**
* Handler to support a block using a site plugin. * Handler to support a block using a site plugin.
*/ */
export class CoreSitePluginsBlockHandler extends CoreSitePluginsBaseHandler implements CoreBlockHandler { export class CoreSitePluginsBlockHandler extends CoreSitePluginsBaseHandler implements CoreBlockHandler {
constructor(name: string, public blockName: string, protected handlerSchema: any, protected initResult: any) { constructor(name: string, public title: string, public blockName: string, protected handlerSchema: any,
protected initResult: any) {
super(name); super(name);
} }
@ -38,23 +41,27 @@ export class CoreSitePluginsBlockHandler extends CoreSitePluginsBaseHandler impl
*/ */
getDisplayData(injector: Injector, block: any, contextLevel: string, instanceId: number): getDisplayData(injector: Injector, block: any, contextLevel: string, instanceId: number):
CoreBlockHandlerData | Promise<CoreBlockHandlerData> { CoreBlockHandlerData | Promise<CoreBlockHandlerData> {
let title, let className,
className; component;
if (this.handlerSchema.displaydata && this.handlerSchema.displaydata.title) {
title = this.handlerSchema.displaydata.title;
} else {
title = 'plugins.block_' + block.name + '.pluginname';
}
if (this.handlerSchema.displaydata && this.handlerSchema.displaydata.class) { if (this.handlerSchema.displaydata && this.handlerSchema.displaydata.class) {
className = this.handlerSchema.displaydata.class; className = this.handlerSchema.displaydata.class;
} else { } else {
className = 'block_' + block.name; className = 'block_' + block.name;
} }
if (this.handlerSchema.displaydata && this.handlerSchema.displaydata.type == 'title') {
component = CoreSitePluginsOnlyTitleBlockComponent;
} else if (this.handlerSchema.displaydata && this.handlerSchema.displaydata.type == 'prerendered') {
component = CoreBlockPreRenderedComponent;
} else {
component = CoreSitePluginsBlockComponent;
}
return { return {
title: title, title: this.title,
class: className, class: className,
component: CoreSitePluginsBlockComponent component: component
}; };
} }
} }

View File

@ -53,7 +53,10 @@ export class CoreSitePluginsBlockComponent extends CoreBlockBaseComponent implem
if (handler) { if (handler) {
this.component = handler.plugin.component; this.component = handler.plugin.component;
this.method = handler.handlerSchema.method; this.method = handler.handlerSchema.method;
this.args = { }; this.args = {
contextlevel: this.contextLevel,
instanceid: this.instanceId,
};
this.initResult = handler.initResult; this.initResult = handler.initResult;
} }
} }

View File

@ -30,12 +30,14 @@ import { CoreSitePluginsAssignFeedbackComponent } from './assign-feedback/assign
import { CoreSitePluginsAssignSubmissionComponent } from './assign-submission/assign-submission'; import { CoreSitePluginsAssignSubmissionComponent } from './assign-submission/assign-submission';
import { CoreSitePluginsWorkshopAssessmentStrategyComponent } from './workshop-assessment-strategy/workshop-assessment-strategy'; import { CoreSitePluginsWorkshopAssessmentStrategyComponent } from './workshop-assessment-strategy/workshop-assessment-strategy';
import { CoreSitePluginsBlockComponent } from '@core/siteplugins/components/block/block'; import { CoreSitePluginsBlockComponent } from '@core/siteplugins/components/block/block';
import { CoreSitePluginsOnlyTitleBlockComponent } from '@core/siteplugins/components/only-title-block/only-title-block';
@NgModule({ @NgModule({
declarations: [ declarations: [
CoreSitePluginsPluginContentComponent, CoreSitePluginsPluginContentComponent,
CoreSitePluginsModuleIndexComponent, CoreSitePluginsModuleIndexComponent,
CoreSitePluginsBlockComponent, CoreSitePluginsBlockComponent,
CoreSitePluginsOnlyTitleBlockComponent,
CoreSitePluginsCourseOptionComponent, CoreSitePluginsCourseOptionComponent,
CoreSitePluginsCourseFormatComponent, CoreSitePluginsCourseFormatComponent,
CoreSitePluginsUserProfileFieldComponent, CoreSitePluginsUserProfileFieldComponent,
@ -59,6 +61,7 @@ import { CoreSitePluginsBlockComponent } from '@core/siteplugins/components/bloc
CoreSitePluginsPluginContentComponent, CoreSitePluginsPluginContentComponent,
CoreSitePluginsModuleIndexComponent, CoreSitePluginsModuleIndexComponent,
CoreSitePluginsBlockComponent, CoreSitePluginsBlockComponent,
CoreSitePluginsOnlyTitleBlockComponent,
CoreSitePluginsCourseOptionComponent, CoreSitePluginsCourseOptionComponent,
CoreSitePluginsCourseFormatComponent, CoreSitePluginsCourseFormatComponent,
CoreSitePluginsUserProfileFieldComponent, CoreSitePluginsUserProfileFieldComponent,
@ -72,6 +75,7 @@ import { CoreSitePluginsBlockComponent } from '@core/siteplugins/components/bloc
entryComponents: [ entryComponents: [
CoreSitePluginsModuleIndexComponent, CoreSitePluginsModuleIndexComponent,
CoreSitePluginsBlockComponent, CoreSitePluginsBlockComponent,
CoreSitePluginsOnlyTitleBlockComponent,
CoreSitePluginsCourseOptionComponent, CoreSitePluginsCourseOptionComponent,
CoreSitePluginsCourseFormatComponent, CoreSitePluginsCourseFormatComponent,
CoreSitePluginsUserProfileFieldComponent, CoreSitePluginsUserProfileFieldComponent,

View File

@ -0,0 +1,3 @@
<ion-item-divider text-wrap detail-push (click)="gotoBlock($event)">
<h2>{{ title | translate }}</h2>
</ion-item-divider>

View File

@ -0,0 +1,69 @@
// (C) Copyright 2015 Martin Dougiamas
//
// 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 { Injector, OnInit, Component, Optional } from '@angular/core';
import { NavController } from 'ionic-angular';
import { CoreBlockBaseComponent } from '@core/block/classes/base-block-component';
import { CoreSitePluginsProvider } from '../../providers/siteplugins';
import { CoreBlockDelegate } from '@core/block/providers/delegate';
import { CoreSplitViewComponent } from '@components/split-view/split-view';
/**
* Component to render blocks with only a title and link.
*/
@Component({
selector: 'core-siteplugins-only-title-block',
templateUrl: 'core-siteplugins-only-title-block.html'
})
export class CoreSitePluginsOnlyTitleBlockComponent extends CoreBlockBaseComponent implements OnInit {
constructor(injector: Injector, protected sitePluginsProvider: CoreSitePluginsProvider,
protected blockDelegate: CoreBlockDelegate, private navCtrl: NavController,
@Optional() private svComponent: CoreSplitViewComponent) {
super(injector, 'CoreSitePluginsOnlyTitleBlockComponent');
}
/**
* Component being initialized.
*/
ngOnInit(): void {
super.ngOnInit();
this.fetchContentDefaultError = 'Error getting ' + this.block.contents.title + ' data.';
}
/**
* Go to the block page.
*/
gotoBlock(): void {
const handlerName = this.blockDelegate.getHandlerName(this.block.name);
const handler = this.sitePluginsProvider.getSitePluginHandler(handlerName);
if (handler) {
const navCtrl = this.svComponent ? this.svComponent.getMasterNav() : this.navCtrl;
navCtrl.push('CoreSitePluginsPluginPage', {
title: this.title,
component: handler.plugin.component,
method: handler.handlerSchema.method,
initResult: handler.initResult,
args: {
contextlevel: this.contextLevel,
instanceid: this.instanceId,
},
});
}
}
}

View File

@ -661,10 +661,11 @@ export class CoreSitePluginsHelperProvider {
string | Promise<string> { string | Promise<string> {
const uniqueName = this.sitePluginsProvider.getHandlerUniqueName(plugin, handlerName), const uniqueName = this.sitePluginsProvider.getHandlerUniqueName(plugin, handlerName),
blockName = (handlerSchema.moodlecomponent || plugin.component).replace('block_', ''); blockName = (handlerSchema.moodlecomponent || plugin.component).replace('block_', ''),
prefixedTitle = this.getPrefixedString(plugin.addon, handlerSchema.displaydata.title || 'pluginname');
this.blockDelegate.registerHandler( this.blockDelegate.registerHandler(
new CoreSitePluginsBlockHandler(uniqueName, blockName, handlerSchema, initResult)); new CoreSitePluginsBlockHandler(uniqueName, prefixedTitle, blockName, handlerSchema, initResult));
return uniqueName; return uniqueName;
} }
@ -709,7 +710,7 @@ export class CoreSitePluginsHelperProvider {
// Create and register the handler. // Create and register the handler.
const uniqueName = this.sitePluginsProvider.getHandlerUniqueName(plugin, handlerName), const uniqueName = this.sitePluginsProvider.getHandlerUniqueName(plugin, handlerName),
prefixedTitle = this.getPrefixedString(plugin.addon, handlerSchema.displaydata.title), prefixedTitle = this.getPrefixedString(plugin.addon, handlerSchema.displaydata.title || 'pluginname'),
handler = new CoreSitePluginsCourseOptionHandler(uniqueName, prefixedTitle, plugin, handler = new CoreSitePluginsCourseOptionHandler(uniqueName, prefixedTitle, plugin,
handlerSchema, initResult, this.sitePluginsProvider, this.utils); handlerSchema, initResult, this.sitePluginsProvider, this.utils);
@ -749,7 +750,7 @@ export class CoreSitePluginsHelperProvider {
// Create and register the handler. // Create and register the handler.
const uniqueName = this.sitePluginsProvider.getHandlerUniqueName(plugin, handlerName), const uniqueName = this.sitePluginsProvider.getHandlerUniqueName(plugin, handlerName),
prefixedTitle = this.getPrefixedString(plugin.addon, handlerSchema.displaydata.title); prefixedTitle = this.getPrefixedString(plugin.addon, handlerSchema.displaydata.title || 'pluginname');
this.mainMenuDelegate.registerHandler( this.mainMenuDelegate.registerHandler(
new CoreSitePluginsMainMenuHandler(uniqueName, prefixedTitle, plugin, handlerSchema, initResult)); new CoreSitePluginsMainMenuHandler(uniqueName, prefixedTitle, plugin, handlerSchema, initResult));
@ -778,7 +779,7 @@ export class CoreSitePluginsHelperProvider {
// Create and register the handler. // Create and register the handler.
const uniqueName = this.sitePluginsProvider.getHandlerUniqueName(plugin, handlerName), const uniqueName = this.sitePluginsProvider.getHandlerUniqueName(plugin, handlerName),
prefixedTitle = this.getPrefixedString(plugin.addon, handlerSchema.displaydata.title), prefixedTitle = this.getPrefixedString(plugin.addon, handlerSchema.displaydata.title || 'pluginname'),
processorName = (handlerSchema.moodlecomponent || plugin.component).replace('message_', ''); processorName = (handlerSchema.moodlecomponent || plugin.component).replace('message_', '');
this.messageOutputDelegate.registerHandler(new CoreSitePluginsMessageOutputHandler(uniqueName, processorName, this.messageOutputDelegate.registerHandler(new CoreSitePluginsMessageOutputHandler(uniqueName, processorName,
@ -897,7 +898,7 @@ export class CoreSitePluginsHelperProvider {
// Create and register the handler. // Create and register the handler.
const uniqueName = this.sitePluginsProvider.getHandlerUniqueName(plugin, handlerName), const uniqueName = this.sitePluginsProvider.getHandlerUniqueName(plugin, handlerName),
prefixedTitle = this.getPrefixedString(plugin.addon, handlerSchema.displaydata.title); prefixedTitle = this.getPrefixedString(plugin.addon, handlerSchema.displaydata.title || 'pluginname');
this.settingsDelegate.registerHandler( this.settingsDelegate.registerHandler(
new CoreSitePluginsSettingsHandler(uniqueName, prefixedTitle, plugin, handlerSchema, initResult)); new CoreSitePluginsSettingsHandler(uniqueName, prefixedTitle, plugin, handlerSchema, initResult));
@ -926,7 +927,7 @@ export class CoreSitePluginsHelperProvider {
// Create and register the handler. // Create and register the handler.
const uniqueName = this.sitePluginsProvider.getHandlerUniqueName(plugin, handlerName), const uniqueName = this.sitePluginsProvider.getHandlerUniqueName(plugin, handlerName),
prefixedTitle = this.getPrefixedString(plugin.addon, handlerSchema.displaydata.title), prefixedTitle = this.getPrefixedString(plugin.addon, handlerSchema.displaydata.title || 'pluginname'),
handler = new CoreSitePluginsUserProfileHandler(uniqueName, prefixedTitle, plugin, handlerSchema, handler = new CoreSitePluginsUserProfileHandler(uniqueName, prefixedTitle, plugin, handlerSchema,
initResult, this.sitePluginsProvider, this.utils); initResult, this.sitePluginsProvider, this.utils);