diff --git a/src/addon/competency/pages/competency/competency.html b/src/addon/competency/pages/competency/competency.html index dc048e446..4f66d9dc1 100644 --- a/src/addon/competency/pages/competency/competency.html +++ b/src/addon/competency/pages/competency/competency.html @@ -76,7 +76,7 @@ {{ 'addon.competency.noevidence' | translate }}

- +

{{ evidence.actionuser.fullname }}

{{ evidence.timemodified * 1000 | coreFormatDate }}

diff --git a/src/addon/competency/pages/competency/competency.ts b/src/addon/competency/pages/competency/competency.ts index dc7e76c9d..c3930b945 100644 --- a/src/addon/competency/pages/competency/competency.ts +++ b/src/addon/competency/pages/competency/competency.ts @@ -151,15 +151,4 @@ export class AddonCompetencyCompetencyPage { const navCtrl = this.svComponent ? this.svComponent.getMasterNav() : this.navCtrl; navCtrl.push('AddonCompetencyCompetencySummaryPage', {competencyId}); } - - /** - * Opens the profile of a user. - * - * @param {number} userId - */ - openUserProfile(userId: number): void { - // Decide which navCtrl to use. If this page is inside a split view, use the split view's master nav. - const navCtrl = this.svComponent ? this.svComponent.getMasterNav() : this.navCtrl; - navCtrl.push('CoreUserProfilePage', {userId, courseId: this.courseId}); - } } diff --git a/src/addon/mod/assign/components/submission/addon-mod-assign-submission.html b/src/addon/mod/assign/components/submission/addon-mod-assign-submission.html index 0ff335202..c46b8942e 100644 --- a/src/addon/mod/assign/components/submission/addon-mod-assign-submission.html +++ b/src/addon/mod/assign/components/submission/addon-mod-assign-submission.html @@ -1,7 +1,7 @@ -
+

{{ user.fullname }}

@@ -110,7 +110,7 @@

{{ 'addon.mod_assign.userswhoneedtosubmit' | translate: {$a: ''} }}

- +

{{ user.fullname }}

@@ -208,7 +208,7 @@ - +

{{ 'addon.mod_assign.gradedby' | translate }}

{{ grader.fullname }}

diff --git a/src/addon/mod/assign/components/submission/submission.ts b/src/addon/mod/assign/components/submission/submission.ts index c3f655855..9d5fd32d2 100644 --- a/src/addon/mod/assign/components/submission/submission.ts +++ b/src/addon/mod/assign/components/submission/submission.ts @@ -620,17 +620,6 @@ export class AddonModAssignSubmissionComponent implements OnInit, OnDestroy { }); } - /** - * Open a user profile. - * - * @param {number} userId User to open. - */ - openUserProfile(userId: number): void { - // Open a user profile. If this component is inside a split view, use the master nav to open it. - const navCtrl = this.splitviewCtrl ? this.splitviewCtrl.getMasterNav() : this.navCtrl; - navCtrl.push('CoreUserProfilePage', { userId: userId, courseId: this.courseId }); - } - /** * Set the submission status name and class. * diff --git a/src/addon/mod/forum/components/post/addon-mod-forum-post.html b/src/addon/mod/forum/components/post/addon-mod-forum-post.html index cb8ffc1b3..9119c2bed 100644 --- a/src/addon/mod/forum/components/post/addon-mod-forum-post.html +++ b/src/addon/mod/forum/components/post/addon-mod-forum-post.html @@ -1,6 +1,6 @@ - +

diff --git a/src/addon/mod/forum/components/post/post.ts b/src/addon/mod/forum/components/post/post.ts index 581c7eefe..a8d010a9e 100644 --- a/src/addon/mod/forum/components/post/post.ts +++ b/src/addon/mod/forum/components/post/post.ts @@ -14,10 +14,9 @@ import { Component, Input, Output, Optional, EventEmitter, OnInit, OnDestroy } from '@angular/core'; import { FormControl } from '@angular/forms'; -import { NavController, Content } from 'ionic-angular'; +import { Content } from 'ionic-angular'; import { TranslateService } from '@ngx-translate/core'; import { CoreFileUploaderProvider } from '@core/fileuploader/providers/fileuploader'; -import { CoreSplitViewComponent } from '@components/split-view/split-view'; import { CoreSyncProvider } from '@providers/sync'; import { CoreDomUtilsProvider } from '@providers/utils/dom'; import { CoreTextUtilsProvider } from '@providers/utils/text'; @@ -57,7 +56,6 @@ export class AddonModForumPostComponent implements OnInit, OnDestroy { protected syncId: string; constructor( - private navCtrl: NavController, private uploaderProvider: CoreFileUploaderProvider, private syncProvider: CoreSyncProvider, private domUtils: CoreDomUtilsProvider, @@ -67,7 +65,6 @@ export class AddonModForumPostComponent implements OnInit, OnDestroy { private forumHelper: AddonModForumHelperProvider, private forumOffline: AddonModForumOfflineProvider, private forumSync: AddonModForumSyncProvider, - @Optional() private svComponent: CoreSplitViewComponent, @Optional() private content: Content) { this.onPostChange = new EventEmitter(); } @@ -79,17 +76,6 @@ export class AddonModForumPostComponent implements OnInit, OnDestroy { this.uniqueId = this.post.id ? 'reply' + this.post.id : 'edit' + this.post.parent; } - /** - * Opens the profile of a user. - * - * @param {number} userId - */ - openUserProfile(userId: number): void { - // Decide which navCtrl to use. If this page is inside a split view, use the split view's master nav. - const navCtrl = this.svComponent ? this.svComponent.getMasterNav() : this.navCtrl; - navCtrl.push('CoreUserProfilePage', {userId, courseId: this.courseId}); - } - /** * Set data to new post, clearing temporary files and updating original data. * diff --git a/src/components/user-avatar/user-avatar.ts b/src/components/user-avatar/user-avatar.ts index 298ace24a..22c6fe5a2 100644 --- a/src/components/user-avatar/user-avatar.ts +++ b/src/components/user-avatar/user-avatar.ts @@ -12,13 +12,14 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { Component, Input, OnInit, OnChanges, OnDestroy, SimpleChange } from '@angular/core'; +import { Component, Input, OnInit, OnChanges, OnDestroy, SimpleChange, Optional } from '@angular/core'; import { NavController } from 'ionic-angular'; import { CoreSitesProvider } from '@providers/sites'; import { CoreAppProvider } from '@providers/app'; import { CoreUtilsProvider } from '@providers/utils/utils'; import { CoreEventsProvider } from '@providers/events'; import { CoreUserProvider } from '@core/user/providers/user'; +import { CoreSplitViewComponent } from '@components/split-view/split-view'; /** * Component to display a "user avatar". @@ -48,8 +49,13 @@ export class CoreUserAvatarComponent implements OnInit, OnChanges, OnDestroy { protected currentUserId: number; protected pictureObs; - constructor(private navCtrl: NavController, private sitesProvider: CoreSitesProvider, private utils: CoreUtilsProvider, - private appProvider: CoreAppProvider, eventsProvider: CoreEventsProvider) { + constructor(private navCtrl: NavController, + private sitesProvider: CoreSitesProvider, + private utils: CoreUtilsProvider, + private appProvider: CoreAppProvider, + eventsProvider: CoreEventsProvider, + @Optional() private svComponent: CoreSplitViewComponent) { + this.currentUserId = this.sitesProvider.getCurrentSiteUserId(); this.pictureObs = eventsProvider.on(CoreUserProvider.PROFILE_PICTURE_UPDATED, (data) => { @@ -121,7 +127,10 @@ export class CoreUserAvatarComponent implements OnInit, OnChanges, OnDestroy { if (this.linkProfile && this.userId) { event.preventDefault(); event.stopPropagation(); - this.navCtrl.push('CoreUserProfilePage', { userId: this.userId, courseId: this.courseId }); + + // Decide which navCtrl to use. If this component is inside a split view, use the split view's master nav. + const navCtrl = this.svComponent ? this.svComponent.getMasterNav() : this.navCtrl; + navCtrl.push('CoreUserProfilePage', { userId: this.userId, courseId: this.courseId }); } } diff --git a/src/directives/user-link.ts b/src/directives/user-link.ts index d1714bacb..981e489b1 100644 --- a/src/directives/user-link.ts +++ b/src/directives/user-link.ts @@ -14,6 +14,7 @@ import { Directive, Input, OnInit, ElementRef, Optional } from '@angular/core'; import { NavController } from 'ionic-angular'; +import { CoreSplitViewComponent } from '@components/split-view/split-view'; /** * Directive to go to user profile on click. @@ -27,7 +28,10 @@ export class CoreUserLinkDirective implements OnInit { protected element: HTMLElement; - constructor(element: ElementRef, @Optional() private navCtrl: NavController) { + constructor(element: ElementRef, + @Optional() private navCtrl: NavController, + @Optional() private svComponent: CoreSplitViewComponent) { + // This directive can be added dynamically. In that case, the first param is the anchor HTMLElement. this.element = element.nativeElement || element; } @@ -41,7 +45,10 @@ export class CoreUserLinkDirective implements OnInit { if (!event.defaultPrevented) { event.preventDefault(); event.stopPropagation(); - this.navCtrl.push('CoreUserProfilePage', { userId: this.userId, courseId: this.courseId }); + + // Decide which navCtrl to use. If this directive is inside a split view, use the split view's master nav. + const navCtrl = this.svComponent ? this.svComponent.getMasterNav() : this.navCtrl; + navCtrl.push('CoreUserProfilePage', { userId: this.userId, courseId: this.courseId }); } }); }