diff --git a/src/addon/calendar/pages/event/event.html b/src/addon/calendar/pages/event/event.html index c8de82b17..f863e1243 100644 --- a/src/addon/calendar/pages/event/event.html +++ b/src/addon/calendar/pages/event/event.html @@ -52,19 +52,19 @@ - + {{ 'addon.calendar.notifications' | translate }} - {{ 'core.defaultvalue' | translate :{$a: defaultTimeReadable} }} + {{ 'core.defaultvalue' | translate :{$a: defaultTimeReadable} }} {{ 'core.settings.disabled' | translate }} {{ 600 | coreDuration }} - {{ 1800 | coreDuration }} - {{ 3600 | coreDuration }} - {{ 7200 | coreDuration }} - {{ 21600 | coreDuration }} - {{ 43200 | coreDuration }} - {{ 86400 | coreDuration }} + {{ 1800 | coreDuration }} + {{ 3600 | coreDuration }} + {{ 7200 | coreDuration }} + {{ 21600 | coreDuration }} + {{ 43200 | coreDuration }} + {{ 86400 | coreDuration }} diff --git a/src/addon/calendar/pages/event/event.ts b/src/addon/calendar/pages/event/event.ts index f8e3dec31..e20a61877 100644 --- a/src/addon/calendar/pages/event/event.ts +++ b/src/addon/calendar/pages/event/event.ts @@ -48,12 +48,14 @@ export class AddonCalendarEventPage { notificationsEnabled = false; moduleUrl = ''; categoryPath = ''; + currentTime: number; + defaultTime: number; constructor(private translate: TranslateService, private calendarProvider: AddonCalendarProvider, navParams: NavParams, - private domUtils: CoreDomUtilsProvider, private coursesProvider: CoreCoursesProvider, timeUtils: CoreTimeUtilsProvider, + private domUtils: CoreDomUtilsProvider, private coursesProvider: CoreCoursesProvider, private calendarHelper: AddonCalendarHelperProvider, private sitesProvider: CoreSitesProvider, localNotificationsProvider: CoreLocalNotificationsProvider, private courseProvider: CoreCourseProvider, - private textUtils: CoreTextUtilsProvider) { + private textUtils: CoreTextUtilsProvider, private timeUtils: CoreTimeUtilsProvider) { this.eventId = navParams.get('id'); this.notificationsEnabled = localNotificationsProvider.isAvailable(); @@ -61,9 +63,12 @@ export class AddonCalendarEventPage { if (this.notificationsEnabled) { this.calendarProvider.getEventNotificationTimeOption(this.eventId).then((notificationTime) => { this.notificationTime = notificationTime; + this.loadNotificationTime(); }); this.calendarProvider.getDefaultNotificationTime().then((defaultTime) => { + this.defaultTime = defaultTime * 60; + this.loadNotificationTime(); if (defaultTime === 0) { // Disabled by default. this.defaultTimeReadable = this.translate.instant('core.settings.disabled'); @@ -111,6 +116,9 @@ export class AddonCalendarEventPage { this.calendarHelper.formatEventData(event); this.event = event; + this.currentTime = this.timeUtils.timestamp(); + this.loadNotificationTime(); + // Reset some of the calculated data. this.categoryPath = ''; this.courseName = ''; @@ -178,6 +186,19 @@ export class AddonCalendarEventPage { }); } + /** + * Loads notification time by discarding options not in the list. + */ + loadNotificationTime(): void { + if (typeof this.notificationTime != 'undefined') { + if (this.notificationTime > 0 && this.event.timestart - this.notificationTime * 60 < this.currentTime) { + this.notificationTime = 0; + } else if (this.notificationTime < 0 && this.event.timestart - this.defaultTime < this.currentTime) { + this.notificationTime = 0; + } + } + } + /** * Refresh the event. * diff --git a/src/addon/mod/data/data.scss b/src/addon/mod/data/data.scss index 6c646f411..d18a66a08 100644 --- a/src/addon/mod/data/data.scss +++ b/src/addon/mod/data/data.scss @@ -18,10 +18,14 @@ tr { @extend .row; padding: 0; + @include media-breakpoint-down(sm) { + flex-direction: column; + } } td, th { @extend .col; + min-height: auto; } } diff --git a/src/addon/mod/data/pages/search/search.html b/src/addon/mod/data/pages/search/search.html index 35b90865d..835a8ff00 100644 --- a/src/addon/mod/data/pages/search/search.html +++ b/src/addon/mod/data/pages/search/search.html @@ -10,8 +10,8 @@
diff --git a/src/addon/mod/data/pages/search/search.ts b/src/addon/mod/data/pages/search/search.ts index 8bd04314b..e7078dfbb 100644 --- a/src/addon/mod/data/pages/search/search.ts +++ b/src/addon/mod/data/pages/search/search.ts @@ -176,9 +176,11 @@ export class AddonModDataSearchPage { /** * Toggles between advanced to normal search. + * + * @param {boolean} advanced True for advanced, false for basic. */ - toggleAdvanced(): void { - this.search.searchingAdvanced = !this.search.searchingAdvanced; + changeAdvanced(advanced: boolean): void { + this.search.searchingAdvanced = advanced; } /** diff --git a/src/addon/mod/url/components/index/index.ts b/src/addon/mod/url/components/index/index.ts index 18b495e57..d5c92ec80 100644 --- a/src/addon/mod/url/components/index/index.ts +++ b/src/addon/mod/url/components/index/index.ts @@ -57,7 +57,12 @@ export class AddonModUrlIndexComponent extends CoreCourseModuleMainResourceCompo this.canGetUrl = this.urlProvider.isGetUrlWSAvailable(); - this.loadContent(); + this.loadContent().then(() => { + if ((this.shouldIframe || (this.shouldEmbed && this.isOther)) || + (!this.shouldIframe && (!this.shouldEmbed || !this.isOther))) { + this.logView(); + } + }); } /** @@ -168,14 +173,23 @@ export class AddonModUrlIndexComponent extends CoreCourseModuleMainResourceCompo } /** - * Opens a file. + * Log view into the site and checks module completion. + * + * @return {Promise} Promise resolved when done. */ - go(): void { - this.urlProvider.logView(this.module.instance).then(() => { + protected logView(): Promise { + return this.urlProvider.logView(this.module.instance).then(() => { this.courseProvider.checkModuleCompletion(this.courseId, this.module.completiondata); }).catch(() => { // Ignore errors. }); + } + + /** + * Opens a file. + */ + go(): void { + this.logView(); this.urlHelper.open(this.url); } } diff --git a/src/app/app.scss b/src/app/app.scss index 2d719bee0..fa548765c 100644 --- a/src/app/app.scss +++ b/src/app/app.scss @@ -33,6 +33,9 @@ ion-app.app-root { .img-responsive { display: block; max-width: 100%; + &[height] { + height: auto; + } } .opacity-hide { opacity: 0; } diff --git a/src/core/course/components/format/format.ts b/src/core/course/components/format/format.ts index a47d48eee..0252248f5 100644 --- a/src/core/course/components/format/format.ts +++ b/src/core/course/components/format/format.ts @@ -297,6 +297,8 @@ export class CoreCourseFormatComponent implements OnInit, OnChanges, OnDestroy { setTimeout(() => { this.domUtils.scrollToElementBySelector(this.content, '#core-course-module-' + this.moduleId); }, 200); + } else { + this.domUtils.scrollToTop(this.content, 0); } } diff --git a/src/directives/format-text.ts b/src/directives/format-text.ts index d907053f1..08b4876e8 100644 --- a/src/directives/format-text.ts +++ b/src/directives/format-text.ts @@ -80,6 +80,7 @@ export class CoreFormatTextDirective implements OnChanges { */ ngOnChanges(changes: { [name: string]: SimpleChange }): void { if (changes.text) { + this.hideShowMore(); this.formatAndRenderContents(); } } diff --git a/src/providers/local-notifications.ts b/src/providers/local-notifications.ts index 8f6d66c60..85b5e30fc 100644 --- a/src/providers/local-notifications.ts +++ b/src/providers/local-notifications.ts @@ -298,7 +298,7 @@ export class CoreLocalNotificationsProvider { return this.appDB.getRecord(this.TRIGGERED_TABLE, { id: notification.id }).then((stored) => { return stored.at === notification.at.getTime() / 1000; }).catch(() => { - return false; + return this.localNotifications.isTriggered(notification.id); }); } @@ -478,22 +478,23 @@ export class CoreLocalNotificationsProvider { protected scheduleNotification(notification: CoreILocalNotification): Promise { // Check if the notification has been triggered already. return this.isTriggered(notification).then((triggered) => { - if (!triggered) { - // Check if sound is enabled for notifications. - return this.configProvider.get(CoreConstants.SETTINGS_NOTIFICATION_SOUND, true).then((soundEnabled) => { - if (!soundEnabled) { - notification.sound = null; - } else { - delete notification.sound; // Use default value. - } + // Cancel the current notification in case it gets scheduled twice. + return this.localNotifications.cancel(notification.id).finally(() => { + if (!triggered) { + // Check if sound is enabled for notifications. + return this.configProvider.get(CoreConstants.SETTINGS_NOTIFICATION_SOUND, true).then((soundEnabled) => { + if (!soundEnabled) { + notification.sound = null; + } else { + delete notification.sound; // Use default value. + } - // Remove from triggered, since the notification could be in there with a different time. - this.removeTriggered(notification.id); - this.localNotifications.cancel(notification.id).finally(() => { + // Remove from triggered, since the notification could be in there with a different time. + this.removeTriggered(notification.id); this.localNotifications.schedule(notification); }); - }); - } + } + }); }); }