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