fix initials avatar not reloading user
This commit is contained in:
parent
5cf4903fd6
commit
8356caa722
@ -125,7 +125,7 @@
|
|||||||
<redaction-needs-work-badge [needsWorkInput]="pw"></redaction-needs-work-badge>
|
<redaction-needs-work-badge [needsWorkInput]="pw"></redaction-needs-work-badge>
|
||||||
</div>
|
</div>
|
||||||
<div class="user-column">
|
<div class="user-column">
|
||||||
<redaction-initials-avatar [user]="getUser(pw.project.ownerId)" [withName]="true"></redaction-initials-avatar>
|
<redaction-initials-avatar [userId]="pw.project.ownerId" [withName]="true"></redaction-initials-avatar>
|
||||||
</div>
|
</div>
|
||||||
<div class="status-container">
|
<div class="status-container">
|
||||||
<redaction-project-listing-actions (actionPerformed)="actionPerformed($event)" [project]="pw"></redaction-project-listing-actions>
|
<redaction-project-listing-actions (actionPerformed)="actionPerformed($event)" [project]="pw"></redaction-project-listing-actions>
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import { Component, Injector, OnDestroy, OnInit, ViewChild } from '@angular/core';
|
import { Component, Injector, OnDestroy, OnInit, ViewChild } from '@angular/core';
|
||||||
import { Project, RuleSetModel, User } from '@redaction/red-ui-http';
|
import { Project, RuleSetModel } from '@redaction/red-ui-http';
|
||||||
import { AppStateService } from '../../../../state/app-state.service';
|
import { AppStateService } from '../../../../state/app-state.service';
|
||||||
import { UserService } from '../../../../services/user.service';
|
import { UserService } from '../../../../services/user.service';
|
||||||
import { DoughnutChartConfig } from '../../../shared/components/simple-doughnut-chart/simple-doughnut-chart.component';
|
import { DoughnutChartConfig } from '../../../shared/components/simple-doughnut-chart/simple-doughnut-chart.component';
|
||||||
@ -157,10 +157,6 @@ export class ProjectListingScreenComponent extends BaseListingComponent<ProjectW
|
|||||||
return this._userService.user;
|
return this._userService.user;
|
||||||
}
|
}
|
||||||
|
|
||||||
public getUser(id: string): User {
|
|
||||||
return this._userService.getUserById(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
public get activeProjectsCount() {
|
public get activeProjectsCount() {
|
||||||
return this.allEntities.filter((p) => p.project.status === Project.StatusEnum.ACTIVE).length;
|
return this.allEntities.filter((p) => p.project.status === Project.StatusEnum.ACTIVE).length;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -51,6 +51,8 @@ export class ProjectOverviewScreenComponent extends BaseListingComponent<FileSta
|
|||||||
@ViewChild('projectDetailsComponent', { static: false })
|
@ViewChild('projectDetailsComponent', { static: false })
|
||||||
private _projectDetailsComponent: ProjectDetailsComponent;
|
private _projectDetailsComponent: ProjectDetailsComponent;
|
||||||
private _filesAutoUpdateTimer: Subscription;
|
private _filesAutoUpdateTimer: Subscription;
|
||||||
|
private _routerEventsScrollPositionSub: Subscription;
|
||||||
|
private _fileChangedSub: Subscription;
|
||||||
private _lastScrollPosition: number;
|
private _lastScrollPosition: number;
|
||||||
|
|
||||||
@ViewChild(CdkVirtualScrollViewport) private _scrollBar: CdkVirtualScrollViewport;
|
@ViewChild(CdkVirtualScrollViewport) private _scrollBar: CdkVirtualScrollViewport;
|
||||||
@ -58,12 +60,10 @@ export class ProjectOverviewScreenComponent extends BaseListingComponent<FileSta
|
|||||||
@ViewChild('statusFilter') private _statusFilterComponent: FilterComponent;
|
@ViewChild('statusFilter') private _statusFilterComponent: FilterComponent;
|
||||||
@ViewChild('peopleFilter') private _peopleFilterComponent: FilterComponent;
|
@ViewChild('peopleFilter') private _peopleFilterComponent: FilterComponent;
|
||||||
@ViewChild('needsWorkFilter') private _needsWorkFilterComponent: FilterComponent;
|
@ViewChild('needsWorkFilter') private _needsWorkFilterComponent: FilterComponent;
|
||||||
private _routerEventsScrollPositionSub: Subscription;
|
|
||||||
private _fileChangedSub: Subscription;
|
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
public readonly userService: UserService,
|
|
||||||
public readonly permissionsService: PermissionsService,
|
public readonly permissionsService: PermissionsService,
|
||||||
|
private readonly _userService: UserService,
|
||||||
private readonly _notificationService: NotificationService,
|
private readonly _notificationService: NotificationService,
|
||||||
private readonly _dialogService: ProjectsDialogService,
|
private readonly _dialogService: ProjectsDialogService,
|
||||||
private readonly _fileUploadService: FileUploadService,
|
private readonly _fileUploadService: FileUploadService,
|
||||||
@ -97,9 +97,9 @@ export class ProjectOverviewScreenComponent extends BaseListingComponent<FileSta
|
|||||||
});
|
});
|
||||||
|
|
||||||
this._routerEventsScrollPositionSub = this._router.events
|
this._routerEventsScrollPositionSub = this._router.events
|
||||||
.pipe(filter((events) => events instanceof NavigationStart || events instanceof NavigationEnd))
|
.pipe(filter((events) => events instanceof NavigationStart))
|
||||||
.subscribe((event) => {
|
.subscribe((event: NavigationStart) => {
|
||||||
if (event instanceof NavigationStart && !event.url.endsWith(this._appStateService.activeProjectId)) {
|
if (!event.url.endsWith(this._appStateService.activeProjectId)) {
|
||||||
this._lastScrollPosition = this._scrollBar.measureScrollOffset('top');
|
this._lastScrollPosition = this._scrollBar.measureScrollOffset('top');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -263,7 +263,7 @@ export class ProjectOverviewScreenComponent extends BaseListingComponent<FileSta
|
|||||||
allDistinctPeople.forEach((userId) => {
|
allDistinctPeople.forEach((userId) => {
|
||||||
peopleFilters.push({
|
peopleFilters.push({
|
||||||
key: userId,
|
key: userId,
|
||||||
label: this.userService.getNameForId(userId)
|
label: this._userService.getNameForId(userId)
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
this.peopleFilters = processFilters(this.peopleFilters, peopleFilters);
|
this.peopleFilters = processFilters(this.peopleFilters, peopleFilters);
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import { Component, Input, OnChanges, OnInit } from '@angular/core';
|
import { Component, Input, OnChanges } from '@angular/core';
|
||||||
import { UserService } from '../../../../services/user.service';
|
import { UserService } from '../../../../services/user.service';
|
||||||
import { User } from '@redaction/red-ui-http';
|
import { User } from '@redaction/red-ui-http';
|
||||||
import { TranslateService } from '@ngx-translate/core';
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
@ -8,7 +8,7 @@ import { TranslateService } from '@ngx-translate/core';
|
|||||||
templateUrl: './initials-avatar.component.html',
|
templateUrl: './initials-avatar.component.html',
|
||||||
styleUrls: ['./initials-avatar.component.scss']
|
styleUrls: ['./initials-avatar.component.scss']
|
||||||
})
|
})
|
||||||
export class InitialsAvatarComponent implements OnInit, OnChanges {
|
export class InitialsAvatarComponent implements OnChanges {
|
||||||
@Input() public userId: string;
|
@Input() public userId: string;
|
||||||
@Input() public user: User;
|
@Input() public user: User;
|
||||||
@Input() public color = 'lightgray';
|
@Input() public color = 'lightgray';
|
||||||
@ -18,65 +18,61 @@ export class InitialsAvatarComponent implements OnInit, OnChanges {
|
|||||||
@Input() public tooltipPosition: 'below' | 'above' = 'above';
|
@Input() public tooltipPosition: 'below' | 'above' = 'above';
|
||||||
|
|
||||||
public displayName: string;
|
public displayName: string;
|
||||||
|
|
||||||
public initials: string;
|
public initials: string;
|
||||||
|
|
||||||
public colorClass: string;
|
public colorClass: string;
|
||||||
|
|
||||||
constructor(private readonly _userService: UserService, private readonly _translateService: TranslateService) {}
|
constructor(private readonly _userService: UserService, private readonly _translateService: TranslateService) {}
|
||||||
|
|
||||||
ngOnInit(): void {}
|
|
||||||
|
|
||||||
ngOnChanges(): void {
|
ngOnChanges(): void {
|
||||||
const isSystemUser = this.userId && this.userId.toLowerCase() === 'system';
|
const isSystemUser = this.userId && this.userId.toLowerCase() === 'system';
|
||||||
if (!isSystemUser) {
|
if (isSystemUser) {
|
||||||
if (this.user) {
|
|
||||||
this.userId = this.user.userId;
|
|
||||||
} else {
|
|
||||||
this.user = this._userService.getUserById(this.userId);
|
|
||||||
}
|
|
||||||
this.displayName = this._userService.getName(this.user);
|
|
||||||
if (this.showYou && this._userService.userId === this.userId) {
|
|
||||||
this.displayName += ` (${this._translateService.instant('initials-avatar.you')})`;
|
|
||||||
}
|
|
||||||
this.initials = this._getInitials();
|
|
||||||
this.colorClass = this._colorClass;
|
|
||||||
} else {
|
|
||||||
this.displayName = 'System';
|
this.displayName = 'System';
|
||||||
this.initials = 'SY';
|
this.initials = 'SY';
|
||||||
this.colorClass = 'red-white red';
|
this.colorClass = 'red-white red';
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.userId) {
|
||||||
|
this.user = this._userService.getUserById(this.userId);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.displayName = this._userService.getName(this.user);
|
||||||
|
if (this.showYou && this._isCurrentUser) {
|
||||||
|
this.displayName += ` (${this._translateService.instant('initials-avatar.you')})`;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.initials = this._getInitials();
|
||||||
|
this.colorClass = this._colorClass;
|
||||||
}
|
}
|
||||||
|
|
||||||
private _getInitials() {
|
private _getInitials(): string {
|
||||||
if (!this.user) {
|
if (!this.user) {
|
||||||
return '?';
|
return '?';
|
||||||
} else {
|
|
||||||
return this._userService
|
|
||||||
.getName(this.user)
|
|
||||||
.split(' ')
|
|
||||||
.filter((value) => value !== ' ')
|
|
||||||
.filter((value, idx) => idx < 2)
|
|
||||||
.map((str) => str[0])
|
|
||||||
.join('');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return this._userService
|
||||||
|
.getName(this.user)
|
||||||
|
.split(' ')
|
||||||
|
.filter((value) => value !== ' ')
|
||||||
|
.filter((value, idx) => idx < 2)
|
||||||
|
.map((str) => str[0])
|
||||||
|
.join('');
|
||||||
}
|
}
|
||||||
|
|
||||||
private get _colorClass() {
|
private get _colorClass(): string {
|
||||||
if (this._userService.userId === this.userId) {
|
if (this._isCurrentUser) return 'red-white';
|
||||||
return 'red-white';
|
if (this.disabled) return 'inactive';
|
||||||
}
|
if (this.color.includes('-')) return this.color;
|
||||||
if (this.disabled) {
|
|
||||||
return 'inactive';
|
|
||||||
}
|
|
||||||
if (this.color.includes('-')) {
|
|
||||||
return this.color;
|
|
||||||
}
|
|
||||||
return `${this.color}-dark`;
|
return `${this.color}-dark`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private get _isCurrentUser(): boolean {
|
||||||
|
return this.user && this._userService.userId === this.user.userId;
|
||||||
|
}
|
||||||
|
|
||||||
public get hasBorder(): boolean {
|
public get hasBorder(): boolean {
|
||||||
return !!this.user && this._userService.userId !== this.userId && this._userService.isManager(this.user);
|
return !!this.user && !this._isCurrentUser && this._userService.isManager(this.user);
|
||||||
}
|
}
|
||||||
|
|
||||||
public get disabled(): boolean {
|
public get disabled(): boolean {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user