MOBILE-2679 myoverview: Add hidden and starred options

main
Pau Ferrer Ocaña 2018-10-30 11:29:35 +01:00
parent 01eaffa3de
commit c04330aa69
8 changed files with 75 additions and 27 deletions

View File

@ -12,13 +12,13 @@
"addon.badges.recipientdetails": "badges",
"addon.block_activitymodules.pluginname": "block_activity_modules",
"addon.block_myoverview.all": "block_myoverview",
"addon.block_myoverview.favourites": "block_myoverview",
"addon.block_myoverview.future": "block_myoverview",
"addon.block_myoverview.hiddencourses": "block_myoverview",
"addon.block_myoverview.inprogress": "block_myoverview",
"addon.block_myoverview.lastaccessed": "block_myoverview",
"addon.block_myoverview.morecourses": "block_myoverview",
"addon.block_myoverview.nocoursesfuture": "block_myoverview",
"addon.block_myoverview.nocoursesinprogress": "block_myoverview",
"addon.block_myoverview.nocoursespast": "block_myoverview",
"addon.block_myoverview.nocourses": "block_myoverview",
"addon.block_myoverview.past": "block_myoverview",
"addon.block_myoverview.pluginname": "block_myoverview",
"addon.block_myoverview.title": "block_myoverview",

View File

@ -17,6 +17,8 @@
<ion-option value="inprogress">{{ 'addon.block_myoverview.inprogress' | translate }}</ion-option>
<ion-option value="future">{{ 'addon.block_myoverview.future' | translate }}</ion-option>
<ion-option value="past">{{ 'addon.block_myoverview.past' | translate }}</ion-option>
<ion-option value="favourite" *ngIf="showFavourite">{{ 'addon.block_myoverview.favourites' | translate }}</ion-option>
<ion-option value="hidden" *ngIf="showHidden">{{ 'addon.block_myoverview.hiddencourses' | translate }}</ion-option>
</ion-select>
</ion-col>
<!-- "Sort" selector. -->
@ -35,11 +37,7 @@
<ion-spinner *ngIf="!prefetchCoursesData[selectedFilter].icon || prefetchCoursesData[selectedFilter].icon == 'spinner'"></ion-spinner>
</ion-col>
</div>
<ng-container *ngIf="courses[selectedFilter].length == 0">
<core-empty-box *ngIf="selectedFilter == 'inprogress'" image="assets/img/icons/courses.svg" [message]="'addon.block_myoverview.nocoursesinprogress' | translate"></core-empty-box>
<core-empty-box *ngIf="selectedFilter == 'future'" image="assets/img/icons/courses.svg" [message]="'addon.block_myoverview.nocoursesfuture' | translate"></core-empty-box>
<core-empty-box *ngIf="selectedFilter == 'past'" image="assets/img/icons/courses.svg" [message]="'addon.block_myoverview.nocoursespast' | translate"></core-empty-box>
</ng-container>
<core-empty-box *ngIf="courses[selectedFilter].length == 0" image="assets/img/icons/courses.svg" [message]="'addon.block_myoverview.nocourses' | translate"></core-empty-box>
<!-- Filter courses. -->
<ion-searchbar #searchbar *ngIf="showFilter" [(ngModel)]="courses.filter" (ionInput)="filterChanged($event)" (ionCancel)="filterChanged()" [placeholder]="'core.courses.filtermycourses' | translate">

View File

@ -40,7 +40,9 @@ export class AddonBlockMyOverviewComponent extends CoreBlockBaseComponent implem
all: [],
past: [],
inprogress: [],
future: []
future: [],
favourite: [],
hidden: []
};
selectedFilter = 'inprogress';
sort = 'title';
@ -51,9 +53,13 @@ export class AddonBlockMyOverviewComponent extends CoreBlockBaseComponent implem
all: {},
inprogress: {},
past: {},
future: {}
future: {},
favourite: {},
hidden: {}
};
showFilter = false;
showFavourite = false;
showHidden = false;
showSelectorFilter = false;
showSortFilter = false;
@ -162,8 +168,10 @@ export class AddonBlockMyOverviewComponent extends CoreBlockBaseComponent implem
this.courses.filter = '';
this.showFilter = false;
this.showSelectorFilter = this.courses.past.length > 0 || this.courses.future.length > 0 || (courses.length > 0 &&
this.showSelectorFilter = courses.length > 0 && (this.courses.past.length > 0 || this.courses.future.length > 0 ||
typeof courses[0].enddate != 'undefined');
this.showHidden = this.showSelectorFilter && typeof courses[0].hidden != 'undefined';
this.showFavourite = this.showSelectorFilter && typeof courses[0].isfavourite != 'undefined';
if (!this.showSelectorFilter) {
// No selector, show all.
this.selectedFilter = 'all';
@ -276,22 +284,34 @@ export class AddonBlockMyOverviewComponent extends CoreBlockBaseComponent implem
}
}
this.courses.all = courses;
this.courses.all = [];
this.courses.past = [];
this.courses.inprogress = [];
this.courses.future = [];
this.courses.favourite = [];
this.courses.hidden = [];
const today = moment().unix();
courses.forEach((course) => {
if ((course.enddate && course.enddate < today) || course.completed) {
// Courses that have already ended.
this.courses.past.push(course);
} else if (course.startdate > today) {
// Courses that have not started yet.
this.courses.future.push(course);
} else {
// Courses still in progress.
this.courses.inprogress.push(course);
if (course.hidden) {
this.courses.hidden.push(course);
} else {
this.courses.all.push(course);
if ((course.enddate && course.enddate < today) || course.completed) {
// Courses that have already ended.
this.courses.past.push(course);
} else if (course.startdate > today) {
// Courses that have not started yet.
this.courses.future.push(course);
} else {
// Courses still in progress.
this.courses.inprogress.push(course);
}
if (course.isfavourite) {
this.courses.favourite.push(course);
}
}
});
}

View File

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

View File

@ -12,13 +12,13 @@
"addon.badges.recipientdetails": "Recipient details",
"addon.block_activitymodules.pluginname": "Activities",
"addon.block_myoverview.all": "All",
"addon.block_myoverview.favourites": "Starred",
"addon.block_myoverview.future": "Future",
"addon.block_myoverview.hiddencourses": "Hidden",
"addon.block_myoverview.inprogress": "In progress",
"addon.block_myoverview.lastaccessed": "Last accessed",
"addon.block_myoverview.morecourses": "More courses",
"addon.block_myoverview.nocoursesfuture": "No future courses",
"addon.block_myoverview.nocoursesinprogress": "No in progress courses",
"addon.block_myoverview.nocoursespast": "No past courses",
"addon.block_myoverview.nocourses": "No courses",
"addon.block_myoverview.past": "Past",
"addon.block_myoverview.pluginname": "Course Overview",
"addon.block_myoverview.title": "Title",

View File

@ -0,0 +1,19 @@
ion-app.app-root core-block {
position: relative;
core-loading.core-loading-center {
display: block;
.core-loading-container {
margin-top: 10px;
position: relative;
}
}
core-empty-box .core-empty-box {
position: relative;
z-index: initial;
@include position(initial, initial, null, initial);
height: auto;
}
}

View File

@ -1,6 +1,7 @@
<ion-card [attr.course-color]="course.id % 10">
<div (click)="openCourse(course)" class="core-course-thumb" [class.core-course-color-img]="course.imageThumb">
<img *ngIf="course.imageThumb" [src]="course.imageThumb" core-external-content alt=""/>
<core-icon name="fa-star" *ngIf="course.isfavourite"></core-icon>
</div>
<ion-item tappable text-wrap detail-none (click)="openCourse(course)" [title]="course.displayname || course.fullname" class="core-course-link" [class.item-disabled]="course.visible == 0">
<h2><core-format-text [text]="course.displayname || course.fullname"></core-format-text></h2>

View File

@ -29,6 +29,16 @@ ion-app.app-root core-courses-course-progress {
bottom: 0;
margin: auto;
}
ion-icon {
position: absolute;
@include position(0, null, null, 0);
padding: 16px;
color: $gray-darker;
-webkit-text-stroke-width: 0.5px;
-webkit-text-stroke-color: $gray-lighter;
font-size: 16px;
}
}
.core-course-link {