From 3d7cfeba4237f85ff1ef589f53f77b60bee00239 Mon Sep 17 00:00:00 2001
From: Dani Palou
Date: Tue, 18 Jun 2024 15:35:07 +0200
Subject: [PATCH 1/5] MOBILE-4612 core: Mark required inputs in components
---
.../classes/base-feedback-plugin-component.ts | 8 ++++----
.../base-submission-plugin-component.ts | 6 +++---
.../edit-feedback-modal.ts | 8 ++++----
.../feedback-plugin/feedback-plugin.ts | 8 ++++----
.../submission-plugin/submission-plugin.ts | 6 +++---
.../components/submission/submission.ts | 6 +++---
.../components/users-modal/users-modal.ts | 4 ++--
.../classes/base-field-plugin-component.ts | 4 ++--
.../mod/data/components/action/action.ts | 8 ++++----
.../components/field-plugin/field-plugin.ts | 4 ++--
.../components/search-modal/search-modal.ts | 6 +++---
.../discussion-options-menu.ts | 6 +++---
.../post-options-menu/post-options-menu.ts | 6 +++---
src/addons/mod/forum/components/post/post.ts | 20 +++++++++----------
.../components/attempt-info/attempt-info.ts | 4 ++--
.../preflight-modal/preflight-modal.ts | 6 +++---
.../components/question-card/question-card.ts | 2 +-
src/addons/mod/scorm/components/toc/toc.ts | 6 +++---
.../subwiki-picker/subwiki-picker.ts | 2 +-
.../classes/assessment-strategy-component.ts | 14 ++++++-------
.../assessment-strategy.ts | 10 +++++-----
.../components/assessment/assessment.ts | 12 +++++------
.../components/phase-modal/phase-modal.ts | 6 +++---
.../components/submission/submission.ts | 10 +++++-----
.../workshop/pages/submission/submission.html | 4 ++--
src/addons/notes/components/add/add-modal.ts | 2 +-
.../components/course-image/course-image.ts | 2 +-
.../group-selector/group-selector.ts | 2 +-
.../infinite-loading/infinite-loading.ts | 2 +-
.../components/progress-bar/progress-bar.ts | 2 +-
.../components/sheet-modal/sheet-modal.ts | 2 +-
src/core/components/sites-list/sites-list.ts | 2 +-
src/core/components/tabs/tab.ts | 2 +-
src/core/directives/user-tour.ts | 2 +-
.../block/classes/base-block-component.ts | 8 ++++----
.../features/block/components/block/block.ts | 8 ++++----
.../side-blocks-button/side-blocks-button.ts | 4 ++--
.../components/side-blocks/side-blocks.ts | 4 ++--
.../comments/components/comments/comments.ts | 8 ++++----
.../components/compile-html/compile-html.ts | 2 +-
.../choose-site-modal/choose-site-modal.ts | 2 +-
.../course/classes/main-resource-component.ts | 4 ++--
.../components/course-format/course-format.ts | 2 +-
.../components/module-info/module-info.ts | 8 ++++----
.../module-navigation/module-navigation.ts | 4 ++--
.../course/components/module/module.ts | 2 +-
.../course-list-item/course-list-item.ts | 2 +-
.../course-options-menu.ts | 4 ++--
.../audio-histogram/audio-histogram.ts | 2 +-
.../exceeded-attempts/exceeded-attempts.ts | 2 +-
.../rating/components/aggregate/aggregate.ts | 12 +++++------
.../features/rating/components/rate/rate.ts | 18 ++++++++---------
.../rating/components/ratings/ratings.ts | 16 +++++++--------
.../components/report-column/report-column.ts | 12 +++++------
.../components/report-detail/report-detail.ts | 2 +-
.../report-summary/report-summary.ts | 2 +-
.../global-search-result.ts | 2 +-
.../siteplugins/classes/call-ws-directive.ts | 2 +-
.../assign-feedback/assign-feedback.ts | 8 ++++----
.../assign-submission/assign-submission.ts | 6 +++---
.../components/module-index/module-index.ts | 4 ++--
.../plugin-content/plugin-content.ts | 2 +-
.../workshop-assessment-strategy.ts | 14 ++++++-------
.../components/user-tour/user-tour.ts | 6 +++---
64 files changed, 183 insertions(+), 183 deletions(-)
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 31713b758..f2211a3bc 100644
--- a/src/addons/mod/assign/classes/base-feedback-plugin-component.ts
+++ b/src/addons/mod/assign/classes/base-feedback-plugin-component.ts
@@ -27,10 +27,10 @@ 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.
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 56f938d0b..b2251af07 100644
--- a/src/addons/mod/assign/classes/base-submission-plugin-component.ts
+++ b/src/addons/mod/assign/classes/base-submission-plugin-component.ts
@@ -23,9 +23,9 @@ 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.
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 35682d76f..aafd35365 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 136e991b5..dbec8e19d 100644
--- a/src/addons/mod/assign/components/feedback-plugin/feedback-plugin.ts
+++ b/src/addons/mod/assign/components/feedback-plugin/feedback-plugin.ts
@@ -37,10 +37,10 @@ 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({ 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() canEdit = false; // Whether the user can edit.
@Input() edit = false; // Whether the user is editing.
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 93210b120..929bf34a4 100644
--- a/src/addons/mod/assign/components/submission-plugin/submission-plugin.ts
+++ b/src/addons/mod/assign/components/submission-plugin/submission-plugin.ts
@@ -37,9 +37,9 @@ 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({ required: true }) assign!: AddonModAssignAssign; // The assignment.
+ @Input({ required: true }) submission!: AddonModAssignSubmission; // The submission.
+ @Input({ required: true }) plugin!: AddonModAssignPlugin; // The plugin object.
@Input() edit = false; // Whether the user is editing.
@Input() allowOffline = false; // Whether to allow offline.
diff --git a/src/addons/mod/assign/components/submission/submission.ts b/src/addons/mod/assign/components/submission/submission.ts
index 420b69701..5d4148030 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 1ebd510e7..6f40a45fd 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 93483a028..72a64b03c 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 10022f9f8..57a9da66d 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 3527ccee3..f364c1a67 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 2867c9fea..9f7cf1086 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 0eb646d2d..91e3041fa 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 8dccdcb02..e7f44e28b 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 759782675..496b313b8 100644
--- a/src/addons/mod/forum/components/post/post.ts
+++ b/src/addons/mod/forum/components/post/post.ts
@@ -65,17 +65,17 @@ 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 }) trackPosts!: boolean; // 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.
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 25c0498ac..4e6ef30c6 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/preflight-modal/preflight-modal.ts b/src/addons/mod/quiz/components/preflight-modal/preflight-modal.ts
index 4ec740b22..59d06ca32 100644
--- a/src/addons/mod/quiz/components/preflight-modal/preflight-modal.ts
+++ b/src/addons/mod/quiz/components/preflight-modal/preflight-modal.ts
@@ -39,12 +39,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({ 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 0f6c4c87a..b89c912cb 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 42199ba11..f91d0bbcf 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 878d918d3..adfb4821a 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 1e9c85548..6d0f5780b 100644
--- a/src/addons/mod/workshop/classes/assessment-strategy-component.ts
+++ b/src/addons/mod/workshop/classes/assessment-strategy-component.ts
@@ -24,13 +24,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 }) edit!: boolean;
+ @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 503174cf5..1e6709cfa 100644
--- a/src/addons/mod/workshop/components/assessment-strategy/assessment-strategy.ts
+++ b/src/addons/mod/workshop/components/assessment-strategy/assessment-strategy.ts
@@ -52,11 +52,11 @@ import {
})
export class AddonModWorkshopAssessmentStrategyComponent implements OnInit, OnDestroy {
- @Input() workshop!: AddonModWorkshopData;
- @Input() access!: AddonModWorkshopGetWorkshopAccessInformationWSResponse;
- @Input() assessmentId!: number;
- @Input() userId!: number;
- @Input() strategy!: string;
+ @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() 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 1e6464bc0..6fac33bd2 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 95bc52faa..c437404ec 100644
--- a/src/addons/mod/workshop/components/phase-modal/phase-modal.ts
+++ b/src/addons/mod/workshop/components/phase-modal/phase-modal.ts
@@ -31,10 +31,10 @@ import { CoreSharedModule } from '@/core/shared.module';
})
export class AddonModWorkshopPhaseInfoModalComponent implements OnInit {
- @Input() phases!: AddonModWorkshopPhaseDataWithSwitch[];
- @Input() workshopPhase!: AddonModWorkshopPhase;
+ @Input({ required: true }) phases!: AddonModWorkshopPhaseDataWithSwitch[];
+ @Input({ required: true }) workshopPhase!: AddonModWorkshopPhase;
@Input() showSubmit = false;
- @Input() externalUrl!: string;
+ @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 53ae4a891..6dfbe5226 100644
--- a/src/addons/mod/workshop/components/submission/submission.ts
+++ b/src/addons/mod/workshop/components/submission/submission.ts
@@ -41,11 +41,11 @@ 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;
diff --git a/src/addons/mod/workshop/pages/submission/submission.html b/src/addons/mod/workshop/pages/submission/submission.html
index dde29a697..0a4ed5029 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.givengrades' | translate }}
-
+
-
+
diff --git a/src/core/features/settings/pages/about/about.html b/src/core/features/settings/pages/about/about.html
index ce17902b3..83002f367 100644
--- a/src/core/features/settings/pages/about/about.html
+++ b/src/core/features/settings/pages/about/about.html
@@ -17,12 +17,12 @@
{{ 'core.settings.opensourcelicenses' | translate }}
-
{{ 'core.settings.privacypolicy' | translate }}
-
{{ 'core.settings.accessstatement' | translate }}
@@ -32,8 +32,8 @@
{{ 'core.settings.helpusimprove' | translate }}
-
+
{{ 'core.settings.legaldisclaimer' | translate }}
diff --git a/src/core/features/settings/pages/deviceinfo/deviceinfo.html b/src/core/features/settings/pages/deviceinfo/deviceinfo.html
index 08886bdc5..1eedc62d5 100644
--- a/src/core/features/settings/pages/deviceinfo/deviceinfo.html
+++ b/src/core/features/settings/pages/deviceinfo/deviceinfo.html
@@ -42,7 +42,7 @@
{{ 'core.settings.siteinfo' | translate }}
*
- {{ deviceInfo.siteUrl }}
+ {{ deviceInfo.siteUrl }}
{{ deviceInfo.siteVersion }}
{{ deviceInfo.siteId }}
@@ -51,7 +51,7 @@
{{ 'core.settings.filesystemroot' | translate }}
-
+
{{ deviceInfo.fileSystemRoot }}
diff --git a/src/core/features/settings/pages/licenses/licenses.html b/src/core/features/settings/pages/licenses/licenses.html
index 7710faa0f..eacf71709 100644
--- a/src/core/features/settings/pages/licenses/licenses.html
+++ b/src/core/features/settings/pages/licenses/licenses.html
@@ -14,30 +14,30 @@
-
+
{{ 'core.settings.opensourcelicenses' | translate }}
-
+
{{ 'core.view' | translate }}
- {{ license.name }}
+ {{ license.name }}
{{ license.name }} - {{ license.version }}
{{ 'core.settings.publisher' | translate }}{{ 'core.labelsep' | translate }} {{ license.publisher }}
{{ 'core.settings.license' | translate }}{{ 'core.labelsep' | translate }} {{ license.licenses }}
- {{ license.url }}
- {{ license.url }}
+ {{ license.email }}
+ [autoLogin]="false" [ariaLabel]="'core.view' | translate">
diff --git a/src/core/features/user/pages/about/about.html b/src/core/features/user/pages/about/about.html
index f068fdc3e..7d7d43007 100644
--- a/src/core/features/user/pages/about/about.html
+++ b/src/core/features/user/pages/about/about.html
@@ -44,7 +44,7 @@
{{ 'core.user.email' | translate }}
-
+
{{ user.email }}
@@ -70,7 +70,7 @@
{{ 'core.user.phone1' | translate}}
-
+
{{ user.phone1 }}
@@ -78,7 +78,7 @@
{{ 'core.user.phone2' | translate}}
-
+
{{ user.phone2 }}
diff --git a/src/core/features/viewer/pages/iframe/iframe.ts b/src/core/features/viewer/pages/iframe/iframe.ts
index 5b6ef0d13..ed468be0b 100644
--- a/src/core/features/viewer/pages/iframe/iframe.ts
+++ b/src/core/features/viewer/pages/iframe/iframe.ts
@@ -31,10 +31,7 @@ export class CoreViewerIframePage implements OnInit {
async ngOnInit(): Promise {
this.title = CoreNavigator.getRouteParam('title');
this.url = CoreNavigator.getRouteParam('url');
- const autoLoginParam = CoreNavigator.getRouteParam('autoLogin') ?? true;
- this.autoLogin = typeof autoLoginParam === 'boolean' ?
- autoLoginParam :
- autoLoginParam !== 'no'; // Support deprecated values yes/no/check.
+ this.autoLogin = CoreNavigator.getRouteBooleanParam('autoLogin') ?? true;
}
}
From e33627f1c1e7f4c3862cec82f951e542a4391085 Mon Sep 17 00:00:00 2001
From: Dani Palou
Date: Thu, 27 Jun 2024 13:09:25 +0200
Subject: [PATCH 4/5] MOBILE-4612 course-image: Use signals in course-image
component
---
.../components/course-image/course-image.html | 6 +--
.../components/course-image/course-image.ts | 44 ++++++++-----------
2 files changed, 21 insertions(+), 29 deletions(-)
diff --git a/src/core/components/course-image/course-image.html b/src/core/components/course-image/course-image.html
index fee483a9d..adc91885c 100644
--- a/src/core/components/course-image/course-image.html
+++ b/src/core/components/course-image/course-image.html
@@ -1,4 +1,4 @@
-
-
-
+
+
+
diff --git a/src/core/components/course-image/course-image.ts b/src/core/components/course-image/course-image.ts
index 46ce93d9f..a6b559873 100644
--- a/src/core/components/course-image/course-image.ts
+++ b/src/core/components/course-image/course-image.ts
@@ -13,7 +13,7 @@
// limitations under the License.
import { toBoolean } from '@/core/transforms/boolean';
-import { Component, Input, ElementRef, OnInit, OnChanges, HostBinding } from '@angular/core';
+import { Component, ElementRef, HostBinding, input, effect } from '@angular/core';
import { CoreCourseListItem } from '@features/courses/services/courses';
import { CoreCoursesHelper } from '@features/courses/services/courses-helper';
import { CoreColors } from '@singletons/colors';
@@ -23,41 +23,31 @@ import { CoreColors } from '@singletons/colors';
templateUrl: 'course-image.html',
styleUrls: ['./course-image.scss'],
})
-export class CoreCourseImageComponent implements OnInit, OnChanges {
+export class CoreCourseImageComponent {
- @Input({ required: true }) course!: CoreCourseListItem;
- @Input({ transform: toBoolean }) fill = false;
+ course = input.required();
+ fill = input(false, { transform: toBoolean });
protected element: HTMLElement;
constructor(element: ElementRef) {
this.element = element.nativeElement;
+
+ effect(() => {
+ this.setCourseColor();
+ });
}
@HostBinding('class.fill-container')
get fillContainer(): boolean {
- return this.fill;
- }
-
- /**
- * @inheritdoc
- */
- ngOnInit(): void {
- this.setCourseColor();
- }
-
- /**
- * @inheritdoc
- */
- ngOnChanges(): void {
- this.setCourseColor();
+ return this.fill();
}
/**
* Removes the course image set because it cannot be loaded and set the fallback icon color.
*/
loadFallbackCourseIcon(): void {
- this.course.courseimage = undefined;
+ this.course().courseimage = undefined;
// Set the color because it won't be set at this point.
this.setCourseColor();
@@ -67,15 +57,17 @@ export class CoreCourseImageComponent implements OnInit, OnChanges {
* Set course color.
*/
protected async setCourseColor(): Promise {
- await CoreCoursesHelper.loadCourseColorAndImage(this.course);
+ const course = this.course();
- if (this.course.color) {
- this.element.style.setProperty('--course-color', this.course.color);
+ await CoreCoursesHelper.loadCourseColorAndImage(course);
- const tint = CoreColors.lighter(this.course.color, 50);
+ if (course.color) {
+ this.element.style.setProperty('--course-color', course.color);
+
+ const tint = CoreColors.lighter(course.color, 50);
this.element.style.setProperty('--course-color-tint', tint);
- } else if(this.course.colorNumber !== undefined) {
- this.element.classList.add('course-color-' + this.course.colorNumber);
+ } else if(course.colorNumber !== undefined) {
+ this.element.classList.add('course-color-' + course.colorNumber);
}
}
From 1f8ddac128afe929279ab841c3e17209e51f9ed7 Mon Sep 17 00:00:00 2001
From: Dani Palou
Date: Tue, 30 Jul 2024 09:56:26 +0200
Subject: [PATCH 5/5] MOBILE-4612 compile: Expose effect to plugins
---
.../components/compile-html/compile-html.ts | 3 +++
src/core/features/compile/services/compile.ts | 25 +++++++++++++++----
2 files changed, 23 insertions(+), 5 deletions(-)
diff --git a/src/core/features/compile/components/compile-html/compile-html.ts b/src/core/features/compile/components/compile-html/compile-html.ts
index 0fa63f9c1..dd6b6edbc 100644
--- a/src/core/features/compile/components/compile-html/compile-html.ts
+++ b/src/core/features/compile/components/compile-html/compile-html.ts
@@ -33,6 +33,7 @@ import {
AfterViewInit,
Type,
KeyValueDiffer,
+ Injector,
} from '@angular/core';
import { CorePromisedValue } from '@classes/promised-value';
@@ -89,6 +90,7 @@ export class CoreCompileHtmlComponent implements OnChanges, OnDestroy, DoCheck {
constructor(
protected changeDetector: ChangeDetectorRef,
+ protected injector: Injector,
element: ElementRef,
differs: KeyValueDiffers,
) {
@@ -223,6 +225,7 @@ export class CoreCompileHtmlComponent implements OnChanges, OnDestroy, DoCheck {
CoreCompile.injectLibraries(
this,
compileInstance.extraProviders,
+ compileInstance.injector,
);
// Always add these elements, they could be needed on component init (componentObservable).
diff --git a/src/core/features/compile/services/compile.ts b/src/core/features/compile/services/compile.ts
index 5bf93d338..476c60c0d 100644
--- a/src/core/features/compile/services/compile.ts
+++ b/src/core/features/compile/services/compile.ts
@@ -23,6 +23,10 @@ import {
ViewContainerRef,
signal,
computed,
+ effect,
+ EffectCleanupRegisterFn,
+ CreateEffectOptions,
+ EffectRef,
} from '@angular/core';
import {
ActionSheetController,
@@ -260,9 +264,10 @@ export class CoreCompileProvider {
*
* @param instance The instance where to inject the libraries.
* @param extraLibraries Extra imported providers if needed and not imported by this class.
+ * @param injector Injector of the injection context. E.g. for a component, use the component's injector.
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
- injectLibraries(instance: any, extraLibraries: Type[] = []): void {
+ injectLibraries(instance: any, extraLibraries: Type[] = [], injector?: Injector): void {
if (!this.libraries || !this.exportedObjects) {
throw new CoreError('Libraries not loaded. You need to call loadLibraries before calling injectLibraries.');
}
@@ -271,6 +276,7 @@ export class CoreCompileProvider {
...this.libraries,
...extraLibraries,
];
+ injector = injector ?? this.injector;
// We cannot inject anything to this constructor. Use the Injector to inject all the providers into the instance.
for (const i in libraries) {
@@ -278,7 +284,7 @@ export class CoreCompileProvider {
if (typeof libraryDef === 'function' && libraryDef.name) {
try {
// Inject the provider to the instance. We use the class name as the property name.
- instance[libraryDef.name.replace(/DelegateService$/, 'Delegate')] = this.injector.get(libraryDef);
+ instance[libraryDef.name.replace(/DelegateService$/, 'Delegate')] = injector.get(libraryDef);
} catch (ex) {
this.logger.error('Error injecting provider', libraryDef.name, ex);
}
@@ -289,17 +295,26 @@ export class CoreCompileProvider {
instance['CoreCompileProvider'] = this;
// Add some final classes.
- instance['injector'] = this.injector;
+ instance['injector'] = injector;
instance['Validators'] = Validators;
instance['CoreConstants'] = CoreConstants;
instance['DownloadStatus'] = DownloadStatus;
instance['CoreConfigConstants'] = CoreConstants.CONFIG;
instance['CoreEventsProvider'] = CoreEvents;
instance['CoreLoggerProvider'] = CoreLogger;
- instance['signal'] = signal;
- instance['computed'] = computed;
instance['moment'] = moment;
instance['Md5'] = Md5;
+ instance['signal'] = signal;
+ instance['computed'] = computed;
+ // Create a wrapper to call effect with the proper injection context.
+ instance['effect'] = (
+ effectFn: (onCleanup: EffectCleanupRegisterFn) => void,
+ options?: Omit,
+ ): EffectRef =>
+ effect(effectFn, {
+ ...options,
+ injector,
+ });
/**
* @deprecated since 4.1, plugins should use CoreNetwork instead.
* Keeping this a bit more to avoid plugins breaking.