Merge pull request #1579 from crazyserver/MOBILE-2700

Mobile 2700
main
Juan Leyva 2018-10-25 15:41:54 +02:00 committed by GitHub
commit 01eaffa3de
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
33 changed files with 512 additions and 165 deletions

View File

@ -20,7 +20,9 @@
"addon.block_myoverview.nocoursesinprogress": "block_myoverview",
"addon.block_myoverview.nocoursespast": "block_myoverview",
"addon.block_myoverview.past": "block_myoverview",
"addon.block_myoverview.pluginname": "block_myoverview",
"addon.block_myoverview.title": "block_myoverview",
"addon.block_recentcourses.nocourses": "moodle",
"addon.block_sitemainmenu.pluginname": "block_site_main_menu",
"addon.block_timeline.duedate": "block_timeline",
"addon.block_timeline.next30days": "block_timeline",
@ -30,6 +32,7 @@
"addon.block_timeline.nocoursesinprogress": "block_timeline",
"addon.block_timeline.noevents": "block_timeline",
"addon.block_timeline.overdue": "block_timeline",
"addon.block_timeline.pluginname": "block_timeline",
"addon.block_timeline.sortbycourses": "block_timeline",
"addon.block_timeline.sortbydates": "block_timeline",
"addon.calendar.calendar": "calendar",
@ -1192,7 +1195,6 @@
"core.courses.searchcoursesadvice": "local_moodlemobileapp",
"core.courses.selfenrolment": "local_moodlemobileapp",
"core.courses.sendpaymentbutton": "enrol_paypal",
"core.courses.timeline": "block_dashboard",
"core.courses.totalcoursesearchresults": "local_moodlemobileapp",
"core.currentdevice": "local_moodlemobileapp",
"core.datastoredoffline": "local_moodlemobileapp",

View File

@ -1,3 +1,6 @@
<ion-item-divider color="light">
<h2>{{ 'addon.block_activitymodules.pluginname' | translate }}</h2>
</ion-item-divider>
<core-loading [hideUntil]="loaded" class="core-loading-center">
<a ion-item text-wrap *ngFor="let entry of entries" class="item-media" detail-none [navPush]="'CoreCourseListModTypePage'" [navParams]="{title: entry.name, courseId: instanceId, modName: entry.modName}">
<img item-start [src]="entry.icon" alt="" role="presentation" class="core-module-icon">

View File

@ -13,28 +13,20 @@
// limitations under the License.
import { Injectable, Injector } from '@angular/core';
import { CoreBlockHandler, CoreBlockHandlerData } from '@core/block/providers/delegate';
import { CoreBlockHandlerData } from '@core/block/providers/delegate';
import { AddonBlockActivityModulesComponent } from '../components/activitymodules/activitymodules';
import { CoreBlockBaseHandler } from '@core/block/classes/base-block-handler';
/**
* Course nav handler.
* Block handler.
*/
@Injectable()
export class AddonBlockActivityModulesHandler implements CoreBlockHandler {
name = 'AddonBlockActivityModulesHandler';
export class AddonBlockActivityModulesHandler extends CoreBlockBaseHandler {
name = 'AddonBlockActivityModules';
blockName = 'activity_modules';
constructor() {
// Nothing to do.
}
/**
* Check if the handler is enabled on a site level.
*
* @return {boolean} Whether or not the handler is enabled on a site level.
*/
isEnabled(): boolean | Promise<boolean> {
return true;
super();
}
/**

View File

@ -0,0 +1,47 @@
// (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 { CommonModule } from '@angular/common';
import { IonicModule } from 'ionic-angular';
import { TranslateModule } from '@ngx-translate/core';
import { CoreCoursesComponentsModule } from '@core/courses/components/components.module';
import { AddonBlockMyOverviewComponent } from './myoverview/myoverview';
import { CoreComponentsModule } from '@components/components.module';
import { CoreDirectivesModule } from '@directives/directives.module';
import { CoreCourseComponentsModule } from '@core/course/components/components.module';
@NgModule({
declarations: [
AddonBlockMyOverviewComponent
],
imports: [
CommonModule,
IonicModule,
TranslateModule.forChild(),
CoreComponentsModule,
CoreDirectivesModule,
CoreCoursesComponentsModule,
CoreCourseComponentsModule
],
providers: [
],
exports: [
AddonBlockMyOverviewComponent
],
entryComponents: [
AddonBlockMyOverviewComponent
]
})
export class AddonBlockMyOverviewComponentsModule {}

View File

@ -1,10 +1,13 @@
<!-- Buttons to add to the header. -->
<core-navbar-buttons end>
<button [hidden]="!showFilterSwitchButton()" ion-button icon-only [attr.aria-label]="'core.courses.filtermycourses' | translate" (click)="switchFilter()">
<button [hidden]="!loaded || !showFilterSwitchButton()" ion-button icon-only [attr.aria-label]="'core.courses.filtermycourses' | translate" (click)="switchFilter()">
<ion-icon name="funnel"></ion-icon>
</button>
</core-navbar-buttons>
<ion-item-divider color="light">
<h2>{{ 'addon.block_myoverview.pluginname' | translate }}</h2>
</ion-item-divider>
<core-loading [hideUntil]="loaded" class="core-loading-center">
<div padding ion-row justify-content-end [hidden]="showFilter">
<!-- "Time" selector. -->

View File

@ -2,11 +2,12 @@
"all": "All",
"future": "Future",
"inprogress": "In progress",
"past": "Past",
"lastaccessed": "Last accessed",
"morecourses": "More courses",
"nocoursesfuture": "No future courses",
"nocoursesinprogress": "No in progress courses",
"nocoursespast": "No past courses",
"lastaccessed": "Last accessed",
"past": "Past",
"pluginname": "Course Overview",
"title": "Title"
}

View File

@ -15,22 +15,26 @@
import { NgModule } from '@angular/core';
import { IonicModule } from 'ionic-angular';
import { TranslateModule } from '@ngx-translate/core';
import { CoreComponentsModule } from '@components/components.module';
import { CoreCoursesComponentsModule } from '@core/courses/components/components.module';
import { AddonBlockMyOverviewComponent } from './component/myoverview';
import { CoreBlockDelegate } from '@core/block/providers/delegate';
import { AddonBlockMyOverviewComponentsModule } from './components/components.module';
import { AddonBlockMyOverviewHandler } from './providers/block-handler';
@NgModule({
declarations: [
AddonBlockMyOverviewComponent
],
imports: [
IonicModule,
CoreComponentsModule,
CoreCoursesComponentsModule,
AddonBlockMyOverviewComponentsModule,
TranslateModule.forChild()
],
exports: [
AddonBlockMyOverviewComponent
],
providers: [
AddonBlockMyOverviewHandler
]
})
export class AddonBlockMyOverviewModule {}
export class AddonBlockMyOverviewModule {
constructor(blockDelegate: CoreBlockDelegate, blockHandler: AddonBlockMyOverviewHandler) {
blockDelegate.registerHandler(blockHandler);
}
}

View File

@ -0,0 +1,62 @@
// (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 { CoreSitesProvider } from '@providers/sites';
import { CoreBlockHandlerData } from '@core/block/providers/delegate';
import { CoreCoursesProvider } from '@core/courses/providers/courses';
import { AddonBlockMyOverviewComponent } from '../components/myoverview/myoverview';
import { CoreBlockBaseHandler } from '@core/block/classes/base-block-handler';
/**
* Block handler.
*/
@Injectable()
export class AddonBlockMyOverviewHandler extends CoreBlockBaseHandler {
name = 'AddonBlockMyOverview';
blockName = 'myoverview';
constructor(private coursesProvider: CoreCoursesProvider, private sitesProvider: CoreSitesProvider) {
super();
}
/**
* Check if the handler is enabled on a site level.
*
* @return {boolean} Whether or not the handler is enabled on a site level.
*/
isEnabled(): boolean | Promise<boolean> {
return this.sitesProvider.getCurrentSite().isVersionGreaterEqualThan('3.6') ||
!this.coursesProvider.isMyCoursesDisabledInSite();
}
/**
* 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: 'addon.block_myoverview.pluginname',
class: 'addon-block-myoverview',
component: AddonBlockMyOverviewComponent
};
}
}

View File

@ -1,3 +1,6 @@
<ion-item-divider color="light">
<h2>{{ 'addon.block_sitemainmenu.pluginname' | translate }}</h2>
</ion-item-divider>
<core-loading [hideUntil]="loaded" class="core-loading-center">
<ion-item text-wrap *ngIf="block.summary">
<core-format-text [text]="block.summary"></core-format-text>

View File

@ -13,28 +13,20 @@
// limitations under the License.
import { Injectable, Injector } from '@angular/core';
import { CoreBlockHandler, CoreBlockHandlerData } from '@core/block/providers/delegate';
import { CoreBlockHandlerData } from '@core/block/providers/delegate';
import { AddonBlockSiteMainMenuComponent } from '../components/sitemainmenu/sitemainmenu';
import { CoreBlockBaseHandler } from '@core/block/classes/base-block-handler';
/**
* Course nav handler.
* Block handler.
*/
@Injectable()
export class AddonBlockSiteMainMenuHandler implements CoreBlockHandler {
name = 'AddonBlockSiteMainMenuHandler';
export class AddonBlockSiteMainMenuHandler extends CoreBlockBaseHandler {
name = 'AddonBlockSiteMainMenu';
blockName = 'site_main_menu';
constructor() {
// Nothing to do.
}
/**
* Check if the handler is enabled on a site level.
*
* @return {boolean} Whether or not the handler is enabled on a site level.
*/
isEnabled(): boolean | Promise<boolean> {
return true;
super();
}
/**

View File

@ -0,0 +1,53 @@
// (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 { CommonModule } from '@angular/common';
import { IonicModule } from 'ionic-angular';
import { TranslateModule } from '@ngx-translate/core';
import { CoreComponentsModule } from '@components/components.module';
import { CoreDirectivesModule } from '@directives/directives.module';
import { CorePipesModule } from '@pipes/pipes.module';
import { CoreCoursesComponentsModule } from '@core/courses/components/components.module';
import { AddonBlockTimelineComponent } from './timeline/timeline';
import { AddonBlockTimelineEventsComponent } from './events/events';
import { CoreCourseComponentsModule } from '@core/course/components/components.module';
@NgModule({
declarations: [
AddonBlockTimelineComponent,
AddonBlockTimelineEventsComponent
],
imports: [
CommonModule,
IonicModule,
TranslateModule.forChild(),
CoreComponentsModule,
CoreDirectivesModule,
CorePipesModule,
CoreCoursesComponentsModule,
CoreCourseComponentsModule
],
providers: [
],
exports: [
AddonBlockTimelineComponent,
AddonBlockTimelineEventsComponent
],
entryComponents: [
AddonBlockTimelineComponent,
AddonBlockTimelineEventsComponent
]
})
export class AddonBlockTimelineComponentsModule {}

View File

@ -1,34 +1,39 @@
<div padding [hidden]="!loaded" ion-row>
<ion-col>
<ion-select text-start [(ngModel)]="filter" (ngModelChange)="switchFilter()" interface="popover" class="core-button-select">
<ion-option value="all">{{ 'core.all' | translate }}</ion-option>
<ion-option value="overdue">{{ 'addon.block_timeline.overdue' | translate }}</ion-option>
<ion-option disabled value="disabled">{{ 'addon.block_timeline.duedate' | translate }}</ion-option>
<ion-option value="next7days">{{ 'addon.block_timeline.next7days' | translate }}</ion-option>
<ion-option value="next30days">{{ 'addon.block_timeline.next30days' | translate }}</ion-option>
<ion-option value="next3months">{{ 'addon.block_timeline.next3months' | translate }}</ion-option>
<ion-option value="next6months">{{ 'addon.block_timeline.next6months' | translate }}</ion-option>
</ion-select>
</ion-col>
<ion-col>
<ion-select text-start [(ngModel)]="sort" (ngModelChange)="switchSort()" interface="popover" class="core-button-select">
<ion-option value="sortbydates">{{ 'addon.block_timeline.sortbydates' | translate }}</ion-option>
<ion-option value="sortbycourses">{{ 'addon.block_timeline.sortbycourses' | translate }}</ion-option>
</ion-select>
</ion-col>
</div>
<core-loading [hideUntil]="loaded && timeline.loaded" [hidden]="sort != 'sortbydates'" class="core-loading-center">
<addon-block-timeline-events [events]="timeline.events" showCourse="true" [canLoadMore]="timeline.canLoadMore" (loadMore)="loadMoreTimeline()" [from]="dataFrom" [to]="dataTo"></addon-block-timeline-events>
</core-loading>
<core-loading [hideUntil]="loaded && timelineCourses.loaded" [hidden]="sort != 'sortbycourses'" class="core-loading-center">
<ion-grid no-padding>
<ion-row no-padding>
<ion-col *ngFor="let course of timelineCourses.courses" no-padding col-12 col-md-6>
<core-courses-course-progress [course]="course">
<addon-block-timeline-events [events]="course.events" [canLoadMore]="course.canLoadMore" (loadMore)="loadMoreCourse(course)" [from]="dataFrom" [to]="dataTo"></addon-block-timeline-events>
</core-courses-course-progress>
</ion-col>
</ion-row>
</ion-grid>
<core-empty-box *ngIf="timelineCourses.courses.length == 0" image="assets/img/icons/courses.svg" [message]="'addon.block_timeline.nocoursesinprogress' | translate"></core-empty-box>
<ion-item-divider color="light">
<h2>{{ 'addon.block_timeline.pluginname' | translate }}</h2>
</ion-item-divider>
<core-loading [hideUntil]="loaded" class="core-loading-center">
<div padding ion-row>
<ion-col>
<ion-select text-start [(ngModel)]="filter" (ngModelChange)="switchFilter()" interface="popover" class="core-button-select">
<ion-option value="all">{{ 'core.all' | translate }}</ion-option>
<ion-option value="overdue">{{ 'addon.block_timeline.overdue' | translate }}</ion-option>
<ion-option disabled value="disabled">{{ 'addon.block_timeline.duedate' | translate }}</ion-option>
<ion-option value="next7days">{{ 'addon.block_timeline.next7days' | translate }}</ion-option>
<ion-option value="next30days">{{ 'addon.block_timeline.next30days' | translate }}</ion-option>
<ion-option value="next3months">{{ 'addon.block_timeline.next3months' | translate }}</ion-option>
<ion-option value="next6months">{{ 'addon.block_timeline.next6months' | translate }}</ion-option>
</ion-select>
</ion-col>
<ion-col>
<ion-select text-start [(ngModel)]="sort" (ngModelChange)="switchSort()" interface="popover" class="core-button-select">
<ion-option value="sortbydates">{{ 'addon.block_timeline.sortbydates' | translate }}</ion-option>
<ion-option value="sortbycourses">{{ 'addon.block_timeline.sortbycourses' | translate }}</ion-option>
</ion-select>
</ion-col>
</div>
<core-loading [hideUntil]="timeline.loaded" [hidden]="sort != 'sortbydates'" class="core-loading-center">
<addon-block-timeline-events [events]="timeline.events" showCourse="true" [canLoadMore]="timeline.canLoadMore" (loadMore)="loadMoreTimeline()" [from]="dataFrom" [to]="dataTo"></addon-block-timeline-events>
</core-loading>
<core-loading [hideUntil]="timelineCourses.loaded" [hidden]="sort != 'sortbycourses'" class="core-loading-center">
<ion-grid no-padding>
<ion-row no-padding>
<ion-col *ngFor="let course of timelineCourses.courses" no-padding col-12 col-md-6>
<core-courses-course-progress [course]="course">
<addon-block-timeline-events [events]="course.events" [canLoadMore]="course.canLoadMore" (loadMore)="loadMoreCourse(course)" [from]="dataFrom" [to]="dataTo"></addon-block-timeline-events>
</core-courses-course-progress>
</ion-col>
</ion-row>
</ion-grid>
<core-empty-box *ngIf="timelineCourses.courses.length == 0" image="assets/img/icons/courses.svg" [message]="'addon.block_timeline.nocoursesinprogress' | translate"></core-empty-box>
</core-loading>
</core-loading>

View File

@ -7,6 +7,7 @@
"nocoursesinprogress": "No in progress courses",
"noevents": "No upcoming activities due",
"overdue": "Overdue",
"pluginname": "Timeline",
"sortbycourses": "Sort by courses",
"sortbydates": "Sort by dates"
}

View File

@ -0,0 +1,65 @@
// (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 { CoreSitesProvider } from '@providers/sites';
import { CoreBlockHandlerData } from '@core/block/providers/delegate';
import { CoreCoursesProvider } from '@core/courses/providers/courses';
import { AddonBlockTimelineProvider } from '@addon/block/timeline/providers/timeline';
import { AddonBlockTimelineComponent } from '../components/timeline/timeline';
import { CoreBlockBaseHandler } from '@core/block/classes/base-block-handler';
/**
* Block handler.
*/
@Injectable()
export class AddonBlockTimelineHandler extends CoreBlockBaseHandler {
name = 'AddonBlockTimeline';
blockName = 'timeline';
constructor(private timelineProvider: AddonBlockTimelineProvider, private coursesProvider: CoreCoursesProvider,
private sitesProvider: CoreSitesProvider) {
super();
}
/**
* Check if the handler is enabled on a site level.
*
* @return {boolean} Whether or not the handler is enabled on a site level.
*/
isEnabled(): boolean | Promise<boolean> {
return this.timelineProvider.isAvailable() && (this.sitesProvider.getCurrentSite().isVersionGreaterEqualThan('3.6') ||
!this.coursesProvider.isMyCoursesDisabledInSite());
}
/**
* 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: 'addon.block_timeline.pluginname',
class: 'addon-block-timeline',
component: AddonBlockTimelineComponent
};
}
}

View File

@ -15,33 +15,28 @@
import { NgModule } from '@angular/core';
import { IonicModule } from 'ionic-angular';
import { TranslateModule } from '@ngx-translate/core';
import { CoreComponentsModule } from '@components/components.module';
import { CoreDirectivesModule } from '@directives/directives.module';
import { CorePipesModule } from '@pipes/pipes.module';
import { CoreCoursesComponentsModule } from '@core/courses/components/components.module';
import { AddonBlockTimelineComponent } from './components/timeline/timeline';
import { AddonBlockTimelineEventsComponent } from './components/events/events';
import { CoreBlockDelegate } from '@core/block/providers/delegate';
import { AddonBlockTimelineComponentsModule } from './components/components.module';
import { AddonBlockTimelineProvider } from './providers/timeline';
import { AddonBlockTimelineHandler } from './providers/block-handler';
@NgModule({
declarations: [
AddonBlockTimelineComponent,
AddonBlockTimelineEventsComponent
],
imports: [
IonicModule,
CoreComponentsModule,
CoreDirectivesModule,
CorePipesModule,
CoreCoursesComponentsModule,
AddonBlockTimelineComponentsModule,
TranslateModule.forChild()
],
exports: [
AddonBlockTimelineComponent,
AddonBlockTimelineEventsComponent
],
providers: [
AddonBlockTimelineProvider
AddonBlockTimelineProvider,
AddonBlockTimelineHandler
]
})
export class AddonBlockTimelineModule {}
export class AddonBlockTimelineModule {
constructor(blockDelegate: CoreBlockDelegate, blockHandler: AddonBlockTimelineHandler) {
blockDelegate.registerHandler(blockHandler);
}
}

View File

@ -11,7 +11,7 @@
<core-loading [hideUntil]="filesLoaded" *ngIf="showPrivateFiles || showSiteFiles">
<!-- Allow selecting the files to see: private or site. -->
<div padding *ngIf="showPrivateFiles && showSiteFiles && !path">
<ion-select [(ngModel)]="root" (ngModelChange)="rootChanged()" interface="popover">
<ion-select [(ngModel)]="root" (ngModelChange)="rootChanged()" interface="popover" class="core-button-select">
<ion-option value="my">{{ 'addon.files.privatefiles' | translate }}</ion-option>
<ion-option value="site">{{ 'addon.files.sitefiles' | translate }}</ion-option>
</ion-select>

View File

@ -63,7 +63,7 @@ ion-app.app-root page-addon-messages-discussion {
min-height: initial;
line-height: initial;
@include margin(0, 0, 0, 10px);
height: auto;
height: 1.6em !important;
-webkit-align-self: flex-end;
-ms-flex-item-align: end;
align-self: flex-end;

View File

@ -738,6 +738,19 @@ ion-app.app-root {
}
}
.core-#{$color-name}-selected-item {
@include border-start(5px, solid, $color-base);
&.item-md {
@include padding(null, null, null, $item-md-padding-start - 5px);
}
&.item-ios {
@include padding(null, null, null, $item-ios-padding-start - 5px);
}
&.item-wp {
@include padding(null, null, null, $item-wp-padding-start - 5px);
}
}
.core-#{$color-name}-circle {
margin: 0 4px;
}

View File

@ -20,6 +20,7 @@
"addon.block_myoverview.nocoursesinprogress": "No in progress courses",
"addon.block_myoverview.nocoursespast": "No past courses",
"addon.block_myoverview.past": "Past",
"addon.block_myoverview.pluginname": "Course Overview",
"addon.block_myoverview.title": "Title",
"addon.block_sitemainmenu.pluginname": "Main menu",
"addon.block_timeline.duedate": "Due date",
@ -30,6 +31,7 @@
"addon.block_timeline.nocoursesinprogress": "No in progress courses",
"addon.block_timeline.noevents": "No upcoming activities due",
"addon.block_timeline.overdue": "Overdue",
"addon.block_timeline.pluginname": "Timeline",
"addon.block_timeline.sortbycourses": "Sort by courses",
"addon.block_timeline.sortbydates": "Sort by dates",
"addon.calendar.calendar": "Calendar",
@ -1192,7 +1194,6 @@
"core.courses.searchcoursesadvice": "You can use the search courses button to find courses to access as a guest or enrol yourself in courses that allow it.",
"core.courses.selfenrolment": "Self enrolment",
"core.courses.sendpaymentbutton": "Send payment via PayPal",
"core.courses.timeline": "Timeline",
"core.courses.totalcoursesearchresults": "Total courses: {{$a}}",
"core.currentdevice": "Current device",
"core.datastoredoffline": "Data stored in the device because it couldn't be sent. It will be sent automatically later.",

View File

@ -287,6 +287,7 @@ export class CoreTabsComponent implements OnInit, AfterViewInit, OnChanges, OnDe
this.slideChanged();
setTimeout(() => {
this.calculateTabBarHeight();
this.slides.update();
this.slides.resize();

View File

@ -1,6 +1,4 @@
<!-- Only render the block if it's supported. -->
<div *ngIf="loaded && componentClass" class="{{class}}">
<ion-item-divider color="light" *ngIf="title">{{ title | translate }}</ion-item-divider>
<core-dynamic-component [component]="componentClass" [data]="data"></core-dynamic-component>
</div>

View File

@ -21,7 +21,7 @@ import { CoreBlockBaseHandler } from '../classes/base-block-handler';
@Injectable()
export class CoreBlockDefaultHandler extends CoreBlockBaseHandler {
name = 'CoreBlockDefault';
type = 'default';
blockName = 'default';
constructor() {
super();

View File

@ -80,6 +80,8 @@ export class CoreBlockDelegate extends CoreDelegate {
protected handlerNameProperty = 'blockName';
protected featurePrefix = 'CoreBlockDelegate_';
constructor(logger: CoreLoggerProvider, sitesProvider: CoreSitesProvider, eventsProvider: CoreEventsProvider,
protected defaultHandler: CoreBlockDefaultHandler) {
super('CoreBlockDelegate', logger, sitesProvider, eventsProvider);

View File

@ -10,7 +10,7 @@
</ion-header>
<ion-content>
<ng-container *ngFor="let section of sections">
<a ion-item *ngIf="!section.hiddenbynumsections && section.id != stealthModulesSectionId" text-wrap (click)="selectSection(section)" [class.core-primary-item]="selected.id == section.id" [class.item-dimmed]="section.visible === 0 || section.uservisible === false" detail-none>
<a ion-item *ngIf="!section.hiddenbynumsections && section.id != stealthModulesSectionId" text-wrap (click)="selectSection(section)" [class.core-primary-selected-item]="selected.id == section.id" [class.item-dimmed]="section.visible === 0 || section.uservisible === false" detail-none>
<core-icon name="fa-folder" item-start></core-icon>
<h2><core-format-text [text]="section.formattedName || section.name"></core-format-text></h2>
<ion-badge color="secondary" *ngIf="section.visible === 0 && section.uservisible !== false">{{ 'core.course.hiddenfromstudents' | translate }}</ion-badge>

View File

@ -28,6 +28,5 @@
"searchcoursesadvice": "You can use the search courses button to find courses to access as a guest or enrol yourself in courses that allow it.",
"selfenrolment": "Self enrolment",
"sendpaymentbutton": "Send payment via PayPal",
"timeline": "Timeline",
"totalcoursesearchresults": "Total courses: {{$a}}"
}

View File

@ -23,26 +23,23 @@
</ng-template>
</core-tab>
<!-- Courses tab. -->
<core-tab [show]="coursesEnabled" [title]="'core.courses.courses' | translate">
<!-- Dashboard tab. -->
<core-tab [show]="dashboardEnabled" [title]="'core.courses.mymoodle' | translate">
<ng-template>
<ion-content>
<ion-refresher [enabled]="!!blockMyOverview && blockMyOverview.loaded" (ionRefresh)="blockMyOverview.doRefresh($event)">
<ion-refresher [enabled]="dashboardLoaded" (ionRefresh)="refreshDashboard($event)">
<ion-refresher-content pullingText="{{ 'core.pulltorefresh' | translate }}"></ion-refresher-content>
</ion-refresher>
<addon-block-myoverview></addon-block-myoverview>
</ion-content>
</ng-template>
</core-tab>
<core-loading [hideUntil]="dashboardLoaded" class="core-loading-center">
<ion-list>
<!-- Dashboard blocks. -->
<ng-container *ngFor="let block of blocks">
<core-block [block]="block" contextLevel="user" [instanceId]="userId"></core-block>
</ng-container>
</ion-list>
<!-- Timeline tab. -->
<core-tab [show]="timelineEnabled" [title]="'core.courses.timeline' | translate">
<ng-template>
<ion-content>
<ion-refresher [enabled]="!!blockTimeline && blockTimeline.loaded" (ionRefresh)="blockTimeline.doRefresh($event)">
<ion-refresher-content pullingText="{{ 'core.pulltorefresh' | translate }}"></ion-refresher-content>
</ion-refresher>
<addon-block-timeline></addon-block-timeline>
<core-empty-box *ngIf="blocks.length == 0" icon="qr-scanner" [message]="'core.course.nocontentavailable' | translate"></core-empty-box>
</core-loading>
</ion-content>
</ng-template>
</core-tab>

View File

@ -19,9 +19,8 @@ import { CoreCoursesDashboardPage } from './dashboard';
import { CoreComponentsModule } from '@components/components.module';
import { CoreDirectivesModule } from '@directives/directives.module';
import { CoreCoursesComponentsModule } from '../../components/components.module';
import { AddonBlockMyOverviewModule } from '@addon/block/myoverview/myoverview.module';
import { AddonBlockTimelineModule } from '@addon/block/timeline/timeline.module';
import { CoreSiteHomeComponentsModule } from '@core/sitehome/components/components.module';
import { CoreBlockComponentsModule } from '@core/block/components/components.module';
@NgModule({
declarations: [
@ -32,8 +31,7 @@ import { CoreSiteHomeComponentsModule } from '@core/sitehome/components/componen
CoreDirectivesModule,
CoreCoursesComponentsModule,
CoreSiteHomeComponentsModule,
AddonBlockMyOverviewModule,
AddonBlockTimelineModule,
CoreBlockComponentsModule,
IonicPageModule.forChild(CoreCoursesDashboardPage),
TranslateModule.forChild()
],

View File

@ -12,17 +12,18 @@
// See the License for the specific language governing permissions and
// limitations under the License.
import { Component, OnDestroy, ViewChild } from '@angular/core';
import { Component, OnDestroy, ViewChild, ViewChildren, QueryList } from '@angular/core';
import { IonicPage, NavController } from 'ionic-angular';
import { CoreEventsProvider } from '@providers/events';
import { CoreSitesProvider } from '@providers/sites';
import { CoreCoursesProvider } from '../../providers/courses';
import { CoreSiteHomeProvider } from '@core/sitehome/providers/sitehome';
import { AddonBlockMyOverviewComponent } from '@addon/block/myoverview/component/myoverview';
import { AddonBlockTimelineComponent } from '@addon/block/timeline/components/timeline/timeline';
import { CoreDomUtilsProvider } from '@providers/utils/dom';
import { CoreTabsComponent } from '@components/tabs/tabs';
import { CoreBlockDelegate } from '@core/block/providers/delegate';
import { CoreBlockComponent } from '@core/block/components/block/block';
import { CoreSiteHomeProvider } from '@core/sitehome/providers/sitehome';
import { CoreSiteHomeIndexComponent } from '@core/sitehome/components/index/index';
import { AddonBlockTimelineProvider } from '@addon/block/timeline/providers/timeline';
import { CoreCoursesProvider } from '../../providers/courses';
import { CoreCoursesDashboardProvider } from '../../providers/dashboard';
/**
* Page that displays the dashboard.
@ -35,25 +36,26 @@ import { AddonBlockTimelineProvider } from '@addon/block/timeline/providers/time
export class CoreCoursesDashboardPage implements OnDestroy {
@ViewChild(CoreTabsComponent) tabsComponent: CoreTabsComponent;
@ViewChild(CoreSiteHomeIndexComponent) siteHomeComponent: CoreSiteHomeIndexComponent;
@ViewChild(AddonBlockMyOverviewComponent) blockMyOverview: AddonBlockMyOverviewComponent;
@ViewChild(AddonBlockTimelineComponent) blockTimeline: AddonBlockTimelineComponent;
@ViewChildren(CoreBlockComponent) blocksComponents: QueryList<CoreBlockComponent>;
firstSelectedTab: number;
siteHomeEnabled = false;
timelineEnabled = false;
coursesEnabled = false;
tabsReady = false;
searchEnabled: boolean;
tabs = [];
siteName: string;
blocks: any[];
dashboardEnabled = false;
userId: number;
dashboardLoaded = false;
protected isDestroyed;
protected updateSiteObserver;
protected courseIds = '';
constructor(private navCtrl: NavController, private coursesProvider: CoreCoursesProvider,
private sitesProvider: CoreSitesProvider, private siteHomeProvider: CoreSiteHomeProvider,
private eventsProvider: CoreEventsProvider, private timelineProvider: AddonBlockTimelineProvider) {
private eventsProvider: CoreEventsProvider, private dashboardProvider: CoreCoursesDashboardProvider,
private domUtils: CoreDomUtilsProvider, private blockDelegate: CoreBlockDelegate) {
this.loadSiteName();
}
@ -71,25 +73,21 @@ export class CoreCoursesDashboardPage implements OnDestroy {
const promises = [];
// Decide which tab to load first.
promises.push(this.siteHomeProvider.isAvailable().then((enabled) => {
this.siteHomeEnabled = enabled;
}));
promises.push(this.timelineProvider.isAvailable().then((enabled) => {
this.timelineEnabled = enabled;
}));
this.coursesEnabled = !this.coursesProvider.isMyCoursesDisabledInSite();
promises.push(this.loadDashboardContent());
// Decide which tab to load first.
Promise.all(promises).finally(() => {
if (this.siteHomeEnabled && (this.coursesEnabled || this.timelineEnabled)) {
if (this.siteHomeEnabled && this.dashboardEnabled) {
const site = this.sitesProvider.getCurrentSite(),
displaySiteHome = site.getInfo() && site.getInfo().userhomepage === 0;
this.firstSelectedTab = displaySiteHome ? 0 : 1;
} else {
this.firstSelectedTab = this.siteHomeEnabled ? 1 : 0;
this.firstSelectedTab = 0;
}
this.tabsReady = true;
@ -124,6 +122,72 @@ export class CoreCoursesDashboardPage implements OnDestroy {
this.siteName = this.sitesProvider.getCurrentSite().getInfo().sitename;
}
/**
* Convenience function to fetch the dashboard data.
*
* @return {Promise<any>} Promise resolved when done.
*/
protected loadDashboardContent(): Promise<any> {
return this.dashboardProvider.isAvailable().then((enabled) => {
if (enabled) {
this.userId = this.sitesProvider.getCurrentSiteUserId();
return this.dashboardProvider.getDashboardBlocks().then((blocks) => {
this.blocks = blocks;
}).catch((error) => {
this.domUtils.showErrorModal(error);
// Cannot get the blocks, just show dashboard if needed.
this.loadFallbackBlocks();
});
}
// Not enabled, check separated tabs.
this.loadFallbackBlocks();
}).finally(() => {
this.dashboardEnabled = this.blockDelegate.hasSupportedBlock(this.blocks);
this.dashboardLoaded = true;
});
}
/**
* Refresh the dashboard data.
*
* @param {any} refresher Refresher.
*/
refreshDashboard(refresher: any): void {
const promises = [];
promises.push(this.dashboardProvider.invalidateDashboardBlocks());
// Invalidate the blocks.
this.blocksComponents.forEach((blockComponent) => {
promises.push(blockComponent.invalidate().catch(() => {
// Ignore errors.
}));
});
Promise.all(promises).finally(() => {
this.loadDashboardContent().finally(() => {
refresher.complete();
});
});
}
/**
* Load fallback blocks to shown before 3.6 when dashboard blocks are not supported.
*/
protected loadFallbackBlocks(): void {
this.blocks = [
{
name: 'myoverview'
},
{
name: 'timeline'
}
];
}
/**
* Component being destroyed.
*/

View File

@ -13,8 +13,7 @@
// limitations under the License.
import { Injectable } from '@angular/core';
import { CoreCoursesProvider } from './courses';
import { AddonBlockTimelineProvider } from '@addon/block/timeline/providers/timeline';
import { CoreSitesProvider } from '@providers/sites';
/**
* Service that provides some features regarding course overview.
@ -22,30 +21,69 @@ import { AddonBlockTimelineProvider } from '@addon/block/timeline/providers/time
@Injectable()
export class CoreCoursesDashboardProvider {
constructor(private coursesProvider: CoreCoursesProvider, private timelineProvider: AddonBlockTimelineProvider) { }
constructor(private sitesProvider: CoreSitesProvider) { }
protected ROOT_CACHE_KEY = 'CoreCoursesDashboard:';
/**
* Returns whether or not My Overview is available for a certain site.
* Get cache key for dashboard blocks WS calls.
*
* @param {number} [userId] User ID. Default, 0 means current user.
* @return {string} Cache key.
*/
protected getDashboardBlocksCacheKey(userId: number = 0): string {
return this.ROOT_CACHE_KEY + 'blocks:' + userId;
}
/**
* Get dashboard blocks.
*
* @param {number} [userId] User ID. Default, current user.
* @param {string} [siteId] Site ID. If not defined, current site.
* @return {Promise<any[]>} Promise resolved with the list of blocks.
* @since 3.6
*/
getDashboardBlocks(userId?: number, siteId?: string): Promise<any[]> {
return this.sitesProvider.getSite(siteId).then((site) => {
const params = {
},
preSets = {
cacheKey: this.getDashboardBlocksCacheKey(userId)
};
if (userId) {
params['userid'] = userId;
}
return site.read('core_block_get_dashboard_blocks', params, preSets).then((result) => {
return result.blocks || [];
});
});
}
/**
* Invalidates dashboard blocks WS call.
*
* @param {number} [userId] User ID. Default, current user.
* @param {string} [siteId] Site ID. If not defined, current site.
* @return {Promise<any>} Promise resolved when the data is invalidated.
*/
invalidateDashboardBlocks(userId?: number, siteId?: string): Promise<any> {
return this.sitesProvider.getSite(siteId).then((site) => {
return site.invalidateWsCacheForKey(this.getDashboardBlocksCacheKey(userId));
});
}
/**
* Returns whether or not block based Dashboard is available for a certain site.
*
* @param {string} [siteId] Site ID. If not defined, current site.
* @return {Promise<boolean>} Promise resolved with true if available, resolved with false or rejected otherwise.
* @since 3.6
*/
isAvailable(siteId?: string): Promise<boolean> {
return this.timelineProvider.isAvailable(siteId);
}
/**
* Check if My Overview is available and not disabled.
*
* @return {Promise<boolean>} Promise resolved with true if enabled, resolved with false otherwise.
*/
isEnabled(): Promise<boolean> {
if (!this.coursesProvider.isMyCoursesDisabledInSite()) {
return this.isAvailable().catch(() => {
return false;
});
}
return Promise.resolve(false);
return this.sitesProvider.getSite(siteId).then((site) => {
return site.wsAvailable('core_block_get_dashboard_blocks');
});
}
}

View File

@ -17,6 +17,7 @@ import { CoreCoursesProvider } from './courses';
import { CoreMainMenuHandler, CoreMainMenuHandlerData } from '@core/mainmenu/providers/delegate';
import { CoreCoursesDashboardProvider } from '../providers/dashboard';
import { CoreSiteHomeProvider } from '@core/sitehome/providers/sitehome';
import { AddonBlockTimelineProvider } from '@addon/block/timeline/providers/timeline';
/**
* Handler to add Dashboard into main menu.
@ -27,7 +28,7 @@ export class CoreDashboardMainMenuHandler implements CoreMainMenuHandler {
priority = 1100;
constructor(private coursesProvider: CoreCoursesProvider, private dashboardProvider: CoreCoursesDashboardProvider,
private siteHomeProvider: CoreSiteHomeProvider) { }
private siteHomeProvider: CoreSiteHomeProvider, private timelineProvider: AddonBlockTimelineProvider) { }
/**
* Check if the handler is enabled on a site level.
@ -35,20 +36,27 @@ export class CoreDashboardMainMenuHandler implements CoreMainMenuHandler {
* @return {boolean | Promise<boolean>} Whether or not the handler is enabled on a site level.
*/
isEnabled(): boolean | Promise<boolean> {
// Check if my overview is enabled.
return this.dashboardProvider.isEnabled().then((enabled) => {
// Check if 3.6 dashboard is enabled.
return this.dashboardProvider.isAvailable().then((enabled) => {
if (enabled) {
return true;
}
return this.siteHomeProvider.isAvailable().then((enabled) => {
// Show in case siteHome is enabled.
// Check if my overview is enabled.
return this.timelineProvider.isAvailable().then((enabled) => {
if (enabled) {
return true;
}
// My overview not enabled, check if my courses is enabled.
return !this.coursesProvider.isMyCoursesDisabledInSite();
return this.siteHomeProvider.isAvailable().then((enabled) => {
// Show in case siteHome is enabled.
if (enabled) {
return true;
}
// My overview not enabled, check if my courses is enabled.
return !this.coursesProvider.isMyCoursesDisabledInSite();
});
});
});
}

View File

@ -8,7 +8,7 @@
<ion-refresher-content pullingText="{{ 'core.pulltorefresh' | translate }}"></ion-refresher-content>
</ion-refresher>
<core-loading [hideUntil]="usageLoaded">
<ion-item *ngFor="let site of sites" [class.core-primary-item]="site.id == currentSiteId">
<ion-item *ngFor="let site of sites" [class.core-primary-selected-item]="site.id == currentSiteId">
<h2><core-format-text [text]="site.siteName"></core-format-text></h2>
<p>{{ site.fullName }}</p>
<p item-end>{{ site.spaceUsage | coreBytesToSize }}</p>

View File

@ -16,7 +16,7 @@
<ion-item-divider color="light">
<p>{{ 'core.settings.sites' | translate }}</p>
</ion-item-divider>
<ion-item *ngFor="let site of sites" [class.core-primary-item]="site.id == currentSiteId" text-wrap>
<ion-item *ngFor="let site of sites" [class.core-primary-selected-item]="site.id == currentSiteId" text-wrap>
<h2><core-format-text [text]="site.siteName"></core-format-text></h2>
<p>{{ site.fullName }}</p>
<p>{{ site.siteUrl }}</p>