diff --git a/src/addons/badges/pages/issued-badge/issued-badge.html b/src/addons/badges/pages/issued-badge/issued-badge.html index 5f06dc1d613..9686be66d7e 100644 --- a/src/addons/badges/pages/issued-badge/issued-badge.html +++ b/src/addons/badges/pages/issued-badge/issued-badge.html @@ -49,7 +49,7 @@

{{ 'addon.badges.issuerdetails' | translate}}

{{ 'addon.badges.contact' | translate}}

-

+

{{ badge.issuercontact }}

@@ -95,7 +95,7 @@

{{ 'addon.badges.badgedetails' | translate}}

{{ 'addon.badges.imageauthoremail' | translate}}

-

+

{{ badge.imageauthoremail }}

@@ -103,7 +103,7 @@

{{ 'addon.badges.badgedetails' | translate}}

{{ 'addon.badges.imageauthorurl' | translate}}

-

{{ badge.imageauthorurl }}

+

{{ badge.imageauthorurl }}

@@ -166,7 +166,7 @@

{{ 'addon.badges.bendorsement' | translate}}

{{ 'addon.badges.issueremail' | translate}}

- + {{ badge.endorsement.issueremail }}

@@ -175,7 +175,7 @@

{{ 'addon.badges.bendorsement' | translate}}

{{ 'addon.badges.issuerurl' | translate}}

-

{{ badge.endorsement.issuerurl }}

+

{{ badge.endorsement.issuerurl }}

@@ -187,7 +187,7 @@

{{ 'addon.badges.bendorsement' | translate}}

{{ 'addon.badges.claimid' | translate}}

-

{{ badge.endorsement.claimid }}

+

{{ badge.endorsement.claimid }}

@@ -225,7 +225,7 @@

{{ 'addon.badges.alignment' | translate}}

+ [autoLogin]="false">

{{ alignment.targetname }}

diff --git a/src/addons/block/timeline/components/events/events.ts b/src/addons/block/timeline/components/events/events.ts index 041c2275574..bb69312bcd6 100644 --- a/src/addons/block/timeline/components/events/events.ts +++ b/src/addons/block/timeline/components/events/events.ts @@ -19,6 +19,7 @@ import { CoreTextUtils } from '@services/utils/text'; import { CoreEnrolledCourseDataWithOptions } from '@features/courses/services/courses-helper'; import { AddonBlockTimelineDayEvents } from '@addons/block/timeline/classes/section'; import { CoreSharedModule } from '@/core/shared.module'; +import { toBoolean } from '@/core/transforms/boolean'; /** * Directive to render a list of events in course overview. @@ -36,9 +37,9 @@ export class AddonBlockTimelineEventsComponent implements OnInit { @Input() events: AddonBlockTimelineDayEvents[] = []; // The events to render. @Input() course?: CoreEnrolledCourseDataWithOptions; // Whether to show the course name. - @Input() showInlineCourse = true; // Whether to show the course name within event items. - @Input() canLoadMore = false; // Whether more events can be loaded. - @Input() loadingMore = false; // Whether loading is ongoing. + @Input({ transform: toBoolean }) showInlineCourse = true; // Whether to show the course name within event items. + @Input({ transform: toBoolean }) canLoadMore = false; // Whether more events can be loaded. + @Input({ transform: toBoolean }) loadingMore = false; // Whether loading is ongoing. @Output() loadMore = new EventEmitter(); // Notify that more events should be loaded. colorizeIcons = false; diff --git a/src/addons/calendar/components/calendar/calendar.ts b/src/addons/calendar/components/calendar/calendar.ts index e2df7777129..2920b385141 100644 --- a/src/addons/calendar/components/calendar/calendar.ts +++ b/src/addons/calendar/components/calendar/calendar.ts @@ -53,6 +53,7 @@ import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics'; import { CoreUrl } from '@singletons/url'; import { CoreTime } from '@singletons/time'; import { Translate } from '@singletons'; +import { toBoolean } from '@/core/transforms/boolean'; /** * Component that displays a calendar. @@ -69,9 +70,9 @@ export class AddonCalendarCalendarComponent implements OnInit, DoCheck, OnDestro @Input() initialYear?: number; // Initial year to load. @Input() initialMonth?: number; // Initial month to load. @Input() filter?: AddonCalendarFilter; // Filter to apply. - @Input() hidden?: boolean; // Whether the component is hidden. - @Input() canNavigate?: string | boolean; // Whether to include arrows to change the month. Defaults to true. - @Input() displayNavButtons?: string | boolean; // Whether to display nav buttons created by this component. Defaults to true. + @Input({ transform: toBoolean }) hidden = false; // Whether the component is hidden. + @Input({ transform: toBoolean }) canNavigate = true; // Whether to include arrows to change the month + @Input({ transform: toBoolean }) displayNavButtons = true; // Whether to display nav buttons created by this component. @Output() onEventClicked = new EventEmitter(); @Output() onDayClicked = new EventEmitter<{day: number; month: number; year: number}>(); @@ -145,10 +146,6 @@ export class AddonCalendarCalendarComponent implements OnInit, DoCheck, OnDestro * @inheritdoc */ ngOnInit(): void { - this.canNavigate = typeof this.canNavigate == 'undefined' ? true : CoreUtils.isTrueOrOne(this.canNavigate); - this.displayNavButtons = typeof this.displayNavButtons == 'undefined' ? true : - CoreUtils.isTrueOrOne(this.displayNavButtons); - const source = new AddonCalendarMonthSlidesItemsManagerSource(this, moment({ year: this.initialYear, month: this.initialMonth ? this.initialMonth - 1 : undefined, diff --git a/src/addons/calendar/pages/event/event.html b/src/addons/calendar/pages/event/event.html index 6f21e79ef02..b7f1ff8e427 100644 --- a/src/addons/calendar/pages/event/event.html +++ b/src/addons/calendar/pages/event/event.html @@ -104,7 +104,7 @@

{{ 'core.location' | translate}}

- + diff --git a/src/addons/mod/assign/classes/base-feedback-plugin-component.ts b/src/addons/mod/assign/classes/base-feedback-plugin-component.ts index 31713b7583c..fd740ca950c 100644 --- a/src/addons/mod/assign/classes/base-feedback-plugin-component.ts +++ b/src/addons/mod/assign/classes/base-feedback-plugin-component.ts @@ -18,6 +18,7 @@ import { CoreError } from '@classes/errors/error'; import { CoreModals } from '@services/modals'; import { AddonModAssignFeedbackCommentsTextData } from '../feedback/comments/services/handler'; import { AddonModAssignAssign, AddonModAssignPlugin, AddonModAssignSubmission } from '../services/assign'; +import { toBoolean } from '@/core/transforms/boolean'; /** * Base class for component to render a feedback plugin. @@ -27,13 +28,13 @@ import { AddonModAssignAssign, AddonModAssignPlugin, AddonModAssignSubmission } }) export class AddonModAssignFeedbackPluginBaseComponent implements IAddonModAssignFeedbackPluginComponent { - @Input() assign!: AddonModAssignAssign; // The assignment. - @Input() submission!: AddonModAssignSubmission; // The submission. - @Input() plugin!: AddonModAssignPlugin; // The plugin object. - @Input() userId!: number; // The user ID of the submission. + @Input({ required: true }) assign!: AddonModAssignAssign; // The assignment. + @Input({ required: true }) submission!: AddonModAssignSubmission; // The submission. + @Input({ required: true }) plugin!: AddonModAssignPlugin; // The plugin object. + @Input({ required: true }) userId!: number; // The user ID of the submission. @Input() configs?: Record; // The configs for the plugin. - @Input() canEdit = false; // Whether the user can edit. - @Input() edit = false; // Whether the user is editing. + @Input({ transform: toBoolean }) canEdit = false; // Whether the user can edit. + @Input({ transform: toBoolean }) edit = false; // Whether the user is editing. /** * Open a modal to edit the feedback plugin. diff --git a/src/addons/mod/assign/classes/base-submission-plugin-component.ts b/src/addons/mod/assign/classes/base-submission-plugin-component.ts index 56f938d0b4c..f245c0a98b1 100644 --- a/src/addons/mod/assign/classes/base-submission-plugin-component.ts +++ b/src/addons/mod/assign/classes/base-submission-plugin-component.ts @@ -14,6 +14,7 @@ import { Component, Input } from '@angular/core'; import { AddonModAssignAssign, AddonModAssignPlugin, AddonModAssignSubmission } from '../services/assign'; +import { toBoolean } from '@/core/transforms/boolean'; /** * Base class for component to render a submission plugin. @@ -23,12 +24,12 @@ import { AddonModAssignAssign, AddonModAssignPlugin, AddonModAssignSubmission } }) export class AddonModAssignSubmissionPluginBaseComponent { - @Input() assign!: AddonModAssignAssign; // The assignment. - @Input() submission!: AddonModAssignSubmission; // The submission. - @Input() plugin!: AddonModAssignPlugin; // The plugin object. + @Input({ required: true }) assign!: AddonModAssignAssign; // The assignment. + @Input({ required: true }) submission!: AddonModAssignSubmission; // The submission. + @Input({ required: true }) plugin!: AddonModAssignPlugin; // The plugin object. @Input() configs?: Record; // The configs for the plugin. - @Input() edit = false; // Whether the user is editing. - @Input() allowOffline = false; // Whether to allow offline. + @Input({ transform: toBoolean }) edit = false; // Whether the user is editing. + @Input({ transform: toBoolean }) allowOffline = false; // Whether to allow offline. /** * Invalidate the data. diff --git a/src/addons/mod/assign/components/edit-feedback-modal/edit-feedback-modal.ts b/src/addons/mod/assign/components/edit-feedback-modal/edit-feedback-modal.ts index 35682d76f77..aafd35365b7 100644 --- a/src/addons/mod/assign/components/edit-feedback-modal/edit-feedback-modal.ts +++ b/src/addons/mod/assign/components/edit-feedback-modal/edit-feedback-modal.ts @@ -37,10 +37,10 @@ import { AddonModAssignComponentsModule } from '../components.module'; }) export class AddonModAssignEditFeedbackModalComponent { - @Input() assign!: AddonModAssignAssign; // The assignment. - @Input() submission!: AddonModAssignSubmission; // The submission. - @Input() plugin!: AddonModAssignPlugin; // The plugin object. - @Input() userId!: number; // The user ID of the submission. + @Input({ required: true }) assign!: AddonModAssignAssign; // The assignment. + @Input({ required: true }) submission!: AddonModAssignSubmission; // The submission. + @Input({ required: true }) plugin!: AddonModAssignPlugin; // The plugin object. + @Input({ required: true }) userId!: number; // The user ID of the submission. @ViewChild('editFeedbackForm') formElement?: ElementRef; diff --git a/src/addons/mod/assign/components/feedback-plugin/feedback-plugin.ts b/src/addons/mod/assign/components/feedback-plugin/feedback-plugin.ts index 136e991b51b..0d3fd81a5bf 100644 --- a/src/addons/mod/assign/components/feedback-plugin/feedback-plugin.ts +++ b/src/addons/mod/assign/components/feedback-plugin/feedback-plugin.ts @@ -25,6 +25,7 @@ import { import { AddonModAssignHelper, AddonModAssignPluginConfig } from '../../services/assign-helper'; import { AddonModAssignFeedbackDelegate } from '../../services/feedback-delegate'; import { ADDON_MOD_ASSIGN_COMPONENT } from '../../constants'; +import { toBoolean } from '@/core/transforms/boolean'; /** * Component that displays an assignment feedback plugin. @@ -37,12 +38,12 @@ export class AddonModAssignFeedbackPluginComponent implements OnInit { @ViewChild(CoreDynamicComponent) dynamicComponent!: CoreDynamicComponent; - @Input() assign!: AddonModAssignAssign; // The assignment. - @Input() submission!: AddonModAssignSubmission; // The submission. - @Input() plugin!: AddonModAssignPlugin; // The plugin object. - @Input() userId!: number; // The user ID of the submission. - @Input() canEdit = false; // Whether the user can edit. - @Input() edit = false; // Whether the user is editing. + @Input({ required: true }) assign!: AddonModAssignAssign; // The assignment. + @Input({ required: true }) submission!: AddonModAssignSubmission; // The submission. + @Input({ required: true }) plugin!: AddonModAssignPlugin; // The plugin object. + @Input({ required: true }) userId!: number; // The user ID of the submission. + @Input({ transform: toBoolean }) canEdit = false; // Whether the user can edit. + @Input({ transform: toBoolean }) edit = false; // Whether the user is editing. pluginComponent?: Type; // Component to render the plugin. data?: AddonModAssignFeedbackPluginData; // Data to pass to the component. diff --git a/src/addons/mod/assign/components/submission-plugin/submission-plugin.ts b/src/addons/mod/assign/components/submission-plugin/submission-plugin.ts index 93210b120e5..4010a919301 100644 --- a/src/addons/mod/assign/components/submission-plugin/submission-plugin.ts +++ b/src/addons/mod/assign/components/submission-plugin/submission-plugin.ts @@ -25,6 +25,7 @@ import { AddonModAssignSubmissionDelegate } from '../../services/submission-dele import { CoreFileEntry } from '@services/file-helper'; import type { AddonModAssignSubmissionPluginBaseComponent } from '@addons/mod/assign/classes/base-submission-plugin-component'; import { ADDON_MOD_ASSIGN_COMPONENT } from '../../constants'; +import { toBoolean } from '@/core/transforms/boolean'; /** * Component that displays an assignment submission plugin. @@ -37,11 +38,11 @@ export class AddonModAssignSubmissionPluginComponent implements OnInit { @ViewChild(CoreDynamicComponent) dynamicComponent!: CoreDynamicComponent; - @Input() assign!: AddonModAssignAssign; // The assignment. - @Input() submission!: AddonModAssignSubmission; // The submission. - @Input() plugin!: AddonModAssignPlugin; // The plugin object. - @Input() edit = false; // Whether the user is editing. - @Input() allowOffline = false; // Whether to allow offline. + @Input({ required: true }) assign!: AddonModAssignAssign; // The assignment. + @Input({ required: true }) submission!: AddonModAssignSubmission; // The submission. + @Input({ required: true }) plugin!: AddonModAssignPlugin; // The plugin object. + @Input({ transform: toBoolean }) edit = false; // Whether the user is editing. + @Input({ transform: toBoolean }) allowOffline = false; // Whether to allow offline. pluginComponent?: Type; // Component to render the plugin. data?: AddonModAssignSubmissionPluginData; // Data to pass to the component. diff --git a/src/addons/mod/assign/components/submission/submission.ts b/src/addons/mod/assign/components/submission/submission.ts index 420b6970181..5d414803067 100644 --- a/src/addons/mod/assign/components/submission/submission.ts +++ b/src/addons/mod/assign/components/submission/submission.ts @@ -82,9 +82,9 @@ export class AddonModAssignSubmissionComponent implements OnInit, OnDestroy, Can @ViewChildren(AddonModAssignSubmissionPluginComponent) submissionComponents!: QueryList; - @Input() courseId!: number; // Course ID the submission belongs to. - @Input() moduleId!: number; // Module ID the submission belongs to. - @Input() submitId!: number; // User that did the submission. + @Input({ required: true }) courseId!: number; // Course ID the submission belongs to. + @Input({ required: true }) moduleId!: number; // Module ID the submission belongs to. + @Input() submitId!: number; // User that did the submission. Defaults to current user @Input() blindId?: number; // Blinded user ID (if it's blinded). loaded = false; // Whether data has been loaded. diff --git a/src/addons/mod/chat/components/users-modal/users-modal.ts b/src/addons/mod/chat/components/users-modal/users-modal.ts index 1ebd510e79f..6f40a45fd80 100644 --- a/src/addons/mod/chat/components/users-modal/users-modal.ts +++ b/src/addons/mod/chat/components/users-modal/users-modal.ts @@ -33,8 +33,8 @@ import { CoreSharedModule } from '@/core/shared.module'; }) export class AddonModChatUsersModalComponent implements OnInit, OnDestroy { - @Input() sessionId!: string; - @Input() cmId!: number; + @Input({ required: true }) sessionId!: string; + @Input({ required: true }) cmId!: number; users: AddonModChatUser[] = []; usersLoaded = false; diff --git a/src/addons/mod/data/classes/base-field-plugin-component.ts b/src/addons/mod/data/classes/base-field-plugin-component.ts index 93483a02891..72a64b03c3e 100644 --- a/src/addons/mod/data/classes/base-field-plugin-component.ts +++ b/src/addons/mod/data/classes/base-field-plugin-component.ts @@ -26,8 +26,8 @@ import { AddonModDataTemplateMode } from '../constants'; }) export abstract class AddonModDataFieldPluginBaseComponent implements OnInit, OnChanges { - @Input() mode!: AddonModDataTemplateMode; // The render mode. - @Input() field!: AddonModDataField; // The field to render. + @Input({ required: true }) mode!: AddonModDataTemplateMode; // The render mode. + @Input({ required: true }) field!: AddonModDataField; // The field to render. @Input() value?: Partial; // The value of the field. @Input() database?: AddonModDataData; // Database object. @Input() error?: string; // Error when editing. diff --git a/src/addons/mod/data/components/action/action.ts b/src/addons/mod/data/components/action/action.ts index 10022f9f821..57a9da66d41 100644 --- a/src/addons/mod/data/components/action/action.ts +++ b/src/addons/mod/data/components/action/action.ts @@ -45,10 +45,10 @@ import { export class AddonModDataActionComponent implements OnInit { @Input() access?: AddonModDataGetDataAccessInformationWSResponse; // Access info. - @Input() mode!: AddonModDataTemplateMode; // The render mode. - @Input() action!: AddonModDataAction; // The field to render. - @Input() entry!: AddonModDataEntry; // The value of the field. - @Input() database!: AddonModDataData; // Database object. + @Input({ required: true }) mode!: AddonModDataTemplateMode; // The render mode. + @Input({ required: true }) action!: AddonModDataAction; // The field to render. + @Input({ required: true }) entry!: AddonModDataEntry; // The value of the field. + @Input({ required: true }) database!: AddonModDataData; // Database object. @Input() title = ''; // Name of the module. @Input() group = 0; // Module group. @Input() offset?: number; // Offset of the entry. diff --git a/src/addons/mod/data/components/field-plugin/field-plugin.ts b/src/addons/mod/data/components/field-plugin/field-plugin.ts index 3527ccee39b..f364c1a6758 100644 --- a/src/addons/mod/data/components/field-plugin/field-plugin.ts +++ b/src/addons/mod/data/components/field-plugin/field-plugin.ts @@ -32,8 +32,8 @@ export class AddonModDataFieldPluginComponent implements OnInit, OnChanges { @ViewChild(CoreDynamicComponent) dynamicComponent?: CoreDynamicComponent; - @Input() mode!: AddonModDataTemplateMode; // The render mode. - @Input() field!: AddonModDataField; // The field to render. + @Input({ required: true }) mode!: AddonModDataTemplateMode; // The render mode. + @Input({ required: true }) field!: AddonModDataField; // The field to render. @Input() value?: unknown; // The value of the field. @Input() database?: AddonModDataData; // Database object. @Input() error?: string; // Error when editing. diff --git a/src/addons/mod/data/components/search-modal/search-modal.ts b/src/addons/mod/data/components/search-modal/search-modal.ts index 2867c9feade..9f7cf1086d3 100644 --- a/src/addons/mod/data/components/search-modal/search-modal.ts +++ b/src/addons/mod/data/components/search-modal/search-modal.ts @@ -50,9 +50,9 @@ export class AddonModDataSearchModalComponent implements OnInit { @ViewChild('searchFormEl') formElement!: ElementRef; - @Input() search!: AddonModDataSearchDataParams; - @Input() fields!: Record; - @Input() database!: AddonModDataData; + @Input({ required: true }) search!: AddonModDataSearchDataParams; + @Input({ required: true }) fields!: Record; + @Input({ required: true }) database!: AddonModDataData; advancedSearch = ''; advancedIndexed: CoreFormFields = {}; diff --git a/src/addons/mod/forum/components/discussion-options-menu/discussion-options-menu.ts b/src/addons/mod/forum/components/discussion-options-menu/discussion-options-menu.ts index 0eb646d2de3..91e3041fa8d 100644 --- a/src/addons/mod/forum/components/discussion-options-menu/discussion-options-menu.ts +++ b/src/addons/mod/forum/components/discussion-options-menu/discussion-options-menu.ts @@ -30,9 +30,9 @@ import { CoreToasts } from '@services/toasts'; }) export class AddonModForumDiscussionOptionsMenuComponent implements OnInit { - @Input() discussion!: AddonModForumDiscussion; // The discussion. - @Input() forumId!: number; // The forum Id. - @Input() cmId!: number; // The component module Id. + @Input({ required: true }) discussion!: AddonModForumDiscussion; // The discussion. + @Input({ required: true }) forumId!: number; // The forum Id. + @Input({ required: true }) cmId!: number; // The component module Id. canPin = false; diff --git a/src/addons/mod/forum/components/post-options-menu/post-options-menu.ts b/src/addons/mod/forum/components/post-options-menu/post-options-menu.ts index 8dccdcb0250..e7f44e28bc2 100644 --- a/src/addons/mod/forum/components/post-options-menu/post-options-menu.ts +++ b/src/addons/mod/forum/components/post-options-menu/post-options-menu.ts @@ -30,9 +30,9 @@ import { CoreNetworkError } from '@classes/errors/network-error'; }) export class AddonModForumPostOptionsMenuComponent implements OnInit { - @Input() post!: AddonModForumPost; // The post. - @Input() cmId!: number; - @Input() forumId!: number; // The forum Id. + @Input({ required: true }) post!: AddonModForumPost; // The post. + @Input({ required: true }) cmId!: number; + @Input({ required: true }) forumId!: number; // The forum Id. canEdit = false; canDelete = false; diff --git a/src/addons/mod/forum/components/post/post.ts b/src/addons/mod/forum/components/post/post.ts index 75978267557..0662f5a3221 100644 --- a/src/addons/mod/forum/components/post/post.ts +++ b/src/addons/mod/forum/components/post/post.ts @@ -54,6 +54,7 @@ import { CoreDom } from '@singletons/dom'; import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics'; import { ADDON_MOD_FORUM_CHANGE_DISCUSSION_EVENT, ADDON_MOD_FORUM_COMPONENT } from '../../constants'; import { CoreToasts } from '@services/toasts'; +import { toBoolean } from '@/core/transforms/boolean'; /** * Components that shows a discussion post, its attachments and the action buttons allowed (reply, etc.). @@ -65,21 +66,21 @@ import { CoreToasts } from '@services/toasts'; }) export class AddonModForumPostComponent implements OnInit, OnDestroy, OnChanges { - @Input() post!: AddonModForumPost; // Post. - @Input() courseId!: number; // Post's course ID. - @Input() discussionId!: number; // Post's' discussion ID. + @Input({ required: true }) post!: AddonModForumPost; // Post. + @Input({ required: true }) courseId!: number; // Post's course ID. + @Input({ required: true }) discussionId!: number; // Post's' discussion ID. @Input() discussion?: AddonModForumDiscussion; // Post's' discussion, only for starting posts. - @Input() component!: string; // Component this post belong to. - @Input() componentId!: number; // Component ID. - @Input() formData!: AddonModForumSharedPostFormData; // Object with the new post data. Usually shared between posts. - @Input() originalData!: Omit; // Original post data. Usually shared between posts. - @Input() trackPosts!: boolean; // True if post is being tracked. - @Input() forum!: AddonModForumData; // The forum the post belongs to. Required for attachments and offline posts. - @Input() accessInfo!: AddonModForumAccessInformation; // Forum access information. + @Input({ required: true }) component!: string; // Component this post belong to. + @Input({ required: true }) componentId!: number; // Component ID. + @Input({ required: true }) formData!: AddonModForumSharedPostFormData; // New post data. Usually shared between posts. + @Input({ required: true }) originalData!: Omit; // Original data. Usually shared between posts. + @Input({ required: true, transform: toBoolean }) trackPosts = false; // True if post is being tracked. + @Input({ required: true }) forum!: AddonModForumData; // The forum the post belongs to. + @Input({ required: true }) accessInfo!: AddonModForumAccessInformation; // Forum access information. @Input() parentSubject?: string; // Subject of parent post. @Input() ratingInfo?: CoreRatingInfo; // Rating info item. - @Input() leavingPage?: boolean; // Whether the page that contains this post is being left and will be destroyed. - @Input() highlight = false; + @Input({ transform: toBoolean }) leavingPage = false; // Whether the page that contains this post is being left. + @Input({ transform: toBoolean }) highlight = false; @Output() onPostChange: EventEmitter = new EventEmitter(); // Event emitted when a reply is posted or modified. @ViewChild('replyFormEl') formElement!: ElementRef; diff --git a/src/addons/mod/quiz/accessrules/offlineattempts/component/offlineattempts.ts b/src/addons/mod/quiz/accessrules/offlineattempts/component/offlineattempts.ts index ea9238e3ebe..bcf26e13718 100644 --- a/src/addons/mod/quiz/accessrules/offlineattempts/component/offlineattempts.ts +++ b/src/addons/mod/quiz/accessrules/offlineattempts/component/offlineattempts.ts @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +import { toBoolean } from '@/core/transforms/boolean'; import { AddonModQuizAttemptWSData, AddonModQuizQuizWSData } from '@addons/mod/quiz/services/quiz'; import { AddonModQuizSync } from '@addons/mod/quiz/services/quiz-sync'; import { Component, OnInit, Input } from '@angular/core'; @@ -29,7 +30,7 @@ export class AddonModQuizAccessOfflineAttemptsComponent implements OnInit { @Input() rule?: string; // The name of the rule. @Input() quiz?: AddonModQuizQuizWSData; // The quiz the rule belongs to. @Input() attempt?: AddonModQuizAttemptWSData; // The attempt being started/continued. - @Input() prefetch?: boolean; // Whether the user is prefetching the quiz. + @Input({ transform: toBoolean }) prefetch = false; // Whether the user is prefetching the quiz. @Input() siteId?: string; // Site ID. @Input() form?: FormGroup; // Form where to add the form control. diff --git a/src/addons/mod/quiz/accessrules/password/component/password.ts b/src/addons/mod/quiz/accessrules/password/component/password.ts index 77ce32ac58f..65e3215dcbc 100644 --- a/src/addons/mod/quiz/accessrules/password/component/password.ts +++ b/src/addons/mod/quiz/accessrules/password/component/password.ts @@ -16,6 +16,7 @@ import { Component, OnInit, Input } from '@angular/core'; import { FormGroup, FormBuilder } from '@angular/forms'; import { AddonModQuizAttemptWSData, AddonModQuizQuizWSData } from '@addons/mod/quiz/services/quiz'; +import { toBoolean } from '@/core/transforms/boolean'; /** * Component to render the preflight for password. @@ -29,7 +30,7 @@ export class AddonModQuizAccessPasswordComponent implements OnInit { @Input() rule?: string; // The name of the rule. @Input() quiz?: AddonModQuizQuizWSData; // The quiz the rule belongs to. @Input() attempt?: AddonModQuizAttemptWSData; // The attempt being started/continued. - @Input() prefetch?: boolean; // Whether the user is prefetching the quiz. + @Input({ transform: toBoolean }) prefetch = false; // Whether the user is prefetching the quiz. @Input() siteId?: string; // Site ID. @Input() form?: FormGroup; // Form where to add the form control. diff --git a/src/addons/mod/quiz/accessrules/timelimit/component/timelimit.ts b/src/addons/mod/quiz/accessrules/timelimit/component/timelimit.ts index b66ae5b3c00..b702e889adb 100644 --- a/src/addons/mod/quiz/accessrules/timelimit/component/timelimit.ts +++ b/src/addons/mod/quiz/accessrules/timelimit/component/timelimit.ts @@ -17,6 +17,7 @@ import { FormGroup } from '@angular/forms'; import { AddonModQuizAttemptWSData, AddonModQuizQuizWSData } from '@addons/mod/quiz/services/quiz'; import { CoreTime } from '@singletons/time'; +import { toBoolean } from '@/core/transforms/boolean'; /** * Component to render the preflight for time limit. @@ -30,7 +31,7 @@ export class AddonModQuizAccessTimeLimitComponent implements OnInit { @Input() rule?: string; // The name of the rule. @Input() quiz?: AddonModQuizQuizWSData; // The quiz the rule belongs to. @Input() attempt?: AddonModQuizAttemptWSData; // The attempt being started/continued. - @Input() prefetch?: boolean; // Whether the user is prefetching the quiz. + @Input({ transform: toBoolean }) prefetch = false; // Whether the user is prefetching the quiz. @Input() siteId?: string; // Site ID. @Input() form?: FormGroup; // Form where to add the form control. diff --git a/src/addons/mod/quiz/components/attempt-info/attempt-info.ts b/src/addons/mod/quiz/components/attempt-info/attempt-info.ts index 25c0498aca0..4e6ef30c63f 100644 --- a/src/addons/mod/quiz/components/attempt-info/attempt-info.ts +++ b/src/addons/mod/quiz/components/attempt-info/attempt-info.ts @@ -30,8 +30,8 @@ import { isSafeNumber } from '@/core/utils/types'; }) export class AddonModQuizAttemptInfoComponent implements OnChanges { - @Input() quiz!: AddonModQuizQuizData; - @Input() attempt!: AddonModQuizAttempt; + @Input({ required: true }) quiz!: AddonModQuizQuizData; + @Input({ required: true }) attempt!: AddonModQuizAttempt; @Input() additionalData?: AddonModQuizWSAdditionalData[]; // Additional data to display for the attempt. isFinished = false; diff --git a/src/addons/mod/quiz/components/attempt-state/attempt-state.ts b/src/addons/mod/quiz/components/attempt-state/attempt-state.ts index dd165198a5f..11bae29dfcd 100644 --- a/src/addons/mod/quiz/components/attempt-state/attempt-state.ts +++ b/src/addons/mod/quiz/components/attempt-state/attempt-state.ts @@ -14,6 +14,7 @@ import { Component, Input, OnChanges } from '@angular/core'; import { AddonModQuiz } from '../../services/quiz'; +import { toBoolean } from '@/core/transforms/boolean'; /** * Component that displays an attempt state. @@ -26,7 +27,7 @@ import { AddonModQuiz } from '../../services/quiz'; export class AddonModQuizAttemptStateComponent implements OnChanges { @Input() state = ''; - @Input() finishedOffline = false; + @Input({ transform: toBoolean }) finishedOffline = false; readableState = ''; color = ''; diff --git a/src/addons/mod/quiz/components/navigation-modal/navigation-modal.ts b/src/addons/mod/quiz/components/navigation-modal/navigation-modal.ts index 1b71ea075d6..5950c7b0488 100644 --- a/src/addons/mod/quiz/components/navigation-modal/navigation-modal.ts +++ b/src/addons/mod/quiz/components/navigation-modal/navigation-modal.ts @@ -13,6 +13,7 @@ // limitations under the License. import { CoreSharedModule } from '@/core/shared.module'; +import { toBoolean } from '@/core/transforms/boolean'; import { Component, Input } from '@angular/core'; import { CoreQuestionQuestionParsed } from '@features/question/services/question'; @@ -32,11 +33,11 @@ import { ModalController } from '@singletons'; export class AddonModQuizNavigationModalComponent { @Input() navigation?: AddonModQuizNavigationQuestion[]; // Whether the user is reviewing the attempt. - @Input() summaryShown?: boolean; // Whether summary is currently being shown. + @Input({ transform: toBoolean }) summaryShown = false; // Whether summary is currently being shown. @Input() nextPage?: number; // Next page. @Input() currentPage?: number; // Current page. - @Input() isReview?: boolean; // Whether the user is reviewing the attempt. - @Input() isSequential?: boolean; // Whether quiz navigation is sequential. + @Input({ transform: toBoolean }) isReview = false; // Whether the user is reviewing the attempt. + @Input({ transform: toBoolean }) isSequential = false; // Whether quiz navigation is sequential. /** * Close modal. diff --git a/src/addons/mod/quiz/components/preflight-modal/preflight-modal.ts b/src/addons/mod/quiz/components/preflight-modal/preflight-modal.ts index 4ec740b22f7..975f4ae429a 100644 --- a/src/addons/mod/quiz/components/preflight-modal/preflight-modal.ts +++ b/src/addons/mod/quiz/components/preflight-modal/preflight-modal.ts @@ -23,6 +23,7 @@ import { AddonModQuizAccessRuleDelegate } from '../../services/access-rules-dele import { AddonModQuizAttemptWSData, AddonModQuizQuizWSData } from '../../services/quiz'; import { CoreDom } from '@singletons/dom'; import { CoreSharedModule } from '@/core/shared.module'; +import { toBoolean } from '@/core/transforms/boolean'; /** * Modal that renders the access rules for a quiz. @@ -39,12 +40,12 @@ export class AddonModQuizPreflightModalComponent implements OnInit { @ViewChild('preflightFormEl') formElement?: ElementRef; - @Input() title!: string; + @Input({ required: true }) title!: string; @Input() quiz?: AddonModQuizQuizWSData; @Input() attempt?: AddonModQuizAttemptWSData; - @Input() prefetch?: boolean; - @Input() siteId!: string; - @Input() rules!: string[]; + @Input({ transform: toBoolean }) prefetch = false; + @Input({ required: true }) siteId!: string; + @Input({ required: true }) rules!: string[]; preflightForm: FormGroup; accessRulesData: { component: Type; data: Record}[] = []; // Component and data for each access rule. diff --git a/src/addons/mod/quiz/components/question-card/question-card.ts b/src/addons/mod/quiz/components/question-card/question-card.ts index 0f6c4c87aa2..b89c912cb4a 100644 --- a/src/addons/mod/quiz/components/question-card/question-card.ts +++ b/src/addons/mod/quiz/components/question-card/question-card.ts @@ -25,6 +25,6 @@ import { CoreQuestionQuestionForView } from '@features/question/services/questio }) export class AddonModQuizQuestionCardComponent { - @Input() question!: CoreQuestionQuestionForView; + @Input({ required: true }) question!: CoreQuestionQuestionForView; } diff --git a/src/addons/mod/scorm/components/toc/toc.ts b/src/addons/mod/scorm/components/toc/toc.ts index 42199ba110c..f91d0bbcf83 100644 --- a/src/addons/mod/scorm/components/toc/toc.ts +++ b/src/addons/mod/scorm/components/toc/toc.ts @@ -35,9 +35,9 @@ export class AddonModScormTocComponent implements OnInit { @Input() toc: AddonModScormTOCScoWithIcon[] = []; @Input() attemptToContinue?: number; @Input() selected?: number; - @Input() moduleId!: number; - @Input() courseId!: number; - @Input() accessInfo!: AddonModScormGetScormAccessInformationWSResponse; + @Input({ required: true }) moduleId!: number; + @Input({ required: true }) courseId!: number; + @Input({ required: true }) accessInfo!: AddonModScormGetScormAccessInformationWSResponse; @Input() mode = ''; isBrowse = false; diff --git a/src/addons/mod/wiki/components/subwiki-picker/subwiki-picker.ts b/src/addons/mod/wiki/components/subwiki-picker/subwiki-picker.ts index 878d918d311..adfb4821ad2 100644 --- a/src/addons/mod/wiki/components/subwiki-picker/subwiki-picker.ts +++ b/src/addons/mod/wiki/components/subwiki-picker/subwiki-picker.ts @@ -32,7 +32,7 @@ export class AddonModWikiSubwikiPickerComponent { @Input() courseId?: number; @Input() subwikis: AddonModWikiSubwikiListGrouping[] = []; - @Input() currentSubwiki!: AddonModWikiSubwiki; + @Input({ required: true }) currentSubwiki!: AddonModWikiSubwiki; /** * Checks if the given subwiki is the one currently selected. diff --git a/src/addons/mod/workshop/classes/assessment-strategy-component.ts b/src/addons/mod/workshop/classes/assessment-strategy-component.ts index 1e9c85548bf..d9ffa86267b 100644 --- a/src/addons/mod/workshop/classes/assessment-strategy-component.ts +++ b/src/addons/mod/workshop/classes/assessment-strategy-component.ts @@ -15,6 +15,7 @@ import { Component, Input } from '@angular/core'; import { AddonModWorkshopGetAssessmentFormFieldsParsedData } from '../services/workshop'; import { AddonModWorkshopSubmissionAssessmentWithFormData } from '../services/workshop-helper'; +import { toBoolean } from '@/core/transforms/boolean'; /** * Base class for component to render an assessment strategy. @@ -24,13 +25,13 @@ import { AddonModWorkshopSubmissionAssessmentWithFormData } from '../services/wo }) export class AddonModWorkshopAssessmentStrategyBaseComponent { - @Input() workshopId!: number; - @Input() assessment!: AddonModWorkshopSubmissionAssessmentWithFormData; - @Input() edit!: boolean; - @Input() selectedValues!: AddonModWorkshopGetAssessmentFormFieldsParsedData[]; - @Input() fieldErrors!: Record; - @Input() strategy!: string; - @Input() moduleId!: number; + @Input({ required: true }) workshopId!: number; + @Input({ required: true }) assessment!: AddonModWorkshopSubmissionAssessmentWithFormData; + @Input({ required: true, transform: toBoolean }) edit = false; + @Input({ required: true }) selectedValues!: AddonModWorkshopGetAssessmentFormFieldsParsedData[]; + @Input({ required: true }) fieldErrors!: Record; + @Input({ required: true }) strategy!: string; + @Input({ required: true }) moduleId!: number; @Input() courseId?: number; } diff --git a/src/addons/mod/workshop/components/assessment-strategy/assessment-strategy.ts b/src/addons/mod/workshop/components/assessment-strategy/assessment-strategy.ts index 503174cf52e..1c190804777 100644 --- a/src/addons/mod/workshop/components/assessment-strategy/assessment-strategy.ts +++ b/src/addons/mod/workshop/components/assessment-strategy/assessment-strategy.ts @@ -42,6 +42,7 @@ import { ADDON_MOD_WORKSHOP_COMPONENT, AddonModWorkshopOverallFeedbackMode, } from '@addons/mod/workshop/constants'; +import { toBoolean } from '@/core/transforms/boolean'; /** * Component that displays workshop assessment strategy form. @@ -52,12 +53,12 @@ import { }) export class AddonModWorkshopAssessmentStrategyComponent implements OnInit, OnDestroy { - @Input() workshop!: AddonModWorkshopData; - @Input() access!: AddonModWorkshopGetWorkshopAccessInformationWSResponse; - @Input() assessmentId!: number; - @Input() userId!: number; - @Input() strategy!: string; - @Input() edit = false; + @Input({ required: true }) workshop!: AddonModWorkshopData; + @Input({ required: true }) access!: AddonModWorkshopGetWorkshopAccessInformationWSResponse; + @Input({ required: true }) assessmentId!: number; + @Input({ required: true }) userId!: number; + @Input({ required: true }) strategy!: string; + @Input({ transform: toBoolean }) edit = false; @ViewChild('assessmentForm') formElement!: ElementRef; diff --git a/src/addons/mod/workshop/components/assessment/assessment.ts b/src/addons/mod/workshop/components/assessment/assessment.ts index 1e6464bc073..6fac33bd21b 100644 --- a/src/addons/mod/workshop/components/assessment/assessment.ts +++ b/src/addons/mod/workshop/components/assessment/assessment.ts @@ -36,12 +36,12 @@ import { AddonModWorkshopOffline } from '../../services/workshop-offline'; }) export class AddonModWorkshopAssessmentComponent implements OnInit { - @Input() assessment!: AddonModWorkshopSubmissionAssessmentWithFormData; - @Input() courseId!: number; - @Input() workshop!: AddonModWorkshopData; - @Input() access!: AddonModWorkshopGetWorkshopAccessInformationWSResponse; - @Input() submission!: AddonModWorkshopSubmissionDataWithOfflineData; - @Input() module!: CoreCourseModuleData; + @Input({ required: true }) assessment!: AddonModWorkshopSubmissionAssessmentWithFormData; + @Input({ required: true }) courseId!: number; + @Input({ required: true }) workshop!: AddonModWorkshopData; + @Input({ required: true }) access!: AddonModWorkshopGetWorkshopAccessInformationWSResponse; + @Input({ required: true }) submission!: AddonModWorkshopSubmissionDataWithOfflineData; + @Input({ required: true }) module!: CoreCourseModuleData; canViewAssessment = false; canSelfAssess = false; diff --git a/src/addons/mod/workshop/components/phase-modal/phase-modal.ts b/src/addons/mod/workshop/components/phase-modal/phase-modal.ts index 95bc52faabc..a6a138526ec 100644 --- a/src/addons/mod/workshop/components/phase-modal/phase-modal.ts +++ b/src/addons/mod/workshop/components/phase-modal/phase-modal.ts @@ -18,6 +18,7 @@ import { ModalController } from '@singletons'; import { AddonModWorkshopPhaseData, AddonModWorkshopPhaseTaskData } from '../../services/workshop'; import { AddonModWorkshopPhase } from '../../constants'; import { CoreSharedModule } from '@/core/shared.module'; +import { toBoolean } from '@/core/transforms/boolean'; /** * Page that displays the phase info modal. @@ -31,10 +32,10 @@ import { CoreSharedModule } from '@/core/shared.module'; }) export class AddonModWorkshopPhaseInfoModalComponent implements OnInit { - @Input() phases!: AddonModWorkshopPhaseDataWithSwitch[]; - @Input() workshopPhase!: AddonModWorkshopPhase; - @Input() showSubmit = false; - @Input() externalUrl!: string; + @Input({ required: true }) phases!: AddonModWorkshopPhaseDataWithSwitch[]; + @Input({ required: true }) workshopPhase!: AddonModWorkshopPhase; + @Input({ transform: toBoolean }) showSubmit = false; + @Input({ required: true }) externalUrl!: string; ngOnInit(): void { diff --git a/src/addons/mod/workshop/components/submission/submission.ts b/src/addons/mod/workshop/components/submission/submission.ts index 53ae4a89150..0b3481f0958 100644 --- a/src/addons/mod/workshop/components/submission/submission.ts +++ b/src/addons/mod/workshop/components/submission/submission.ts @@ -30,6 +30,7 @@ import { } from '../../services/workshop-helper'; import { AddonModWorkshopOffline } from '../../services/workshop-offline'; import { ADDON_MOD_WORKSHOP_COMPONENT, ADDON_MOD_WORKSHOP_PAGE_NAME, AddonModWorkshopPhase } from '@addons/mod/workshop/constants'; +import { toBoolean } from '@/core/transforms/boolean'; /** * Component that displays workshop submission. @@ -41,13 +42,13 @@ import { ADDON_MOD_WORKSHOP_COMPONENT, ADDON_MOD_WORKSHOP_PAGE_NAME, AddonModWor }) export class AddonModWorkshopSubmissionComponent implements OnInit { - @Input() submission!: AddonModWorkshopSubmissionDataWithOfflineData; - @Input() module!: CoreCourseModuleData; - @Input() workshop!: AddonModWorkshopData; - @Input() access!: AddonModWorkshopGetWorkshopAccessInformationWSResponse; - @Input() courseId!: number; + @Input({ required: true }) submission!: AddonModWorkshopSubmissionDataWithOfflineData; + @Input({ required: true }) module!: CoreCourseModuleData; + @Input({ required: true }) workshop!: AddonModWorkshopData; + @Input({ required: true }) access!: AddonModWorkshopGetWorkshopAccessInformationWSResponse; + @Input({ required: true }) courseId!: number; @Input() assessment?: AddonModWorkshopSubmissionAssessmentWithFormData; - @Input() summary = false; + @Input({ transform: toBoolean }) summary = false; component = ADDON_MOD_WORKSHOP_COMPONENT; componentId?: number; diff --git a/src/addons/mod/workshop/pages/submission/submission.html b/src/addons/mod/workshop/pages/submission/submission.html index dde29a6976a..0a4ed502901 100644 --- a/src/addons/mod/workshop/pages/submission/submission.html +++ b/src/addons/mod/workshop/pages/submission/submission.html @@ -88,8 +88,8 @@

{{ 'addon.mod_workshop.receivedgrades' | translate }}

{{ 'addon.mod_workshop.givengrades' | translate }}

- +
diff --git a/src/addons/notes/components/add/add-modal.ts b/src/addons/notes/components/add/add-modal.ts index 337b97dc67e..c4c12b786ca 100644 --- a/src/addons/notes/components/add/add-modal.ts +++ b/src/addons/notes/components/add/add-modal.ts @@ -36,7 +36,7 @@ export class AddonNotesAddComponent { @ViewChild('itemEdit') formElement?: ElementRef; - @Input() courseId!: number; + @Input({ required: true }) courseId!: number; @Input() userId?: number; @Input() type: AddonNotesPublishState = 'personal'; text = ''; diff --git a/src/addons/qbehaviour/deferredcbm/component/deferredcbm.ts b/src/addons/qbehaviour/deferredcbm/component/deferredcbm.ts index ab931d06ad1..3214d423226 100644 --- a/src/addons/qbehaviour/deferredcbm/component/deferredcbm.ts +++ b/src/addons/qbehaviour/deferredcbm/component/deferredcbm.ts @@ -13,6 +13,7 @@ // limitations under the License. import { ContextLevel } from '@/core/constants'; +import { toBoolean } from '@/core/transforms/boolean'; import { Component, Input, Output, EventEmitter } from '@angular/core'; import { CoreQuestionBehaviourButton, CoreQuestionQuestion } from '@features/question/services/question-helper'; @@ -30,11 +31,11 @@ export class AddonQbehaviourDeferredCBMComponent { @Input() component?: string; // The component the question belongs to. @Input() componentId?: number; // ID of the component the question belongs to. @Input() attemptId?: number; // Attempt ID. - @Input() offlineEnabled?: boolean | string; // Whether the question can be answered in offline. + @Input({ transform: toBoolean }) offlineEnabled = false; // Whether the question can be answered in offline. @Input() contextLevel?: ContextLevel; // The context level. @Input() contextInstanceId?: number; // The instance ID related to the context. @Input() courseId?: number; // Course ID the question belongs to (if any). It can be used to improve performance with filters. - @Input() review?: boolean; // Whether the user is in review mode. + @Input({ transform: toBoolean }) review = false; // Whether the user is in review mode. @Input() preferredBehaviour?: string; // Preferred behaviour. @Output() buttonClicked = new EventEmitter(); // Will emit when a behaviour button is clicked. @Output() onAbort = new EventEmitter(); // Should emit an event if the question should be aborted. diff --git a/src/addons/qbehaviour/informationitem/component/informationitem.ts b/src/addons/qbehaviour/informationitem/component/informationitem.ts index f3a6a64a200..1dd6717c380 100644 --- a/src/addons/qbehaviour/informationitem/component/informationitem.ts +++ b/src/addons/qbehaviour/informationitem/component/informationitem.ts @@ -13,6 +13,7 @@ // limitations under the License. import { ContextLevel } from '@/core/constants'; +import { toBoolean } from '@/core/transforms/boolean'; import { Component, Input, Output, EventEmitter } from '@angular/core'; import { CoreQuestionBehaviourButton, CoreQuestionQuestion } from '@features/question/services/question-helper'; @@ -30,11 +31,11 @@ export class AddonQbehaviourInformationItemComponent { @Input() component?: string; // The component the question belongs to. @Input() componentId?: number; // ID of the component the question belongs to. @Input() attemptId?: number; // Attempt ID. - @Input() offlineEnabled?: boolean | string; // Whether the question can be answered in offline. + @Input({ transform: toBoolean }) offlineEnabled = false; // Whether the question can be answered in offline. @Input() contextLevel?: ContextLevel; // The context level. @Input() contextInstanceId?: number; // The instance ID related to the context. @Input() courseId?: number; // Course ID the question belongs to (if any). It can be used to improve performance with filters. - @Input() review?: boolean; // Whether the user is in review mode. + @Input({ transform: toBoolean }) review = false; // Whether the user is in review mode. @Input() preferredBehaviour?: string; // Preferred behaviour. @Output() buttonClicked = new EventEmitter(); // Will emit when a behaviour button is clicked. @Output() onAbort = new EventEmitter(); // Should emit an event if the question should be aborted. diff --git a/src/core/classes/tabs.ts b/src/core/classes/tabs.ts index 08d76b5648a..cf0b196146e 100644 --- a/src/core/classes/tabs.ts +++ b/src/core/classes/tabs.ts @@ -39,6 +39,7 @@ import { CoreDirectivesRegistry } from '@singletons/directives-registry'; import { Swiper } from 'swiper'; import { SwiperOptions } from 'swiper/types'; import { CoreSwiper } from '@singletons/swiper'; +import { toBoolean } from '../transforms/boolean'; /** * Class to abstract some common code for tabs. @@ -52,7 +53,7 @@ export class CoreTabsBaseComponent implements AfterViewIn protected static readonly MIN_TAB_WIDTH = 107; @Input() selectedIndex = 0; // Index of the tab to select. - @Input() hideUntil = false; // Determine when should the contents be shown. + @Input({ transform: toBoolean }) hideUntil = false; // Determine when should the contents be shown. @Output() protected ionChange = new EventEmitter(); // Emitted when the tab changes. protected swiper?: Swiper; diff --git a/src/core/components/attachments/attachments.ts b/src/core/components/attachments/attachments.ts index ca67ff38a0d..c844e8206f9 100644 --- a/src/core/components/attachments/attachments.ts +++ b/src/core/components/attachments/attachments.ts @@ -25,6 +25,7 @@ import { CoreFileUploaderHelper } from '@features/fileuploader/services/fileuplo import { CoreFileEntry } from '@services/file-helper'; import { CoreCourses } from '@features/courses/services/courses'; import { CoreUtils } from '@services/utils/utils'; +import { toBoolean } from '@/core/transforms/boolean'; /** * Component to render attachments, allow adding more and delete the current ones. @@ -51,9 +52,9 @@ export class CoreAttachmentsComponent implements OnInit { @Input() maxSubmissions?: number; // Max number of attachments. -1 means unlimited, not defined means unknown limit. @Input() component?: string; // Component the downloaded files will be linked to. @Input() componentId?: string | number; // Component ID. - @Input() allowOffline?: boolean | string; // Whether to allow selecting files in offline. + @Input({ transform: toBoolean }) allowOffline = false; // Whether to allow selecting files in offline. @Input() acceptedTypes?: string; // List of supported filetypes. If undefined, all types supported. - @Input() required?: boolean; // Whether to display the required mark. + @Input({ transform: toBoolean }) required = false; // Whether to display the required mark. @Input() courseId?: number; // Course ID. @Input() title = Translate.instant('core.fileuploader.attachedfiles'); // Title to display. @@ -131,9 +132,7 @@ export class CoreAttachmentsComponent implements OnInit { * Add a new attachment. */ async add(): Promise { - const allowOffline = !!this.allowOffline && this.allowOffline !== 'false'; - - if (!allowOffline && !CoreNetwork.isOnline()) { + if (!this.allowOffline && !CoreNetwork.isOnline()) { CoreDomUtils.showErrorModal('core.fileuploader.errormustbeonlinetoupload', true); return; @@ -142,7 +141,7 @@ export class CoreAttachmentsComponent implements OnInit { const mimetypes = this.fileTypes && this.fileTypes.mimetypes; try { - const result = await CoreFileUploaderHelper.selectFile(this.maxSize, allowOffline, undefined, mimetypes); + const result = await CoreFileUploaderHelper.selectFile(this.maxSize, this.allowOffline, undefined, mimetypes); this.files?.push(result); } catch (error) { diff --git a/src/core/components/bs-tooltip/bs-tooltip.ts b/src/core/components/bs-tooltip/bs-tooltip.ts index f3738b099bb..3e7825ddb9b 100644 --- a/src/core/components/bs-tooltip/bs-tooltip.ts +++ b/src/core/components/bs-tooltip/bs-tooltip.ts @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +import { toBoolean } from '@/core/transforms/boolean'; import { Component, Input } from '@angular/core'; /** @@ -24,6 +25,6 @@ import { Component, Input } from '@angular/core'; export class CoreBSTooltipComponent { @Input() content = ''; - @Input() html?: boolean; + @Input({ transform: toBoolean }) html = false; } diff --git a/src/core/components/button-with-spinner/button-with-spinner.ts b/src/core/components/button-with-spinner/button-with-spinner.ts index 76cfa0c5c7a..ab6b611e782 100644 --- a/src/core/components/button-with-spinner/button-with-spinner.ts +++ b/src/core/components/button-with-spinner/button-with-spinner.ts @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +import { toBoolean } from '@/core/transforms/boolean'; import { Component, Input } from '@angular/core'; import { CoreAnimations } from '@components/animations'; @@ -31,7 +32,7 @@ import { CoreAnimations } from '@components/animations'; }) export class CoreButtonWithSpinnerComponent { - @Input() loading = true; + @Input({ transform: toBoolean }) loading = true; @Input() loadingLabel = 'core.loading'; } diff --git a/src/core/components/chart/chart.ts b/src/core/components/chart/chart.ts index dd566186dab..5f5affbd38b 100644 --- a/src/core/components/chart/chart.ts +++ b/src/core/components/chart/chart.ts @@ -13,10 +13,10 @@ // limitations under the License. import { ContextLevel } from '@/core/constants'; +import { toBoolean } from '@/core/transforms/boolean'; import { Component, Input, OnDestroy, OnInit, ElementRef, OnChanges, ViewChild, SimpleChange } from '@angular/core'; import { CoreFilter } from '@features/filter/services/filter'; import { CoreFilterHelper } from '@features/filter/services/filter-helper'; -import { CoreUtils } from '@services/utils/utils'; import { ChartLegendLabelItem, ChartLegendOptions } from 'chart.js'; /** @@ -50,11 +50,12 @@ export class CoreChartComponent implements OnDestroy, OnInit, OnChanges { @Input() type?: string; // Type of chart. @Input() legend?: ChartLegendOptions; // Legend options. @Input() height = 300; // Height of the chart element. - @Input() filter?: boolean | string; // Whether to filter labels. If not defined, true if contextLevel and instanceId are set. + @Input({ transform: toBoolean }) filter?: boolean; // Whether to filter labels. + // If not defined, true if contextLevel and instanceId are set. @Input() contextLevel?: ContextLevel; // The context level of the text. @Input() contextInstanceId?: number; // The instance ID related to the context. @Input() courseId?: number; // Course ID the text belongs to. It can be used to improve performance with filters. - @Input() wsNotFiltered?: boolean | string; // If true it means the WS didn't filter the labels for some reason. + @Input({ transform: toBoolean }) wsNotFiltered = false; // If true it means the WS didn't filter the labels for some reason. @ViewChild('canvas') canvas?: ElementRef; chart?: ChartWithLegend; @@ -158,7 +159,7 @@ export class CoreChartComponent implements OnDestroy, OnInit, OnChanges { clean: true, singleLine: true, courseId: this.courseId, - wsNotFiltered: CoreUtils.isTrueOrOne(this.wsNotFiltered), + wsNotFiltered: this.wsNotFiltered, }; const filters = await CoreFilterHelper.getFilters(this.contextLevel, this.contextInstanceId, options); diff --git a/src/core/components/chrono/chrono.ts b/src/core/components/chrono/chrono.ts index 0604cc65e66..18823991dbc 100644 --- a/src/core/components/chrono/chrono.ts +++ b/src/core/components/chrono/chrono.ts @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +import { toBoolean } from '@/core/transforms/boolean'; import { Component, Input, @@ -42,11 +43,11 @@ import { }) export class CoreChronoComponent implements OnInit, OnChanges, OnDestroy { - @Input() running?: boolean; // Set it to true to start the chrono. Set it to false to stop it. + @Input({ transform: toBoolean }) running = false; // Set it to true to start the chrono. Set it to false to stop it. @Input() startTime = 0; // Number of milliseconds to put in the chrono before starting. @Input() endTime?: number; // Number of milliseconds to stop the chrono. - @Input() reset?: boolean; // Set it to true to reset the chrono. - @Input() hours = true; + @Input({ transform: toBoolean }) reset = false; // Set it to true to reset the chrono. + @Input({ transform: toBoolean }) hours = true; @Output() onEnd: EventEmitter; // Will emit an event when the endTime is reached. time = 0; diff --git a/src/core/components/combobox/combobox.ts b/src/core/components/combobox/combobox.ts index e85060584f6..51a8ee8a339 100644 --- a/src/core/components/combobox/combobox.ts +++ b/src/core/components/combobox/combobox.ts @@ -17,6 +17,7 @@ import { Translate } from '@singletons'; import { ModalOptions } from '@ionic/core'; import { CoreModals } from '@services/modals'; import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms'; +import { toBoolean } from '@/core/transforms/boolean'; /** * Component that show a combo select button (combobox). @@ -52,7 +53,7 @@ export class CoreComboboxComponent implements ControlValueAccessor { @Input() interface: 'popover' | 'modal' = 'popover'; @Input() label = Translate.instant('core.show'); // Aria label. - @Input() disabled = false; + @Input({ transform: toBoolean }) disabled = false; @Input() selection = ''; @Output() onChange = new EventEmitter(); // Will emit an event the value changed. diff --git a/src/core/components/context-menu/context-menu-item.ts b/src/core/components/context-menu/context-menu-item.ts index 25a2ab4d460..3008fc82d9b 100644 --- a/src/core/components/context-menu/context-menu-item.ts +++ b/src/core/components/context-menu/context-menu-item.ts @@ -14,6 +14,7 @@ import { Component, Input, Output, OnInit, OnDestroy, EventEmitter, OnChanges, SimpleChange } from '@angular/core'; import { CoreContextMenuComponent } from '../context-menu/context-menu'; +import { toBoolean } from '@/core/transforms/boolean'; /** * This directive adds a item to the Context Menu popover. @@ -40,19 +41,19 @@ export class CoreContextMenuItemComponent implements OnInit, OnDestroy, OnChange // If is "toggle" a toggle switch will be shown. // If no icon or spinner is selected, no action or link will work. // If href but no iconAction is provided arrow-right will be used. - @Input() iconSlash?: boolean; // Display a red slash over the icon. + @Input({ transform: toBoolean }) iconSlash = false; // Display a red slash over the icon. @Input() ariaAction?: string; // Aria label to add to iconAction. If not set, it will be equal to content. @Input() href?: string; // Link to go if no action provided. - @Input() captureLink?: boolean | string; // Whether the link needs to be captured by the app. - @Input() autoLogin: boolean | string = true; // Whether the link needs to be opened using auto-login. - @Input() closeOnClick = true; // Whether to close the popover when the item is clicked. + @Input({ transform: toBoolean }) captureLink = false; // Whether the link needs to be captured by the app. + @Input({ transform: toBoolean }) autoLogin = true; // Whether the link needs to be opened using auto-login. + @Input({ transform: toBoolean }) closeOnClick = true; // Whether to close the popover when the item is clicked. @Input() priority?: number; // Used to sort items. The highest priority, the highest position. @Input() badge?: string; // A badge to show in the item. @Input() badgeClass?: number; // A class to set in the badge. @Input() badgeA11yText?: string; // Description for the badge, if needed. - @Input() hidden?: boolean; // Whether the item should be hidden. - @Input() showBrowserWarning = true; // Whether to show a warning before opening browser (for links). Defaults to true. - @Input() toggle = false; // Whether the toggle is on or off. + @Input({ transform: toBoolean }) hidden = false; // Whether the item should be hidden. + @Input({ transform: toBoolean }) showBrowserWarning = true; // Whether to show a warning before opening browser (for links). + @Input({ transform: toBoolean }) toggle = false; // Whether the toggle is on or off. @Output() action?: EventEmitter<() => void>; // Will emit an event when the item clicked. @Output() onClosed?: EventEmitter<() => void>; // Will emit an event when the popover is closed because the item was clicked. @Output() toggleChange = new EventEmitter();// Will emit an event when toggle changes to enable 2-way data binding. @@ -94,10 +95,6 @@ export class CoreContextMenuItemComponent implements OnInit, OnDestroy, OnChange * @param event Event. */ toggleChanged(event: Event): void { - if (this.toggle === undefined) { - return; - } - event.preventDefault(); event.stopPropagation(); this.toggleChange.emit(this.toggle); diff --git a/src/core/components/course-image/course-image.html b/src/core/components/course-image/course-image.html index fee483a9d22..adc91885c63 100644 --- a/src/core/components/course-image/course-image.html +++ b/src/core/components/course-image/course-image.html @@ -1,4 +1,4 @@ -