Merge pull request #2853 from dpalou/MOBILE-3320

Mobile 3320
main
Pau Ferrer Ocaña 2021-06-29 12:00:10 +02:00 committed by GitHub
commit ef9a9db0c4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 20 additions and 17 deletions

View File

@ -9,7 +9,7 @@
<ion-radio-group [(ngModel)]="courseId" (ionChange)="onChange()"> <ion-radio-group [(ngModel)]="courseId" (ionChange)="onChange()">
<ion-item class="ion-text-wrap" *ngFor="let course of courses"> <ion-item class="ion-text-wrap" *ngFor="let course of courses">
<ion-label><core-format-text [text]="course.fullname"></core-format-text></ion-label> <ion-label><core-format-text [text]="course.fullname"></core-format-text></ion-label>
<ion-radio slot="end" value="{{course.id}}"></ion-radio> <ion-radio slot="end" [value]="course.id"></ion-radio>
</ion-item> </ion-item>
</ion-radio-group> </ion-radio-group>
</ng-container> </ng-container>

View File

@ -31,7 +31,7 @@ export class AddonCalendarFilterPopoverComponent implements OnInit {
@Input() filter: AddonCalendarFilter = { @Input() filter: AddonCalendarFilter = {
filtered: false, filtered: false,
courseId: -1, courseId: undefined,
categoryId: undefined, categoryId: undefined,
course: true, course: true,
group: true, group: true,
@ -40,7 +40,7 @@ export class AddonCalendarFilterPopoverComponent implements OnInit {
category: true, category: true,
}; };
courseId = '-1'; courseId = -1;
@Input() courses: Partial<CoreEnrolledCourseData>[] = []; @Input() courses: Partial<CoreEnrolledCourseData>[] = [];
typeIcons: AddonCalendarEventIcons[] = []; typeIcons: AddonCalendarEventIcons[] = [];
@ -59,24 +59,23 @@ export class AddonCalendarFilterPopoverComponent implements OnInit {
* Init the component. * Init the component.
*/ */
ngOnInit(): void { ngOnInit(): void {
this.courseId = (this.filter.courseId || -1) + ''; this.courseId = this.filter.courseId || -1;
} }
/** /**
* Function called when an item is clicked. * Function called when an item is clicked.
*/ */
onChange(): void { onChange(): void {
const courseId = parseInt(this.courseId, 10); if (this.courseId > 0) {
if (courseId > 0) { const course = this.courses.find((course) => this.courseId == course.id);
const course = this.courses.find((course) => courseId == course.id); this.filter.courseId = course?.id;
this.filter.courseId = course?.id || -1;
this.filter.categoryId = course?.categoryid; this.filter.categoryId = course?.categoryid;
} else { } else {
this.filter.courseId = -1; this.filter.courseId = undefined;
this.filter.categoryId = undefined; this.filter.categoryId = undefined;
} }
this.filter.filtered = this.filter.courseId > 0 || this.types.some((name) => !this.filter[name]); this.filter.filtered = !!this.filter.courseId || this.types.some((name) => !this.filter[name]);
CoreEvents.trigger(AddonCalendarProvider.FILTER_CHANGED_EVENT, this.filter); CoreEvents.trigger(AddonCalendarProvider.FILTER_CHANGED_EVENT, this.filter);
} }

View File

@ -89,7 +89,7 @@ export class AddonCalendarListPage implements OnInit, OnDestroy {
syncIcon = CoreConstants.ICON_LOADING; syncIcon = CoreConstants.ICON_LOADING;
filter: AddonCalendarFilter = { filter: AddonCalendarFilter = {
filtered: false, filtered: false,
courseId: -1, courseId: undefined,
categoryId: undefined, categoryId: undefined,
course: true, course: true,
group: true, group: true,
@ -212,7 +212,7 @@ export class AddonCalendarListPage implements OnInit, OnDestroy {
* View loaded. * View loaded.
*/ */
async ngOnInit(): Promise<void> { async ngOnInit(): Promise<void> {
this.filter.courseId = CoreNavigator.getRouteNumberParam('courseId') || -1; this.filter.courseId = CoreNavigator.getRouteNumberParam('courseId');
this.syncIcon = CoreConstants.ICON_LOADING; this.syncIcon = CoreConstants.ICON_LOADING;
await this.fetchData(false, true, false); await this.fetchData(false, true, false);

View File

@ -36,6 +36,10 @@ export class AddonModDataFieldDateComponent extends AddonModDataFieldPluginCompo
*/ */
protected init(): void { protected init(): void {
if (this.displayMode) { if (this.displayMode) {
this.displayDate = this.value?.content
? parseInt(this.value.content, 10) * 1000
: undefined;
return; return;
} }
@ -62,10 +66,6 @@ export class AddonModDataFieldDateComponent extends AddonModDataFieldPluginCompo
? new Date(parseInt(this.value.content, 10) * 1000) ? new Date(parseInt(this.value.content, 10) * 1000)
: new Date(); : new Date();
this.displayDate = this.value?.content
? parseInt(this.value.content, 10) * 1000
: undefined;
} }
this.addControl('f_' + this.field.id, CoreTimeUtils.toDatetimeFormat(date.getTime())); this.addControl('f_' + this.field.id, CoreTimeUtils.toDatetimeFormat(date.getTime()));

View File

@ -407,7 +407,11 @@ export class CoreDomUtilsProvider {
return size; return size;
} }
size = Number(size); if (typeof size == 'string') {
// It's important to use parseInt instead of Number because Number('') is 0 instead of NaN.
size = parseInt(size, 10);
}
if (!isNaN(size)) { if (!isNaN(size)) {
return size + 'px'; return size + 'px';
} }