commit
5a1bcb8380
|
@ -1,3 +1,5 @@
|
||||||
|
@import "~theme/globals";
|
||||||
|
|
||||||
:host {
|
:host {
|
||||||
.core-notification-icon {
|
.core-notification-icon {
|
||||||
width: 34px;
|
width: 34px;
|
||||||
|
@ -17,11 +19,17 @@
|
||||||
|
|
||||||
.header {
|
.header {
|
||||||
background-color: var(--gray-lighter);
|
background-color: var(--gray-lighter);
|
||||||
}
|
|
||||||
|
|
||||||
.picture {
|
.picture {
|
||||||
width: auto;
|
width: 48px;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
|
@include padding-horizontal(4px, 0px);
|
||||||
|
padding-top: 8px;
|
||||||
|
|
||||||
|
img {
|
||||||
|
width: 44px !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.subject {
|
.subject {
|
|
@ -48,7 +48,7 @@
|
||||||
<ion-item class="ion-text-wrap">
|
<ion-item class="ion-text-wrap">
|
||||||
<ion-label>
|
<ion-label>
|
||||||
<core-format-text [text]="notification.mobiletext | coreCreateLinks" contextLevel="system"
|
<core-format-text [text]="notification.mobiletext | coreCreateLinks" contextLevel="system"
|
||||||
[contextInstanceId]="0" [maxHeight]="notification.displayfullhtml ? 120 : null">
|
[contextInstanceId]="0" [maxHeight]="120">
|
||||||
</core-format-text>
|
</core-format-text>
|
||||||
</ion-label>
|
</ion-label>
|
||||||
</ion-item>
|
</ion-item>
|
||||||
|
|
|
@ -36,7 +36,7 @@ import {
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'page-addon-notifications-list',
|
selector: 'page-addon-notifications-list',
|
||||||
templateUrl: 'list.html',
|
templateUrl: 'list.html',
|
||||||
styleUrls: ['list.scss'],
|
styleUrls: ['../../notifications.scss'],
|
||||||
})
|
})
|
||||||
export class AddonNotificationsListPage implements OnInit, OnDestroy {
|
export class AddonNotificationsListPage implements OnInit, OnDestroy {
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,7 @@ import { CoreUtils } from '@services/utils/utils';
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'page-addon-notifications-notification',
|
selector: 'page-addon-notifications-notification',
|
||||||
templateUrl: 'notification.html',
|
templateUrl: 'notification.html',
|
||||||
|
styleUrls: ['../../notifications.scss'],
|
||||||
})
|
})
|
||||||
export class AddonNotificationsNotificationPage implements OnInit {
|
export class AddonNotificationsNotificationPage implements OnInit {
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,6 @@ import {
|
||||||
AddonNotificationsPreferencesNotificationProcessor,
|
AddonNotificationsPreferencesNotificationProcessor,
|
||||||
AddonNotificationsPreferencesProcessor,
|
AddonNotificationsPreferencesProcessor,
|
||||||
} from './notifications';
|
} from './notifications';
|
||||||
import { CoreTextUtils } from '@services/utils/text';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Service that provides some helper functions for notifications.
|
* Service that provides some helper functions for notifications.
|
||||||
|
@ -42,13 +41,8 @@ export class AddonNotificationsHelperProvider {
|
||||||
notification: AddonNotificationsNotificationMessageFormatted,
|
notification: AddonNotificationsNotificationMessageFormatted,
|
||||||
): AddonNotificationsNotificationToRender {
|
): AddonNotificationsNotificationToRender {
|
||||||
const formattedNotification: AddonNotificationsNotificationToRender = notification;
|
const formattedNotification: AddonNotificationsNotificationToRender = notification;
|
||||||
formattedNotification.displayfullhtml = this.shouldDisplayFullHtml(notification);
|
|
||||||
formattedNotification.iconurl = formattedNotification.iconurl || undefined; // Make sure the property exists.
|
formattedNotification.iconurl = formattedNotification.iconurl || undefined; // Make sure the property exists.
|
||||||
|
|
||||||
formattedNotification.mobiletext = formattedNotification.displayfullhtml ?
|
|
||||||
notification.fullmessagehtml :
|
|
||||||
CoreTextUtils.replaceNewLines((formattedNotification.mobiletext || '').replace(/-{4,}/ig, ''), '<br>');
|
|
||||||
|
|
||||||
return formattedNotification;
|
return formattedNotification;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -140,16 +134,6 @@ export class AddonNotificationsHelperProvider {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Check whether we should display full HTML of the notification.
|
|
||||||
*
|
|
||||||
* @param notification Notification.
|
|
||||||
* @return Whether to display full HTML.
|
|
||||||
*/
|
|
||||||
protected shouldDisplayFullHtml(notification: AddonNotificationsNotificationToRender): boolean {
|
|
||||||
return notification.component == 'mod_forum' && notification.eventtype == 'digests';
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const AddonNotificationsHelper = makeSingleton(AddonNotificationsHelperProvider);
|
export const AddonNotificationsHelper = makeSingleton(AddonNotificationsHelperProvider);
|
||||||
|
@ -187,6 +171,5 @@ export type AddonNotificationsPreferencesProcessorFormatted = AddonNotifications
|
||||||
* Notification with some calculated data to render it.
|
* Notification with some calculated data to render it.
|
||||||
*/
|
*/
|
||||||
export type AddonNotificationsNotificationToRender = AddonNotificationsNotificationMessageFormatted & {
|
export type AddonNotificationsNotificationToRender = AddonNotificationsNotificationMessageFormatted & {
|
||||||
displayfullhtml?: boolean; // Whether to display the full HTML of the notification.
|
|
||||||
iconurl?: string;
|
iconurl?: string;
|
||||||
};
|
};
|
||||||
|
|
|
@ -56,13 +56,7 @@ export class AddonNotificationsProvider {
|
||||||
const promises = notifications.map(async (notificationRaw) => {
|
const promises = notifications.map(async (notificationRaw) => {
|
||||||
const notification = <AddonNotificationsNotificationMessageFormatted> notificationRaw;
|
const notification = <AddonNotificationsNotificationMessageFormatted> notificationRaw;
|
||||||
|
|
||||||
// Set message to show.
|
notification.mobiletext = notification.fullmessagehtml || notification.fullmessage || notification.smallmessage;
|
||||||
if (notification.component && notification.component == 'mod_forum') {
|
|
||||||
notification.mobiletext = notification.smallmessage;
|
|
||||||
} else {
|
|
||||||
notification.mobiletext = notification.fullmessage;
|
|
||||||
}
|
|
||||||
|
|
||||||
notification.moodlecomponent = notification.component;
|
notification.moodlecomponent = notification.component;
|
||||||
notification.notification = 1;
|
notification.notification = 1;
|
||||||
notification.notif = 1;
|
notification.notif = 1;
|
||||||
|
@ -171,7 +165,7 @@ export class AddonNotificationsProvider {
|
||||||
|
|
||||||
// Request 1 more notification so we can know if there are more notifications.
|
// Request 1 more notification so we can know if there are more notifications.
|
||||||
const originalLimit = options.limit;
|
const originalLimit = options.limit;
|
||||||
options.limit + 1;
|
options.limit = options.limit + 1;
|
||||||
|
|
||||||
const site = await CoreSites.getSite(options.siteId);
|
const site = await CoreSites.getSite(options.siteId);
|
||||||
|
|
||||||
|
|
|
@ -166,8 +166,8 @@ export class CoreFormatTextDirective implements OnChanges {
|
||||||
const originalWidth = img.attributes.getNamedItem('width');
|
const originalWidth = img.attributes.getNamedItem('width');
|
||||||
|
|
||||||
const forcedWidth = Number(originalWidth?.value);
|
const forcedWidth = Number(originalWidth?.value);
|
||||||
if (!isNaN(forcedWidth)) {
|
if (originalWidth && !isNaN(forcedWidth)) {
|
||||||
if (originalWidth!.value.indexOf('%') < 0) {
|
if (originalWidth.value.indexOf('%') < 0) {
|
||||||
img.style.width = forcedWidth + 'px';
|
img.style.width = forcedWidth + 'px';
|
||||||
} else {
|
} else {
|
||||||
img.style.width = forcedWidth + '%';
|
img.style.width = forcedWidth + '%';
|
||||||
|
|
Loading…
Reference in New Issue