MOBILE-3002 block: Add Recent activity block feature

main
Pau Ferrer Ocaña 2019-05-14 13:51:26 +02:00
parent 83a899acd6
commit 8ede493cef
7 changed files with 118 additions and 1 deletions

View File

@ -53,7 +53,8 @@
"addon.block_recentlyaccessedcourses.nocourses": "block_recentlyaccessedcourses",
"addon.block_recentlyaccessedcourses.pluginname": "block_recentlyaccessedcourses",
"addon.block_recentlyaccesseditems.noitems": "block_recentlyaccesseditems",
"addon.block_recentlyaccesseditems.pluginname": "block_recentlyaccesseditems",
"addon.block_recentactivity.pluginname": "block_recent_activity",
"addon.block_glossaryrandom.pluginname": "block_glossary_random",
"addon.block_selfcompletion.pluginname": "block_selfcompletion",
"addon.block_sitemainmenu.pluginname": "block_site_main_menu",
"addon.block_starredcourses.nocourses": "block_starredcourses",

View File

@ -0,0 +1,3 @@
{
"pluginname": "Recent activity"
}

View File

@ -0,0 +1,52 @@
// (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 { Injectable, Injector } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
import { CoreBlockHandlerData } from '@core/block/providers/delegate';
import { CoreBlockPreRenderedComponent } from '@core/block/components/pre-rendered-block/pre-rendered-block';
import { CoreBlockBaseHandler } from '@core/block/classes/base-block-handler';
/**
* Block handler.
*/
@Injectable()
export class AddonBlockRecentActivityHandler extends CoreBlockBaseHandler {
name = 'AddonBlockRecentActivity';
blockName = 'recent_activity';
constructor(private translate: TranslateService) {
super();
}
/**
* Returns the data needed to render the block.
*
* @param {Injector} injector Injector.
* @param {any} block The block to render.
* @param {string} contextLevel The context where the block will be used.
* @param {number} instanceId The instance ID associated with the context level.
* @return {CoreBlockHandlerData|Promise<CoreBlockHandlerData>} Data or promise resolved with the data.
*/
getDisplayData(injector: Injector, block: any, contextLevel: string, instanceId: number)
: CoreBlockHandlerData | Promise<CoreBlockHandlerData> {
return {
title: this.translate.instant('addon.block_recentactivity.pluginname'),
class: 'addon-block-recent-activity',
component: CoreBlockPreRenderedComponent
};
}
}

View File

@ -0,0 +1,38 @@
// (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 { NgModule } from '@angular/core';
import { IonicModule } from 'ionic-angular';
import { TranslateModule } from '@ngx-translate/core';
import { CoreBlockDelegate } from '@core/block/providers/delegate';
import { AddonBlockRecentActivityHandler } from './providers/block-handler';
@NgModule({
declarations: [
],
imports: [
IonicModule,
TranslateModule.forChild()
],
exports: [
],
providers: [
AddonBlockRecentActivityHandler
]
})
export class AddonBlockRecentActivityModule {
constructor(blockDelegate: CoreBlockDelegate, blockHandler: AddonBlockRecentActivityHandler) {
blockDelegate.registerHandler(blockHandler);
}
}

View File

@ -0,0 +1,20 @@
.addon-block-recent-activity core-block-pre-rendered {
.core-block-content {
.activitydate, .activityhead {
text-align: center;
}
.unlist {
list-style: none;
@include margin-horizontal(0);
-webkit-padding-start: 0;
li {
margin-bottom: 1em;
.head .date {
@include float(end);
}
}
}
}
}

View File

@ -109,6 +109,7 @@ import { AddonBlockSiteMainMenuModule } from '@addon/block/sitemainmenu/sitemain
import { AddonBlockTimelineModule } from '@addon/block/timeline/timeline.module';
import { AddonBlockRecentlyAccessedCoursesModule } from '@addon/block/recentlyaccessedcourses/recentlyaccessedcourses.module';
import { AddonBlockRecentlyAccessedItemsModule } from '@addon/block/recentlyaccesseditems/recentlyaccesseditems.module';
import { AddonBlockRecentActivityModule } from '@addon/block/recentactivity/recentactivity.module';
import { AddonBlockStarredCoursesModule } from '@addon/block/starredcourses/starredcourses.module';
import { AddonBlockSelfCompletionModule } from '@addon/block/selfcompletion/selfcompletion.module';
import { AddonBlockTagsModule } from '@addon/block/tags/tags.module';
@ -246,6 +247,7 @@ export const CORE_PROVIDERS: any[] = [
AddonBlockTimelineModule,
AddonBlockRecentlyAccessedCoursesModule,
AddonBlockRecentlyAccessedItemsModule,
AddonBlockRecentActivityModule,
AddonBlockStarredCoursesModule,
AddonBlockSelfCompletionModule,
AddonBlockTagsModule,

View File

@ -50,6 +50,7 @@
"addon.block_newsitems.pluginname": "Latest announcements",
"addon.block_onlineusers.pluginname": "Online users",
"addon.block_privatefiles.pluginname": "Private files",
"addon.block_recentactivity.pluginname": "Recent activity",
"addon.block_recentlyaccessedcourses.nocourses": "No recent courses",
"addon.block_recentlyaccessedcourses.pluginname": "Recently accessed courses",
"addon.block_recentlyaccesseditems.noitems": "No recent items",