RED-6176: Sorted users 2.
This commit is contained in:
parent
882620b5ed
commit
a961419aee
@ -153,7 +153,7 @@ export class ConfigService {
|
||||
checker: (dossier: Dossier, filter: INestedFilter) => this._dossierStatusChecker(dossier, filter),
|
||||
});
|
||||
|
||||
const peopleFilters = [...allDistinctPeople].map(
|
||||
const peopleFilters = this._sortByName([...allDistinctPeople]).map(
|
||||
userId =>
|
||||
new NestedFilter({
|
||||
id: userId,
|
||||
@ -265,4 +265,8 @@ export class ConfigService {
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
private _sortByName(ids: string[]) {
|
||||
return ids.sort((a, b) => this._userService.getName(a).localeCompare(this._userService.getName(b)));
|
||||
}
|
||||
}
|
||||
|
||||
@ -27,7 +27,7 @@
|
||||
(save)="assignReviewer(file, $event)"
|
||||
*ngIf="editingReviewer"
|
||||
[options]="usersOptions$ | async"
|
||||
[value]="file.assignee"
|
||||
[value]="file.assignee === null ? undefined : file.assignee"
|
||||
></redaction-assign-user-dropdown>
|
||||
|
||||
<div *ngIf="!editingReviewer && canAssign$ | async" class="assign-actions-wrapper">
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { Component } from '@angular/core';
|
||||
import { Dossier, File, StatusBarConfigs, User } from '@red/domain';
|
||||
import { List, LoadingService, Toaster } from '@iqser/common-ui';
|
||||
import { getCurrentUser, List, LoadingService, Toaster } from '@iqser/common-ui';
|
||||
import { PermissionsService } from '@services/permissions.service';
|
||||
import { workflowFileStatusTranslations } from '@translations/file-status-translations';
|
||||
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
|
||||
@ -32,6 +32,7 @@ export class UserManagementComponent {
|
||||
private readonly _dossier$: Observable<Dossier>;
|
||||
private readonly _canAssignUser$: Observable<boolean>;
|
||||
private readonly _canUnassignUser$: Observable<boolean>;
|
||||
readonly currentUserId = getCurrentUser().id;
|
||||
|
||||
constructor(
|
||||
readonly fileAssignService: FileAssignService,
|
||||
@ -89,10 +90,11 @@ export class UserManagementComponent {
|
||||
|
||||
this.usersOptions$ = combineLatest([this._canUnassignUser$, this.stateService.file$, this._dossier$]).pipe(
|
||||
map(([canUnassignUser, file, dossier]) => {
|
||||
const unassignUser = canUnassignUser ? [undefined] : [];
|
||||
const unassignUser = canUnassignUser && file.assignee ? [undefined] : [];
|
||||
console.log(unassignUser);
|
||||
return file.isUnderApproval
|
||||
? this._customSort([...dossier.approverIds, ...unassignUser], file)
|
||||
: this._customSort([...dossier.memberIds, ...unassignUser], file);
|
||||
? this.#customSort([...dossier.approverIds, ...unassignUser])
|
||||
: this.#customSort([...dossier.memberIds, ...unassignUser]);
|
||||
}),
|
||||
);
|
||||
}
|
||||
@ -117,12 +119,12 @@ export class UserManagementComponent {
|
||||
this.editingReviewer = false;
|
||||
}
|
||||
|
||||
private _customSort(ids: string[], file: File) {
|
||||
#customSort(ids: string[]) {
|
||||
let sorted = [...ids].sort((a, b) => this.userService.getName(a).localeCompare(this.userService.getName(b)));
|
||||
if (file.assignee) {
|
||||
sorted = moveElementInArray(sorted, file.assignee, 0);
|
||||
sorted = moveElementInArray(sorted, this.currentUserId, 0);
|
||||
if (sorted.includes(undefined)) {
|
||||
sorted = moveElementInArray(sorted, undefined, 1);
|
||||
}
|
||||
sorted = moveElementInArray(sorted, undefined, file.assignee ? 1 : 0);
|
||||
return sorted;
|
||||
}
|
||||
}
|
||||
|
||||
@ -90,28 +90,11 @@ export class AssignReviewerApproverDialogComponent {
|
||||
return this.permissionsService.canUnassignUser(this.data.files, this.dossier);
|
||||
}
|
||||
|
||||
get #uniqueReviewers(): Set<string> {
|
||||
const uniqueReviewers = new Set<string>();
|
||||
|
||||
for (const file of this.data.files) {
|
||||
if (file.assignee) {
|
||||
uniqueReviewers.add(file.assignee);
|
||||
}
|
||||
}
|
||||
|
||||
return uniqueReviewers;
|
||||
}
|
||||
|
||||
get #user(): string {
|
||||
const userOptions = this.userOptions;
|
||||
|
||||
if (this.data.withCurrentUserAsDefault && userOptions.includes(this.currentUser.id)) {
|
||||
return this.currentUser.id;
|
||||
if (this.data.files.every(file => !file.assignee)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const uniqueReviewers = [...this.#uniqueReviewers.values()];
|
||||
const user = uniqueReviewers.length === 1 ? uniqueReviewers[0] : this.currentUser.id;
|
||||
return userOptions.indexOf(user) >= 0 ? userOptions[userOptions.indexOf(user)] : user;
|
||||
return this.data.files.length === 1 ? this.data.files[0].assignee : this.currentUser.id;
|
||||
}
|
||||
|
||||
get #form() {
|
||||
@ -145,14 +128,10 @@ export class AssignReviewerApproverDialogComponent {
|
||||
#customSort(ids: string[]) {
|
||||
let sorted = ids.sort((a, b) => this.userService.getName(a).localeCompare(this.userService.getName(b)));
|
||||
|
||||
const fileHasAssignee = this.data.files.length === 1 && this.data.files[0].assignee;
|
||||
|
||||
if (fileHasAssignee) {
|
||||
sorted = moveElementInArray(sorted, this.data.files[0].assignee, 0);
|
||||
}
|
||||
sorted = moveElementInArray(sorted, this.currentUser.id, 0);
|
||||
|
||||
if (sorted.includes('undefined')) {
|
||||
sorted = moveElementInArray(sorted, 'undefined', fileHasAssignee ? 1 : 0);
|
||||
sorted = moveElementInArray(sorted, 'undefined', 1);
|
||||
}
|
||||
|
||||
return sorted;
|
||||
|
||||
@ -1,14 +1,14 @@
|
||||
import { ChangeDetectionStrategy, Component, Input, OnInit } from '@angular/core';
|
||||
import { UserService } from '@users/user.service';
|
||||
import { UntypedFormBuilder, UntypedFormGroup, Validators } from '@angular/forms';
|
||||
import { Dossier, IDossierRequest, User } from '@red/domain';
|
||||
import { Dossier, IDossierRequest } from '@red/domain';
|
||||
import { EditDossierSaveResult, EditDossierSectionInterface } from '../edit-dossier-section.interface';
|
||||
import { BehaviorSubject, firstValueFrom } from 'rxjs';
|
||||
import { PermissionsService } from '@services/permissions.service';
|
||||
import { DossiersService } from '@services/dossiers/dossiers.service';
|
||||
import { compareLists } from '@utils/functions';
|
||||
import { FilesService } from '@services/files/files.service';
|
||||
import { Debounce, getCurrentUser } from '@iqser/common-ui';
|
||||
import { Debounce } from '@iqser/common-ui';
|
||||
|
||||
@Component({
|
||||
selector: 'redaction-edit-dossier-team',
|
||||
@ -25,7 +25,6 @@ export class EditDossierTeamComponent implements EditDossierSectionInterface, On
|
||||
membersSelectOptions: string[] = [];
|
||||
readonly ownersSelectOptions = this.userService.all.filter(u => u.isManager).map(m => m.id);
|
||||
readonly selectedReviewers$ = new BehaviorSubject<string[]>([]);
|
||||
readonly #currentUser = getCurrentUser<User>();
|
||||
|
||||
constructor(
|
||||
readonly userService: UserService,
|
||||
@ -140,7 +139,8 @@ export class EditDossierTeamComponent implements EditDossierSectionInterface, On
|
||||
this.membersSelectOptions = possibleMembers
|
||||
.filter(user => this.userService.getName(user.id).toLowerCase().includes(value.toLowerCase()))
|
||||
.filter(user => this.selectedOwnerId !== user.id)
|
||||
.map(user => user.id);
|
||||
.map(user => user.id)
|
||||
.sort((a, b) => this.userService.getName(a).localeCompare(this.userService.getName(b)));
|
||||
}
|
||||
|
||||
@Debounce(0)
|
||||
@ -156,7 +156,7 @@ export class EditDossierTeamComponent implements EditDossierSectionInterface, On
|
||||
|
||||
private _setSelectedReviewersList() {
|
||||
const selectedReviewers = this.selectedMembersList.filter(m => this.selectedApproversList.indexOf(m) === -1);
|
||||
this.selectedReviewers$.next(selectedReviewers);
|
||||
this.selectedReviewers$.next(this._sortByName(selectedReviewers));
|
||||
}
|
||||
|
||||
private _loadData() {
|
||||
@ -168,8 +168,8 @@ export class EditDossierTeamComponent implements EditDossierSectionInterface, On
|
||||
},
|
||||
Validators.required,
|
||||
],
|
||||
approvers: [[...this.dossier.approverIds]],
|
||||
members: [[...this.dossier.memberIds]],
|
||||
approvers: [this._sortByName([...this.dossier.approverIds])],
|
||||
members: [this._sortByName([...this.dossier.memberIds])],
|
||||
});
|
||||
this._updateLists();
|
||||
}
|
||||
@ -178,4 +178,8 @@ export class EditDossierTeamComponent implements EditDossierSectionInterface, On
|
||||
this._setSelectedReviewersList();
|
||||
this.setMembersSelectOptions();
|
||||
}
|
||||
|
||||
private _sortByName(ids: string[]) {
|
||||
return ids.sort((a, b) => this.userService.getName(a).localeCompare(this.userService.getName(b)));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,18 +1,20 @@
|
||||
import { Component, ElementRef, EventEmitter, Input, Output, ViewChild } from '@angular/core';
|
||||
import { Component, ElementRef, EventEmitter, inject, Input, OnChanges, Output, ViewChild } from '@angular/core';
|
||||
import { CircleButtonTypes, getCurrentUser, List } from '@iqser/common-ui';
|
||||
import { DossiersDialogService } from '../../../shared-dossiers/services/dossiers-dialog.service';
|
||||
import { ROLES } from '@users/roles';
|
||||
import { User } from '@red/domain';
|
||||
import { UserService } from '@users/user.service';
|
||||
|
||||
@Component({
|
||||
selector: 'redaction-team-members',
|
||||
templateUrl: './team-members.component.html',
|
||||
styleUrls: ['./team-members.component.scss'],
|
||||
})
|
||||
export class TeamMembersComponent {
|
||||
export class TeamMembersComponent implements OnChanges {
|
||||
readonly circleButtonTypes = CircleButtonTypes;
|
||||
readonly roles = ROLES;
|
||||
readonly currentUser = getCurrentUser<User>();
|
||||
readonly userService = inject(UserService);
|
||||
|
||||
@Input() memberIds: List;
|
||||
@Input() perLine: number;
|
||||
@ -29,6 +31,10 @@ export class TeamMembersComponent {
|
||||
|
||||
constructor(private readonly _dialogService: DossiersDialogService) {}
|
||||
|
||||
ngOnChanges() {
|
||||
this.memberIds = [...this.memberIds].sort((a, b) => this.userService.getName(a).localeCompare(this.userService.getName(b)));
|
||||
}
|
||||
|
||||
get maxTeamMembersBeforeExpand(): number {
|
||||
return this.perLine - (this.canAdd ? 1 : 0);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user