MOBILE-4470 edit-entry: Add module and course context
parent
5ff760ddc2
commit
fab71435eb
|
@ -41,7 +41,7 @@
|
|||
<core-attachments [files]="files" [maxSubmissions]="maxFiles" [maxSize]="0" [component]="component" [allowOffline]="true"
|
||||
[componentId]="entry?.id ?? 0" />
|
||||
|
||||
@if (entry && courseId && associatedCourse) {
|
||||
@if (courseId && associatedCourse) {
|
||||
<ion-item class="divider section" (click)="toggleAssociations()" button [detail]="false"
|
||||
[attr.aria-label]="(associationsExpanded ? 'core.collapse' : 'core.expand') | translate"
|
||||
[attr.aria-expanded]="associationsExpanded" aria-controls="addon-blog-associations"
|
||||
|
@ -59,15 +59,13 @@
|
|||
<ion-toggle formControlName="associateWithModule">
|
||||
<core-format-text [text]="'addon.blog.associatewithmodule' | translate: {
|
||||
$a: { modtype: associatedModule.modname, modname: associatedModule.name }
|
||||
}" [component]="component" [componentId]="entry.id" [contextLevel]="contextLevel"
|
||||
[contextInstanceId]="contextInstanceId" [courseId]="entry.courseid" />
|
||||
}" [contextLevel]="moduleContext" [contextInstanceId]="modId" [courseId]="courseId" />
|
||||
</ion-toggle>
|
||||
} @else if (associatedCourse) {
|
||||
<ion-toggle formControlName="associateWithCourse">
|
||||
<core-format-text
|
||||
[text]="'addon.blog.associatewithcourse' | translate: { $a: { coursename: associatedCourse.fullname } }"
|
||||
[component]="component" [componentId]="entry.id" [contextLevel]="contextLevel"
|
||||
[contextInstanceId]="contextInstanceId" [courseId]="entry.courseid" />
|
||||
[contextLevel]="courseContext" [contextInstanceId]="courseId" [courseId]="courseId" />
|
||||
</ion-toggle>
|
||||
}
|
||||
</ion-item>
|
||||
|
|
|
@ -77,6 +77,8 @@ export class AddonBlogEditEntryPage implements CanLeave, OnInit {
|
|||
associatedCourse?: CoreCourseBasicData;
|
||||
associatedModule?: CoreCourseModuleData;
|
||||
associationsExpanded = false;
|
||||
moduleContext: ContextLevel = ContextLevel.MODULE;
|
||||
courseContext: ContextLevel = ContextLevel.COURSE;
|
||||
contextLevel: ContextLevel = ContextLevel.SYSTEM;
|
||||
contextInstanceId = 0;
|
||||
component = AddonBlogProvider.COMPONENT;
|
||||
|
@ -127,9 +129,17 @@ export class AddonBlogEditEntryPage implements CanLeave, OnInit {
|
|||
const entryId = CoreNavigator.getRouteNumberParam('id');
|
||||
const lastModified = CoreNavigator.getRouteNumberParam('lastModified');
|
||||
const filters: AddonBlogFilter | undefined = CoreNavigator.getRouteParam('filters');
|
||||
const courseId = CoreNavigator.getRouteNumberParam('courseId');
|
||||
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;
|
||||
|
||||
|
@ -140,7 +150,7 @@ export class AddonBlogEditEntryPage implements CanLeave, OnInit {
|
|||
this.entry = await this.getEntry({ filters, lastModified, entryId });
|
||||
this.files = this.entry.attachmentfiles ?? [];
|
||||
this.initialFiles = [...this.files];
|
||||
this.courseId = CoreNavigator.getRouteNumberParam('courseId') ?? this.entry.courseid;
|
||||
this.courseId = this.courseId || this.entry.courseid;
|
||||
this.modId = this.entry.coursemoduleid ? this.entry.coursemoduleid : CoreNavigator.getRouteNumberParam('cmId');
|
||||
|
||||
if (this.courseId) {
|
||||
|
|
Loading…
Reference in New Issue