MOBILE-2790 dashboard: Add download toggle to block input
parent
c67ac67270
commit
5407657f13
|
@ -1,7 +1,7 @@
|
|||
<ion-item-divider color="light">
|
||||
<h2>{{ 'addon.block_myoverview.pluginname' | translate }}</h2>
|
||||
<!-- Download all courses. -->
|
||||
<div *ngIf="downloadAllCoursesEnabled && courses[selectedFilter] && courses[selectedFilter].length > 1 && !showFilter" class="core-button-spinner" item-end>
|
||||
<div *ngIf="downloadEnabled && courses[selectedFilter] && courses[selectedFilter].length > 1 && !showFilter" class="core-button-spinner" item-end>
|
||||
<button *ngIf="prefetchCoursesData[selectedFilter].icon && prefetchCoursesData[selectedFilter].icon != 'spinner'" ion-button icon-only clear color="dark" (click)="prefetchCourses()">
|
||||
<core-icon [name]="prefetchCoursesData[selectedFilter].icon"></core-icon>
|
||||
</button>
|
||||
|
@ -36,7 +36,7 @@
|
|||
<ion-grid no-padding>
|
||||
<ion-row no-padding>
|
||||
<ion-col *ngFor="let course of filteredCourses" no-padding col-12 col-sm-6 col-md-6 col-lg-4 col-xl-4 align-self-stretch>
|
||||
<core-courses-course-progress [course]="course" class="core-courseoverview" showAll="true" [showDownload]="downloadAllCoursesEnabled"></core-courses-course-progress>
|
||||
<core-courses-course-progress [course]="course" class="core-courseoverview" showAll="true" [showDownload]="downloadEnabled"></core-courses-course-progress>
|
||||
</ion-col>
|
||||
</ion-row>
|
||||
</ion-grid>
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
import { Component, OnInit, OnDestroy, ViewChild, Injector } from '@angular/core';
|
||||
import { Component, OnInit, Input, OnDestroy, ViewChild, Injector } from '@angular/core';
|
||||
import { Searchbar } from 'ionic-angular';
|
||||
import { CoreEventsProvider } from '@providers/events';
|
||||
import { CoreUtilsProvider } from '@providers/utils/utils';
|
||||
|
@ -34,6 +34,7 @@ import { CoreBlockBaseComponent } from '@core/block/classes/base-block-component
|
|||
})
|
||||
export class AddonBlockMyOverviewComponent extends CoreBlockBaseComponent implements OnInit, OnDestroy {
|
||||
@ViewChild('searchbar') searchbar: Searchbar;
|
||||
@Input() downloadEnabled: boolean;
|
||||
|
||||
courses = {
|
||||
filter: '',
|
||||
|
@ -47,7 +48,6 @@ export class AddonBlockMyOverviewComponent extends CoreBlockBaseComponent implem
|
|||
selectedFilter = 'inprogress';
|
||||
sort = 'fullname';
|
||||
currentSite: any;
|
||||
downloadAllCoursesEnabled: boolean;
|
||||
filteredCourses: any[];
|
||||
prefetchCoursesData = {
|
||||
all: {},
|
||||
|
@ -86,11 +86,11 @@ export class AddonBlockMyOverviewComponent extends CoreBlockBaseComponent implem
|
|||
// Refresh the enabled flags if enabled.
|
||||
this.downloadButtonObserver = this.eventsProvider.on(CoreCoursesProvider.EVENT_DASHBOARD_DOWNLOAD_ENABLED_CHANGED,
|
||||
(data) => {
|
||||
const wasEnabled = this.downloadAllCoursesEnabled;
|
||||
const wasEnabled = this.downloadEnabled;
|
||||
|
||||
this.downloadAllCoursesEnabled = data.enabled;
|
||||
this.downloadEnabled = data.enabled;
|
||||
|
||||
if (!wasEnabled && this.downloadAllCoursesEnabled && this.loaded) {
|
||||
if (!wasEnabled && this.downloadEnabled && this.loaded) {
|
||||
// Download all courses is enabled now, initialize it.
|
||||
this.initPrefetchCoursesIcons();
|
||||
}
|
||||
|
@ -198,7 +198,7 @@ export class AddonBlockMyOverviewComponent extends CoreBlockBaseComponent implem
|
|||
* Initialize the prefetch icon for selected courses.
|
||||
*/
|
||||
protected initPrefetchCoursesIcons(): void {
|
||||
if (this.prefetchIconsInitialized || !this.downloadAllCoursesEnabled) {
|
||||
if (this.prefetchIconsInitialized || !this.downloadEnabled) {
|
||||
// Already initialized.
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<ion-item-divider color="light">
|
||||
<h2>{{ 'addon.block_recentlyaccessedcourses.pluginname' | translate }}</h2>
|
||||
<div *ngIf="downloadAllCoursesEnabled && courses && courses.length > 1" class="core-button-spinner" item-end>
|
||||
<div *ngIf="downloadEnabled && courses && courses.length > 1" class="core-button-spinner" item-end>
|
||||
<button *ngIf="prefetchCoursesData.icon && prefetchCoursesData.icon != 'spinner'" ion-button icon-only clear color="dark" (click)="prefetchCourses()">
|
||||
<core-icon [name]="prefetchCoursesData.icon"></core-icon>
|
||||
</button>
|
||||
|
@ -14,7 +14,7 @@
|
|||
<div class="safe-area-page">
|
||||
<div class="core-horizontal-scroll">
|
||||
<ng-container *ngFor="let course of courses">
|
||||
<core-courses-course-progress [course]="course" class="core-recentlyaccessedcourses" [showDownload]="downloadAllCoursesEnabled"></core-courses-course-progress>
|
||||
<core-courses-course-progress [course]="course" class="core-recentlyaccessedcourses" [showDownload]="downloadEnabled"></core-courses-course-progress>
|
||||
</ng-container>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
import { Component, OnInit, OnDestroy, Injector } from '@angular/core';
|
||||
import { Component, OnInit, OnDestroy, Injector, Input } from '@angular/core';
|
||||
import { CoreEventsProvider } from '@providers/events';
|
||||
import { CoreUtilsProvider } from '@providers/utils/utils';
|
||||
import { CoreSitesProvider } from '@providers/sites';
|
||||
|
@ -31,12 +31,13 @@ import { CoreBlockBaseComponent } from '@core/block/classes/base-block-component
|
|||
templateUrl: 'addon-block-recentlyaccessedcourses.html'
|
||||
})
|
||||
export class AddonBlockRecentlyAccessedCoursesComponent extends CoreBlockBaseComponent implements OnInit, OnDestroy {
|
||||
@Input() downloadEnabled: boolean;
|
||||
|
||||
courses = [];
|
||||
prefetchCoursesData = {
|
||||
icon: '',
|
||||
badge: ''
|
||||
};
|
||||
downloadAllCoursesEnabled: boolean;
|
||||
|
||||
protected prefetchIconsInitialized = false;
|
||||
protected isDestroyed;
|
||||
|
@ -61,11 +62,11 @@ export class AddonBlockRecentlyAccessedCoursesComponent extends CoreBlockBaseCom
|
|||
// Refresh the enabled flags if enabled.
|
||||
this.downloadButtonObserver = this.eventsProvider.on(CoreCoursesProvider.EVENT_DASHBOARD_DOWNLOAD_ENABLED_CHANGED,
|
||||
(data) => {
|
||||
const wasEnabled = this.downloadAllCoursesEnabled;
|
||||
const wasEnabled = this.downloadEnabled;
|
||||
|
||||
this.downloadAllCoursesEnabled = data.enabled;
|
||||
this.downloadEnabled = data.enabled;
|
||||
|
||||
if (!wasEnabled && this.downloadAllCoursesEnabled && this.loaded) {
|
||||
if (!wasEnabled && this.downloadEnabled && this.loaded) {
|
||||
// Download all courses is enabled now, initialize it.
|
||||
this.initPrefetchCoursesIcons();
|
||||
}
|
||||
|
@ -120,7 +121,7 @@ export class AddonBlockRecentlyAccessedCoursesComponent extends CoreBlockBaseCom
|
|||
* Initialize the prefetch icon for selected courses.
|
||||
*/
|
||||
protected initPrefetchCoursesIcons(): void {
|
||||
if (this.prefetchIconsInitialized || !this.downloadAllCoursesEnabled) {
|
||||
if (this.prefetchIconsInitialized || !this.downloadEnabled) {
|
||||
// Already initialized.
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<ion-item-divider color="light">
|
||||
<h2>{{ 'addon.block_starredcourses.pluginname' | translate }}</h2>
|
||||
<div *ngIf="downloadAllCoursesEnabled && courses && courses.length > 1" class="core-button-spinner" item-end>
|
||||
<div *ngIf="downloadEnabled && courses && courses.length > 1" class="core-button-spinner" item-end>
|
||||
<button *ngIf="prefetchCoursesData.icon && prefetchCoursesData.icon != 'spinner'" ion-button icon-only clear color="dark" (click)="prefetchCourses()">
|
||||
<core-icon [name]="prefetchCoursesData.icon"></core-icon>
|
||||
</button>
|
||||
|
@ -14,7 +14,7 @@
|
|||
<div class="safe-area-page">
|
||||
<div class="core-horizontal-scroll">
|
||||
<ng-container *ngFor="let course of courses">
|
||||
<core-courses-course-progress [course]="course" class="core-block_starredcourses" [showDownload]="downloadAllCoursesEnabled"></core-courses-course-progress>
|
||||
<core-courses-course-progress [course]="course" class="core-block_starredcourses" [showDownload]="downloadEnabled"></core-courses-course-progress>
|
||||
</ng-container>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
import { Component, OnInit, OnDestroy, Injector } from '@angular/core';
|
||||
import { Component, OnInit, OnDestroy, Injector, Input } from '@angular/core';
|
||||
import { CoreEventsProvider } from '@providers/events';
|
||||
import { CoreUtilsProvider } from '@providers/utils/utils';
|
||||
import { CoreSitesProvider } from '@providers/sites';
|
||||
|
@ -31,12 +31,13 @@ import { CoreBlockBaseComponent } from '@core/block/classes/base-block-component
|
|||
templateUrl: 'addon-block-starredcourses.html'
|
||||
})
|
||||
export class AddonBlockStarredCoursesComponent extends CoreBlockBaseComponent implements OnInit, OnDestroy {
|
||||
@Input() downloadEnabled: boolean;
|
||||
|
||||
courses = [];
|
||||
prefetchCoursesData = {
|
||||
icon: '',
|
||||
badge: ''
|
||||
};
|
||||
downloadAllCoursesEnabled: boolean;
|
||||
|
||||
protected prefetchIconsInitialized = false;
|
||||
protected isDestroyed;
|
||||
|
@ -61,11 +62,11 @@ export class AddonBlockStarredCoursesComponent extends CoreBlockBaseComponent im
|
|||
// Refresh the enabled flags if enabled.
|
||||
this.downloadButtonObserver = this.eventsProvider.on(CoreCoursesProvider.EVENT_DASHBOARD_DOWNLOAD_ENABLED_CHANGED,
|
||||
(data) => {
|
||||
const wasEnabled = this.downloadAllCoursesEnabled;
|
||||
const wasEnabled = this.downloadEnabled;
|
||||
|
||||
this.downloadAllCoursesEnabled = data.enabled;
|
||||
this.downloadEnabled = data.enabled;
|
||||
|
||||
if (!wasEnabled && this.downloadAllCoursesEnabled && this.loaded) {
|
||||
if (!wasEnabled && this.downloadEnabled && this.loaded) {
|
||||
// Download all courses is enabled now, initialize it.
|
||||
this.initPrefetchCoursesIcons();
|
||||
}
|
||||
|
@ -120,7 +121,7 @@ export class AddonBlockStarredCoursesComponent extends CoreBlockBaseComponent im
|
|||
* Initialize the prefetch icon for selected courses.
|
||||
*/
|
||||
protected initPrefetchCoursesIcons(): void {
|
||||
if (this.prefetchIconsInitialized || !this.downloadAllCoursesEnabled) {
|
||||
if (this.prefetchIconsInitialized || !this.downloadEnabled) {
|
||||
// Already initialized.
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
<ion-list>
|
||||
<!-- Dashboard blocks. -->
|
||||
<ng-container *ngFor="let block of blocks">
|
||||
<core-block [block]="block" contextLevel="user" [instanceId]="userId"></core-block>
|
||||
<core-block [block]="block" contextLevel="user" [instanceId]="userId" [extraData]="{'downloadEnabled': downloadEnabled}"></core-block>
|
||||
</ng-container>
|
||||
</ion-list>
|
||||
|
||||
|
|
Loading…
Reference in New Issue