diff --git a/scripts/langindex.json b/scripts/langindex.json index aae5bdd55..40c4b9144 100644 --- a/scripts/langindex.json +++ b/scripts/langindex.json @@ -2162,6 +2162,7 @@ "core.settings.disableall": "message", "core.settings.disabled": "lesson", "core.settings.disabledfeatures": "tool_mobile", + "core.settings.disallowed": "message", "core.settings.displayformat": "local_moodlemobileapp", "core.settings.enabledownloadsection": "local_moodlemobileapp", "core.settings.enablefirebaseanalytics": "local_moodlemobileapp", @@ -2176,6 +2177,7 @@ "core.settings.filesystemroot": "local_moodlemobileapp", "core.settings.fontsize": "local_moodlemobileapp", "core.settings.fontsizecharacter": "block_accessibility/char", + "core.settings.forced": "message", "core.settings.forcedsetting": "local_moodlemobileapp", "core.settings.forcesafeareamargins": "local_moodlemobileapp", "core.settings.general": "moodle", @@ -2186,7 +2188,6 @@ "core.settings.license": "moodle", "core.settings.localnotifavailable": "local_moodlemobileapp", "core.settings.locationhref": "local_moodlemobileapp", - "core.settings.locked": "admin", "core.settings.loggedin": "message", "core.settings.loggedoff": "message", "core.settings.navigatorlanguage": "local_moodlemobileapp", diff --git a/src/addons/block/activitymodules/components/activitymodules/addon-block-activitymodules.html b/src/addons/block/activitymodules/components/activitymodules/addon-block-activitymodules.html index 1c23cf54f..50e95546f 100644 --- a/src/addons/block/activitymodules/components/activitymodules/addon-block-activitymodules.html +++ b/src/addons/block/activitymodules/components/activitymodules/addon-block-activitymodules.html @@ -1,6 +1,6 @@ -

{{ 'addon.block_activitymodules.pluginname' | translate }}

+

{{ 'addon.block_activitymodules.pluginname' | translate }}

diff --git a/src/addons/block/myoverview/components/filteroptions/filteroptions.html b/src/addons/block/myoverview/components/filteroptions/filteroptions.html index 39dcd2491..8d747fcfe 100644 --- a/src/addons/block/myoverview/components/filteroptions/filteroptions.html +++ b/src/addons/block/myoverview/components/filteroptions/filteroptions.html @@ -41,12 +41,12 @@ - {{ 'addon.block_myoverview.favouritesonly' | translate }} + {{ 'addon.block_myoverview.favouritesonly' | translate }} - {{ 'addon.block_myoverview.aria:hiddencourses' | translate }} + {{ 'addon.block_myoverview.aria:hiddencourses' | translate }} diff --git a/src/addons/block/recentlyaccessedcourses/components/recentlyaccessedcourses/addon-block-recentlyaccessedcourses.html b/src/addons/block/recentlyaccessedcourses/components/recentlyaccessedcourses/addon-block-recentlyaccessedcourses.html index 6f10e6e92..113048db0 100644 --- a/src/addons/block/recentlyaccessedcourses/components/recentlyaccessedcourses/addon-block-recentlyaccessedcourses.html +++ b/src/addons/block/recentlyaccessedcourses/components/recentlyaccessedcourses/addon-block-recentlyaccessedcourses.html @@ -1,6 +1,6 @@ -

{{ 'addon.block_recentlyaccessedcourses.pluginname' | translate }}

+

{{ 'addon.block_recentlyaccessedcourses.pluginname' | translate }}

diff --git a/src/addons/block/recentlyaccesseditems/components/recentlyaccesseditems/addon-block-recentlyaccesseditems.html b/src/addons/block/recentlyaccesseditems/components/recentlyaccesseditems/addon-block-recentlyaccesseditems.html index e93ac8cd1..14298293a 100644 --- a/src/addons/block/recentlyaccesseditems/components/recentlyaccesseditems/addon-block-recentlyaccesseditems.html +++ b/src/addons/block/recentlyaccesseditems/components/recentlyaccesseditems/addon-block-recentlyaccesseditems.html @@ -1,6 +1,6 @@ -

{{ 'addon.block_recentlyaccesseditems.pluginname' | translate }}

+

{{ 'addon.block_recentlyaccesseditems.pluginname' | translate }}

diff --git a/src/addons/block/sitemainmenu/components/sitemainmenu/addon-block-sitemainmenu.html b/src/addons/block/sitemainmenu/components/sitemainmenu/addon-block-sitemainmenu.html index de45bf3af..3ce510a26 100644 --- a/src/addons/block/sitemainmenu/components/sitemainmenu/addon-block-sitemainmenu.html +++ b/src/addons/block/sitemainmenu/components/sitemainmenu/addon-block-sitemainmenu.html @@ -1,6 +1,6 @@ -

{{ 'addon.block_sitemainmenu.pluginname' | translate }}

+

{{ 'addon.block_sitemainmenu.pluginname' | translate }}

diff --git a/src/addons/block/starredcourses/components/starredcourses/addon-block-starredcourses.html b/src/addons/block/starredcourses/components/starredcourses/addon-block-starredcourses.html index 3697b8439..fd6a1a860 100644 --- a/src/addons/block/starredcourses/components/starredcourses/addon-block-starredcourses.html +++ b/src/addons/block/starredcourses/components/starredcourses/addon-block-starredcourses.html @@ -1,6 +1,6 @@ -

{{ 'addon.block_starredcourses.pluginname' | translate }}

+

{{ 'addon.block_starredcourses.pluginname' | translate }}

diff --git a/src/addons/block/timeline/components/timeline/addon-block-timeline.html b/src/addons/block/timeline/components/timeline/addon-block-timeline.html index a0774f1d9..a4155a94d 100644 --- a/src/addons/block/timeline/components/timeline/addon-block-timeline.html +++ b/src/addons/block/timeline/components/timeline/addon-block-timeline.html @@ -1,6 +1,6 @@ -

{{ 'addon.block_timeline.pluginname' | translate }}

+

{{ 'addon.block_timeline.pluginname' | translate }}

diff --git a/src/addons/blog/pages/entries/entries.html b/src/addons/blog/pages/entries/entries.html index 550ee3fd2..41697ecd3 100644 --- a/src/addons/blog/pages/entries/entries.html +++ b/src/addons/blog/pages/entries/entries.html @@ -17,7 +17,7 @@ - {{ 'addon.blog.showonlyyourentries' | translate }} + {{ 'addon.blog.showonlyyourentries' | translate }} diff --git a/src/addons/calendar/pages/edit-event/edit-event.html b/src/addons/calendar/pages/edit-event/edit-event.html index 0ba264922..4b536a12d 100644 --- a/src/addons/calendar/pages/edit-event/edit-event.html +++ b/src/addons/calendar/pages/edit-event/edit-event.html @@ -30,7 +30,7 @@

{{ 'core.date' | translate }}

- @@ -156,7 +156,7 @@ + [placeholder]="'addon.calendar.durationuntil' | translate" [displayFormat]="dateFormat" display-timezone="utc"> diff --git a/src/addons/messages/pages/discussion/discussion.html b/src/addons/messages/pages/discussion/discussion.html index 2c85e5dbd..fe42e7ac1 100644 --- a/src/addons/messages/pages/discussion/discussion.html +++ b/src/addons/messages/pages/discussion/discussion.html @@ -40,10 +40,10 @@ - - - {{ 'addon.messages.blocknoncontacts' | translate }} + {{ 'addon.messages.blocknoncontacts' | translate }} @@ -46,88 +46,12 @@ -
- - - - - -

{{ notification.displayname }}

-
- -

{{ 'core.settings.loggedin' | translate }}

-
- -

{{ 'core.settings.loggedoff' | translate }}

-
-
-

{{ 'addon.notifications.notificationpreferences' | translate }}

-
-
- - - - - {{ processor.displayname }} - - - - - {{ processor.lockedmessage }} - - - - {{ 'core.settings.disabled' | translate }} - - - - - - - - {{ processor.displayname }} - - - - - -
- {{'core.settings.locked' | translate }} -
-
- - {{ 'core.settings.disabled' | translate }} -
-
- - - {{ processor.displayname }} - - - - {{ 'core.settings.' + state | translate }} - - - - - {{'core.settings.locked' | translate }} - - - - {{ 'core.settings.disabled' | translate }} - - -
-
-
-
+ + + + + +
@@ -148,3 +72,77 @@
+ + + + + + + + +

{{ notification.displayname }}

+
+
+
+ + + + +

{{ processor.displayname }}

+
+
+ + + {{ 'core.settings.' + state | translate }} + + + + + + + + {{'core.settings.forced' | translate }} + + + {{'core.settings.disallowed' | translate }} + + + {{ 'core.settings.disabled' | translate }} + +
+
+
+
+
+ + + + + + + +

{{ 'addon.notifications.notificationpreferences' | translate }}

+
+
+ + + + {{ processor.displayname }} + + + + + + + + {{ processor.lockedmessage }} + + + {{ 'core.settings.disabled' | translate }} + + +
+
+
diff --git a/src/addons/messages/pages/settings/settings.page.ts b/src/addons/messages/pages/settings/settings.page.ts index b986e55b3..06b4902b1 100644 --- a/src/addons/messages/pages/settings/settings.page.ts +++ b/src/addons/messages/pages/settings/settings.page.ts @@ -27,6 +27,7 @@ import { CoreSites } from '@services/sites'; import { CoreDomUtils } from '@services/utils/dom'; import { CoreConstants } from '@/core/constants'; import { IonRefresher } from '@ionic/angular'; +import { AddonNotificationsPreferencesNotificationProcessorState } from '@addons/notifications/services/notifications'; /** * Page that displays the messages settings page. @@ -50,14 +51,16 @@ export class AddonMessagesSettingsPage implements OnInit, OnDestroy { groupMessagingEnabled = false; sendOnEnter = false; + protected loggedInOffLegacyMode = false; protected previousContactableValue?: number | boolean; constructor() { - const currentSite = CoreSites.getCurrentSite(); - this.advancedContactable = !!currentSite?.isVersionGreaterEqualThan('3.6'); - this.allowSiteMessaging = !!currentSite?.canUseAdvancedFeature('messagingallusers'); + const currentSite = CoreSites.getRequiredCurrentSite(); + this.advancedContactable = !!currentSite.isVersionGreaterEqualThan('3.6'); + this.allowSiteMessaging = !!currentSite.canUseAdvancedFeature('messagingallusers'); this.groupMessagingEnabled = AddonMessages.isGroupMessagingEnabled(); + this.loggedInOffLegacyMode = !currentSite.isVersionGreaterEqualThan('4.0'); this.asyncInit(); } @@ -90,13 +93,16 @@ export class AddonMessagesSettingsPage implements OnInit, OnDestroy { component.notifications = component.notifications.filter((notification) => notification.preferencekey == AddonMessagesProvider.NOTIFICATION_PREFERENCES_KEY); - component.notifications.forEach((notification) => { - notification.processors.forEach( - (processor: AddonMessagesMessagePreferencesNotificationProcessorFormatted) => { - processor.checked = processor.loggedin.checked || processor.loggedoff.checked; - }, - ); - }); + if (this.loggedInOffLegacyMode) { + // Load enabled from loggedin / loggedoff values. + component.notifications.forEach((notification) => { + notification.processors.forEach( + (processor) => { + processor.enabled = processor.loggedin.checked || processor.loggedoff.checked; + }, + ); + }); + } } } @@ -165,74 +171,70 @@ export class AddonMessagesSettingsPage implements OnInit, OnDestroy { } /** - * Change the value of a certain preference. + * Change the value of a certain preference. Versions 3.6 onwards. * * @param notification Notification object. - * @param state State name, ['loggedin', 'loggedoff']. * @param processor Notification processor. */ async changePreference( notification: AddonMessagesMessagePreferencesNotificationFormatted, - state: string, - processor: AddonMessagesMessagePreferencesNotificationProcessorFormatted, + processor: AddonMessagesMessagePreferencesNotificationProcessor, ): Promise { + // Update both states at the same time. + let value = notification.processors + .filter((processor) => processor.enabled) + .map((processor) => processor.name) + .join(','); - const valueArray: string[] = []; - let value = 'none'; + if (value == '') { + value = 'none'; + } - if (this.groupMessagingEnabled) { - // Update both states at the same time. - const promises: Promise[] = []; - - notification.processors.forEach((processor: AddonMessagesMessagePreferencesNotificationProcessorFormatted) => { - if (processor.checked) { - valueArray.push(processor.name); - } - }); - - if (value.length > 0) { - value = valueArray.join(','); - } - - notification.updating = true; + notification.updating = true; + const promises: Promise[] = []; + if (this.loggedInOffLegacyMode) { promises.push(CoreUser.updateUserPreference(notification.preferencekey + '_loggedin', value)); promises.push(CoreUser.updateUserPreference(notification.preferencekey + '_loggedoff', value)); - - try { - await Promise.all(promises); - // Update the preferences since they were modified. - this.updatePreferencesAfterDelay(); - } catch (error) { - // Show error and revert change. - CoreDomUtils.showErrorModal(error); - processor.checked = !processor.checked; - } finally { - notification.updating = false; - } - - return; + } else { + promises.push(CoreUser.updateUserPreference(notification.preferencekey + '_enabled', value)); } + try { + await Promise.all(promises); + // Update the preferences since they were modified. + this.updatePreferencesAfterDelay(); + } catch (error) { + // Show error and revert change. + CoreDomUtils.showErrorModal(error); + processor.enabled = !processor.enabled; + } finally { + notification.updating = false; + } + } + + /** + * Change the value of a certain preference. Only on version 3.5. + * + * @param notification Notification object. + * @param processor Notification processor. + * @param state State name, ['loggedin', 'loggedoff']. + */ + async changePreferenceLegacy( + notification: AddonMessagesMessagePreferencesNotificationFormatted, + processor: AddonMessagesMessagePreferencesNotificationProcessor, + state: 'loggedin' | 'loggedoff', + ): Promise { // Update only the specified state. - const processorState = processor[state]; + const processorState: AddonNotificationsPreferencesNotificationProcessorState = processor[state]; const preferenceName = notification.preferencekey + '_' + processorState.name; - notification.processors.forEach((processor) => { - if (processor[state].checked) { - valueArray.push(processor.name); - } - }); + const value = notification.processors + .filter((processor) => processor[state].checked) + .map((processor) => processor.name) + .join(','); - if (value.length > 0) { - value = valueArray.join(','); - } - - if (!notification.updating) { - notification.updating = {}; - } - - notification.updating[state] = true; + notification['updating'+state] = true; try { await CoreUser.updateUserPreference(preferenceName, value); // Update the preferences since they were modified. @@ -242,7 +244,7 @@ export class AddonMessagesSettingsPage implements OnInit, OnDestroy { CoreDomUtils.showErrorModal(error); processorState.checked = !processorState.checked; } finally { - notification.updating[state] = false; + notification['updating'+state] = false; } } @@ -288,12 +290,7 @@ export class AddonMessagesSettingsPage implements OnInit, OnDestroy { * Message preferences notification with some caclulated data. */ type AddonMessagesMessagePreferencesNotificationFormatted = AddonMessagesMessagePreferencesNotification & { - updating?: boolean | {[state: string]: boolean}; // Calculated in the app. Whether the notification is being updated. -}; - -/** - * Message preferences notification processor with some caclulated data. - */ -type AddonMessagesMessagePreferencesNotificationProcessorFormatted = AddonMessagesMessagePreferencesNotificationProcessor & { - checked?: boolean; // Calculated in the app. Whether the processor is checked either for loggedin or loggedoff. + updating?: boolean; // Calculated in the app. Whether the notification is being updated. + updatingloggedin?: boolean; // Calculated in the app. Whether the notification is being updated. + updatingloggedoff?: boolean; // Calculated in the app. Whether the notification is being updated. }; diff --git a/src/addons/messages/services/messages.ts b/src/addons/messages/services/messages.ts index ba07393c5..c53ddfac3 100644 --- a/src/addons/messages/services/messages.ts +++ b/src/addons/messages/services/messages.ts @@ -32,6 +32,7 @@ import { makeSingleton } from '@singletons'; import { CoreError } from '@classes/errors/error'; import { AddonMessagesSyncEvents, AddonMessagesSyncProvider } from './messages-sync'; import { CoreWSError } from '@classes/errors/wserror'; +import { AddonNotificationsPreferencesNotificationProcessorState } from '@addons/notifications/services/notifications'; const ROOT_CACHE_KEY = 'mmaMessages:'; @@ -3047,16 +3048,9 @@ export type AddonMessagesMessagePreferencesNotificationProcessor = { locked: boolean; // Is locked by admin?. lockedmessage?: string; // @since 3.6. Text to display if locked. userconfigured: number; // Is configured?. - loggedin: { - name: string; // Name. - displayname: string; // Display name. - checked: boolean; // Is checked?. - }; - loggedoff: { - name: string; // Name. - displayname: string; // Display name. - checked: boolean; // Is checked?. - }; + enabled?: boolean; // @since 4.0. Processor enabled. + loggedin: AddonNotificationsPreferencesNotificationProcessorState; // @deprecated removed on 4.0. + loggedoff: AddonNotificationsPreferencesNotificationProcessorState; // @deprecated removed on 4.0. }; /** diff --git a/src/addons/mod/assign/submission/onlinetext/component/addon-mod-assign-submission-onlinetext.html b/src/addons/mod/assign/submission/onlinetext/component/addon-mod-assign-submission-onlinetext.html index f17a5dca5..639d40c26 100644 --- a/src/addons/mod/assign/submission/onlinetext/component/addon-mod-assign-submission-onlinetext.html +++ b/src/addons/mod/assign/submission/onlinetext/component/addon-mod-assign-submission-onlinetext.html @@ -20,7 +20,7 @@ -

{{ 'addon.mod_assign.wordlimit' | translate }}

+

{{ 'addon.mod_assign.wordlimit' | translate }}

{{ 'core.numwords' | translate: {'$a': words + ' / ' + wordLimit} }}

diff --git a/src/addons/mod/forum/components/post/post.html b/src/addons/mod/forum/components/post/post.html index 09ea67c71..c23057906 100644 --- a/src/addons/mod/forum/components/post/post.html +++ b/src/addons/mod/forum/components/post/post.html @@ -1,5 +1,5 @@
- + diff --git a/src/addons/mod/resource/components/index/addon-mod-resource-index.html b/src/addons/mod/resource/components/index/addon-mod-resource-index.html index bdeaa056d..bbad8ec56 100644 --- a/src/addons/mod/resource/components/index/addon-mod-resource-index.html +++ b/src/addons/mod/resource/components/index/addon-mod-resource-index.html @@ -101,7 +101,7 @@ - {{ 'core.openwith' | translate }} diff --git a/src/addons/notifications/pages/settings/settings.html b/src/addons/notifications/pages/settings/settings.html index cafdb246d..6bd5e89d8 100644 --- a/src/addons/notifications/pages/settings/settings.html +++ b/src/addons/notifications/pages/settings/settings.html @@ -35,75 +35,144 @@ - + {{ processor.displayname }} - - - - - {{ component.displayname }} - - {{ 'core.settings.loggedin' | translate }} - - - {{ 'core.settings.loggedoff' | translate }} - - - - - - - - - {{ notification.displayname }} - - - - - - - - {{'core.settings.locked' | translate }} - - - {{ 'core.settings.disabled' | translate }} - - - + + + - - - {{ notification.displayname }} - - - - {{ 'core.settings.' + state | translate }} - - - - - - {{'core.settings.locked' | translate }} - - {{ 'core.settings.disabled' | translate }} - - - + + + + + + + + + + + + + +

{{ component.displayname }}

+
+ +

{{ 'core.settings.loggedin' | translate }}

+
+ +

{{ 'core.settings.loggedoff' | translate }}

+
+
+
+
+
+ + + + + + +

{{ notification.displayname }}

+
+ + + + + + + + + {{'core.settings.forced' | translate }} + + + {{'core.settings.disallowed' | translate }} + + + + {{ 'core.settings.disabled' | translate }} + +
+
+
+ + + +

{{ notification.displayname }}

+
+ + + +

{{ 'core.settings.' + state | translate }}

+
+
+ + + + + + {{'core.settings.forced' | translate }} + + + {{'core.settings.disallowed' | translate }} + +
+ {{ 'core.settings.disabled' | translate }} +
+
+
+
+ + + + + + +

{{ component.displayname }}

+
+
+ + + + +

{{ notification.displayname }}

+
+ +
+ + + + + + {{'core.settings.forced' | translate }} + + + {{'core.settings.disallowed' | translate }} + +
+ {{ 'core.settings.disabled' | translate }} +
+
+
+ +
diff --git a/src/addons/notifications/pages/settings/settings.scss b/src/addons/notifications/pages/settings/settings.scss index 8fea99c17..d224357cb 100644 --- a/src/addons/notifications/pages/settings/settings.scss +++ b/src/addons/notifications/pages/settings/settings.scss @@ -1,5 +1,3 @@ -:host { - .addon-notifications-table-content ion-row { - min-height: 35px; - } +.addon-notifications-table-content ion-row { + min-height: 35px; } diff --git a/src/addons/notifications/pages/settings/settings.ts b/src/addons/notifications/pages/settings/settings.ts index d8cc886d3..a9fbe1210 100644 --- a/src/addons/notifications/pages/settings/settings.ts +++ b/src/addons/notifications/pages/settings/settings.ts @@ -27,7 +27,6 @@ import { CoreError } from '@classes/errors/error'; import { CoreEvents } from '@singletons/events'; import { AddonNotifications, - AddonNotificationsPreferencesProcessor, AddonNotificationsPreferencesNotificationProcessorState, } from '../../services/notifications'; import { @@ -51,16 +50,20 @@ export class AddonNotificationsSettingsPage implements OnInit, OnDestroy { preferences?: AddonNotificationsPreferencesFormatted; components?: AddonNotificationsPreferencesComponentFormatted[]; - currentProcessor?: AddonNotificationsPreferencesProcessor; + currentProcessorName = 'airnotifier'; preferencesLoaded = false; notificationSound = false; canChangeSound: boolean; processorHandlers: AddonMessageOutputHandlerData[] = []; + loggedInOffLegacyMode = false; protected updateTimeout?: number; constructor() { this.canChangeSound = CoreLocalNotifications.canDisableSound(); + + const currentSite = CoreSites.getRequiredCurrentSite(); + this.loggedInOffLegacyMode = !currentSite.isVersionGreaterEqualThan('4.0'); } /** @@ -83,20 +86,20 @@ export class AddonNotificationsSettingsPage implements OnInit, OnDestroy { try { const preferences = await AddonNotifications.getNotificationPreferences(); - if (!this.currentProcessor) { - // Initialize current processor. Load "Mobile" (airnotifier) if available. - this.currentProcessor = AddonNotificationsHelper.getProcessor(preferences.processors, 'airnotifier'); + // Initialize current processor. Load "Mobile" (airnotifier) if available. + let currentProcessor = preferences.processors.find((processor) => processor.name == this.currentProcessorName); + if (!currentProcessor) { + currentProcessor = preferences.processors[0]; } - if (!this.currentProcessor) { + if (!currentProcessor) { // Shouldn't happen. throw new CoreError('No processor found'); } preferences.enableall = !preferences.disableall; this.preferences = AddonNotificationsHelper.formatPreferences(preferences); - this.loadProcessor(this.currentProcessor); - + this.loadProcessor(currentProcessor); } catch (error) { CoreDomUtils.showErrorModal(error); } finally { @@ -114,7 +117,7 @@ export class AddonNotificationsSettingsPage implements OnInit, OnDestroy { return; } - this.currentProcessor = processor; + this.currentProcessorName = processor.name; this.processorHandlers = []; this.components = AddonNotificationsHelper.getProcessorComponents( processor.name, @@ -199,27 +202,21 @@ export class AddonNotificationsSettingsPage implements OnInit, OnDestroy { * @param state State name, ['loggedin', 'loggedoff']. * @return Promise resolved when done. */ - async changePreference(notification: AddonNotificationsPreferencesNotificationFormatted, state: string): Promise { - const processor = notification.processorsByName?.[this.currentProcessor?.name || '']; + async changePreferenceLegacy(notification: AddonNotificationsPreferencesNotificationFormatted, state: string): Promise { + const processor = notification.processorsByName?.[this.currentProcessorName]; if (!processor) { return; } const processorState: ProcessorStateFormatted = processor[state]; const preferenceName = notification.preferencekey + '_' + processorState.name; - let value: string | undefined; - notification.processors.forEach((processor) => { - if (processor[state].checked) { - if (!value) { - value = processor.name; - } else { - value += ',' + processor.name; - } - } - }); + let value = notification.processors + .filter((processor) => processor[state].checked) + .map((processor) => processor.name) + .join(','); - if (!value) { + if (value == '') { value = 'none'; } @@ -239,6 +236,45 @@ export class AddonNotificationsSettingsPage implements OnInit, OnDestroy { } } + /** + * Change the value of a certain preference. + * + * @param notification Notification object. + * @return Promise resolved when done. + */ + async changePreference(notification: AddonNotificationsPreferencesNotificationFormatted): Promise { + const processor = notification.processorsByName?.[this.currentProcessorName]; + if (!processor) { + return; + } + + const preferenceName = notification.preferencekey + '_enabled'; + + let value = notification.processors + .filter((processor) => processor.enabled) + .map((processor) => processor.name) + .join(','); + + if (value == '') { + value = 'none'; + } + + processor.updating = true; + + try { + await CoreUser.updateUserPreference(preferenceName, value); + + // Update the preferences since they were modified. + this.updatePreferencesAfterDelay(); + } catch (error) { + // Show error and revert change. + CoreDomUtils.showErrorModal(error); + processor.enabled = !processor.enabled; + } finally { + processor.updating = false; + } + } + /** * Enable all notifications changed. * @@ -294,6 +330,8 @@ export class AddonNotificationsSettingsPage implements OnInit, OnDestroy { /** * State in notification processor in notification preferences component with some calculated data. + * + * @deprecated 4.0 */ type ProcessorStateFormatted = AddonNotificationsPreferencesNotificationProcessorState & { updating?: boolean; // Calculated in the app. Whether the state is being updated. diff --git a/src/addons/notifications/services/notifications-helper.ts b/src/addons/notifications/services/notifications-helper.ts index 8ccd98f55..8eb24bfdc 100644 --- a/src/addons/notifications/services/notifications-helper.ts +++ b/src/addons/notifications/services/notifications-helper.ts @@ -77,34 +77,6 @@ export class AddonNotificationsHelperProvider { return formattedPreferences; } - /** - * Get a certain processor from a list of processors. - * - * @param processors List of processors. - * @param name Name of the processor to get. - * @param fallback True to return first processor if not found, false to not return any. Defaults to true. - * @return Processor. - */ - getProcessor( - processors: AddonNotificationsPreferencesProcessor[], - name: string, - fallback: boolean = true, - ): AddonNotificationsPreferencesProcessor | undefined { - if (!processors || !processors.length) { - return; - } - - const processor = processors.find((processor) => processor.name == name); - if (processor) { - return processor; - } - - // Processor not found, return first if requested. - if (fallback) { - return processors[0]; - } - } - /** * Return the components and notifications that have a certain processor. * @@ -166,7 +138,11 @@ export type AddonNotificationsPreferencesComponentFormatted = Omit; // Calculated in the app. + processorsByName?: Record; // Calculated in the app. +}; + +type AddonNotificationsPreferencesNotificationProcessorFormatted = AddonNotificationsPreferencesNotificationProcessor & { + updating?: boolean; // Calculated in the app. Whether the state is being updated. }; /** diff --git a/src/addons/notifications/services/notifications.ts b/src/addons/notifications/services/notifications.ts index 86b5f5f49..1fab101db 100644 --- a/src/addons/notifications/services/notifications.ts +++ b/src/addons/notifications/services/notifications.ts @@ -435,19 +435,24 @@ export type AddonNotificationsPreferencesNotificationProcessor = { locked: boolean; // Is locked by admin?. lockedmessage?: string; // @since 3.6. Text to display if locked. userconfigured: number; // Is configured?. - loggedin: AddonNotificationsPreferencesNotificationProcessorState; - loggedoff: AddonNotificationsPreferencesNotificationProcessorState; + enabled?: boolean; // @since 4.0. Processor enabled. + loggedin: AddonNotificationsPreferencesNotificationProcessorState; // @deprecated removed on 4.0. + loggedoff: AddonNotificationsPreferencesNotificationProcessorState; // @deprecated removed on 4.0. }; /** * State in notification processor in notification preferences component. + * + * @deprecated removed on 4.0. */ export type AddonNotificationsPreferencesNotificationProcessorState = { - name: string; // Name. + name: 'loggedoff' | 'loggedin'; // Name. displayname: string; // Display name. checked: boolean; // Is checked?. }; +export type AddonNotificationsPreferencesNotificationProcessorStateSetting = 'loggedoff' | 'loggedin' | 'enabled'; + /** * Params of core_message_get_messages WS. */ diff --git a/src/addons/qtype/essay/component/addon-qtype-essay.html b/src/addons/qtype/essay/component/addon-qtype-essay.html index dffb87858..5fb2e2e29 100644 --- a/src/addons/qtype/essay/component/addon-qtype-essay.html +++ b/src/addons/qtype/essay/component/addon-qtype-essay.html @@ -69,7 +69,7 @@ - + {{ field.name }} - diff --git a/src/addons/userprofilefield/menu/component/addon-user-profile-field-menu.html b/src/addons/userprofilefield/menu/component/addon-user-profile-field-menu.html index b31734b71..3816c2090 100644 --- a/src/addons/userprofilefield/menu/component/addon-user-profile-field-menu.html +++ b/src/addons/userprofilefield/menu/component/addon-user-profile-field-menu.html @@ -14,9 +14,9 @@ {{ field.name }} - - {{ 'core.choosedots' | translate }} + {{ 'core.choosedots' | translate }} {{option}} diff --git a/src/core/components/attachments/core-attachments.html b/src/core/components/attachments/core-attachments.html index 46fbc7693..f18d06124 100644 --- a/src/core/components/attachments/core-attachments.html +++ b/src/core/components/attachments/core-attachments.html @@ -1,7 +1,7 @@ - {{ 'core.maxsizeandattachments' | translate:{$a: {size: maxSizeReadable, attachments: maxSubmissionsReadable} } }} + {{ 'core.maxsizeandattachments' | translate:{$a: {size: maxSizeReadable, attachments: maxSubmissionsReadable} } }} {{ 'core.maxfilesize' | translate:{$a: maxSizeReadable} }} diff --git a/src/core/components/combobox/combobox.scss b/src/core/components/combobox/combobox.scss index 2548e9f1b..bef06c30c 100644 --- a/src/core/components/combobox/combobox.scss +++ b/src/core/components/combobox/combobox.scss @@ -28,7 +28,6 @@ --padding-top: 8px; --padding-end: 8px; --padding-bottom: 8px; - --padding-start: 8px; &.md { --background-activated-opacity: 0; @@ -40,6 +39,14 @@ --background-focused-opacity: .15; } } + + ion-button { + --padding-start: 8px; + } + + ion-select { + --padding-start: 16px; + } } ion-select, @@ -48,7 +55,7 @@ ion-button { color: var(--color); text-overflow: ellipsis; white-space: nowrap; - min-height: 25px; + min-height: 26px; overflow: hidden; margin: 8px; box-shadow: var(--box-shadow); @@ -109,7 +116,7 @@ ion-button { } .select-text { - margin-inline-end: auto; + @include margin-horizontal(null, auto); overflow: hidden; text-overflow: ellipsis; } diff --git a/src/core/features/course/components/unsupported-module/core-course-unsupported-module.html b/src/core/features/course/components/unsupported-module/core-course-unsupported-module.html index a55256ca3..4fd22a35d 100644 --- a/src/core/features/course/components/unsupported-module/core-course-unsupported-module.html +++ b/src/core/features/course/components/unsupported-module/core-course-unsupported-module.html @@ -1,6 +1,6 @@

{{ 'core.whoops' | translate }}

-

{{ 'core.uhoh' | translate }}

+

{{ 'core.uhoh' | translate }}

{{ 'core.course.activitydisabled' | translate }}

@@ -9,7 +9,7 @@

{{ 'core.course.activitynotyetviewableremoteaddon' | translate }}

-

{{ 'core.course.askadmintosupport' | translate }}

+

{{ 'core.course.askadmintosupport' | translate }}

{{ 'core.course.useactivityonbrowser' | translate }}

diff --git a/src/core/features/course/pages/preview/preview.html b/src/core/features/course/pages/preview/preview.html index 4cb9bad62..476c38c92 100644 --- a/src/core/features/course/pages/preview/preview.html +++ b/src/core/features/course/pages/preview/preview.html @@ -100,7 +100,7 @@ -

{{ 'core.courses.paypalaccepted' | translate }}

+

{{ 'core.courses.paypalaccepted' | translate }}

{{ 'core.paymentinstant' | translate }}

{{ 'core.courses.sendpaymentbutton' | translate }} diff --git a/src/core/features/settings/lang.json b/src/core/features/settings/lang.json index edaa16204..a7fe5e31f 100644 --- a/src/core/features/settings/lang.json +++ b/src/core/features/settings/lang.json @@ -29,6 +29,7 @@ "disableall": "Disable notifications", "disabled": "Disabled", "disabledfeatures": "Disabled features", + "disallowed": "Disallowed", "displayformat": "Display format", "enabledownloadsection": "Enable download sections", "enablefirebaseanalytics": "Enable Firebase analytics", @@ -43,6 +44,7 @@ "filesystemroot": "File system root", "fontsize": "Text size", "fontsizecharacter": "A", + "forced": "Locked", "forcedsetting": "This setting has been forced by your site configuration.", "forcesafeareamargins": "Force safe area margins", "general": "General", @@ -53,7 +55,6 @@ "license": "Licence", "localnotifavailable": "Local notifications available", "locationhref": "Web view URL", - "locked": "Locked", "loggedin": "Online", "loggedoff": "Offline", "navigatorlanguage": "Navigator language", diff --git a/src/core/features/settings/pages/deviceinfo/deviceinfo.html b/src/core/features/settings/pages/deviceinfo/deviceinfo.html index ed8401cd8..54ffba79a 100644 --- a/src/core/features/settings/pages/deviceinfo/deviceinfo.html +++ b/src/core/features/settings/pages/deviceinfo/deviceinfo.html @@ -33,7 +33,7 @@

{{ 'core.settings.compilationinfo' | translate }}

-

{{ deviceInfo.compilationTime | coreFormatDate: "LLL Z": false }}

+

{{ deviceInfo.compilationTime | coreFormatDate: "LLL Z": false }}

{{ deviceInfo.lastCommit }}

diff --git a/src/core/features/settings/pages/site/site.html b/src/core/features/settings/pages/site/site.html index 3361e02ab..24043ef35 100644 --- a/src/core/features/settings/pages/site/site.html +++ b/src/core/features/settings/pages/site/site.html @@ -18,7 +18,7 @@