Merge pull request #4069 from alfonso-salces/MOBILE-4470

MOBILE-4470 edit-entry: Add module and course context
main
Noel De Martin 2024-05-28 12:11:18 +02:00 committed by GitHub
commit 9dee3b172d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 14 additions and 6 deletions

View File

@ -39,7 +39,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"
@ -57,15 +57,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>

View File

@ -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) {