MOBILE-3833 navigator: Add required route params functions
parent
0d3123d2af
commit
34f9c3ab57
|
@ -147,7 +147,16 @@ export class AddonCalendarEventPage implements OnInit, OnDestroy {
|
||||||
* View loaded.
|
* View loaded.
|
||||||
*/
|
*/
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
this.eventId = CoreNavigator.getRouteNumberParam('id')!;
|
try {
|
||||||
|
this.eventId = CoreNavigator.getRequiredRouteNumberParam('id');
|
||||||
|
} catch (error) {
|
||||||
|
CoreDomUtils.showErrorModal(error);
|
||||||
|
|
||||||
|
CoreNavigator.back();
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this.syncIcon = CoreConstants.ICON_LOADING;
|
this.syncIcon = CoreConstants.ICON_LOADING;
|
||||||
|
|
||||||
this.fetchEvent();
|
this.fetchEvent();
|
||||||
|
|
|
@ -60,11 +60,19 @@ export class AddonCompetencyCompetencyPage implements OnInit {
|
||||||
* @inheritdoc
|
* @inheritdoc
|
||||||
*/
|
*/
|
||||||
async ngOnInit(): Promise<void> {
|
async ngOnInit(): Promise<void> {
|
||||||
this.competencyId = CoreNavigator.getRouteNumberParam('competencyId')!;
|
try {
|
||||||
this.planId = CoreNavigator.getRouteNumberParam('planId');
|
this.competencyId = CoreNavigator.getRequiredRouteNumberParam('competencyId');
|
||||||
if (!this.planId) {
|
this.planId = CoreNavigator.getRouteNumberParam('planId');
|
||||||
this.courseId = CoreNavigator.getRouteNumberParam('courseId')!;
|
if (!this.planId) {
|
||||||
this.userId = CoreNavigator.getRouteNumberParam('userId');
|
this.courseId = CoreNavigator.getRequiredRouteNumberParam('courseId');
|
||||||
|
this.userId = CoreNavigator.getRouteNumberParam('userId');
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
CoreDomUtils.showErrorModal(error);
|
||||||
|
|
||||||
|
CoreNavigator.back();
|
||||||
|
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -40,9 +40,17 @@ export class AddonCompetencyCompetencySummaryPage implements OnInit {
|
||||||
* @inheritdoc
|
* @inheritdoc
|
||||||
*/
|
*/
|
||||||
async ngOnInit(): Promise<void> {
|
async ngOnInit(): Promise<void> {
|
||||||
this.competencyId = CoreNavigator.getRouteNumberParam('competencyId')!;
|
try {
|
||||||
this.contextLevel = CoreNavigator.getRouteParam<ContextLevel>('contextLevel');
|
this.competencyId = CoreNavigator.getRequiredRouteNumberParam('competencyId');
|
||||||
this.contextInstanceId = CoreNavigator.getRouteNumberParam('contextInstanceId');
|
this.contextLevel = CoreNavigator.getRouteParam<ContextLevel>('contextLevel');
|
||||||
|
this.contextInstanceId = CoreNavigator.getRouteNumberParam('contextInstanceId');
|
||||||
|
} catch (error) {
|
||||||
|
CoreDomUtils.showErrorModal(error);
|
||||||
|
|
||||||
|
CoreNavigator.back();
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await this.fetchCompetency();
|
await this.fetchCompetency();
|
||||||
|
|
|
@ -42,8 +42,16 @@ export class AddonCompetencyCourseCompetenciesPage implements OnInit {
|
||||||
* View loaded.
|
* View loaded.
|
||||||
*/
|
*/
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
this.courseId = CoreNavigator.getRouteNumberParam('courseId')!;
|
try {
|
||||||
this.userId = CoreNavigator.getRouteNumberParam('userId')!;
|
this.courseId = CoreNavigator.getRequiredRouteNumberParam('courseId');
|
||||||
|
this.userId = CoreNavigator.getRequiredRouteNumberParam('userId');
|
||||||
|
} catch (error) {
|
||||||
|
CoreDomUtils.showErrorModal(error);
|
||||||
|
|
||||||
|
CoreNavigator.back();
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this.fetchCourseCompetencies().finally(() => {
|
this.fetchCourseCompetencies().finally(() => {
|
||||||
this.competenciesLoaded = true;
|
this.competenciesLoaded = true;
|
||||||
|
|
|
@ -39,7 +39,15 @@ export class AddonCompetencyPlanPage implements OnInit {
|
||||||
* @inheritdoc
|
* @inheritdoc
|
||||||
*/
|
*/
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
this.planId = CoreNavigator.getRouteNumberParam('planId')!;
|
try {
|
||||||
|
this.planId = CoreNavigator.getRequiredRouteNumberParam('planId');
|
||||||
|
} catch (error) {
|
||||||
|
CoreDomUtils.showErrorModal(error);
|
||||||
|
|
||||||
|
CoreNavigator.back();
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this.fetchLearningPlan().finally(() => {
|
this.fetchLearningPlan().finally(() => {
|
||||||
this.loaded = true;
|
this.loaded = true;
|
||||||
|
|
|
@ -44,11 +44,15 @@ export class AddonCourseCompletionReportPage implements OnInit {
|
||||||
* @inheritdoc
|
* @inheritdoc
|
||||||
*/
|
*/
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
this.courseId = CoreNavigator.getRouteNumberParam('courseId')!;
|
try {
|
||||||
this.userId = CoreNavigator.getRouteNumberParam('userId') || CoreSites.getCurrentSiteUserId();
|
this.courseId = CoreNavigator.getRequiredRouteNumberParam('courseId');
|
||||||
|
this.userId = CoreNavigator.getRouteNumberParam('userId') || CoreSites.getCurrentSiteUserId();
|
||||||
|
} catch (error) {
|
||||||
|
CoreDomUtils.showErrorModal(error);
|
||||||
|
|
||||||
if (!this.userId) {
|
CoreNavigator.back();
|
||||||
this.userId = CoreSites.getCurrentSiteUserId();
|
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.fetchCompletion().finally(() => {
|
this.fetchCompletion().finally(() => {
|
||||||
|
|
|
@ -78,9 +78,17 @@ export class AddonModAssignEditPage implements OnInit, OnDestroy, CanLeave {
|
||||||
* Component being initialized.
|
* Component being initialized.
|
||||||
*/
|
*/
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
this.moduleId = CoreNavigator.getRouteNumberParam('cmId')!;
|
try {
|
||||||
this.courseId = CoreNavigator.getRouteNumberParam('courseId')!;
|
this.moduleId = CoreNavigator.getRequiredRouteNumberParam('cmId');
|
||||||
this.isBlind = !!CoreNavigator.getRouteNumberParam('blindId');
|
this.courseId = CoreNavigator.getRequiredRouteNumberParam('courseId');
|
||||||
|
this.isBlind = !!CoreNavigator.getRouteNumberParam('blindId');
|
||||||
|
} catch (error) {
|
||||||
|
CoreDomUtils.showErrorModal(error);
|
||||||
|
|
||||||
|
CoreNavigator.back();
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this.fetchAssignment().finally(() => {
|
this.fetchAssignment().finally(() => {
|
||||||
this.loaded = true;
|
this.loaded = true;
|
||||||
|
|
|
@ -120,10 +120,18 @@ export class AddonModAssignSubmissionListPage implements AfterViewInit, OnDestro
|
||||||
* Component being initialized.
|
* Component being initialized.
|
||||||
*/
|
*/
|
||||||
ngAfterViewInit(): void {
|
ngAfterViewInit(): void {
|
||||||
this.moduleId = CoreNavigator.getRouteNumberParam('cmId')!;
|
try {
|
||||||
this.courseId = CoreNavigator.getRouteNumberParam('courseId')!;
|
this.moduleId = CoreNavigator.getRequiredRouteNumberParam('cmId');
|
||||||
this.groupId = CoreNavigator.getRouteNumberParam('groupId') || 0;
|
this.courseId = CoreNavigator.getRequiredRouteNumberParam('courseId');
|
||||||
this.selectedStatus = CoreNavigator.getRouteParam('status');
|
this.groupId = CoreNavigator.getRouteNumberParam('groupId') || 0;
|
||||||
|
this.selectedStatus = CoreNavigator.getRouteParam('status');
|
||||||
|
} catch (error) {
|
||||||
|
CoreDomUtils.showErrorModal(error);
|
||||||
|
|
||||||
|
CoreNavigator.back();
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (this.selectedStatus) {
|
if (this.selectedStatus) {
|
||||||
if (this.selectedStatus == AddonModAssignProvider.NEED_GRADING) {
|
if (this.selectedStatus == AddonModAssignProvider.NEED_GRADING) {
|
||||||
|
|
|
@ -55,10 +55,18 @@ export class AddonModAssignSubmissionReviewPage implements OnInit, CanLeave {
|
||||||
*/
|
*/
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
this.route.queryParams.subscribe((params) => {
|
this.route.queryParams.subscribe((params) => {
|
||||||
this.moduleId = CoreNavigator.getRouteNumberParam('cmId')!;
|
try {
|
||||||
this.courseId = CoreNavigator.getRouteNumberParam('courseId')!;
|
this.moduleId = CoreNavigator.getRequiredRouteNumberParam('cmId');
|
||||||
this.submitId = CoreNavigator.getRouteNumberParam('submitId') || 0;
|
this.courseId = CoreNavigator.getRequiredRouteNumberParam('courseId');
|
||||||
this.blindId = CoreNavigator.getRouteNumberParam('blindId', { params });
|
this.submitId = CoreNavigator.getRouteNumberParam('submitId') || 0;
|
||||||
|
this.blindId = CoreNavigator.getRouteNumberParam('blindId', { params });
|
||||||
|
} catch (error) {
|
||||||
|
CoreDomUtils.showErrorModal(error);
|
||||||
|
|
||||||
|
CoreNavigator.back();
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this.fetchSubmission().finally(() => {
|
this.fetchSubmission().finally(() => {
|
||||||
this.loaded = true;
|
this.loaded = true;
|
||||||
|
|
|
@ -78,12 +78,12 @@ export class AddonModChatChatPage implements OnInit, OnDestroy, CanLeave {
|
||||||
* @inheritdoc
|
* @inheritdoc
|
||||||
*/
|
*/
|
||||||
async ngOnInit(): Promise<void> {
|
async ngOnInit(): Promise<void> {
|
||||||
this.courseId = CoreNavigator.getRouteNumberParam('courseId')!;
|
|
||||||
this.cmId = CoreNavigator.getRouteNumberParam('cmId')!;
|
|
||||||
this.chatId = CoreNavigator.getRouteNumberParam('chatId')!;
|
|
||||||
this.title = CoreNavigator.getRouteParam('title') || '';
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
this.courseId = CoreNavigator.getRequiredRouteNumberParam('courseId');
|
||||||
|
this.cmId = CoreNavigator.getRequiredRouteNumberParam('cmId');
|
||||||
|
this.chatId = CoreNavigator.getRequiredRouteNumberParam('chatId');
|
||||||
|
this.title = CoreNavigator.getRouteParam('title') || '';
|
||||||
|
|
||||||
await this.loginUser();
|
await this.loginUser();
|
||||||
|
|
||||||
await this.fetchMessages();
|
await this.fetchMessages();
|
||||||
|
|
|
@ -47,12 +47,20 @@ export class AddonModChatSessionMessagesPage implements OnInit {
|
||||||
* @inheritdoc
|
* @inheritdoc
|
||||||
*/
|
*/
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
this.courseId = CoreNavigator.getRouteNumberParam('courseId')!;
|
try {
|
||||||
this.cmId = CoreNavigator.getRouteNumberParam('cmId')!;
|
this.courseId = CoreNavigator.getRequiredRouteNumberParam('courseId');
|
||||||
this.sessionStart = CoreNavigator.getRouteNumberParam('sessionStart')!;
|
this.cmId = CoreNavigator.getRequiredRouteNumberParam('cmId');
|
||||||
this.sessionEnd = CoreNavigator.getRouteNumberParam('sessionEnd')!;
|
this.sessionStart = CoreNavigator.getRequiredRouteNumberParam('sessionStart');
|
||||||
this.chatId = CoreNavigator.getRouteNumberParam('chatId')!;
|
this.sessionEnd = CoreNavigator.getRequiredRouteNumberParam('sessionEnd');
|
||||||
this.groupId = CoreNavigator.getRouteNumberParam('groupId') || 0;
|
this.chatId = CoreNavigator.getRequiredRouteNumberParam('chatId');
|
||||||
|
this.groupId = CoreNavigator.getRouteNumberParam('groupId') || 0;
|
||||||
|
} catch (error) {
|
||||||
|
CoreDomUtils.showErrorModal(error);
|
||||||
|
|
||||||
|
CoreNavigator.back();
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this.currentUserId = CoreSites.getCurrentSiteUserId();
|
this.currentUserId = CoreSites.getCurrentSiteUserId();
|
||||||
|
|
||||||
|
|
|
@ -53,10 +53,18 @@ export class AddonModChatSessionsPage implements AfterViewInit, OnDestroy {
|
||||||
* @inheritdoc
|
* @inheritdoc
|
||||||
*/
|
*/
|
||||||
async ngAfterViewInit(): Promise<void> {
|
async ngAfterViewInit(): Promise<void> {
|
||||||
this.courseId = CoreNavigator.getRouteNumberParam('courseId')!;
|
try {
|
||||||
this.cmId = CoreNavigator.getRouteNumberParam('cmId')!;
|
this.courseId = CoreNavigator.getRequiredRouteNumberParam('courseId');
|
||||||
this.chatId = CoreNavigator.getRouteNumberParam('chatId')!;
|
this.cmId = CoreNavigator.getRequiredRouteNumberParam('cmId');
|
||||||
this.sessions.setChatId(this.chatId);
|
this.chatId = CoreNavigator.getRequiredRouteNumberParam('chatId');
|
||||||
|
this.sessions.setChatId(this.chatId);
|
||||||
|
} catch (error) {
|
||||||
|
CoreDomUtils.showErrorModal(error);
|
||||||
|
|
||||||
|
CoreNavigator.back();
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
await this.fetchSessions();
|
await this.fetchSessions();
|
||||||
|
|
||||||
|
|
|
@ -53,7 +53,7 @@ export class AddonModDataFieldPluginComponent implements OnInit, OnChanges {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
try{
|
try {
|
||||||
// Check if the plugin has defined its own component to render itself.
|
// Check if the plugin has defined its own component to render itself.
|
||||||
this.fieldComponent = await AddonModDataFieldsDelegate.getComponentForField(this.field);
|
this.fieldComponent = await AddonModDataFieldsDelegate.getComponentForField(this.field);
|
||||||
|
|
||||||
|
|
|
@ -96,10 +96,18 @@ export class AddonModDataEditPage implements OnInit {
|
||||||
* @inheritdoc
|
* @inheritdoc
|
||||||
*/
|
*/
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
this.module = CoreNavigator.getRouteParam<CoreCourseModule>('module')!;
|
try {
|
||||||
this.entryId = CoreNavigator.getRouteNumberParam('entryId') || undefined;
|
this.module = CoreNavigator.getRequiredRouteParam<CoreCourseModule>('module');
|
||||||
this.courseId = CoreNavigator.getRouteNumberParam('courseId')!;
|
this.entryId = CoreNavigator.getRouteNumberParam('entryId') || undefined;
|
||||||
this.selectedGroup = CoreNavigator.getRouteNumberParam('group') || 0;
|
this.courseId = CoreNavigator.getRequiredRouteNumberParam('courseId');
|
||||||
|
this.selectedGroup = CoreNavigator.getRouteNumberParam('group') || 0;
|
||||||
|
} catch (error) {
|
||||||
|
CoreDomUtils.showErrorModal(error);
|
||||||
|
|
||||||
|
CoreNavigator.back();
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// If entryId is lower than 0 or null, it is a new entry or an offline entry.
|
// If entryId is lower than 0 or null, it is a new entry or an offline entry.
|
||||||
this.isEditing = typeof this.entryId != 'undefined' && this.entryId > 0;
|
this.isEditing = typeof this.entryId != 'undefined' && this.entryId > 0;
|
||||||
|
|
|
@ -132,11 +132,20 @@ export class AddonModDataEntryPage implements OnInit, OnDestroy {
|
||||||
* @inheritdoc
|
* @inheritdoc
|
||||||
*/
|
*/
|
||||||
async ngOnInit(): Promise<void> {
|
async ngOnInit(): Promise<void> {
|
||||||
this.module = CoreNavigator.getRouteParam<CoreCourseModule>('module')!;
|
try {
|
||||||
this.entryId = CoreNavigator.getRouteNumberParam('entryId') || undefined;
|
this.module = CoreNavigator.getRequiredRouteParam<CoreCourseModule>('module');
|
||||||
this.courseId = CoreNavigator.getRouteNumberParam('courseId')!;
|
this.entryId = CoreNavigator.getRouteNumberParam('entryId') || undefined;
|
||||||
this.selectedGroup = CoreNavigator.getRouteNumberParam('group') || 0;
|
this.courseId = CoreNavigator.getRequiredRouteNumberParam('courseId');
|
||||||
this.offset = CoreNavigator.getRouteNumberParam('offset');
|
this.selectedGroup = CoreNavigator.getRouteNumberParam('group') || 0;
|
||||||
|
this.offset = CoreNavigator.getRouteNumberParam('offset');
|
||||||
|
} catch (error) {
|
||||||
|
CoreDomUtils.showErrorModal(error);
|
||||||
|
|
||||||
|
CoreNavigator.back();
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this.title = this.module.name;
|
this.title = this.module.name;
|
||||||
|
|
||||||
this.commentsEnabled = !CoreComments.areCommentsDisabledInSite();
|
this.commentsEnabled = !CoreComments.areCommentsDisabledInSite();
|
||||||
|
|
|
@ -49,9 +49,17 @@ export class AddonModFeedbackAttemptPage implements OnInit {
|
||||||
* @inheritdoc
|
* @inheritdoc
|
||||||
*/
|
*/
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
this.cmId = CoreNavigator.getRouteNumberParam('cmId')!;
|
try {
|
||||||
this.courseId = CoreNavigator.getRouteNumberParam('courseId')!;
|
this.cmId = CoreNavigator.getRequiredRouteNumberParam('cmId');
|
||||||
this.attemptId = CoreNavigator.getRouteNumberParam('attemptId')!;
|
this.courseId = CoreNavigator.getRequiredRouteNumberParam('courseId');
|
||||||
|
this.attemptId = CoreNavigator.getRequiredRouteNumberParam('attemptId');
|
||||||
|
} catch (error) {
|
||||||
|
CoreDomUtils.showErrorModal(error);
|
||||||
|
|
||||||
|
CoreNavigator.back();
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this.fetchData();
|
this.fetchData();
|
||||||
}
|
}
|
||||||
|
|
|
@ -92,12 +92,20 @@ export class AddonModFeedbackFormPage implements OnInit, OnDestroy, CanLeave {
|
||||||
* @inheritdoc
|
* @inheritdoc
|
||||||
*/
|
*/
|
||||||
async ngOnInit(): Promise<void> {
|
async ngOnInit(): Promise<void> {
|
||||||
this.cmId = CoreNavigator.getRouteNumberParam('cmId')!;
|
try {
|
||||||
this.courseId = CoreNavigator.getRouteNumberParam('courseId')!;
|
this.cmId = CoreNavigator.getRequiredRouteNumberParam('cmId');
|
||||||
this.currentPage = CoreNavigator.getRouteNumberParam('page');
|
this.courseId = CoreNavigator.getRequiredRouteNumberParam('courseId');
|
||||||
this.title = CoreNavigator.getRouteParam('title');
|
this.currentPage = CoreNavigator.getRouteNumberParam('page');
|
||||||
this.preview = !!CoreNavigator.getRouteBooleanParam('preview');
|
this.title = CoreNavigator.getRouteParam('title');
|
||||||
this.fromIndex = !!CoreNavigator.getRouteBooleanParam('fromIndex');
|
this.preview = !!CoreNavigator.getRouteBooleanParam('preview');
|
||||||
|
this.fromIndex = !!CoreNavigator.getRouteBooleanParam('fromIndex');
|
||||||
|
} catch (error) {
|
||||||
|
CoreDomUtils.showErrorModal(error);
|
||||||
|
|
||||||
|
CoreNavigator.back();
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
await this.fetchData();
|
await this.fetchData();
|
||||||
|
|
||||||
|
|
|
@ -47,9 +47,17 @@ export class AddonModFeedbackNonRespondentsPage implements OnInit {
|
||||||
* @inheritdoc
|
* @inheritdoc
|
||||||
*/
|
*/
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
this.cmId = CoreNavigator.getRouteNumberParam('cmId')!;
|
try {
|
||||||
this.courseId = CoreNavigator.getRouteNumberParam('courseId')!;
|
this.cmId = CoreNavigator.getRequiredRouteNumberParam('cmId');
|
||||||
this.selectedGroup = CoreNavigator.getRouteNumberParam('group') || 0;
|
this.courseId = CoreNavigator.getRequiredRouteNumberParam('courseId');
|
||||||
|
this.selectedGroup = CoreNavigator.getRouteNumberParam('group') || 0;
|
||||||
|
} catch (error) {
|
||||||
|
CoreDomUtils.showErrorModal(error);
|
||||||
|
|
||||||
|
CoreNavigator.back();
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this.fetchData();
|
this.fetchData();
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,9 +63,17 @@ export class AddonModFeedbackRespondentsPage implements AfterViewInit {
|
||||||
* @inheritdoc
|
* @inheritdoc
|
||||||
*/
|
*/
|
||||||
async ngAfterViewInit(): Promise<void> {
|
async ngAfterViewInit(): Promise<void> {
|
||||||
this.cmId = CoreNavigator.getRouteNumberParam('cmId')!;
|
try {
|
||||||
this.courseId = CoreNavigator.getRouteNumberParam('courseId')!;
|
this.cmId = CoreNavigator.getRequiredRouteNumberParam('cmId');
|
||||||
this.selectedGroup = CoreNavigator.getRouteNumberParam('group') || 0;
|
this.courseId = CoreNavigator.getRequiredRouteNumberParam('courseId');
|
||||||
|
this.selectedGroup = CoreNavigator.getRouteNumberParam('group') || 0;
|
||||||
|
} catch (error) {
|
||||||
|
CoreDomUtils.showErrorModal(error);
|
||||||
|
|
||||||
|
CoreNavigator.back();
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
await this.fetchData();
|
await this.fetchData();
|
||||||
|
|
||||||
|
|
|
@ -65,7 +65,7 @@ export class AddonModForumDiscussionPage implements OnInit, AfterViewInit, OnDes
|
||||||
discussionId!: number;
|
discussionId!: number;
|
||||||
forum: Partial<AddonModForumData> = {};
|
forum: Partial<AddonModForumData> = {};
|
||||||
accessInfo: AddonModForumAccessInformation = {};
|
accessInfo: AddonModForumAccessInformation = {};
|
||||||
discussion!: AddonModForumDiscussion;
|
discussion?: AddonModForumDiscussion;
|
||||||
startingPost?: Post;
|
startingPost?: Post;
|
||||||
posts!: Post[];
|
posts!: Post[];
|
||||||
discussionLoaded = false;
|
discussionLoaded = false;
|
||||||
|
@ -100,8 +100,8 @@ export class AddonModForumDiscussionPage implements OnInit, AfterViewInit, OnDes
|
||||||
leavingPage = false;
|
leavingPage = false;
|
||||||
|
|
||||||
protected forumId!: number;
|
protected forumId!: number;
|
||||||
protected postId!: number;
|
protected postId?: number;
|
||||||
protected parent!: number;
|
protected parent?: number;
|
||||||
protected onlineObserver?: Subscription;
|
protected onlineObserver?: Subscription;
|
||||||
protected syncObserver?: CoreEventObserver;
|
protected syncObserver?: CoreEventObserver;
|
||||||
protected syncManualObserver?: CoreEventObserver;
|
protected syncManualObserver?: CoreEventObserver;
|
||||||
|
@ -122,16 +122,25 @@ export class AddonModForumDiscussionPage implements OnInit, AfterViewInit, OnDes
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
this.courseId = CoreNavigator.getRouteNumberParam('courseId')!;
|
try {
|
||||||
this.cmId = CoreNavigator.getRouteNumberParam('cmId')!;
|
this.courseId = CoreNavigator.getRequiredRouteNumberParam('courseId');
|
||||||
this.forumId = CoreNavigator.getRouteNumberParam('forumId')!;
|
this.cmId = CoreNavigator.getRequiredRouteNumberParam('cmId');
|
||||||
this.discussion = CoreNavigator.getRouteParam<AddonModForumDiscussion>('discussion')!;
|
this.forumId = CoreNavigator.getRequiredRouteNumberParam('forumId');
|
||||||
this.discussionId = this.discussion
|
this.discussion = CoreNavigator.getRouteParam<AddonModForumDiscussion>('discussion');
|
||||||
? this.discussion.discussion
|
this.discussionId = this.discussion
|
||||||
: CoreNavigator.getRouteNumberParam('discussionId')!;
|
? this.discussion.discussion
|
||||||
this.trackPosts = CoreNavigator.getRouteBooleanParam('trackPosts')!;
|
: CoreNavigator.getRequiredRouteNumberParam('discussionId');
|
||||||
this.postId = CoreNavigator.getRouteNumberParam('postId')!;
|
this.trackPosts = CoreNavigator.getRouteBooleanParam('trackPosts') || false;
|
||||||
this.parent = CoreNavigator.getRouteNumberParam('parent')!;
|
this.postId = CoreNavigator.getRouteNumberParam('postId');
|
||||||
|
this.parent = CoreNavigator.getRouteNumberParam('parent');
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
CoreDomUtils.showErrorModal(error);
|
||||||
|
|
||||||
|
this.goBack();
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this.isOnline = CoreApp.isOnline();
|
this.isOnline = CoreApp.isOnline();
|
||||||
this.onlineObserver = Network.onChange().subscribe(() => {
|
this.onlineObserver = Network.onChange().subscribe(() => {
|
||||||
|
@ -148,11 +157,9 @@ export class AddonModForumDiscussionPage implements OnInit, AfterViewInit, OnDes
|
||||||
* View loaded.
|
* View loaded.
|
||||||
*/
|
*/
|
||||||
async ngAfterViewInit(): Promise<void> {
|
async ngAfterViewInit(): Promise<void> {
|
||||||
if (this.parent) {
|
this.sort = this.parent
|
||||||
this.sort = 'nested'; // Force nested order.
|
? 'nested' // Force nested order.
|
||||||
} else {
|
: await this.getUserSort();
|
||||||
this.sort = await this.getUserSort();
|
|
||||||
}
|
|
||||||
|
|
||||||
await this.fetchPosts(true, false, true);
|
await this.fetchPosts(true, false, true);
|
||||||
|
|
||||||
|
@ -183,6 +190,16 @@ export class AddonModForumDiscussionPage implements OnInit, AfterViewInit, OnDes
|
||||||
await this.loadDiscussion(this.forumId, this.cmId, this.discussionId);
|
await this.loadDiscussion(this.forumId, this.cmId, this.discussionId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!this.discussion) {
|
||||||
|
CoreDomUtils.showErrorModal('Cannot get the discussion');
|
||||||
|
|
||||||
|
this.goBack();
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const discussion = this.discussion;
|
||||||
|
|
||||||
// Refresh data if this discussion is synchronized automatically.
|
// Refresh data if this discussion is synchronized automatically.
|
||||||
this.syncObserver = CoreEvents.on(AddonModForumSyncProvider.AUTO_SYNCED, data => {
|
this.syncObserver = CoreEvents.on(AddonModForumSyncProvider.AUTO_SYNCED, data => {
|
||||||
if (data.forumId == this.forumId && this.discussionId == data.discussionId
|
if (data.forumId == this.forumId && this.discussionId == data.discussionId
|
||||||
|
@ -204,7 +221,7 @@ export class AddonModForumDiscussionPage implements OnInit, AfterViewInit, OnDes
|
||||||
}, CoreSites.getCurrentSiteId());
|
}, CoreSites.getCurrentSiteId());
|
||||||
|
|
||||||
// Invalidate discussion list if it was not read.
|
// Invalidate discussion list if it was not read.
|
||||||
if (this.discussion.numunread > 0) {
|
if (discussion.numunread > 0) {
|
||||||
AddonModForum.invalidateDiscussionsList(this.forumId);
|
AddonModForum.invalidateDiscussionsList(this.forumId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -227,22 +244,18 @@ export class AddonModForumDiscussionPage implements OnInit, AfterViewInit, OnDes
|
||||||
if ((this.forumId && this.forumId === data.forumId) || data.cmId === this.cmId) {
|
if ((this.forumId && this.forumId === data.forumId) || data.cmId === this.cmId) {
|
||||||
AddonModForum.invalidateDiscussionsList(this.forumId).finally(() => {
|
AddonModForum.invalidateDiscussionsList(this.forumId).finally(() => {
|
||||||
if (typeof data.locked != 'undefined') {
|
if (typeof data.locked != 'undefined') {
|
||||||
this.discussion.locked = data.locked;
|
discussion.locked = data.locked;
|
||||||
}
|
}
|
||||||
if (typeof data.pinned != 'undefined') {
|
if (typeof data.pinned != 'undefined') {
|
||||||
this.discussion.pinned = data.pinned;
|
discussion.pinned = data.pinned;
|
||||||
}
|
}
|
||||||
if (typeof data.starred != 'undefined') {
|
if (typeof data.starred != 'undefined') {
|
||||||
this.discussion.starred = data.starred;
|
discussion.starred = data.starred;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof data.deleted != 'undefined' && data.deleted) {
|
if (typeof data.deleted != 'undefined' && data.deleted) {
|
||||||
if (!data.post?.parentid) {
|
if (!data.post?.parentid) {
|
||||||
if (this.splitView?.outletActivated) {
|
this.goBack();
|
||||||
CoreNavigator.navigate('../');
|
|
||||||
} else {
|
|
||||||
CoreNavigator.back();
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
this.discussionLoaded = false;
|
this.discussionLoaded = false;
|
||||||
this.refreshPosts();
|
this.refreshPosts();
|
||||||
|
@ -272,6 +285,17 @@ export class AddonModForumDiscussionPage implements OnInit, AfterViewInit, OnDes
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper function to go back.
|
||||||
|
*/
|
||||||
|
protected goBack(): void {
|
||||||
|
if (this.splitView?.outletActivated) {
|
||||||
|
CoreNavigator.navigate('../');
|
||||||
|
} else {
|
||||||
|
CoreNavigator.back();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Runs when the page is about to leave and no longer be the active page.
|
* Runs when the page is about to leave and no longer be the active page.
|
||||||
*/
|
*/
|
||||||
|
@ -515,7 +539,7 @@ export class AddonModForumDiscussionPage implements OnInit, AfterViewInit, OnDes
|
||||||
this.syncIcon = CoreConstants.ICON_SYNC;
|
this.syncIcon = CoreConstants.ICON_SYNC;
|
||||||
|
|
||||||
if (forceMarkAsRead || (hasUnreadPosts && this.trackPosts)) {
|
if (forceMarkAsRead || (hasUnreadPosts && this.trackPosts)) {
|
||||||
// // Add log in Moodle and mark unread posts as readed.
|
// Add log in Moodle and mark unread posts as readed.
|
||||||
AddonModForum.logDiscussionView(this.discussionId, this.forumId || -1, this.forum.name).catch(() => {
|
AddonModForum.logDiscussionView(this.discussionId, this.forumId || -1, this.forum.name).catch(() => {
|
||||||
// Ignore errors.
|
// Ignore errors.
|
||||||
}).finally(() => {
|
}).finally(() => {
|
||||||
|
@ -543,14 +567,8 @@ export class AddonModForumDiscussionPage implements OnInit, AfterViewInit, OnDes
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
this.discussion = await AddonModForumHelper.getDiscussionById(forumId, cmId, discussionId);
|
||||||
const discussion = await AddonModForumHelper.getDiscussionById(forumId, cmId, discussionId);
|
this.discussionId = this.discussion.discussion;
|
||||||
|
|
||||||
this.discussion = discussion;
|
|
||||||
this.discussionId = this.discussion.discussion;
|
|
||||||
} catch (error) {
|
|
||||||
// Ignore errors.
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -630,7 +648,7 @@ export class AddonModForumDiscussionPage implements OnInit, AfterViewInit, OnDes
|
||||||
* @param showErrors Whether to show errors in a modal.
|
* @param showErrors Whether to show errors in a modal.
|
||||||
* @return Promise resolved when done.
|
* @return Promise resolved when done.
|
||||||
*/
|
*/
|
||||||
refreshPosts(sync?: boolean, showErrors?: boolean): Promise<void> {
|
async refreshPosts(sync?: boolean, showErrors?: boolean): Promise<void> {
|
||||||
this.content.scrollToTop();
|
this.content.scrollToTop();
|
||||||
this.refreshIcon = CoreConstants.ICON_LOADING;
|
this.refreshIcon = CoreConstants.ICON_LOADING;
|
||||||
this.syncIcon = CoreConstants.ICON_LOADING;
|
this.syncIcon = CoreConstants.ICON_LOADING;
|
||||||
|
@ -642,9 +660,9 @@ export class AddonModForumDiscussionPage implements OnInit, AfterViewInit, OnDes
|
||||||
AddonModForum.invalidateCanAddDiscussion(this.forumId),
|
AddonModForum.invalidateCanAddDiscussion(this.forumId),
|
||||||
];
|
];
|
||||||
|
|
||||||
return CoreUtils.allPromises(promises).catch(() => {
|
await CoreUtils.ignoreErrors(CoreUtils.allPromises(promises));
|
||||||
// Ignore errors.
|
|
||||||
}).then(() => this.fetchPosts(sync, showErrors));
|
await this.fetchPosts(sync, showErrors);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -668,6 +686,10 @@ export class AddonModForumDiscussionPage implements OnInit, AfterViewInit, OnDes
|
||||||
* @param locked True to lock the discussion, false to unlock.
|
* @param locked True to lock the discussion, false to unlock.
|
||||||
*/
|
*/
|
||||||
async setLockState(locked: boolean): Promise<void> {
|
async setLockState(locked: boolean): Promise<void> {
|
||||||
|
if (!this.discussion) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const modal = await CoreDomUtils.showModalLoading('core.sending', true);
|
const modal = await CoreDomUtils.showModalLoading('core.sending', true);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -696,6 +718,10 @@ export class AddonModForumDiscussionPage implements OnInit, AfterViewInit, OnDes
|
||||||
* @param pinned True to pin the discussion, false to unpin it.
|
* @param pinned True to pin the discussion, false to unpin it.
|
||||||
*/
|
*/
|
||||||
async setPinState(pinned: boolean): Promise<void> {
|
async setPinState(pinned: boolean): Promise<void> {
|
||||||
|
if (!this.discussion) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const modal = await CoreDomUtils.showModalLoading('core.sending', true);
|
const modal = await CoreDomUtils.showModalLoading('core.sending', true);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -725,6 +751,10 @@ export class AddonModForumDiscussionPage implements OnInit, AfterViewInit, OnDes
|
||||||
* @param starred True to star the discussion, false to unstar it.
|
* @param starred True to star the discussion, false to unstar it.
|
||||||
*/
|
*/
|
||||||
async toggleFavouriteState(starred: boolean): Promise<void> {
|
async toggleFavouriteState(starred: boolean): Promise<void> {
|
||||||
|
if (!this.discussion) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const modal = await CoreDomUtils.showModalLoading('core.sending', true);
|
const modal = await CoreDomUtils.showModalLoading('core.sending', true);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -103,10 +103,18 @@ export class AddonModForumNewDiscussionPage implements OnInit, OnDestroy, CanLea
|
||||||
* Component being initialized.
|
* Component being initialized.
|
||||||
*/
|
*/
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
this.courseId = CoreNavigator.getRouteNumberParam('courseId')!;
|
try {
|
||||||
this.cmId = CoreNavigator.getRouteNumberParam('cmId')!;
|
this.courseId = CoreNavigator.getRequiredRouteNumberParam('courseId');
|
||||||
this.forumId = CoreNavigator.getRouteNumberParam('forumId')!;
|
this.cmId = CoreNavigator.getRequiredRouteNumberParam('cmId');
|
||||||
this.timeCreated = CoreNavigator.getRouteNumberParam('timeCreated')!;
|
this.forumId = CoreNavigator.getRequiredRouteNumberParam('forumId');
|
||||||
|
this.timeCreated = CoreNavigator.getRequiredRouteNumberParam('timeCreated');
|
||||||
|
} catch (error) {
|
||||||
|
CoreDomUtils.showErrorModal(error);
|
||||||
|
|
||||||
|
this.goBack();
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this.fetchDiscussionData().finally(() => {
|
this.fetchDiscussionData().finally(() => {
|
||||||
this.groupsLoaded = true;
|
this.groupsLoaded = true;
|
||||||
|
@ -595,6 +603,17 @@ export class AddonModForumNewDiscussionPage implements OnInit, OnDestroy, CanLea
|
||||||
delete this.syncObserver;
|
delete this.syncObserver;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper function to go back.
|
||||||
|
*/
|
||||||
|
protected goBack(): void {
|
||||||
|
if (this.splitView?.outletActivated) {
|
||||||
|
CoreNavigator.navigate('../../');
|
||||||
|
} else {
|
||||||
|
CoreNavigator.back();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Page destroyed.
|
* Page destroyed.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -73,7 +73,7 @@ export class AddonModGlossaryEditPage implements OnInit, CanLeave {
|
||||||
};
|
};
|
||||||
|
|
||||||
protected timecreated!: number;
|
protected timecreated!: number;
|
||||||
protected concept?: string;
|
protected concept = '';
|
||||||
protected syncId?: string;
|
protected syncId?: string;
|
||||||
protected syncObserver?: CoreEventObserver;
|
protected syncObserver?: CoreEventObserver;
|
||||||
protected isDestroyed = false;
|
protected isDestroyed = false;
|
||||||
|
@ -86,11 +86,19 @@ export class AddonModGlossaryEditPage implements OnInit, CanLeave {
|
||||||
* Component being initialized.
|
* Component being initialized.
|
||||||
*/
|
*/
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
this.cmId = CoreNavigator.getRouteNumberParam('cmId')!;
|
try {
|
||||||
this.courseId = CoreNavigator.getRouteNumberParam('courseId')!;
|
this.cmId = CoreNavigator.getRequiredRouteNumberParam('cmId');
|
||||||
this.timecreated = CoreNavigator.getRouteNumberParam('timecreated')!;
|
this.courseId = CoreNavigator.getRequiredRouteNumberParam('courseId');
|
||||||
this.concept = CoreNavigator.getRouteParam<string>('concept')!;
|
this.timecreated = CoreNavigator.getRequiredRouteNumberParam('timecreated');
|
||||||
this.editorExtraParams.timecreated = this.timecreated;
|
this.concept = CoreNavigator.getRouteParam<string>('concept') || '';
|
||||||
|
this.editorExtraParams.timecreated = this.timecreated;
|
||||||
|
} catch (error) {
|
||||||
|
CoreDomUtils.showErrorModal(error);
|
||||||
|
|
||||||
|
this.goBack();
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this.fetchData();
|
this.fetchData();
|
||||||
}
|
}
|
||||||
|
@ -116,7 +124,7 @@ export class AddonModGlossaryEditPage implements OnInit, CanLeave {
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
CoreDomUtils.showErrorModalDefault(error, 'addon.mod_glossary.errorloadingglossary', true);
|
CoreDomUtils.showErrorModalDefault(error, 'addon.mod_glossary.errorloadingglossary', true);
|
||||||
|
|
||||||
CoreNavigator.back();
|
this.goBack();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -126,7 +134,7 @@ export class AddonModGlossaryEditPage implements OnInit, CanLeave {
|
||||||
* @return Promise resolved when done.
|
* @return Promise resolved when done.
|
||||||
*/
|
*/
|
||||||
protected async loadOfflineData(): Promise<void> {
|
protected async loadOfflineData(): Promise<void> {
|
||||||
const entry = await AddonModGlossaryOffline.getNewEntry(this.glossary!.id, this.concept || '', this.timecreated);
|
const entry = await AddonModGlossaryOffline.getNewEntry(this.glossary!.id, this.concept, this.timecreated);
|
||||||
|
|
||||||
this.entry.concept = entry.concept || '';
|
this.entry.concept = entry.concept || '';
|
||||||
this.entry.definition = entry.definition || '';
|
this.entry.definition = entry.definition || '';
|
||||||
|
@ -367,4 +375,15 @@ export class AddonModGlossaryEditPage implements OnInit, CanLeave {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper function to go back.
|
||||||
|
*/
|
||||||
|
protected goBack(): void {
|
||||||
|
if (this.splitView?.outletActivated) {
|
||||||
|
CoreNavigator.navigate('../../');
|
||||||
|
} else {
|
||||||
|
CoreNavigator.back();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,10 +57,18 @@ export class AddonModGlossaryEntryPage implements OnInit {
|
||||||
* @inheritdoc
|
* @inheritdoc
|
||||||
*/
|
*/
|
||||||
async ngOnInit(): Promise<void> {
|
async ngOnInit(): Promise<void> {
|
||||||
this.courseId = CoreNavigator.getRouteNumberParam('courseId')!;
|
try {
|
||||||
this.entryId = CoreNavigator.getRouteNumberParam('entryId')!;
|
this.courseId = CoreNavigator.getRequiredRouteNumberParam('courseId');
|
||||||
this.tagsEnabled = CoreTag.areTagsAvailableInSite();
|
this.entryId = CoreNavigator.getRequiredRouteNumberParam('entryId');
|
||||||
this.commentsEnabled = !CoreComments.areCommentsDisabledInSite();
|
this.tagsEnabled = CoreTag.areTagsAvailableInSite();
|
||||||
|
this.commentsEnabled = !CoreComments.areCommentsDisabledInSite();
|
||||||
|
} catch (error) {
|
||||||
|
CoreDomUtils.showErrorModal(error);
|
||||||
|
|
||||||
|
CoreNavigator.back();
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await this.fetchEntry();
|
await this.fetchEntry();
|
||||||
|
|
|
@ -50,9 +50,17 @@ export class AddonModH5PActivityAttemptResultsPage implements OnInit {
|
||||||
* @inheritdoc
|
* @inheritdoc
|
||||||
*/
|
*/
|
||||||
async ngOnInit(): Promise<void> {
|
async ngOnInit(): Promise<void> {
|
||||||
this.courseId = CoreNavigator.getRouteNumberParam('courseId')!;
|
try {
|
||||||
this.cmId = CoreNavigator.getRouteNumberParam('cmId')!;
|
this.courseId = CoreNavigator.getRequiredRouteNumberParam('courseId');
|
||||||
this.attemptId = CoreNavigator.getRouteNumberParam('attemptId')!;
|
this.cmId = CoreNavigator.getRequiredRouteNumberParam('cmId');
|
||||||
|
this.attemptId = CoreNavigator.getRequiredRouteNumberParam('attemptId');
|
||||||
|
} catch (error) {
|
||||||
|
CoreDomUtils.showErrorModal(error);
|
||||||
|
|
||||||
|
CoreNavigator.back();
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await this.fetchData();
|
await this.fetchData();
|
||||||
|
|
|
@ -51,9 +51,18 @@ export class AddonModH5PActivityUserAttemptsPage implements OnInit {
|
||||||
* @inheritdoc
|
* @inheritdoc
|
||||||
*/
|
*/
|
||||||
async ngOnInit(): Promise<void> {
|
async ngOnInit(): Promise<void> {
|
||||||
this.courseId = CoreNavigator.getRouteNumberParam('courseId')!;
|
try {
|
||||||
this.cmId = CoreNavigator.getRouteNumberParam('cmId')!;
|
this.courseId = CoreNavigator.getRequiredRouteNumberParam('courseId');
|
||||||
this.userId = CoreNavigator.getRouteNumberParam('userId') || CoreSites.getCurrentSiteUserId();
|
this.cmId = CoreNavigator.getRequiredRouteNumberParam('cmId');
|
||||||
|
this.userId = CoreNavigator.getRouteNumberParam('userId') || CoreSites.getCurrentSiteUserId();
|
||||||
|
} catch (error) {
|
||||||
|
CoreDomUtils.showErrorModal(error);
|
||||||
|
|
||||||
|
CoreNavigator.back();
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this.isCurrentUser = this.userId == CoreSites.getCurrentSiteUserId();
|
this.isCurrentUser = this.userId == CoreSites.getCurrentSiteUserId();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -49,8 +49,16 @@ export class AddonModH5PActivityUsersAttemptsPage implements OnInit {
|
||||||
* @inheritdoc
|
* @inheritdoc
|
||||||
*/
|
*/
|
||||||
async ngOnInit(): Promise<void> {
|
async ngOnInit(): Promise<void> {
|
||||||
this.courseId = CoreNavigator.getRouteNumberParam('courseId')!;
|
try {
|
||||||
this.cmId = CoreNavigator.getRouteNumberParam('cmId')!;
|
this.courseId = CoreNavigator.getRequiredRouteNumberParam('courseId');
|
||||||
|
this.cmId = CoreNavigator.getRequiredRouteNumberParam('cmId');
|
||||||
|
} catch (error) {
|
||||||
|
CoreDomUtils.showErrorModal(error);
|
||||||
|
|
||||||
|
CoreNavigator.back();
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await this.fetchData();
|
await this.fetchData();
|
||||||
|
|
|
@ -119,12 +119,20 @@ export class AddonModLessonPlayerPage implements OnInit, OnDestroy, CanLeave {
|
||||||
* Component being initialized.
|
* Component being initialized.
|
||||||
*/
|
*/
|
||||||
async ngOnInit(): Promise<void> {
|
async ngOnInit(): Promise<void> {
|
||||||
this.cmId = CoreNavigator.getRouteNumberParam('cmId')!;
|
try {
|
||||||
this.courseId = CoreNavigator.getRouteNumberParam('courseId')!;
|
this.cmId = CoreNavigator.getRequiredRouteNumberParam('cmId');
|
||||||
this.password = CoreNavigator.getRouteParam('password');
|
this.courseId = CoreNavigator.getRequiredRouteNumberParam('courseId');
|
||||||
this.review = !!CoreNavigator.getRouteBooleanParam('review');
|
this.password = CoreNavigator.getRouteParam('password');
|
||||||
this.currentPage = CoreNavigator.getRouteNumberParam('pageId');
|
this.review = !!CoreNavigator.getRouteBooleanParam('review');
|
||||||
this.retakeToReview = CoreNavigator.getRouteNumberParam('retake');
|
this.currentPage = CoreNavigator.getRouteNumberParam('pageId');
|
||||||
|
this.retakeToReview = CoreNavigator.getRouteNumberParam('retake');
|
||||||
|
} catch (error) {
|
||||||
|
CoreDomUtils.showErrorModal(error);
|
||||||
|
|
||||||
|
CoreNavigator.back();
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Fetch the Lesson data.
|
// Fetch the Lesson data.
|
||||||
|
|
|
@ -64,10 +64,18 @@ export class AddonModLessonUserRetakePage implements OnInit {
|
||||||
* Component being initialized.
|
* Component being initialized.
|
||||||
*/
|
*/
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
this.cmId = CoreNavigator.getRouteNumberParam('cmId')!;
|
try {
|
||||||
this.courseId = CoreNavigator.getRouteNumberParam('courseId')!;
|
this.cmId = CoreNavigator.getRequiredRouteNumberParam('cmId');
|
||||||
this.userId = CoreNavigator.getRouteNumberParam('userId') || CoreSites.getCurrentSiteUserId();
|
this.courseId = CoreNavigator.getRequiredRouteNumberParam('courseId');
|
||||||
this.retakeNumber = CoreNavigator.getRouteNumberParam('retake');
|
this.userId = CoreNavigator.getRouteNumberParam('userId') || CoreSites.getCurrentSiteUserId();
|
||||||
|
this.retakeNumber = CoreNavigator.getRouteNumberParam('retake');
|
||||||
|
} catch (error) {
|
||||||
|
CoreDomUtils.showErrorModal(error);
|
||||||
|
|
||||||
|
CoreNavigator.back();
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Fetch the data.
|
// Fetch the data.
|
||||||
this.fetchData().finally(() => {
|
this.fetchData().finally(() => {
|
||||||
|
|
|
@ -52,9 +52,17 @@ export class AddonModQuizAttemptPage implements OnInit {
|
||||||
* Component being initialized.
|
* Component being initialized.
|
||||||
*/
|
*/
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
this.cmId = CoreNavigator.getRouteNumberParam('cmId')!;
|
try {
|
||||||
this.courseId = CoreNavigator.getRouteNumberParam('courseId')!;
|
this.cmId = CoreNavigator.getRequiredRouteNumberParam('cmId');
|
||||||
this.attemptId = CoreNavigator.getRouteNumberParam('attemptId')!;
|
this.courseId = CoreNavigator.getRequiredRouteNumberParam('courseId');
|
||||||
|
this.attemptId = CoreNavigator.getRequiredRouteNumberParam('attemptId');
|
||||||
|
} catch (error) {
|
||||||
|
CoreDomUtils.showErrorModal(error);
|
||||||
|
|
||||||
|
CoreNavigator.back();
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this.fetchQuizData().finally(() => {
|
this.fetchQuizData().finally(() => {
|
||||||
this.loaded = true;
|
this.loaded = true;
|
||||||
|
|
|
@ -106,9 +106,17 @@ export class AddonModQuizPlayerPage implements OnInit, OnDestroy, CanLeave {
|
||||||
* Component being initialized.
|
* Component being initialized.
|
||||||
*/
|
*/
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
this.cmId = CoreNavigator.getRouteNumberParam('cmId')!;
|
try {
|
||||||
this.courseId = CoreNavigator.getRouteNumberParam('courseId')!;
|
this.cmId = CoreNavigator.getRequiredRouteNumberParam('cmId');
|
||||||
this.moduleUrl = CoreNavigator.getRouteParam('moduleUrl');
|
this.courseId = CoreNavigator.getRequiredRouteNumberParam('courseId');
|
||||||
|
this.moduleUrl = CoreNavigator.getRouteParam('moduleUrl');
|
||||||
|
} catch (error) {
|
||||||
|
CoreDomUtils.showErrorModal(error);
|
||||||
|
|
||||||
|
CoreNavigator.back();
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Create the auto save instance.
|
// Create the auto save instance.
|
||||||
this.autoSave = new AddonModQuizAutoSave(
|
this.autoSave = new AddonModQuizAutoSave(
|
||||||
|
|
|
@ -83,11 +83,19 @@ export class AddonModQuizReviewPage implements OnInit {
|
||||||
* Component being initialized.
|
* Component being initialized.
|
||||||
*/
|
*/
|
||||||
async ngOnInit(): Promise<void> {
|
async ngOnInit(): Promise<void> {
|
||||||
this.cmId = CoreNavigator.getRouteNumberParam('cmId')!;
|
try {
|
||||||
this.courseId = CoreNavigator.getRouteNumberParam('courseId')!;
|
this.cmId = CoreNavigator.getRequiredRouteNumberParam('cmId');
|
||||||
this.attemptId = CoreNavigator.getRouteNumberParam('attemptId')!;
|
this.courseId = CoreNavigator.getRequiredRouteNumberParam('courseId');
|
||||||
this.currentPage = CoreNavigator.getRouteNumberParam('page') || -1;
|
this.attemptId = CoreNavigator.getRequiredRouteNumberParam('attemptId');
|
||||||
this.showAll = this.currentPage == -1;
|
this.currentPage = CoreNavigator.getRouteNumberParam('page') || -1;
|
||||||
|
this.showAll = this.currentPage == -1;
|
||||||
|
} catch (error) {
|
||||||
|
CoreDomUtils.showErrorModal(error);
|
||||||
|
|
||||||
|
CoreNavigator.back();
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await this.fetchData();
|
await this.fetchData();
|
||||||
|
|
|
@ -88,14 +88,22 @@ export class AddonModScormPlayerPage implements OnInit, OnDestroy {
|
||||||
* @inheritdoc
|
* @inheritdoc
|
||||||
*/
|
*/
|
||||||
async ngOnInit(): Promise<void> {
|
async ngOnInit(): Promise<void> {
|
||||||
this.cmId = CoreNavigator.getRouteNumberParam('cmId')!;
|
try {
|
||||||
this.courseId = CoreNavigator.getRouteNumberParam('courseId')!;
|
this.cmId = CoreNavigator.getRequiredRouteNumberParam('cmId');
|
||||||
this.mode = CoreNavigator.getRouteParam('mode') || AddonModScormProvider.MODENORMAL;
|
this.courseId = CoreNavigator.getRequiredRouteNumberParam('courseId');
|
||||||
this.moduleUrl = CoreNavigator.getRouteParam('moduleUrl') || '';
|
this.mode = CoreNavigator.getRouteParam('mode') || AddonModScormProvider.MODENORMAL;
|
||||||
this.newAttempt = !!CoreNavigator.getRouteBooleanParam('newAttempt');
|
this.moduleUrl = CoreNavigator.getRouteParam('moduleUrl') || '';
|
||||||
this.organizationId = CoreNavigator.getRouteParam('organizationId');
|
this.newAttempt = !!CoreNavigator.getRouteBooleanParam('newAttempt');
|
||||||
this.initialScoId = CoreNavigator.getRouteNumberParam('scoId');
|
this.organizationId = CoreNavigator.getRouteParam('organizationId');
|
||||||
this.siteId = CoreSites.getCurrentSiteId();
|
this.initialScoId = CoreNavigator.getRouteNumberParam('scoId');
|
||||||
|
this.siteId = CoreSites.getCurrentSiteId();
|
||||||
|
} catch (error) {
|
||||||
|
CoreDomUtils.showErrorModal(error);
|
||||||
|
|
||||||
|
CoreNavigator.back();
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Fetch the SCORM data.
|
// Fetch the SCORM data.
|
||||||
|
|
|
@ -117,10 +117,18 @@ export class AddonModWorkshopAssessmentPage implements OnInit, OnDestroy, CanLea
|
||||||
* Component being initialized.
|
* Component being initialized.
|
||||||
*/
|
*/
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
this.assessment = CoreNavigator.getRouteParam<AddonModWorkshopSubmissionAssessmentWithFormData>('assessment')!;
|
try {
|
||||||
this.submission = CoreNavigator.getRouteParam<AddonModWorkshopSubmissionData>('submission')!;
|
this.assessment = CoreNavigator.getRequiredRouteParam<AddonModWorkshopSubmissionAssessmentWithFormData>('assessment');
|
||||||
this.profile = CoreNavigator.getRouteParam<CoreUserProfile>('profile')!;
|
this.submission = CoreNavigator.getRequiredRouteParam<AddonModWorkshopSubmissionData>('submission');
|
||||||
this.courseId = CoreNavigator.getRouteNumberParam('courseId')!;
|
this.profile = CoreNavigator.getRequiredRouteParam<CoreUserProfile>('profile');
|
||||||
|
this.courseId = CoreNavigator.getRequiredRouteNumberParam('courseId');
|
||||||
|
} catch (error) {
|
||||||
|
CoreDomUtils.showErrorModal(error);
|
||||||
|
|
||||||
|
CoreNavigator.back();
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this.assessmentId = this.assessment.id;
|
this.assessmentId = this.assessment.id;
|
||||||
this.workshopId = this.submission.workshopid;
|
this.workshopId = this.submission.workshopid;
|
||||||
|
|
|
@ -99,10 +99,18 @@ export class AddonModWorkshopEditSubmissionPage implements OnInit, OnDestroy, Ca
|
||||||
* Component being initialized.
|
* Component being initialized.
|
||||||
*/
|
*/
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
this.module = CoreNavigator.getRouteParam<CoreCourseModule>('module')!;
|
try {
|
||||||
this.courseId = CoreNavigator.getRouteNumberParam('courseId')!;
|
this.module = CoreNavigator.getRequiredRouteParam<CoreCourseModule>('module');
|
||||||
this.access = CoreNavigator.getRouteParam<AddonModWorkshopGetWorkshopAccessInformationWSResponse>('access')!;
|
this.courseId = CoreNavigator.getRequiredRouteNumberParam('courseId');
|
||||||
this.submissionId = CoreNavigator.getRouteNumberParam('submissionId') || 0;
|
this.access = CoreNavigator.getRequiredRouteParam<AddonModWorkshopGetWorkshopAccessInformationWSResponse>('access');
|
||||||
|
this.submissionId = CoreNavigator.getRouteNumberParam('submissionId') || 0;
|
||||||
|
} catch (error) {
|
||||||
|
CoreDomUtils.showErrorModal(error);
|
||||||
|
|
||||||
|
CoreNavigator.back();
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (this.submissionId > 0) {
|
if (this.submissionId > 0) {
|
||||||
this.editorExtraParams.id = this.submissionId;
|
this.editorExtraParams.id = this.submissionId;
|
||||||
|
|
|
@ -130,15 +130,22 @@ export class AddonModWorkshopSubmissionPage implements OnInit, OnDestroy, CanLea
|
||||||
* Component being initialized.
|
* Component being initialized.
|
||||||
*/
|
*/
|
||||||
async ngOnInit(): Promise<void> {
|
async ngOnInit(): Promise<void> {
|
||||||
|
try {
|
||||||
|
this.submissionId = CoreNavigator.getRequiredRouteNumberParam('submissionId');
|
||||||
|
this.module = CoreNavigator.getRequiredRouteParam<CoreCourseModule>('module');
|
||||||
|
this.workshop = CoreNavigator.getRequiredRouteParam<AddonModWorkshopData>('workshop');
|
||||||
|
this.access = CoreNavigator.getRequiredRouteParam<AddonModWorkshopGetWorkshopAccessInformationWSResponse>('access');
|
||||||
|
this.courseId = CoreNavigator.getRequiredRouteNumberParam('courseId');
|
||||||
|
this.profile = CoreNavigator.getRouteParam<CoreUserProfile>('profile');
|
||||||
|
this.submissionInfo = CoreNavigator.getRequiredRouteParam<AddonModWorkshopSubmissionDataWithOfflineData>('submission');
|
||||||
|
this.assessment = CoreNavigator.getRouteParam<AddonModWorkshopSubmissionAssessmentWithFormData>('assessment');
|
||||||
|
} catch (error) {
|
||||||
|
CoreDomUtils.showErrorModal(error);
|
||||||
|
|
||||||
this.submissionId = CoreNavigator.getRouteNumberParam('submissionId')!;
|
CoreNavigator.back();
|
||||||
this.module = CoreNavigator.getRouteParam<CoreCourseModule>('module')!;
|
|
||||||
this.workshop = CoreNavigator.getRouteParam<AddonModWorkshopData>('workshop')!;
|
return;
|
||||||
this.access = CoreNavigator.getRouteParam<AddonModWorkshopGetWorkshopAccessInformationWSResponse>('access')!;
|
}
|
||||||
this.courseId = CoreNavigator.getRouteNumberParam('courseId')!;
|
|
||||||
this.profile = CoreNavigator.getRouteParam<CoreUserProfile>('profile');
|
|
||||||
this.submissionInfo = CoreNavigator.getRouteParam<AddonModWorkshopSubmissionDataWithOfflineData>('submission')!;
|
|
||||||
this.assessment = CoreNavigator.getRouteParam<AddonModWorkshopSubmissionAssessmentWithFormData>('assessment');
|
|
||||||
|
|
||||||
this.title = this.module.name;
|
this.title = this.module.name;
|
||||||
this.workshopId = this.module.instance || this.workshop.id;
|
this.workshopId = this.module.instance || this.workshop.id;
|
||||||
|
|
|
@ -40,7 +40,7 @@ export class AddonNotesListPage implements OnInit, OnDestroy {
|
||||||
|
|
||||||
@ViewChild(IonContent) content?: IonContent;
|
@ViewChild(IonContent) content?: IonContent;
|
||||||
|
|
||||||
courseId: number;
|
courseId!: number;
|
||||||
userId?: number;
|
userId?: number;
|
||||||
type: AddonNotesPublishState = 'course';
|
type: AddonNotesPublishState = 'course';
|
||||||
refreshIcon = CoreConstants.ICON_LOADING;
|
refreshIcon = CoreConstants.ICON_LOADING;
|
||||||
|
@ -51,13 +51,21 @@ export class AddonNotesListPage implements OnInit, OnDestroy {
|
||||||
user?: CoreUserProfile;
|
user?: CoreUserProfile;
|
||||||
showDelete = false;
|
showDelete = false;
|
||||||
canDeleteNotes = false;
|
canDeleteNotes = false;
|
||||||
currentUserId: number;
|
currentUserId!: number;
|
||||||
|
|
||||||
protected syncObserver: CoreEventObserver;
|
protected syncObserver!: CoreEventObserver;
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
this.courseId = CoreNavigator.getRouteNumberParam('courseId')!;
|
try {
|
||||||
this.userId = CoreNavigator.getRouteNumberParam('userId');
|
this.courseId = CoreNavigator.getRequiredRouteNumberParam('courseId');
|
||||||
|
this.userId = CoreNavigator.getRouteNumberParam('userId');
|
||||||
|
} catch (error) {
|
||||||
|
CoreDomUtils.showErrorModal(error);
|
||||||
|
|
||||||
|
CoreNavigator.back();
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Refresh data if notes are synchronized automatically.
|
// Refresh data if notes are synchronized automatically.
|
||||||
this.syncObserver = CoreEvents.on(AddonNotesSyncProvider.AUTO_SYNCED, (data) => {
|
this.syncObserver = CoreEvents.on(AddonNotesSyncProvider.AUTO_SYNCED, (data) => {
|
||||||
|
|
|
@ -69,19 +69,27 @@ export class AddonPrivateFilesIndexPage implements OnInit, OnDestroy {
|
||||||
* Component being initialized.
|
* Component being initialized.
|
||||||
*/
|
*/
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
this.root = CoreNavigator.getRouteParam('root');
|
try {
|
||||||
const contextId = CoreNavigator.getRouteNumberParam('contextid');
|
this.root = CoreNavigator.getRouteParam('root');
|
||||||
|
const contextId = CoreNavigator.getRouteNumberParam('contextid');
|
||||||
|
|
||||||
if (contextId) {
|
if (contextId) {
|
||||||
// Loading a certain folder.
|
// Loading a certain folder.
|
||||||
this.path = {
|
this.path = {
|
||||||
contextid: contextId,
|
contextid: contextId,
|
||||||
component: CoreNavigator.getRouteParam<string>('component')!,
|
component: CoreNavigator.getRequiredRouteParam<string>('component'),
|
||||||
filearea: CoreNavigator.getRouteParam<string>('filearea')!,
|
filearea: CoreNavigator.getRequiredRouteParam<string>('filearea'),
|
||||||
itemid: CoreNavigator.getRouteNumberParam('itemid')!,
|
itemid: CoreNavigator.getRequiredRouteNumberParam('itemid'),
|
||||||
filepath: CoreNavigator.getRouteParam<string>('filepath')!,
|
filepath: CoreNavigator.getRequiredRouteParam<string>('filepath'),
|
||||||
filename: CoreNavigator.getRouteParam<string>('filename')!,
|
filename: CoreNavigator.getRequiredRouteParam<string>('filename'),
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
CoreDomUtils.showErrorModal(error);
|
||||||
|
|
||||||
|
CoreNavigator.back();
|
||||||
|
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.title = this.path?.filename || Translate.instant('addon.privatefiles.files');
|
this.title = this.path?.filename || Translate.instant('addon.privatefiles.files');
|
||||||
|
|
|
@ -42,7 +42,15 @@ export class AddonStorageManagerCourseStoragePage implements OnInit {
|
||||||
* View loaded.
|
* View loaded.
|
||||||
*/
|
*/
|
||||||
async ngOnInit(): Promise<void> {
|
async ngOnInit(): Promise<void> {
|
||||||
this.course = CoreNavigator.getRouteParam<CoreEnrolledCourseData>('course')!;
|
try {
|
||||||
|
this.course = CoreNavigator.getRequiredRouteParam<CoreEnrolledCourseData>('course');
|
||||||
|
} catch (error) {
|
||||||
|
CoreDomUtils.showErrorModal(error);
|
||||||
|
|
||||||
|
CoreNavigator.back();
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this.sections = await CoreCourse.getSections(this.course.id, false, true);
|
this.sections = await CoreCourse.getSections(this.course.id, false, true);
|
||||||
CoreCourseHelper.addHandlerDataForModules(this.sections, this.course.id);
|
CoreCourseHelper.addHandlerDataForModules(this.sections, this.course.id);
|
||||||
|
|
|
@ -66,14 +66,8 @@ export class CoreSplitViewComponent implements AfterViewInit, OnDestroy {
|
||||||
this.disableScrollOnParent();
|
this.disableScrollOnParent();
|
||||||
|
|
||||||
this.subscriptions = [
|
this.subscriptions = [
|
||||||
this.contentOutlet.activateEvents.subscribe(() => {
|
this.contentOutlet.activateEvents.subscribe(() => this.updateOutletRoute()),
|
||||||
this.updateClasses();
|
this.contentOutlet.deactivateEvents.subscribe(() => this.updateOutletRoute()),
|
||||||
this.outletRouteSubject.next(this.contentOutlet.activatedRoute.snapshot);
|
|
||||||
}),
|
|
||||||
this.contentOutlet.deactivateEvents.subscribe(() => {
|
|
||||||
this.updateClasses();
|
|
||||||
this.outletRouteSubject.next(null);
|
|
||||||
}),
|
|
||||||
CoreScreen.layoutObservable.subscribe(() => this.updateClasses()),
|
CoreScreen.layoutObservable.subscribe(() => this.updateClasses()),
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -89,6 +83,17 @@ export class CoreSplitViewComponent implements AfterViewInit, OnDestroy {
|
||||||
this.enableScrollOnParent();
|
this.enableScrollOnParent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update outlet status.
|
||||||
|
*/
|
||||||
|
private updateOutletRoute(): void {
|
||||||
|
const outletRoute = this.contentOutlet.isActivated ? this.contentOutlet.activatedRoute.snapshot : null;
|
||||||
|
|
||||||
|
this.updateClasses();
|
||||||
|
|
||||||
|
this.outletRouteSubject.next(outletRoute);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update host classes.
|
* Update host classes.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -110,19 +110,28 @@ export class CoreCommentsViewerPage implements OnInit, OnDestroy {
|
||||||
* View loaded.
|
* View loaded.
|
||||||
*/
|
*/
|
||||||
async ngOnInit(): Promise<void> {
|
async ngOnInit(): Promise<void> {
|
||||||
|
try {
|
||||||
|
this.contextLevel = CoreNavigator.getRequiredRouteParam<ContextLevel>('contextLevel');
|
||||||
|
this.instanceId = CoreNavigator.getRequiredRouteNumberParam('instanceId');
|
||||||
|
this.componentName = CoreNavigator.getRequiredRouteParam<string>('componentName');
|
||||||
|
this.itemId = CoreNavigator.getRequiredRouteNumberParam('itemId');
|
||||||
|
this.area = CoreNavigator.getRouteParam('area') || '';
|
||||||
|
this.title = CoreNavigator.getRouteNumberParam('title') ||
|
||||||
|
Translate.instant('core.comments.comments');
|
||||||
|
this.courseId = CoreNavigator.getRouteNumberParam('courseId');
|
||||||
|
} catch (error) {
|
||||||
|
CoreDomUtils.showErrorModal(error);
|
||||||
|
|
||||||
|
CoreNavigator.back();
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Is implicit the user can delete if he can add.
|
// Is implicit the user can delete if he can add.
|
||||||
this.addDeleteCommentsAvailable = await CoreComments.isAddCommentsAvailable();
|
this.addDeleteCommentsAvailable = await CoreComments.isAddCommentsAvailable();
|
||||||
this.currentUserId = CoreSites.getCurrentSiteUserId();
|
this.currentUserId = CoreSites.getCurrentSiteUserId();
|
||||||
|
|
||||||
this.commentsLoaded = false;
|
this.commentsLoaded = false;
|
||||||
this.contextLevel = CoreNavigator.getRouteParam<ContextLevel>('contextLevel')!;
|
|
||||||
this.instanceId = CoreNavigator.getRouteNumberParam('instanceId')!;
|
|
||||||
this.componentName = CoreNavigator.getRouteParam<string>('componentName')!;
|
|
||||||
this.itemId = CoreNavigator.getRouteNumberParam('itemId')!;
|
|
||||||
this.area = CoreNavigator.getRouteParam('area') || '';
|
|
||||||
this.title = CoreNavigator.getRouteNumberParam('title') ||
|
|
||||||
Translate.instant('core.comments.comments');
|
|
||||||
this.courseId = CoreNavigator.getRouteNumberParam('courseId');
|
|
||||||
|
|
||||||
await this.fetchComments(true);
|
await this.fetchComments(true);
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,10 +14,10 @@
|
||||||
|
|
||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
import { CoreNavigator } from '@services/navigator';
|
import { CoreNavigator } from '@services/navigator';
|
||||||
|
import { CoreDomUtils } from '@services/utils/dom';
|
||||||
import { CoreCourseAnyModuleData } from '../services/course';
|
import { CoreCourseAnyModuleData } from '../services/course';
|
||||||
import { CoreCourseModuleMainResourceComponent } from './main-resource-component';
|
import { CoreCourseModuleMainResourceComponent } from './main-resource-component';
|
||||||
|
|
||||||
/**
|
|
||||||
/**
|
/**
|
||||||
* Template class to easily create CoreCourseModuleMainComponent of resources (or activities without syncing).
|
* Template class to easily create CoreCourseModuleMainComponent of resources (or activities without syncing).
|
||||||
*/
|
*/
|
||||||
|
@ -36,8 +36,17 @@ export class CoreCourseModuleMainActivityPage<ActivityType extends CoreCourseMod
|
||||||
* Component being initialized.
|
* Component being initialized.
|
||||||
*/
|
*/
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
this.module = CoreNavigator.getRouteParam<CoreCourseAnyModuleData>('module')!;
|
try {
|
||||||
this.courseId = CoreNavigator.getRouteNumberParam('courseId')!;
|
this.module = CoreNavigator.getRequiredRouteParam<CoreCourseAnyModuleData>('module');
|
||||||
|
this.courseId = CoreNavigator.getRequiredRouteNumberParam('courseId');
|
||||||
|
} catch (error) {
|
||||||
|
CoreDomUtils.showErrorModal(error);
|
||||||
|
|
||||||
|
CoreNavigator.back();
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this.title = this.module?.name;
|
this.title = this.module?.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -59,7 +59,7 @@ export class CoreCoursesCategoriesPage implements OnInit {
|
||||||
* @return Promise resolved when done.
|
* @return Promise resolved when done.
|
||||||
*/
|
*/
|
||||||
protected async fetchCategories(): Promise<void> {
|
protected async fetchCategories(): Promise<void> {
|
||||||
try{
|
try {
|
||||||
const categories: CoreCategoryData[] = await CoreCourses.getCategories(this.categoryId, true);
|
const categories: CoreCategoryData[] = await CoreCourses.getCategories(this.categoryId, true);
|
||||||
|
|
||||||
this.currentCategory = undefined;
|
this.currentCategory = undefined;
|
||||||
|
|
|
@ -40,14 +40,26 @@ import { CoreNavigator } from '@services/navigator';
|
||||||
})
|
})
|
||||||
export class CoreGradesCoursePage implements AfterViewInit, OnDestroy {
|
export class CoreGradesCoursePage implements AfterViewInit, OnDestroy {
|
||||||
|
|
||||||
grades: CoreGradesCourseManager;
|
grades!: CoreGradesCourseManager;
|
||||||
splitViewMode?: CoreSplitViewMode;
|
splitViewMode?: CoreSplitViewMode;
|
||||||
|
|
||||||
@ViewChild(CoreSplitViewComponent) splitView!: CoreSplitViewComponent;
|
@ViewChild(CoreSplitViewComponent) splitView!: CoreSplitViewComponent;
|
||||||
|
|
||||||
constructor(protected route: ActivatedRoute) {
|
constructor(protected route: ActivatedRoute) {
|
||||||
const courseId = CoreNavigator.getRouteNumberParam('courseId', { route })!;
|
let courseId: number;
|
||||||
const userId = CoreNavigator.getRouteNumberParam('userId', { route }) ?? CoreSites.getCurrentSiteUserId();
|
let userId: number;
|
||||||
|
|
||||||
|
try {
|
||||||
|
courseId = CoreNavigator.getRequiredRouteNumberParam('courseId', { route });
|
||||||
|
userId = CoreNavigator.getRouteNumberParam('userId', { route }) ?? CoreSites.getCurrentSiteUserId();
|
||||||
|
} catch (error) {
|
||||||
|
CoreDomUtils.showErrorModal(error);
|
||||||
|
|
||||||
|
CoreNavigator.back();
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const useSplitView = route.snapshot.data.useSplitView ?? true;
|
const useSplitView = route.snapshot.data.useSplitView ?? true;
|
||||||
const outsideGradesTab = route.snapshot.data.outsideGradesTab ?? false;
|
const outsideGradesTab = route.snapshot.data.outsideGradesTab ?? false;
|
||||||
|
|
||||||
|
|
|
@ -31,16 +31,24 @@ import { CoreNavigator } from '@services/navigator';
|
||||||
})
|
})
|
||||||
export class CoreGradesGradePage implements OnInit {
|
export class CoreGradesGradePage implements OnInit {
|
||||||
|
|
||||||
courseId: number;
|
courseId!: number;
|
||||||
userId: number;
|
userId!: number;
|
||||||
gradeId: number;
|
gradeId!: number;
|
||||||
grade?: CoreGradesFormattedRow | null;
|
grade?: CoreGradesFormattedRow | null;
|
||||||
gradeLoaded = false;
|
gradeLoaded = false;
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
this.courseId = CoreNavigator.getRouteNumberParam('courseId')!;
|
try {
|
||||||
this.gradeId = CoreNavigator.getRouteNumberParam('gradeId')!;
|
this.courseId = CoreNavigator.getRequiredRouteNumberParam('courseId');
|
||||||
this.userId = CoreNavigator.getRouteNumberParam('userId') ?? CoreSites.getCurrentSiteUserId();
|
this.gradeId = CoreNavigator.getRequiredRouteNumberParam('gradeId');
|
||||||
|
this.userId = CoreNavigator.getRouteNumberParam('userId') ?? CoreSites.getCurrentSiteUserId();
|
||||||
|
} catch (error) {
|
||||||
|
CoreDomUtils.showErrorModal(error);
|
||||||
|
|
||||||
|
CoreNavigator.back();
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -33,7 +33,7 @@ import { CoreUtils } from '@services/utils/utils';
|
||||||
})
|
})
|
||||||
export class CoreUserParticipantsPage implements OnInit, AfterViewInit, OnDestroy {
|
export class CoreUserParticipantsPage implements OnInit, AfterViewInit, OnDestroy {
|
||||||
|
|
||||||
participants: CoreUserParticipantsManager;
|
participants!: CoreUserParticipantsManager;
|
||||||
searchQuery: string | null = null;
|
searchQuery: string | null = null;
|
||||||
searchInProgress = false;
|
searchInProgress = false;
|
||||||
searchEnabled = false;
|
searchEnabled = false;
|
||||||
|
@ -43,7 +43,17 @@ export class CoreUserParticipantsPage implements OnInit, AfterViewInit, OnDestro
|
||||||
@ViewChild(CoreSplitViewComponent) splitView!: CoreSplitViewComponent;
|
@ViewChild(CoreSplitViewComponent) splitView!: CoreSplitViewComponent;
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
const courseId = CoreNavigator.getRouteNumberParam('courseId')!;
|
let courseId: number;
|
||||||
|
|
||||||
|
try {
|
||||||
|
courseId = CoreNavigator.getRequiredRouteNumberParam('courseId');
|
||||||
|
} catch (error) {
|
||||||
|
CoreDomUtils.showErrorModal(error);
|
||||||
|
|
||||||
|
CoreNavigator.back();
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this.participants = new CoreUserParticipantsManager(CoreUserParticipantsPage, courseId);
|
this.participants = new CoreUserParticipantsManager(CoreUserParticipantsPage, courseId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,6 +30,7 @@ import { makeSingleton, NavController, Router } from '@singletons';
|
||||||
import { CoreScreen } from './screen';
|
import { CoreScreen } from './screen';
|
||||||
import { CoreApp } from './app';
|
import { CoreApp } from './app';
|
||||||
import { CoreSitePlugins } from '@features/siteplugins/services/siteplugins';
|
import { CoreSitePlugins } from '@features/siteplugins/services/siteplugins';
|
||||||
|
import { CoreError } from '@classes/errors/error';
|
||||||
|
|
||||||
const DEFAULT_MAIN_MENU_TAB = CoreMainMenuHomeHandlerService.PAGE_NAME;
|
const DEFAULT_MAIN_MENU_TAB = CoreMainMenuHomeHandlerService.PAGE_NAME;
|
||||||
|
|
||||||
|
@ -269,7 +270,7 @@ export class CoreNavigatorService {
|
||||||
|
|
||||||
const value = route.snapshot.queryParams[name] ?? route.snapshot.params[name];
|
const value = route.snapshot.queryParams[name] ?? route.snapshot.params[name];
|
||||||
|
|
||||||
if (typeof value != 'undefined') {
|
if (value !== undefined) {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -300,7 +301,7 @@ export class CoreNavigatorService {
|
||||||
value = routeOptions.params[name];
|
value = routeOptions.params[name];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof value == 'undefined') {
|
if (value === undefined) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -345,7 +346,7 @@ export class CoreNavigatorService {
|
||||||
getRouteBooleanParam(name: string, routeOptions: CoreNavigatorCurrentRouteOptions = {}): boolean | undefined {
|
getRouteBooleanParam(name: string, routeOptions: CoreNavigatorCurrentRouteOptions = {}): boolean | undefined {
|
||||||
const value = this.getRouteParam<string>(name, routeOptions);
|
const value = this.getRouteParam<string>(name, routeOptions);
|
||||||
|
|
||||||
if (typeof value == 'undefined') {
|
if (value === undefined) {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -360,6 +361,67 @@ export class CoreNavigatorService {
|
||||||
return Boolean(value);
|
return Boolean(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a parameter for the current route.
|
||||||
|
* Please notice that objects can only be retrieved once. You must call this function only once per page and parameter,
|
||||||
|
* unless there's a new navigation to the page.
|
||||||
|
*
|
||||||
|
* This function will fail if parameter is not found.
|
||||||
|
*
|
||||||
|
* @param name Name of the parameter.
|
||||||
|
* @param routeOptions Optional routeOptions to get the params or route value from. If missing, it will autodetect.
|
||||||
|
* @return Value of the parameter, undefined if not found.
|
||||||
|
*/
|
||||||
|
getRequiredRouteParam<T = unknown>(name: string, routeOptions: CoreNavigatorCurrentRouteOptions = {}): T {
|
||||||
|
const value = this.getRouteParam<T>(name, routeOptions);
|
||||||
|
|
||||||
|
if (value === undefined) {
|
||||||
|
throw new CoreError(`Required param '${name}' not found.`);
|
||||||
|
}
|
||||||
|
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a number route param.
|
||||||
|
* Angular router automatically converts numbers to string, this function automatically converts it back to number.
|
||||||
|
*
|
||||||
|
* This function will fail if parameter is not found.
|
||||||
|
*
|
||||||
|
* @param name Name of the parameter.
|
||||||
|
* @param routeOptions Optional routeOptions to get the params or route value from. If missing, it will autodetect.
|
||||||
|
* @return Value of the parameter, undefined if not found.
|
||||||
|
*/
|
||||||
|
getRequiredRouteNumberParam(name: string, routeOptions: CoreNavigatorCurrentRouteOptions = {}): number {
|
||||||
|
const value = this.getRouteNumberParam(name, routeOptions);
|
||||||
|
|
||||||
|
if (value === undefined) {
|
||||||
|
throw new CoreError(`Required number param '${name}' not found.`);
|
||||||
|
}
|
||||||
|
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a boolean route param.
|
||||||
|
* Angular router automatically converts booleans to string, this function automatically converts it back to boolean.
|
||||||
|
*
|
||||||
|
* This function will fail if parameter is not found.
|
||||||
|
*
|
||||||
|
* @param name Name of the parameter.
|
||||||
|
* @param routeOptions Optional routeOptions to get the params or route value from. If missing, it will autodetect.
|
||||||
|
* @return Value of the parameter, undefined if not found.
|
||||||
|
*/
|
||||||
|
getRequiredRouteBooleanParam(name: string, routeOptions: CoreNavigatorCurrentRouteOptions = {}): boolean {
|
||||||
|
const value = this.getRouteBooleanParam(name, routeOptions);
|
||||||
|
|
||||||
|
if (value === undefined) {
|
||||||
|
throw new CoreError(`Required boolean param '${name}' not found.`);
|
||||||
|
}
|
||||||
|
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Navigate back.
|
* Navigate back.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue