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