MOBILE-4470 blog: add module association from cmId
parent
53e346d7ae
commit
f535c5bbd7
|
@ -133,19 +133,30 @@ export class AddonBlogEditEntryPage implements CanLeave, OnInit {
|
|||
const lastModified = CoreNavigator.getRouteNumberParam('lastModified');
|
||||
const filters: AddonBlogFilter | undefined = CoreNavigator.getRouteParam('filters');
|
||||
const courseId = CoreNavigator.getRouteNumberParam('courseId');
|
||||
const cmId = CoreNavigator.getRouteNumberParam('cmId');
|
||||
this.userId = CoreNavigator.getRouteNumberParam('userId');
|
||||
this.siteHomeId = CoreSites.getCurrentSiteHomeId();
|
||||
|
||||
if (courseId) {
|
||||
this.courseId = courseId;
|
||||
this.form.controls.associateWithCourse.setValue(true);
|
||||
const { course } = await CoreCourseHelper.getCourse(this.courseId);
|
||||
this.associatedCourse = course;
|
||||
}
|
||||
|
||||
if (!entryId) {
|
||||
this.loaded = true;
|
||||
|
||||
try {
|
||||
if (cmId) {
|
||||
this.modId = cmId;
|
||||
this.form.controls.associateWithModule.setValue(true);
|
||||
this.associatedModule = await CoreCourse.getModule(this.modId);
|
||||
}
|
||||
|
||||
if (courseId) {
|
||||
this.courseId = courseId;
|
||||
this.form.controls.associateWithCourse.setValue(true);
|
||||
const { course } = await CoreCourseHelper.getCourse(this.courseId);
|
||||
this.associatedCourse = course;
|
||||
}
|
||||
} catch (error) {
|
||||
CoreDomUtils.showErrorModalDefault(error, 'Error getting associations, they may not be displayed correctly.');
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -154,7 +165,7 @@ export class AddonBlogEditEntryPage implements CanLeave, OnInit {
|
|||
this.files = this.entry.attachmentfiles ?? [];
|
||||
this.initialFiles = [...this.files];
|
||||
this.courseId = this.courseId || this.entry.courseid;
|
||||
this.modId = this.entry.coursemoduleid ? this.entry.coursemoduleid : CoreNavigator.getRouteNumberParam('cmId');
|
||||
this.modId = CoreNavigator.getRouteNumberParam('cmId') || this.entry.coursemoduleid;
|
||||
|
||||
if (this.courseId) {
|
||||
this.form.controls.associateWithCourse.setValue(true);
|
||||
|
|
|
@ -298,7 +298,7 @@ export class AddonBlogIndexPage implements OnInit, OnDestroy {
|
|||
* Redirect to entry creation form.
|
||||
*/
|
||||
createNewEntry(): void {
|
||||
CoreNavigator.navigateToSitePath('blog/edit/0');
|
||||
CoreNavigator.navigateToSitePath('blog/edit/0', { params: { cmId: this.filter.cmid } });
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue