@masterteam/users-groups 0.0.45 → 0.0.47

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,12 +1,13 @@
1
1
  import { CommonModule } from '@angular/common';
2
2
  import * as i0 from '@angular/core';
3
- import { inject, Injectable, computed, signal, Component, input, effect, untracked, linkedSignal, viewChild } from '@angular/core';
3
+ import { inject, Injectable, computed, DestroyRef, signal, Component, input, effect, untracked, linkedSignal, viewChild } from '@angular/core';
4
+ import { toSignal, takeUntilDestroyed } from '@angular/core/rxjs-interop';
4
5
  import { Breadcrumb } from '@masterteam/components/breadcrumb';
5
- import { CrudStateBase, REQUEST_CONTEXT, handleApiRequest, UserSearchFieldConfig, ValidatorConfig, UploadFileFieldConfig, TextareaFieldConfig } from '@masterteam/components';
6
+ import { CrudStateBase, REQUEST_CONTEXT, handleApiRequest, UserSearchFieldConfig, ValidatorConfig, UploadFileFieldConfig, SelectFieldConfig, TextareaFieldConfig, MTDateFormatPipe } from '@masterteam/components';
6
7
  import { Action, Selector, State, Store, select } from '@ngxs/store';
7
8
  import { HttpClient, HttpContext } from '@angular/common/http';
8
- import { of, from, concatMap, map, toArray, catchError, finalize } from 'rxjs';
9
- import { ActivatedRoute, Router, RouterOutlet } from '@angular/router';
9
+ import { of, from, concatMap, map, toArray, catchError, shareReplay, filter, firstValueFrom, take, finalize, distinctUntilChanged } from 'rxjs';
10
+ import { ActivatedRoute, Router, NavigationEnd, RouterOutlet } from '@angular/router';
10
11
  import { TranslocoService, TranslocoDirective, TranslocoPipe } from '@jsverse/transloco';
11
12
  import { Page } from '@masterteam/components/page';
12
13
  import { Button } from '@masterteam/components/button';
@@ -16,7 +17,6 @@ import * as i1 from 'primeng/skeleton';
16
17
  import { SkeletonModule } from 'primeng/skeleton';
17
18
  import { Icon } from '@masterteam/icons';
18
19
  import { ModalService } from '@masterteam/components/modal';
19
- import { toSignal } from '@angular/core/rxjs-interop';
20
20
  import * as i1$1 from '@angular/forms';
21
21
  import { FormControl, ReactiveFormsModule } from '@angular/forms';
22
22
  import { DynamicForm } from '@masterteam/forms/dynamic-form';
@@ -28,6 +28,9 @@ import { EmptyState } from '@masterteam/components/empty-state';
28
28
  import { TextField } from '@masterteam/components/text-field';
29
29
  import { Tree } from '@masterteam/components/tree';
30
30
  import { SecureImagePipe } from '@masterteam/components/upload-field';
31
+ import { ConfirmationService } from '@masterteam/components/confirmation';
32
+ import * as i2 from 'primeng/progressbar';
33
+ import { ProgressBarModule } from 'primeng/progressbar';
31
34
 
32
35
  class GetUserLockStatuses {
33
36
  userIds;
@@ -78,9 +81,15 @@ class UpdateUser {
78
81
  }
79
82
  class DeleteUser {
80
83
  userName;
84
+ acknowledgeRemainingWork;
81
85
  static type = '[UsersGroups] Delete User';
82
- constructor(userName) {
86
+ /**
87
+ * `acknowledgeRemainingWork`: remove the person although they still hold
88
+ * work in the application (the Replace by "Remove anyway" path).
89
+ */
90
+ constructor(userName, acknowledgeRemainingWork = false) {
83
91
  this.userName = userName;
92
+ this.acknowledgeRemainingWork = acknowledgeRemainingWork;
84
93
  }
85
94
  }
86
95
  class LinkUserToApplication {
@@ -369,11 +378,14 @@ let UsersGroupsState = class UsersGroupsState extends CrudStateBase {
369
378
  },
370
379
  });
371
380
  }
372
- deleteUser(ctx, { userName }) {
381
+ deleteUser(ctx, { userName, acknowledgeRemainingWork }) {
373
382
  const encodedUserName = this.encodeUserName(userName);
374
383
  const userNameKey = String(userName);
375
384
  const req$ = this.http.delete(`Identity/users/${encodedUserName}`, {
376
385
  context: this.context,
386
+ ...(acknowledgeRemainingWork
387
+ ? { params: { acknowledgeRemainingWork: true } }
388
+ : {}),
377
389
  });
378
390
  return handleApiRequest({
379
391
  ctx,
@@ -712,8 +724,8 @@ class UsersGroupsFacade {
712
724
  updateUser(id, changes) {
713
725
  return this.store.dispatch(new UpdateUser(id, changes));
714
726
  }
715
- deleteUser(userName) {
716
- return this.store.dispatch(new DeleteUser(userName));
727
+ deleteUser(userName, acknowledgeRemainingWork = false) {
728
+ return this.store.dispatch(new DeleteUser(userName, acknowledgeRemainingWork));
717
729
  }
718
730
  linkUserToApplication(userName) {
719
731
  return this.store.dispatch(new LinkUserToApplication(userName));
@@ -753,13 +765,151 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImpor
753
765
  args: [{ providedIn: 'root' }]
754
766
  }] });
755
767
 
768
+ const BASE = 'identity/users/replacement';
769
+ const OPERATIONS = `${BASE}/operations`;
770
+ /**
771
+ * Every failure is shown by the Replace by screens themselves, translated from
772
+ * the backend's stable key, so the app's message interceptor stays silent.
773
+ */
774
+ const SILENT = { noMessage: 'true' };
775
+ /**
776
+ * HTTP calls of the Replace by flow. The flow's state is page-local (one
777
+ * replacement on one screen, the list on another), so the screens keep it in
778
+ * signals instead of the shared users-groups store.
779
+ *
780
+ * One confirmation (`start`) is all a screen sends: the server finds the work
781
+ * and hands it over in the background. The old preview routes (collect,
782
+ * accept, execute, takeover), the capabilities list and the successor check
783
+ * are gone and must not be called.
784
+ */
785
+ class UserReplacementService {
786
+ http = inject(HttpClient);
787
+ available$ = null;
788
+ /**
789
+ * Whether this backend runs replacements: one small read of the list, once
790
+ * per session. False when the route is missing (an older backend) or
791
+ * refused (no CONTROL_PANEL, a delegation session): the screens then hide
792
+ * the feature. A failure is not cached, so a later screen asks again.
793
+ */
794
+ available() {
795
+ this.available$ ??= this.http
796
+ .get(OPERATIONS, {
797
+ headers: SILENT,
798
+ params: { filter: 'Active', pageSize: 1 },
799
+ })
800
+ .pipe(map(() => true), catchError(() => {
801
+ this.available$ = null;
802
+ return of(false);
803
+ }), shareReplay(1));
804
+ return this.available$;
805
+ }
806
+ /**
807
+ * The one confirmation: authorizes the background handover. Success means
808
+ * it was recorded, not that anything moved yet.
809
+ */
810
+ start(request) {
811
+ return this.http
812
+ .post(OPERATIONS, request, {
813
+ headers: SILENT,
814
+ })
815
+ .pipe(map((response) => response.data));
816
+ }
817
+ /** Current and past replacements of this application, newest first. */
818
+ list(request) {
819
+ const params = {
820
+ filter: request.filter,
821
+ pageSize: request.pageSize ?? 25,
822
+ };
823
+ if (request.afterOperationId)
824
+ params['afterOperationId'] = request.afterOperationId;
825
+ if (request.sourceUserId)
826
+ params['sourceUserId'] = request.sourceUserId;
827
+ return this.http
828
+ .get(OPERATIONS, {
829
+ headers: SILENT,
830
+ params,
831
+ })
832
+ .pipe(map((response) => response.data));
833
+ }
834
+ get(operationId) {
835
+ return this.http
836
+ .get(`${OPERATIONS}/${encodeURIComponent(operationId)}`, { headers: SILENT })
837
+ .pipe(map((response) => response.data));
838
+ }
839
+ /** One page of items with their results; page size 1–200. */
840
+ results(operationId, afterItemId, pageSize = 200) {
841
+ return this.http
842
+ .get(`${OPERATIONS}/${encodeURIComponent(operationId)}/results`, { headers: SILENT, params: { afterItemId, pageSize } })
843
+ .pipe(map((response) => response.data));
844
+ }
845
+ /**
846
+ * Stop or close. What was handed over stays handed over. A 409
847
+ * `UserReplacement_ProcessingBusy` means it did NOT stop: the server was
848
+ * in the middle of a step; refresh and let the admin try again.
849
+ */
850
+ cancel(operationId) {
851
+ return this.http
852
+ .post(`${OPERATIONS}/${encodeURIComponent(operationId)}/cancel`, null, { headers: SILENT })
853
+ .pipe(map((response) => response.data));
854
+ }
855
+ remainingWork(userId) {
856
+ return this.http
857
+ .get(`${BASE}/remaining-work`, {
858
+ headers: SILENT,
859
+ params: { userId },
860
+ })
861
+ .pipe(map((response) => response.data));
862
+ }
863
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: UserReplacementService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
864
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: UserReplacementService, providedIn: 'root' });
865
+ }
866
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: UserReplacementService, decorators: [{
867
+ type: Injectable,
868
+ args: [{ providedIn: 'root' }]
869
+ }] });
870
+ /**
871
+ * The stable failure key (`UserReplacement_*`) the backend puts in the
872
+ * envelope's `message`; else the first message it sent, which the screens
873
+ * show as the generic failure text.
874
+ */
875
+ function replacementErrorKey(error) {
876
+ const body = error?.error;
877
+ const candidates = [
878
+ body?.message,
879
+ body?.errors?.message,
880
+ body?.errors?.code,
881
+ body?.code,
882
+ body?.Message,
883
+ ].filter((value) => typeof value === 'string' && !!value.trim());
884
+ return (candidates.find((value) => /^UserReplacement_\w+$/.test(value)) ??
885
+ candidates[0] ??
886
+ null);
887
+ }
888
+ /**
889
+ * The open replacement that blocks a new one (`UserReplacement_ConcurrentHandover`,
890
+ * 409): the backend puts its id in `errors.details.blockingOperationId`.
891
+ */
892
+ function blockingOperationId(error) {
893
+ const body = error?.error;
894
+ const id = body?.errors?.details?.blockingOperationId;
895
+ return typeof id === 'string' && id ? id : null;
896
+ }
897
+ /** A gateway timeout or restart: nothing is damaged; read it again. */
898
+ function isTransientGatewayError(error) {
899
+ const status = error?.status;
900
+ return status === 502 || status === 503 || status === 504 || status === 0;
901
+ }
902
+
756
903
  class UsersGroups {
757
904
  facade = inject(UsersGroupsFacade);
758
905
  route = inject(ActivatedRoute);
759
906
  router = inject(Router);
907
+ destroyRef = inject(DestroyRef);
760
908
  translocoService = inject(TranslocoService);
761
909
  selectedTab = signal('users', ...(ngDevMode ? [{ debugName: "selectedTab" }] : /* istanbul ignore next */ []));
762
- tabsList = [
910
+ /** Replacements get their own tab where this backend runs them. */
911
+ replacementsAvailable = toSignal(inject(UserReplacementService).available(), { initialValue: false });
912
+ tabsList = computed(() => [
763
913
  {
764
914
  label: this.translocoService.translate('users-groups.users'),
765
915
  value: 'users',
@@ -768,7 +918,27 @@ class UsersGroups {
768
918
  label: this.translocoService.translate('users-groups.groups'),
769
919
  value: 'groups',
770
920
  },
771
- ];
921
+ ...(this.replacementsAvailable()
922
+ ? [
923
+ {
924
+ label: this.translocoService.translate('users-groups.replacements'),
925
+ value: 'replacements',
926
+ },
927
+ ]
928
+ : []),
929
+ ], ...(ngDevMode ? [{ debugName: "tabsList" }] : /* istanbul ignore next */ []));
930
+ /**
931
+ * `mt-tabs` falls back to its first option when the active value is not
932
+ * one of its options, and keeps that choice when the option appears later.
933
+ * The Replacements tab arrives once the backend answers, so hold the value
934
+ * back until its tab exists; the change then re-selects it.
935
+ */
936
+ activeTab = computed(() => {
937
+ const tab = this.selectedTab();
938
+ return this.tabsList().some((option) => option.value === tab)
939
+ ? tab
940
+ : undefined;
941
+ }, ...(ngDevMode ? [{ debugName: "activeTab" }] : /* istanbul ignore next */ []));
772
942
  breadcrumbItems = [
773
943
  {
774
944
  label: '',
@@ -782,9 +952,17 @@ class UsersGroups {
782
952
  { label: this.translocoService.translate('users-groups.users-groups') },
783
953
  ];
784
954
  ngOnInit() {
785
- const selectedTab = this.route.snapshot.firstChild?.data['componentType'];
786
955
  // No users load here: the Users page is the only reader and loads them
787
956
  // itself. Loading here too doubled both Identity/users and lock-status.
957
+ this.syncTab();
958
+ // Pages move between tabs themselves (Users → a replacement plan), so
959
+ // follow the route instead of reading it once.
960
+ this.router.events
961
+ .pipe(filter((event) => event instanceof NavigationEnd), takeUntilDestroyed(this.destroyRef))
962
+ .subscribe(() => this.syncTab());
963
+ }
964
+ syncTab() {
965
+ const selectedTab = this.route.snapshot.firstChild?.data['componentType'];
788
966
  this.selectedTab.set(selectedTab || 'users');
789
967
  }
790
968
  goBack() {
@@ -798,12 +976,15 @@ class UsersGroups {
798
976
  else if (event == 'groups') {
799
977
  this.router.navigate(['groups'], { relativeTo: this.route });
800
978
  }
979
+ else if (event == 'replacements') {
980
+ this.router.navigate(['replacements'], { relativeTo: this.route });
981
+ }
801
982
  }
802
983
  getUsers() {
803
984
  this.facade.getUsers();
804
985
  }
805
986
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: UsersGroups, deps: [], target: i0.ɵɵFactoryTarget.Component });
806
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.8", type: UsersGroups, isStandalone: true, selector: "mt-users-groups", ngImport: i0, template: "<ng-container *transloco=\"let t; prefix: 'users-groups'\">\r\n <mt-page\r\n [title]=\"t('users-groups')\"\r\n [avatarIcon]=\"'user.user-circle'\"\r\n [avatarStyle]=\"{\r\n '--p-avatar-background': 'var(--p-sky-100)',\r\n '--p-avatar-color': 'var(--p-sky-700)',\r\n }\"\r\n [tabs]=\"tabsList\"\r\n [activeTab]=\"selectedTab()\"\r\n (tabChange)=\"onTabChange($event)\"\r\n (backButtonClick)=\"goBack()\"\r\n backButton\r\n >\r\n <div class=\"flex justify-between items-end\">\r\n <div>\r\n <h3 class=\"font-bold text-lg\">{{ t(\"users-groups\") }}</h3>\r\n <mt-breadcrumb\r\n [items]=\"breadcrumbItems\"\r\n [styleClass]=\"'flex justify-start mx-1'\"\r\n ></mt-breadcrumb>\r\n </div>\r\n @if (selectedTab() === \"users\") {\r\n <mt-button\r\n [icon]=\"'arrow.refresh-cw-02'\"\r\n [label]=\"\r\n translocoService.translate('users-groups.sync-users-information')\r\n \"\r\n [severity]=\"'primary'\"\r\n [variant]=\"'outlined'\"\r\n [size]=\"'small'\"\r\n (click)=\"getUsers()\"\r\n class=\"mx-4\"\r\n >\r\n </mt-button>\r\n }\r\n </div>\r\n <router-outlet />\r\n </mt-page>\r\n</ng-container>\r\n", styles: [""], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "component", type: Page, selector: "mt-page", inputs: ["backButton", "backButtonIcon", "avatarIcon", "avatarStyle", "avatarShape", "title", "tabs", "activeTab", "contentClass", "contentId"], outputs: ["backButtonClick", "tabChange"] }, { kind: "component", type: Breadcrumb, selector: "mt-breadcrumb", inputs: ["items", "styleClass"], outputs: ["onItemClick"] }, { kind: "directive", type: RouterOutlet, selector: "router-outlet", inputs: ["name", "routerOutletData"], outputs: ["activate", "deactivate", "attach", "detach"], exportAs: ["outlet"] }, { kind: "directive", type: TranslocoDirective, selector: "[transloco]", inputs: ["transloco", "translocoParams", "translocoScope", "translocoRead", "translocoPrefix", "translocoLang", "translocoLoadingTpl"] }, { kind: "component", type: Button, selector: "mt-button", inputs: ["icon", "label", "tooltip", "class", "type", "styleClass", "severity", "badge", "variant", "badgeSeverity", "size", "iconPos", "autofocus", "fluid", "raised", "rounded", "text", "plain", "outlined", "link", "disabled", "loading", "pInputs", "ariaLabel"], outputs: ["onClick", "onFocus", "onBlur"] }] });
987
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.8", type: UsersGroups, isStandalone: true, selector: "mt-users-groups", ngImport: i0, template: "<ng-container *transloco=\"let t; prefix: 'users-groups'\">\r\n <mt-page\r\n [title]=\"t('users-groups')\"\r\n [avatarIcon]=\"'user.user-circle'\"\r\n [avatarStyle]=\"{\r\n '--p-avatar-background': 'var(--p-sky-100)',\r\n '--p-avatar-color': 'var(--p-sky-700)',\r\n }\"\r\n [tabs]=\"tabsList()\"\r\n [activeTab]=\"activeTab()\"\r\n (tabChange)=\"onTabChange($event)\"\r\n (backButtonClick)=\"goBack()\"\r\n backButton\r\n >\r\n <div class=\"flex justify-between items-end\">\r\n <div>\r\n <h3 class=\"font-bold text-lg\">{{ t(\"users-groups\") }}</h3>\r\n <mt-breadcrumb\r\n [items]=\"breadcrumbItems\"\r\n [styleClass]=\"'flex justify-start mx-1'\"\r\n ></mt-breadcrumb>\r\n </div>\r\n @if (selectedTab() === \"users\") {\r\n <mt-button\r\n [icon]=\"'arrow.refresh-cw-02'\"\r\n [label]=\"\r\n translocoService.translate('users-groups.sync-users-information')\r\n \"\r\n [severity]=\"'primary'\"\r\n [variant]=\"'outlined'\"\r\n [size]=\"'small'\"\r\n (click)=\"getUsers()\"\r\n class=\"mx-4\"\r\n >\r\n </mt-button>\r\n }\r\n </div>\r\n <router-outlet />\r\n </mt-page>\r\n</ng-container>\r\n", styles: [""], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "component", type: Page, selector: "mt-page", inputs: ["backButton", "backButtonIcon", "avatarIcon", "avatarStyle", "avatarShape", "title", "tabs", "activeTab", "contentClass", "contentId"], outputs: ["backButtonClick", "tabChange"] }, { kind: "component", type: Breadcrumb, selector: "mt-breadcrumb", inputs: ["items", "styleClass"], outputs: ["onItemClick"] }, { kind: "directive", type: RouterOutlet, selector: "router-outlet", inputs: ["name", "routerOutletData"], outputs: ["activate", "deactivate", "attach", "detach"], exportAs: ["outlet"] }, { kind: "directive", type: TranslocoDirective, selector: "[transloco]", inputs: ["transloco", "translocoParams", "translocoScope", "translocoRead", "translocoPrefix", "translocoLang", "translocoLoadingTpl"] }, { kind: "component", type: Button, selector: "mt-button", inputs: ["icon", "label", "tooltip", "class", "type", "styleClass", "severity", "badge", "variant", "badgeSeverity", "size", "iconPos", "autofocus", "fluid", "raised", "rounded", "text", "plain", "outlined", "link", "disabled", "loading", "pInputs", "ariaLabel"], outputs: ["onClick", "onFocus", "onBlur"] }] });
807
988
  }
808
989
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: UsersGroups, decorators: [{
809
990
  type: Component,
@@ -814,7 +995,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImpor
814
995
  RouterOutlet,
815
996
  TranslocoDirective,
816
997
  Button,
817
- ], template: "<ng-container *transloco=\"let t; prefix: 'users-groups'\">\r\n <mt-page\r\n [title]=\"t('users-groups')\"\r\n [avatarIcon]=\"'user.user-circle'\"\r\n [avatarStyle]=\"{\r\n '--p-avatar-background': 'var(--p-sky-100)',\r\n '--p-avatar-color': 'var(--p-sky-700)',\r\n }\"\r\n [tabs]=\"tabsList\"\r\n [activeTab]=\"selectedTab()\"\r\n (tabChange)=\"onTabChange($event)\"\r\n (backButtonClick)=\"goBack()\"\r\n backButton\r\n >\r\n <div class=\"flex justify-between items-end\">\r\n <div>\r\n <h3 class=\"font-bold text-lg\">{{ t(\"users-groups\") }}</h3>\r\n <mt-breadcrumb\r\n [items]=\"breadcrumbItems\"\r\n [styleClass]=\"'flex justify-start mx-1'\"\r\n ></mt-breadcrumb>\r\n </div>\r\n @if (selectedTab() === \"users\") {\r\n <mt-button\r\n [icon]=\"'arrow.refresh-cw-02'\"\r\n [label]=\"\r\n translocoService.translate('users-groups.sync-users-information')\r\n \"\r\n [severity]=\"'primary'\"\r\n [variant]=\"'outlined'\"\r\n [size]=\"'small'\"\r\n (click)=\"getUsers()\"\r\n class=\"mx-4\"\r\n >\r\n </mt-button>\r\n }\r\n </div>\r\n <router-outlet />\r\n </mt-page>\r\n</ng-container>\r\n" }]
998
+ ], template: "<ng-container *transloco=\"let t; prefix: 'users-groups'\">\r\n <mt-page\r\n [title]=\"t('users-groups')\"\r\n [avatarIcon]=\"'user.user-circle'\"\r\n [avatarStyle]=\"{\r\n '--p-avatar-background': 'var(--p-sky-100)',\r\n '--p-avatar-color': 'var(--p-sky-700)',\r\n }\"\r\n [tabs]=\"tabsList()\"\r\n [activeTab]=\"activeTab()\"\r\n (tabChange)=\"onTabChange($event)\"\r\n (backButtonClick)=\"goBack()\"\r\n backButton\r\n >\r\n <div class=\"flex justify-between items-end\">\r\n <div>\r\n <h3 class=\"font-bold text-lg\">{{ t(\"users-groups\") }}</h3>\r\n <mt-breadcrumb\r\n [items]=\"breadcrumbItems\"\r\n [styleClass]=\"'flex justify-start mx-1'\"\r\n ></mt-breadcrumb>\r\n </div>\r\n @if (selectedTab() === \"users\") {\r\n <mt-button\r\n [icon]=\"'arrow.refresh-cw-02'\"\r\n [label]=\"\r\n translocoService.translate('users-groups.sync-users-information')\r\n \"\r\n [severity]=\"'primary'\"\r\n [variant]=\"'outlined'\"\r\n [size]=\"'small'\"\r\n (click)=\"getUsers()\"\r\n class=\"mx-4\"\r\n >\r\n </mt-button>\r\n }\r\n </div>\r\n <router-outlet />\r\n </mt-page>\r\n</ng-container>\r\n" }]
818
999
  }] });
819
1000
 
820
1001
  class UserForm {
@@ -1637,6 +1818,300 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImpor
1637
1818
  ], template: "<ng-container *transloco=\"let t; prefix: 'users-groups'\">\r\n <!-- Who this is \u2014 rendered from the table row, so it never waits on the request. -->\r\n <div class=\"min-h-0 flex-1 overflow-y-auto\">\r\n <section class=\"flex items-center gap-3 border-b border-surface p-4\">\r\n <mt-avatar\r\n [image]=\"\r\n profile().image\r\n ? $any(profile().image | secureImage: true : context : 'avatar/')\r\n : ''\r\n \"\r\n icon=\"user.user-01\"\r\n size=\"large\"\r\n styleClass=\"text-surface-600! bg-surface-200!\"\r\n />\r\n\r\n <div class=\"flex min-w-0 flex-1 flex-col gap-1\">\r\n <div class=\"flex min-w-0 flex-wrap items-center gap-2\">\r\n <h2\r\n class=\"min-w-0 truncate text-base font-semibold text-color\"\r\n [title]=\"profile().displayName\"\r\n >\r\n {{ profile().displayName }}\r\n </h2>\r\n @if (profile().isExternal) {\r\n <mt-summary-pill tone=\"neutral\">\r\n <mt-icon icon=\"general.link-external-02\" class=\"text-xs\" />\r\n {{ t(\"external\") }}\r\n </mt-summary-pill>\r\n } @else {\r\n <mt-summary-pill tone=\"success\">\r\n <mt-icon icon=\"user.users-01\" class=\"text-xs\" />\r\n {{ t(\"internal\") }}\r\n </mt-summary-pill>\r\n }\r\n </div>\r\n\r\n @if (profile().userName) {\r\n <span\r\n class=\"inline-flex min-w-0 items-center gap-1 text-sm text-muted-color\"\r\n >\r\n <mt-icon icon=\"user.user-01\" class=\"shrink-0 text-sm\" />\r\n <span class=\"truncate\">{{ profile().userName }}</span>\r\n </span>\r\n }\r\n </div>\r\n </section>\r\n\r\n <div class=\"sticky top-0 z-10 bg-content px-4 pt-2\">\r\n <mt-tabs [options]=\"tabs()\" [(active)]=\"activeTab\" mode=\"underline\" />\r\n </div>\r\n\r\n <div class=\"p-4\">\r\n @if (loading()) {\r\n <div class=\"flex flex-col gap-3\">\r\n @for (row of [1, 2, 3, 4]; track row) {\r\n <p-skeleton height=\"3.5rem\" borderRadius=\"0.375rem\" />\r\n }\r\n </div>\r\n } @else if (error()) {\r\n <div\r\n class=\"flex flex-col items-start gap-3 rounded-md border border-rose-200 bg-rose-50 p-4 dark:border-rose-800 dark:bg-rose-900/30\"\r\n role=\"alert\"\r\n >\r\n <div class=\"flex flex-col gap-1\">\r\n <span\r\n class=\"text-sm font-semibold text-rose-700 dark:text-rose-200\"\r\n >\r\n {{ t(\"summary-load-failed\") }}\r\n </span>\r\n <span class=\"text-sm text-rose-600 dark:text-rose-300\">\r\n {{ t(\"summary-load-failed-hint\") }}\r\n </span>\r\n </div>\r\n <mt-button\r\n icon=\"arrow.refresh-cw-02\"\r\n severity=\"danger\"\r\n variant=\"outlined\"\r\n size=\"small\"\r\n [label]=\"t('try-again')\"\r\n (onClick)=\"load()\"\r\n />\r\n </div>\r\n } @else {\r\n @switch (activeTab()) {\r\n @case (\"groups\") {\r\n @if (groups().length === 0) {\r\n <mt-empty-state\r\n illustration=\"none\"\r\n [title]=\"t('no-linked-groups')\"\r\n [description]=\"t('user-groups-hint')\"\r\n />\r\n } @else {\r\n <div class=\"flex flex-col gap-3\">\r\n @if (showGroupSearch()) {\r\n <mt-text-field\r\n [formControl]=\"groupSearch\"\r\n icon=\"general.search-lg\"\r\n [placeholder]=\"t('search-groups')\"\r\n />\r\n }\r\n <ul class=\"rounded-md border border-surface\">\r\n @for (group of filteredGroups(); track group.id) {\r\n <li\r\n class=\"flex items-center gap-3 border-b border-surface px-3 py-2.5 last:border-b-0\"\r\n >\r\n <mt-avatar\r\n icon=\"user.users-01\"\r\n shape=\"square\"\r\n styleClass=\"bg-primary-50! text-primary!\"\r\n />\r\n <div class=\"flex min-w-0 flex-1 flex-col\">\r\n <span\r\n class=\"truncate text-sm font-medium text-color\"\r\n [title]=\"group.name\"\r\n >\r\n {{ group.name }}\r\n </span>\r\n @if (group.description) {\r\n <span\r\n class=\"truncate text-xs text-muted-color\"\r\n [title]=\"group.description\"\r\n >\r\n {{ group.description }}\r\n </span>\r\n }\r\n </div>\r\n <span\r\n class=\"inline-flex shrink-0 items-center gap-1 text-xs text-muted-color\"\r\n >\r\n <mt-icon icon=\"user.user-01\" class=\"text-sm\" />\r\n {{ group.membersCount }}\r\n </span>\r\n @if (group.isActivated) {\r\n <mt-summary-pill tone=\"success\">\r\n {{ t(\"active\") }}\r\n </mt-summary-pill>\r\n } @else {\r\n <mt-summary-pill tone=\"neutral\">\r\n {{ t(\"inactive\") }}\r\n </mt-summary-pill>\r\n }\r\n </li>\r\n } @empty {\r\n <li>\r\n <mt-empty-state\r\n variant=\"filtered\"\r\n illustration=\"none\"\r\n [title]=\"t('no-search-results')\"\r\n />\r\n </li>\r\n }\r\n </ul>\r\n </div>\r\n }\r\n }\r\n\r\n @case (\"roles\") {\r\n @if (roleTree().length === 0) {\r\n <mt-empty-state\r\n illustration=\"none\"\r\n [title]=\"t('no-roles')\"\r\n [description]=\"t('user-roles-hint')\"\r\n />\r\n } @else {\r\n <mt-tree\r\n class=\"block\"\r\n [value]=\"roleTree()\"\r\n [filter]=\"true\"\r\n [filterPlaceholder]=\"t('search-roles')\"\r\n />\r\n }\r\n }\r\n\r\n @case (\"permissions\") {\r\n @if (permissionTree().length === 0) {\r\n <mt-empty-state\r\n illustration=\"none\"\r\n [title]=\"t('no-permissions')\"\r\n [description]=\"t('user-permissions-hint')\"\r\n />\r\n } @else {\r\n <mt-tree\r\n class=\"block\"\r\n [value]=\"permissionTree()\"\r\n [filter]=\"true\"\r\n [filterPlaceholder]=\"t('search-permissions')\"\r\n />\r\n }\r\n }\r\n\r\n @case (\"accessibilities\") {\r\n <mt-summary-accessibilities\r\n [accessibilities]=\"accessibilities()\"\r\n [emptyMessage]=\"t('no-accessibilities')\"\r\n />\r\n }\r\n }\r\n }\r\n </div>\r\n </div>\r\n</ng-container>\r\n" }]
1638
1819
  }], propDecorators: { user: [{ type: i0.Input, args: [{ isSignal: true, alias: "user", required: false }] }] } });
1639
1820
 
1821
+ const ROOT = 'users-groups.replacement';
1822
+ /**
1823
+ * The backend returns stable codes (failure keys, reasons, results, stores)
1824
+ * and never translated text. Known codes are translated; an unknown one is
1825
+ * shown as it is, never hidden.
1826
+ */
1827
+ class ReplacementText {
1828
+ transloco;
1829
+ constructor(transloco) {
1830
+ this.transloco = transloco;
1831
+ }
1832
+ t(key, params) {
1833
+ return this.transloco.translate(`${ROOT}.${key}`, params);
1834
+ }
1835
+ /** Translation of `<group>.<code>`, or `fallback` when it has none. */
1836
+ code(group, code, fallback) {
1837
+ if (!code)
1838
+ return fallback ?? '';
1839
+ const path = `${ROOT}.${group}.${code}`;
1840
+ const text = this.transloco.translate(path);
1841
+ return text && text !== path ? text : (fallback ?? code);
1842
+ }
1843
+ /** A failure key from the envelope's `message`, or the generic text. */
1844
+ error(key) {
1845
+ return this.code('errors', key, this.t('errors.generic'));
1846
+ }
1847
+ /** `property-values` → the translated label, else "Property values". */
1848
+ store(id) {
1849
+ return this.code('stores', id, humanize$1(id));
1850
+ }
1851
+ }
1852
+ /** "Sara Al Ali" → "SA"; one word → its first two letters. For avatars. */
1853
+ function initialsOf(name) {
1854
+ const words = (name ?? '').trim().split(/\s+/).filter(Boolean);
1855
+ if (!words.length)
1856
+ return '?';
1857
+ const letters = words.length > 1
1858
+ ? words[0].charAt(0) + words[words.length - 1].charAt(0)
1859
+ : words[0].slice(0, 2);
1860
+ return letters.toUpperCase();
1861
+ }
1862
+ /**
1863
+ * A timestamp worth showing, else null. Older backends sent `createdAtUtc` as
1864
+ * `0001-01-01T00:00:00+00:00` (the .NET default), which
1865
+ * must not render as a date in year 1.
1866
+ */
1867
+ function validDate(value) {
1868
+ if (!value)
1869
+ return null;
1870
+ const time = Date.parse(value);
1871
+ return Number.isFinite(time) && new Date(time).getUTCFullYear() > 1
1872
+ ? value
1873
+ : null;
1874
+ }
1875
+ function humanize$1(id) {
1876
+ const words = id.replace(/[-_]+/g, ' ').trim();
1877
+ return words ? words.charAt(0).toUpperCase() + words.slice(1) : id;
1878
+ }
1879
+
1880
+ /**
1881
+ * Replace by, in one step: choose the successor, give a reason, read the
1882
+ * same general explanation every replacement gets, start. Submitting is the
1883
+ * one confirmation the backend asks for; it closes with the new
1884
+ * replacement's `operationId` and the opener navigates to it.
1885
+ *
1886
+ * Nothing is searched or checked before Start: the backend validates the
1887
+ * successor and finds the work itself, and a refusal comes back as the
1888
+ * start's error.
1889
+ */
1890
+ class ReplaceUserDialog {
1891
+ modal = inject(ModalService);
1892
+ ref = inject(ModalRef);
1893
+ api = inject(UserReplacementService);
1894
+ transloco = inject(TranslocoService);
1895
+ destroyRef = inject(DestroyRef);
1896
+ text = new ReplacementText(this.transloco);
1897
+ source = input.required(...(ngDevMode ? [{ debugName: "source" }] : /* istanbul ignore next */ []));
1898
+ /** The users list the page already has; the API returns IDs only. */
1899
+ users = input([], ...(ngDevMode ? [{ debugName: "users" }] : /* istanbul ignore next */ []));
1900
+ /** Preselected successor, when starting again after a closed replacement. */
1901
+ successorUserId = input(null, ...(ngDevMode ? [{ debugName: "successorUserId" }] : /* istanbul ignore next */ []));
1902
+ creating = signal(false, ...(ngDevMode ? [{ debugName: "creating" }] : /* istanbul ignore next */ []));
1903
+ createError = signal(null, ...(ngDevMode ? [{ debugName: "createError" }] : /* istanbul ignore next */ []));
1904
+ /** The open replacement that blocks this one (409): "Open that replacement". */
1905
+ blockingId = signal(null, ...(ngDevMode ? [{ debugName: "blockingId" }] : /* istanbul ignore next */ []));
1906
+ successorForm = new FormControl({ successorUserId: null }, { nonNullable: true });
1907
+ reasonForm = new FormControl({ reason: '' }, { nonNullable: true });
1908
+ successorValue = toSignal(this.successorForm.valueChanges, {
1909
+ initialValue: this.successorForm.getRawValue(),
1910
+ });
1911
+ reasonValue = toSignal(this.reasonForm.valueChanges, {
1912
+ initialValue: this.reasonForm.getRawValue(),
1913
+ });
1914
+ candidates = computed(() => this.users().filter((user) => user.id &&
1915
+ user.id !== this.source().id &&
1916
+ user.isLinkedToCurrentApplication !== false), ...(ngDevMode ? [{ debugName: "candidates" }] : /* istanbul ignore next */ []));
1917
+ successorConfig = computed(() => ({
1918
+ sections: [
1919
+ {
1920
+ key: 'successor',
1921
+ type: 'none',
1922
+ columns: 12,
1923
+ fields: [
1924
+ new SelectFieldConfig({
1925
+ key: 'successorUserId',
1926
+ label: this.text.t('dialog.successor'),
1927
+ placeholder: this.text.t('dialog.successor-placeholder'),
1928
+ options: this.candidates().map((user) => ({
1929
+ value: user.id,
1930
+ label: user.userName
1931
+ ? `${user.displayName || user.userName} (${user.userName})`
1932
+ : user.displayName || user.id,
1933
+ })),
1934
+ filter: true,
1935
+ validators: [ValidatorConfig.required()],
1936
+ readonly: this.creating(),
1937
+ }),
1938
+ ],
1939
+ },
1940
+ ],
1941
+ }), ...(ngDevMode ? [{ debugName: "successorConfig" }] : /* istanbul ignore next */ []));
1942
+ reasonConfig = computed(() => ({
1943
+ sections: [
1944
+ {
1945
+ key: 'reason',
1946
+ type: 'none',
1947
+ columns: 12,
1948
+ fields: [
1949
+ new TextareaFieldConfig({
1950
+ key: 'reason',
1951
+ label: this.text.t('dialog.reason'),
1952
+ placeholder: this.text.t('dialog.reason-placeholder'),
1953
+ hint: this.text.t('dialog.reason-hint'),
1954
+ rows: 3,
1955
+ validators: [
1956
+ ValidatorConfig.required(),
1957
+ ValidatorConfig.minLength(3),
1958
+ ValidatorConfig.maxLength(1000),
1959
+ ],
1960
+ readonly: this.creating(),
1961
+ }),
1962
+ ],
1963
+ },
1964
+ ],
1965
+ }), ...(ngDevMode ? [{ debugName: "reasonConfig" }] : /* istanbul ignore next */ []));
1966
+ sourceName = computed(() => this.source().displayName || this.source().userName || this.source().id, ...(ngDevMode ? [{ debugName: "sourceName" }] : /* istanbul ignore next */ []));
1967
+ sourceInitials = computed(() => initialsOf(this.sourceName()), ...(ngDevMode ? [{ debugName: "sourceInitials" }] : /* istanbul ignore next */ []));
1968
+ canSubmit = computed(() => {
1969
+ const reason = (this.reasonValue().reason ?? '').trim();
1970
+ return (!this.creating() &&
1971
+ !!this.successorValue().successorUserId &&
1972
+ reason.length >= 3 &&
1973
+ reason.length <= 1000);
1974
+ }, ...(ngDevMode ? [{ debugName: "canSubmit" }] : /* istanbul ignore next */ []));
1975
+ ngOnInit() {
1976
+ const preselected = this.successorUserId();
1977
+ if (preselected &&
1978
+ this.candidates().some((candidate) => candidate.id === preselected))
1979
+ this.successorForm.setValue({ successorUserId: preselected });
1980
+ // Another successor clears the last refusal.
1981
+ this.successorForm.valueChanges
1982
+ .pipe(takeUntilDestroyed(this.destroyRef))
1983
+ .subscribe(() => this.clearError());
1984
+ }
1985
+ async submit() {
1986
+ if (!this.canSubmit())
1987
+ return;
1988
+ const sourceUserId = this.source().id;
1989
+ const successorId = this.successorForm.getRawValue().successorUserId;
1990
+ this.creating.set(true);
1991
+ this.clearError();
1992
+ try {
1993
+ const summary = await firstValueFrom(this.api.start({
1994
+ sourceUserId,
1995
+ defaultSuccessorUserId: successorId,
1996
+ reason: this.reasonForm.getRawValue().reason.trim(),
1997
+ }));
1998
+ this.ref.close({
1999
+ operationId: summary.operationId,
2000
+ });
2001
+ }
2002
+ catch (error) {
2003
+ if (isTransientGatewayError(error)) {
2004
+ await this.recoverAfterTimeout(sourceUserId, successorId);
2005
+ return;
2006
+ }
2007
+ this.createError.set(this.text.error(replacementErrorKey(error)));
2008
+ this.blockingId.set(blockingOperationId(error));
2009
+ }
2010
+ finally {
2011
+ this.creating.set(false);
2012
+ }
2013
+ }
2014
+ /**
2015
+ * The connection dropped before the answer came back, so the start may or
2016
+ * may not have been recorded. The backend asks screens to look before
2017
+ * sending it again.
2018
+ */
2019
+ async recoverAfterTimeout(sourceUserId, successorId) {
2020
+ try {
2021
+ const page = await firstValueFrom(this.api.list({ filter: 'Active', sourceUserId, pageSize: 5 }));
2022
+ const started = page.items.find((item) => item.sourceUserId === sourceUserId &&
2023
+ item.defaultSuccessorUserId === successorId);
2024
+ if (started) {
2025
+ this.ref.close({
2026
+ operationId: started.operationId,
2027
+ });
2028
+ return;
2029
+ }
2030
+ this.blockingId.set(page.items[0]?.operationId ?? null);
2031
+ this.createError.set(page.items.length
2032
+ ? this.text.error('UserReplacement_ConcurrentHandover')
2033
+ : this.text.t('dialog.not-started'));
2034
+ }
2035
+ catch {
2036
+ this.createError.set(this.text.t('dialog.start-unconfirmed'));
2037
+ }
2038
+ }
2039
+ /** Close and let the opener navigate to the replacement that blocks this one. */
2040
+ openBlocking() {
2041
+ const operationId = this.blockingId();
2042
+ if (operationId)
2043
+ this.ref.close({ operationId });
2044
+ }
2045
+ close() {
2046
+ this.ref.close(null);
2047
+ }
2048
+ clearError() {
2049
+ this.createError.set(null);
2050
+ this.blockingId.set(null);
2051
+ }
2052
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: ReplaceUserDialog, deps: [], target: i0.ɵɵFactoryTarget.Component });
2053
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.8", type: ReplaceUserDialog, isStandalone: true, selector: "mt-replace-user-dialog", inputs: { source: { classPropertyName: "source", publicName: "source", isSignal: true, isRequired: true, transformFunction: null }, users: { classPropertyName: "users", publicName: "users", isSignal: true, isRequired: false, transformFunction: null }, successorUserId: { classPropertyName: "successorUserId", publicName: "successorUserId", isSignal: true, isRequired: false, transformFunction: null } }, host: { styleAttribute: "display: contents" }, ngImport: i0, template: "<ng-container *transloco=\"let t; prefix: 'users-groups.replacement'\">\r\n <div class=\"flex flex-col gap-5 p-4\" [class]=\"modal.contentClass\">\r\n <!-- Who is leaving -->\r\n <div class=\"flex flex-col gap-3\">\r\n <div class=\"flex min-w-0 items-center gap-3\">\r\n <mt-avatar\r\n [label]=\"sourceInitials()\"\r\n shape=\"circle\"\r\n size=\"large\"\r\n styleClass=\"bg-surface-100! text-color! dark:bg-surface-800!\"\r\n />\r\n <div class=\"min-w-0\">\r\n <div class=\"text-xs text-muted-color\">\r\n {{ t(\"dialog.replacing\") }}\r\n </div>\r\n <div class=\"truncate text-base font-semibold\">{{ sourceName() }}</div>\r\n </div>\r\n </div>\r\n <p class=\"text-sm text-muted-color\">\r\n {{ t(\"dialog.intro\", { name: sourceName() }) }}\r\n </p>\r\n </div>\r\n\r\n <mt-dynamic-form\r\n [formConfig]=\"successorConfig()\"\r\n [formControl]=\"successorForm\"\r\n />\r\n\r\n <mt-dynamic-form [formConfig]=\"reasonConfig()\" [formControl]=\"reasonForm\" />\r\n\r\n <!-- The backend's general explanation, the same for every person: this\r\n is what the admin confirms. Nothing is looked up for this person. -->\r\n <section\r\n class=\"flex flex-col gap-2 rounded-md border border-surface bg-surface-50 p-4 text-sm dark:bg-surface-900\"\r\n >\r\n <div class=\"flex items-center gap-2 font-semibold\">\r\n <mt-icon icon=\"general.info-circle\" class=\"text-muted-color\" />\r\n {{ t(\"dialog.what-happens\") }}\r\n </div>\r\n <ul class=\"flex flex-col gap-2\">\r\n <li class=\"flex items-start gap-2\">\r\n <mt-icon\r\n icon=\"user.user-right-01\"\r\n class=\"mt-0.5 shrink-0 text-primary\"\r\n />\r\n <span>{{ t(\"dialog.explain-moves\") }}</span>\r\n </li>\r\n <li class=\"flex items-start gap-2\">\r\n <mt-icon\r\n icon=\"time.clock-rewind\"\r\n class=\"mt-0.5 shrink-0 text-muted-color\"\r\n />\r\n <span>{{ t(\"dialog.explain-history\") }}</span>\r\n </li>\r\n <li class=\"flex items-start gap-2\">\r\n <mt-icon\r\n icon=\"alert.alert-triangle\"\r\n class=\"mt-0.5 shrink-0 text-muted-color\"\r\n />\r\n <span>{{ t(\"dialog.explain-manual\") }}</span>\r\n </li>\r\n <li class=\"flex items-start gap-2\">\r\n <mt-icon\r\n icon=\"user.user-check-01\"\r\n class=\"mt-0.5 shrink-0 text-muted-color\"\r\n />\r\n <span>{{ t(\"dialog.explain-account\") }}</span>\r\n </li>\r\n </ul>\r\n </section>\r\n\r\n @if (createError()) {\r\n <div\r\n class=\"flex items-start gap-2 rounded-md border border-red-200 bg-red-50 p-3 text-sm text-red-700 dark:border-red-900 dark:bg-red-950 dark:text-red-200\"\r\n >\r\n <mt-icon icon=\"alert.alert-circle\" class=\"mt-0.5 shrink-0\" />\r\n <div class=\"flex flex-col items-start gap-2\">\r\n <span>{{ createError() }}</span>\r\n @if (blockingId()) {\r\n <mt-button\r\n [label]=\"t('dialog.open-blocking')\"\r\n icon=\"general.link-external-01\"\r\n variant=\"outlined\"\r\n severity=\"danger\"\r\n size=\"small\"\r\n (click)=\"openBlocking()\"\r\n />\r\n }\r\n </div>\r\n </div>\r\n }\r\n </div>\r\n\r\n <div [class]=\"modal.footerClass\">\r\n <mt-button\r\n [label]=\"t('cancel')\"\r\n variant=\"outlined\"\r\n [disabled]=\"creating()\"\r\n (click)=\"close()\"\r\n />\r\n <mt-button\r\n [label]=\"t('dialog.submit')\"\r\n icon=\"user.user-right-01\"\r\n [loading]=\"creating()\"\r\n [disabled]=\"!canSubmit()\"\r\n (click)=\"submit()\"\r\n />\r\n </div>\r\n</ng-container>\r\n", dependencies: [{ kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i1$1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1$1.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { kind: "component", type: DynamicForm, selector: "mt-dynamic-form", inputs: ["formConfig", "forcedHiddenFieldKeys", "forcedDisabledFieldKeys", "preserveForcedHiddenValues", "visibleSectionKeys", "externalValues", "serverFieldErrors"], outputs: ["runtimeMessagesChange"] }, { kind: "component", type: Avatar, selector: "mt-avatar", inputs: ["label", "icon", "image", "styleClass", "size", "shape", "badge", "badgeSize", "badgeSeverity"], outputs: ["onImageError"] }, { kind: "component", type: Button, selector: "mt-button", inputs: ["icon", "label", "tooltip", "class", "type", "styleClass", "severity", "badge", "variant", "badgeSeverity", "size", "iconPos", "autofocus", "fluid", "raised", "rounded", "text", "plain", "outlined", "link", "disabled", "loading", "pInputs", "ariaLabel"], outputs: ["onClick", "onFocus", "onBlur"] }, { kind: "component", type: Icon, selector: "mt-icon", inputs: ["icon"] }, { kind: "directive", type: TranslocoDirective, selector: "[transloco]", inputs: ["transloco", "translocoParams", "translocoScope", "translocoRead", "translocoPrefix", "translocoLang", "translocoLoadingTpl"] }] });
2054
+ }
2055
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: ReplaceUserDialog, decorators: [{
2056
+ type: Component,
2057
+ args: [{ selector: 'mt-replace-user-dialog', host: { style: 'display: contents' }, imports: [
2058
+ ReactiveFormsModule,
2059
+ DynamicForm,
2060
+ Avatar,
2061
+ Button,
2062
+ Icon,
2063
+ TranslocoDirective,
2064
+ ], template: "<ng-container *transloco=\"let t; prefix: 'users-groups.replacement'\">\r\n <div class=\"flex flex-col gap-5 p-4\" [class]=\"modal.contentClass\">\r\n <!-- Who is leaving -->\r\n <div class=\"flex flex-col gap-3\">\r\n <div class=\"flex min-w-0 items-center gap-3\">\r\n <mt-avatar\r\n [label]=\"sourceInitials()\"\r\n shape=\"circle\"\r\n size=\"large\"\r\n styleClass=\"bg-surface-100! text-color! dark:bg-surface-800!\"\r\n />\r\n <div class=\"min-w-0\">\r\n <div class=\"text-xs text-muted-color\">\r\n {{ t(\"dialog.replacing\") }}\r\n </div>\r\n <div class=\"truncate text-base font-semibold\">{{ sourceName() }}</div>\r\n </div>\r\n </div>\r\n <p class=\"text-sm text-muted-color\">\r\n {{ t(\"dialog.intro\", { name: sourceName() }) }}\r\n </p>\r\n </div>\r\n\r\n <mt-dynamic-form\r\n [formConfig]=\"successorConfig()\"\r\n [formControl]=\"successorForm\"\r\n />\r\n\r\n <mt-dynamic-form [formConfig]=\"reasonConfig()\" [formControl]=\"reasonForm\" />\r\n\r\n <!-- The backend's general explanation, the same for every person: this\r\n is what the admin confirms. Nothing is looked up for this person. -->\r\n <section\r\n class=\"flex flex-col gap-2 rounded-md border border-surface bg-surface-50 p-4 text-sm dark:bg-surface-900\"\r\n >\r\n <div class=\"flex items-center gap-2 font-semibold\">\r\n <mt-icon icon=\"general.info-circle\" class=\"text-muted-color\" />\r\n {{ t(\"dialog.what-happens\") }}\r\n </div>\r\n <ul class=\"flex flex-col gap-2\">\r\n <li class=\"flex items-start gap-2\">\r\n <mt-icon\r\n icon=\"user.user-right-01\"\r\n class=\"mt-0.5 shrink-0 text-primary\"\r\n />\r\n <span>{{ t(\"dialog.explain-moves\") }}</span>\r\n </li>\r\n <li class=\"flex items-start gap-2\">\r\n <mt-icon\r\n icon=\"time.clock-rewind\"\r\n class=\"mt-0.5 shrink-0 text-muted-color\"\r\n />\r\n <span>{{ t(\"dialog.explain-history\") }}</span>\r\n </li>\r\n <li class=\"flex items-start gap-2\">\r\n <mt-icon\r\n icon=\"alert.alert-triangle\"\r\n class=\"mt-0.5 shrink-0 text-muted-color\"\r\n />\r\n <span>{{ t(\"dialog.explain-manual\") }}</span>\r\n </li>\r\n <li class=\"flex items-start gap-2\">\r\n <mt-icon\r\n icon=\"user.user-check-01\"\r\n class=\"mt-0.5 shrink-0 text-muted-color\"\r\n />\r\n <span>{{ t(\"dialog.explain-account\") }}</span>\r\n </li>\r\n </ul>\r\n </section>\r\n\r\n @if (createError()) {\r\n <div\r\n class=\"flex items-start gap-2 rounded-md border border-red-200 bg-red-50 p-3 text-sm text-red-700 dark:border-red-900 dark:bg-red-950 dark:text-red-200\"\r\n >\r\n <mt-icon icon=\"alert.alert-circle\" class=\"mt-0.5 shrink-0\" />\r\n <div class=\"flex flex-col items-start gap-2\">\r\n <span>{{ createError() }}</span>\r\n @if (blockingId()) {\r\n <mt-button\r\n [label]=\"t('dialog.open-blocking')\"\r\n icon=\"general.link-external-01\"\r\n variant=\"outlined\"\r\n severity=\"danger\"\r\n size=\"small\"\r\n (click)=\"openBlocking()\"\r\n />\r\n }\r\n </div>\r\n </div>\r\n }\r\n </div>\r\n\r\n <div [class]=\"modal.footerClass\">\r\n <mt-button\r\n [label]=\"t('cancel')\"\r\n variant=\"outlined\"\r\n [disabled]=\"creating()\"\r\n (click)=\"close()\"\r\n />\r\n <mt-button\r\n [label]=\"t('dialog.submit')\"\r\n icon=\"user.user-right-01\"\r\n [loading]=\"creating()\"\r\n [disabled]=\"!canSubmit()\"\r\n (click)=\"submit()\"\r\n />\r\n </div>\r\n</ng-container>\r\n" }]
2065
+ }], propDecorators: { source: [{ type: i0.Input, args: [{ isSignal: true, alias: "source", required: true }] }], users: [{ type: i0.Input, args: [{ isSignal: true, alias: "users", required: false }] }], successorUserId: [{ type: i0.Input, args: [{ isSignal: true, alias: "successorUserId", required: false }] }] } });
2066
+
2067
+ const COUNT_ICONS = {
2068
+ teamRoles: 'user.users-01',
2069
+ pendingSteps: 'general.check-square',
2070
+ openRequests: 'file.file-04',
2071
+ escalationSteps: 'alert.bell-ringing-01',
2072
+ scheduleAssignments: 'time.calendar',
2073
+ };
2074
+ /**
2075
+ * Shown when "Remove from application" finds work the person still holds
2076
+ * (section 9d): offers Replace by first and "Remove anyway" second, and no
2077
+ * removal at all while the person is being replaced.
2078
+ */
2079
+ class RemainingWorkDialog {
2080
+ modal = inject(ModalService);
2081
+ ref = inject(ModalRef);
2082
+ text = new ReplacementText(inject(TranslocoService));
2083
+ user = input.required(...(ngDevMode ? [{ debugName: "user" }] : /* istanbul ignore next */ []));
2084
+ work = input.required(...(ngDevMode ? [{ debugName: "work" }] : /* istanbul ignore next */ []));
2085
+ canReplace = input(false, ...(ngDevMode ? [{ debugName: "canReplace" }] : /* istanbul ignore next */ []));
2086
+ userName = computed(() => this.user().displayName || this.user().userName || this.user().id, ...(ngDevMode ? [{ debugName: "userName" }] : /* istanbul ignore next */ []));
2087
+ counts = computed(() => {
2088
+ const work = this.work();
2089
+ return [
2090
+ ['teamRoles', work.teamRoles],
2091
+ ['pendingSteps', work.pendingSteps],
2092
+ ['openRequests', work.openRequests],
2093
+ ['escalationSteps', work.escalationSteps],
2094
+ ['scheduleAssignments', work.scheduleAssignments],
2095
+ ]
2096
+ .filter(([, count]) => count > 0)
2097
+ .map(([key, count]) => ({ key, count, icon: COUNT_ICONS[key] }));
2098
+ }, ...(ngDevMode ? [{ debugName: "counts" }] : /* istanbul ignore next */ []));
2099
+ close(result) {
2100
+ this.ref.close(result);
2101
+ }
2102
+ openReplacement() {
2103
+ const operationId = this.work().operationId;
2104
+ if (operationId)
2105
+ this.close({ action: 'open-replacement', operationId });
2106
+ }
2107
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: RemainingWorkDialog, deps: [], target: i0.ɵɵFactoryTarget.Component });
2108
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.8", type: RemainingWorkDialog, isStandalone: true, selector: "mt-remaining-work-dialog", inputs: { user: { classPropertyName: "user", publicName: "user", isSignal: true, isRequired: true, transformFunction: null }, work: { classPropertyName: "work", publicName: "work", isSignal: true, isRequired: true, transformFunction: null }, canReplace: { classPropertyName: "canReplace", publicName: "canReplace", isSignal: true, isRequired: false, transformFunction: null } }, host: { styleAttribute: "display: contents" }, ngImport: i0, template: "<ng-container *transloco=\"let t; prefix: 'users-groups.replacement'\">\r\n <div class=\"flex flex-col gap-4 p-4\" [class]=\"modal.contentClass\">\r\n @if (work().handoverInProgress) {\r\n <div class=\"flex items-start gap-3\">\r\n <span\r\n class=\"flex size-10 shrink-0 items-center justify-center rounded-full bg-amber-50 text-lg text-amber-700 dark:bg-amber-950 dark:text-amber-200\"\r\n >\r\n <mt-icon icon=\"time.hourglass-03\" />\r\n </span>\r\n <div class=\"flex min-w-0 flex-col gap-1\">\r\n <div class=\"font-semibold\">\r\n {{ t(\"remaining.in-progress-title\", { name: userName() }) }}\r\n </div>\r\n <div class=\"text-sm text-muted-color\">\r\n {{ t(\"remaining.in-progress\") }}\r\n </div>\r\n </div>\r\n </div>\r\n } @else {\r\n <div class=\"flex items-start gap-3\">\r\n <span\r\n class=\"flex size-10 shrink-0 items-center justify-center rounded-full bg-amber-50 text-lg text-amber-700 dark:bg-amber-950 dark:text-amber-200\"\r\n >\r\n <mt-icon icon=\"alert.alert-triangle\" />\r\n </span>\r\n <div class=\"flex min-w-0 flex-col gap-1\">\r\n <div class=\"font-semibold\">\r\n {{ t(\"remaining.title\", { name: userName() }) }}\r\n </div>\r\n <div class=\"text-sm text-muted-color\">{{ t(\"remaining.body\") }}</div>\r\n </div>\r\n </div>\r\n\r\n <ul\r\n class=\"flex flex-col divide-y divide-surface-200 rounded-md border border-surface dark:divide-surface-700\"\r\n >\r\n @for (row of counts(); track row.key) {\r\n <li class=\"flex items-center gap-3 px-3 py-2.5 text-sm\">\r\n <mt-icon [icon]=\"row.icon\" class=\"text-muted-color\" />\r\n <span class=\"flex-1\">{{ t(\"remaining.\" + row.key) }}</span>\r\n <span class=\"font-semibold tabular-nums\">{{ row.count }}</span>\r\n </li>\r\n }\r\n </ul>\r\n <p class=\"text-xs text-muted-color\">\r\n {{ t(\"remaining.whole-application\") }}\r\n </p>\r\n }\r\n </div>\r\n\r\n <div [class]=\"modal.footerClass\">\r\n <mt-button [label]=\"t('cancel')\" variant=\"outlined\" (click)=\"close(null)\" />\r\n @if (work().handoverInProgress) {\r\n @if (work().operationId) {\r\n <mt-button\r\n [label]=\"t('remaining.open-replacement')\"\r\n icon=\"general.link-external-01\"\r\n (click)=\"openReplacement()\"\r\n />\r\n }\r\n } @else {\r\n <mt-button\r\n [label]=\"t('remaining.remove-anyway')\"\r\n severity=\"danger\"\r\n variant=\"outlined\"\r\n (click)=\"close({ action: 'remove' })\"\r\n />\r\n @if (canReplace()) {\r\n <mt-button\r\n [label]=\"t('replace-by')\"\r\n icon=\"user.user-right-01\"\r\n (click)=\"close({ action: 'replace' })\"\r\n />\r\n }\r\n }\r\n </div>\r\n</ng-container>\r\n", dependencies: [{ kind: "component", type: Button, selector: "mt-button", inputs: ["icon", "label", "tooltip", "class", "type", "styleClass", "severity", "badge", "variant", "badgeSeverity", "size", "iconPos", "autofocus", "fluid", "raised", "rounded", "text", "plain", "outlined", "link", "disabled", "loading", "pInputs", "ariaLabel"], outputs: ["onClick", "onFocus", "onBlur"] }, { kind: "component", type: Icon, selector: "mt-icon", inputs: ["icon"] }, { kind: "directive", type: TranslocoDirective, selector: "[transloco]", inputs: ["transloco", "translocoParams", "translocoScope", "translocoRead", "translocoPrefix", "translocoLang", "translocoLoadingTpl"] }] });
2109
+ }
2110
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: RemainingWorkDialog, decorators: [{
2111
+ type: Component,
2112
+ args: [{ selector: 'mt-remaining-work-dialog', host: { style: 'display: contents' }, imports: [Button, Icon, TranslocoDirective], template: "<ng-container *transloco=\"let t; prefix: 'users-groups.replacement'\">\r\n <div class=\"flex flex-col gap-4 p-4\" [class]=\"modal.contentClass\">\r\n @if (work().handoverInProgress) {\r\n <div class=\"flex items-start gap-3\">\r\n <span\r\n class=\"flex size-10 shrink-0 items-center justify-center rounded-full bg-amber-50 text-lg text-amber-700 dark:bg-amber-950 dark:text-amber-200\"\r\n >\r\n <mt-icon icon=\"time.hourglass-03\" />\r\n </span>\r\n <div class=\"flex min-w-0 flex-col gap-1\">\r\n <div class=\"font-semibold\">\r\n {{ t(\"remaining.in-progress-title\", { name: userName() }) }}\r\n </div>\r\n <div class=\"text-sm text-muted-color\">\r\n {{ t(\"remaining.in-progress\") }}\r\n </div>\r\n </div>\r\n </div>\r\n } @else {\r\n <div class=\"flex items-start gap-3\">\r\n <span\r\n class=\"flex size-10 shrink-0 items-center justify-center rounded-full bg-amber-50 text-lg text-amber-700 dark:bg-amber-950 dark:text-amber-200\"\r\n >\r\n <mt-icon icon=\"alert.alert-triangle\" />\r\n </span>\r\n <div class=\"flex min-w-0 flex-col gap-1\">\r\n <div class=\"font-semibold\">\r\n {{ t(\"remaining.title\", { name: userName() }) }}\r\n </div>\r\n <div class=\"text-sm text-muted-color\">{{ t(\"remaining.body\") }}</div>\r\n </div>\r\n </div>\r\n\r\n <ul\r\n class=\"flex flex-col divide-y divide-surface-200 rounded-md border border-surface dark:divide-surface-700\"\r\n >\r\n @for (row of counts(); track row.key) {\r\n <li class=\"flex items-center gap-3 px-3 py-2.5 text-sm\">\r\n <mt-icon [icon]=\"row.icon\" class=\"text-muted-color\" />\r\n <span class=\"flex-1\">{{ t(\"remaining.\" + row.key) }}</span>\r\n <span class=\"font-semibold tabular-nums\">{{ row.count }}</span>\r\n </li>\r\n }\r\n </ul>\r\n <p class=\"text-xs text-muted-color\">\r\n {{ t(\"remaining.whole-application\") }}\r\n </p>\r\n }\r\n </div>\r\n\r\n <div [class]=\"modal.footerClass\">\r\n <mt-button [label]=\"t('cancel')\" variant=\"outlined\" (click)=\"close(null)\" />\r\n @if (work().handoverInProgress) {\r\n @if (work().operationId) {\r\n <mt-button\r\n [label]=\"t('remaining.open-replacement')\"\r\n icon=\"general.link-external-01\"\r\n (click)=\"openReplacement()\"\r\n />\r\n }\r\n } @else {\r\n <mt-button\r\n [label]=\"t('remaining.remove-anyway')\"\r\n severity=\"danger\"\r\n variant=\"outlined\"\r\n (click)=\"close({ action: 'remove' })\"\r\n />\r\n @if (canReplace()) {\r\n <mt-button\r\n [label]=\"t('replace-by')\"\r\n icon=\"user.user-right-01\"\r\n (click)=\"close({ action: 'replace' })\"\r\n />\r\n }\r\n }\r\n </div>\r\n</ng-container>\r\n" }]
2113
+ }], propDecorators: { user: [{ type: i0.Input, args: [{ isSignal: true, alias: "user", required: true }] }], work: [{ type: i0.Input, args: [{ isSignal: true, alias: "work", required: true }] }], canReplace: [{ type: i0.Input, args: [{ isSignal: true, alias: "canReplace", required: false }] }] } });
2114
+
1640
2115
  class Users {
1641
2116
  typeCol = viewChild.required('typeCol');
1642
2117
  applicationLinkCol = viewChild.required('applicationLinkCol');
@@ -1645,6 +2120,24 @@ class Users {
1645
2120
  toast = inject(ToastService);
1646
2121
  modal = inject(ModalService);
1647
2122
  translocoService = inject(TranslocoService);
2123
+ replacementApi = inject(UserReplacementService);
2124
+ confirmation = inject(ConfirmationService);
2125
+ router = inject(Router);
2126
+ route = inject(ActivatedRoute);
2127
+ destroyRef = inject(DestroyRef);
2128
+ replacementText = new ReplacementText(this.translocoService);
2129
+ /**
2130
+ * Whether this backend runs replacements (`UserReplacementService.available`);
2131
+ * false until known, and when the route is missing or refused (no
2132
+ * CONTROL_PANEL, delegation): Replace by stays hidden. Where it runs, the
2133
+ * backend also protects removal, so the trash action checks what the person
2134
+ * still holds first (guide §9d). A start refused by the backend's switches
2135
+ * comes back as the dialog's error.
2136
+ */
2137
+ canReplace = signal(false, ...(ngDevMode ? [{ debugName: "canReplace" }] : /* istanbul ignore next */ []));
2138
+ checkingWorkRowIds = signal([], ...(ngDevMode ? [{ debugName: "checkingWorkRowIds" }] : /* istanbul ignore next */ []));
2139
+ /** Person being replaced → their open replacement (`operationId`). */
2140
+ activeReplacements = signal(new Map(), ...(ngDevMode ? [{ debugName: "activeReplacements" }] : /* istanbul ignore next */ []));
1648
2141
  users = computed(() => {
1649
2142
  const tab = this.activeTab();
1650
2143
  const all = this.allUsers();
@@ -1767,6 +2260,41 @@ class Users {
1767
2260
  },
1768
2261
  loading: (row) => this.linkingRowIds().includes(row.userName),
1769
2262
  },
2263
+ {
2264
+ icon: 'user.user-right-01',
2265
+ tooltip: this.translocoService.translate('users-groups.replacement.replace-by'),
2266
+ color: 'secondary',
2267
+ action: (row) => this.openReplaceDialog(row),
2268
+ hidden: (row) => !this.canReplace() ||
2269
+ !row.id ||
2270
+ this.activeReplacements().has(row.id) ||
2271
+ !this.isLinkedToCurrentApplication(row),
2272
+ },
2273
+ {
2274
+ // A person who is already being replaced gets that replacement instead
2275
+ // of a second one (the backend allows one open replacement per person).
2276
+ icon: 'user.user-right-01',
2277
+ tooltip: this.translocoService.translate('users-groups.replacement.open-replacement'),
2278
+ color: 'warn',
2279
+ action: (row) => {
2280
+ const operationId = this.activeReplacements().get(row.id);
2281
+ if (operationId)
2282
+ this.openReplacement(operationId);
2283
+ },
2284
+ hidden: (row) => !this.canReplace() || !this.activeReplacements().has(row.id),
2285
+ },
2286
+ {
2287
+ // Protected removal: no table confirmation, the remaining-work check
2288
+ // decides which dialog to show.
2289
+ icon: 'general.trash-01',
2290
+ tooltip: this.translocoService.translate('users-groups.unlink-from-application'),
2291
+ color: 'danger',
2292
+ variant: 'outlined',
2293
+ action: (row) => this.removeWithRemainingWorkCheck(row),
2294
+ hidden: (row) => !this.canReplace() || !this.isLinkedToCurrentApplication(row),
2295
+ loading: (row) => this.checkingWorkRowIds().includes(row.id) ||
2296
+ this.deletingRowIds().includes(row.userName),
2297
+ },
1770
2298
  {
1771
2299
  icon: 'general.trash-01',
1772
2300
  tooltip: this.translocoService.translate('users-groups.unlink-from-application'),
@@ -1775,7 +2303,7 @@ class Users {
1775
2303
  action: (row) => {
1776
2304
  this.unlinkUserFromApplication(row);
1777
2305
  },
1778
- hidden: (row) => !this.isLinkedToCurrentApplication(row),
2306
+ hidden: (row) => this.canReplace() || !this.isLinkedToCurrentApplication(row),
1779
2307
  confirmation: {
1780
2308
  type: 'popup',
1781
2309
  header: this.translocoService.translate('users-groups.unlink-confirm-header'),
@@ -1861,6 +2389,119 @@ class Users {
1861
2389
  activeUsers = computed(() => this.allUsers().filter((user) => this.isLinkedToCurrentApplication(user)), ...(ngDevMode ? [{ debugName: "activeUsers" }] : /* istanbul ignore next */ []));
1862
2390
  ngOnInit() {
1863
2391
  this.facade.getUsers();
2392
+ this.replacementApi
2393
+ .available()
2394
+ .pipe(takeUntilDestroyed(this.destroyRef))
2395
+ .subscribe((available) => {
2396
+ this.canReplace.set(available);
2397
+ if (available)
2398
+ this.loadActiveReplacements();
2399
+ });
2400
+ }
2401
+ // ---------------------------------------------------------------------------
2402
+ // Replace by
2403
+ // ---------------------------------------------------------------------------
2404
+ /** Who is already being replaced, so their row opens that instead. */
2405
+ loadActiveReplacements() {
2406
+ const active = new Map();
2407
+ const page = (afterOperationId, pagesLeft) => {
2408
+ this.replacementApi
2409
+ .list({ filter: 'Active', afterOperationId, pageSize: 100 })
2410
+ .pipe(takeUntilDestroyed(this.destroyRef))
2411
+ .subscribe({
2412
+ next: (result) => {
2413
+ for (const replacement of result.items)
2414
+ if (!active.has(replacement.sourceUserId))
2415
+ active.set(replacement.sourceUserId, replacement.operationId);
2416
+ if (result.nextAfterOperationId && pagesLeft > 1)
2417
+ page(result.nextAfterOperationId, pagesLeft - 1);
2418
+ else
2419
+ this.activeReplacements.set(active);
2420
+ },
2421
+ // The list is a convenience here: without it, Replace by still
2422
+ // works and a duplicate start links to the blocking replacement.
2423
+ error: () => this.activeReplacements.set(active),
2424
+ });
2425
+ };
2426
+ page(null, 10);
2427
+ }
2428
+ openReplaceDialog(user) {
2429
+ this.modal
2430
+ .openModal(ReplaceUserDialog, 'dialog', {
2431
+ header: this.replacementText.t('replace-by'),
2432
+ styleClass: '!w-[40rem] max-w-[96vw]',
2433
+ contentStyle: { display: 'flex', flexDirection: 'column' },
2434
+ dismissableMask: true,
2435
+ dismissible: true,
2436
+ inputValues: {
2437
+ source: user,
2438
+ users: this.allUsers(),
2439
+ },
2440
+ })
2441
+ .onClose.pipe(take(1))
2442
+ .subscribe((result) => {
2443
+ if (result?.operationId)
2444
+ this.openReplacement(result.operationId);
2445
+ });
2446
+ }
2447
+ openReplacement(operationId) {
2448
+ // The Replacements tab (a sibling of this route) opens `?id=` in its drawer.
2449
+ void this.router.navigate(['..', 'replacements'], {
2450
+ relativeTo: this.route,
2451
+ queryParams: { id: operationId },
2452
+ });
2453
+ }
2454
+ /** Guide §9d: remaining work decides between delete, Replace by, and no delete. */
2455
+ removeWithRemainingWorkCheck(user) {
2456
+ const id = user.id;
2457
+ if (!id || this.checkingWorkRowIds().includes(id))
2458
+ return;
2459
+ this.checkingWorkRowIds.update((ids) => [...ids, id]);
2460
+ this.replacementApi
2461
+ .remainingWork(id)
2462
+ .pipe(finalize(() => this.checkingWorkRowIds.update((ids) => ids.filter((value) => value !== id))))
2463
+ .subscribe({
2464
+ next: (work) => {
2465
+ if (work.safeToRemove) {
2466
+ this.confirmPlainRemoval(user);
2467
+ return;
2468
+ }
2469
+ this.modal
2470
+ .openModal(RemainingWorkDialog, 'dialog', {
2471
+ header: this.translocoService.translate('users-groups.unlink-confirm-header'),
2472
+ styleClass: '!w-[32rem] max-w-[96vw]',
2473
+ contentStyle: { display: 'flex', flexDirection: 'column' },
2474
+ dismissableMask: true,
2475
+ dismissible: true,
2476
+ inputValues: { user, work, canReplace: this.canReplace() },
2477
+ })
2478
+ .onClose.pipe(take(1))
2479
+ .subscribe((result) => {
2480
+ if (result?.action === 'replace')
2481
+ this.openReplaceDialog(user);
2482
+ else if (result?.action === 'remove')
2483
+ this.unlinkUserFromApplication(user, true);
2484
+ else if (result?.action === 'open-replacement')
2485
+ this.openReplacement(result.operationId);
2486
+ });
2487
+ },
2488
+ error: (error) => {
2489
+ // The check itself failed: say so, and leave removal to a retry.
2490
+ this.toast.error(this.replacementText.error(replacementErrorKey(error)));
2491
+ },
2492
+ });
2493
+ }
2494
+ confirmPlainRemoval(user) {
2495
+ this.confirmation.confirm({
2496
+ type: 'dialog',
2497
+ header: this.translocoService.translate('users-groups.unlink-confirm-header'),
2498
+ message: this.translocoService.translate('users-groups.unlink-confirm-message'),
2499
+ icon: 'general.link-broken-01',
2500
+ acceptLabel: this.translocoService.translate('users-groups.unlink-from-application'),
2501
+ rejectLabel: this.translocoService.translate('users-groups.cancel'),
2502
+ acceptButton: { severity: 'danger' },
2503
+ accept: () => this.unlinkUserFromApplication(user),
2504
+ });
1864
2505
  }
1865
2506
  unlockUser(user) {
1866
2507
  const id = user.id;
@@ -1903,14 +2544,14 @@ class Users {
1903
2544
  }))
1904
2545
  .subscribe();
1905
2546
  }
1906
- unlinkUserFromApplication(user) {
2547
+ unlinkUserFromApplication(user, acknowledgeRemainingWork = false) {
1907
2548
  const userName = user?.userName;
1908
2549
  if (!userName || !this.isLinkedToCurrentApplication(user)) {
1909
2550
  return;
1910
2551
  }
1911
2552
  this.deletingRowIds.update((ids) => [...ids, userName]);
1912
2553
  this.facade
1913
- .deleteUser(userName)
2554
+ .deleteUser(userName, acknowledgeRemainingWork)
1914
2555
  .pipe(finalize(() => {
1915
2556
  this.deletingRowIds.update((ids) => ids.filter((id) => id !== userName));
1916
2557
  }))
@@ -1967,7 +2608,7 @@ class Users {
1967
2608
  });
1968
2609
  }
1969
2610
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: Users, deps: [], target: i0.ɵɵFactoryTarget.Component });
1970
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.8", type: Users, isStandalone: true, selector: "mt-users", viewQueries: [{ propertyName: "typeCol", first: true, predicate: ["typeCol"], descendants: true, isSignal: true }, { propertyName: "applicationLinkCol", first: true, predicate: ["applicationLinkCol"], descendants: true, isSignal: true }, { propertyName: "emailCol", first: true, predicate: ["emailCol"], descendants: true, isSignal: true }], ngImport: i0, template: "<ng-container *transloco=\"let t; prefix: 'users-groups'\">\r\n <!-- mt-table wraps row actions; a locked row has five, so keep them on one line. -->\r\n <div class=\"mt-5 [&_.mt-actions-column>div]:flex-nowrap\">\r\n <ng-template #typeCol let-row>\r\n @if (row.isExternal) {\r\n <span\r\n class=\"inline-flex items-center gap-1 rounded-md bg-slate-50 dark:bg-slate-900/30 p-2\"\r\n >\r\n <mt-icon\r\n icon=\"general.link-external-02\"\r\n class=\"text-slate-600 dark:text-slate-300 text-sm\"\r\n />\r\n <span class=\"text-slate-700 dark:text-slate-200 text-xs font-medium\">\r\n {{ t(\"external\") }}\r\n </span>\r\n </span>\r\n } @else {\r\n <span\r\n class=\"inline-flex items-center gap-1 rounded-md bg-emerald-50 dark:bg-emerald-900/30 p-2\"\r\n >\r\n <mt-icon\r\n icon=\"user.users-01\"\r\n class=\"text-emerald-600 dark:text-emerald-300 text-sm\"\r\n />\r\n <span\r\n class=\"text-emerald-700 dark:text-emerald-200 text-xs font-medium\"\r\n >\r\n {{ t(\"internal\") }}\r\n </span>\r\n </span>\r\n }\r\n </ng-template>\r\n\r\n <ng-template #applicationLinkCol let-row>\r\n @if (isLinkedToCurrentApplication(row)) {\r\n <span\r\n class=\"inline-flex items-center gap-1 rounded-md bg-emerald-50 dark:bg-emerald-900/30 p-2\"\r\n >\r\n <mt-icon\r\n icon=\"user.user-check-01\"\r\n class=\"text-emerald-600 dark:text-emerald-300 text-sm\"\r\n />\r\n <span\r\n class=\"text-emerald-700 dark:text-emerald-200 text-xs font-medium\"\r\n >\r\n {{ t(\"linked\") }}\r\n </span>\r\n </span>\r\n } @else {\r\n <span\r\n class=\"inline-flex items-center gap-1 rounded-md bg-amber-50 dark:bg-amber-900/30 p-2\"\r\n >\r\n <mt-icon\r\n icon=\"general.link-broken-01\"\r\n class=\"text-amber-600 dark:text-amber-300 text-sm\"\r\n />\r\n <span class=\"text-amber-700 dark:text-amber-200 text-xs font-medium\">\r\n {{ t(\"not-linked\") }}\r\n </span>\r\n </span>\r\n }\r\n </ng-template>\r\n\r\n <ng-template #emailCol let-row>\r\n <span\r\n class=\"block max-w-64 truncate\"\r\n mtTruncateTooltip\r\n tooltipPosition=\"top\"\r\n >{{ row.email }}</span\r\n >\r\n </ng-template>\r\n\r\n <mt-table\r\n [tabs]=\"tabs()\"\r\n [(activeTab)]=\"activeTab\"\r\n [data]=\"users()\"\r\n [columns]=\"tableColumns()\"\r\n [actions]=\"tableActions()\"\r\n [rowActions]=\"rowActions()\"\r\n [generalSearch]=\"true\"\r\n [showFilters]=\"false\"\r\n [loading]=\"loading()\"\r\n storageKey=\"users-groups-users-table\"\r\n >\r\n </mt-table>\r\n </div>\r\n</ng-container>\r\n", styles: [""], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "ngmodule", type: SkeletonModule }, { kind: "component", type: Table, selector: "mt-table", inputs: ["filters", "data", "columns", "rowActions", "size", "showGridlines", "stripedRows", "selectableRows", "clickableRows", "generalSearch", "lazyLocalSearch", "showFilters", "filterMode", "filterCloseOnOutsideClick", "loading", "updating", "lazy", "lazyLocalSort", "lazyTotalRecords", "reorderableColumns", "reorderableRows", "dataKey", "storageKey", "storageMode", "persistStateExclude", "exportable", "printable", "groupable", "groupCountMap", "cellClickFilter", "freezeActions", "virtualScroll", "virtualScrollItemSize", "scrollHeight", "printTitle", "exportFilename", "actionShape", "rowActionsLoadingFn", "tableLayout", "noCard", "tabs", "tabsOptionLabel", "tabsOptionValue", "activeTab", "actions", "captionStartTemplate", "captionEndTemplate", "emptyTitle", "emptyDescription", "emptyActionLabel", "emptyActionIcon", "externalFiltersActive", "paginatorPosition", "alwaysShowPaginator", "rowsPerPageOptions", "pageSize", "currentPage", "first", "filterTerm", "groupBy", "sortField", "sortDirection"], outputs: ["selectionChange", "cellChange", "lazyLoad", "columnReorder", "rowReorder", "rowClick", "emptyAction", "filtersCleared", "rowActionsRequested", "filtersChange", "activeTabChange", "onTabChange", "pageSizeChange", "currentPageChange", "firstChange", "filterTermChange", "groupByChange", "sortFieldChange", "sortDirectionChange"] }, { kind: "component", type: Icon, selector: "mt-icon", inputs: ["icon"] }, { kind: "directive", type: TranslocoDirective, selector: "[transloco]", inputs: ["transloco", "translocoParams", "translocoScope", "translocoRead", "translocoPrefix", "translocoLang", "translocoLoadingTpl"] }, { kind: "directive", type: TruncateTooltip, selector: "[mtTruncateTooltip]" }] });
2611
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.8", type: Users, isStandalone: true, selector: "mt-users", viewQueries: [{ propertyName: "typeCol", first: true, predicate: ["typeCol"], descendants: true, isSignal: true }, { propertyName: "applicationLinkCol", first: true, predicate: ["applicationLinkCol"], descendants: true, isSignal: true }, { propertyName: "emailCol", first: true, predicate: ["emailCol"], descendants: true, isSignal: true }], ngImport: i0, template: "<ng-container *transloco=\"let t; prefix: 'users-groups'\">\r\n <!-- mt-table wraps row actions; a locked row has five, so keep them on one line. -->\r\n <div class=\"mt-5 [&_.mt-actions-column>div]:flex-nowrap\">\r\n <ng-template #typeCol let-row>\r\n @if (row.isExternal) {\r\n <span\r\n class=\"inline-flex items-center gap-1 rounded-md bg-slate-50 dark:bg-slate-900/30 p-2\"\r\n >\r\n <mt-icon\r\n icon=\"general.link-external-02\"\r\n class=\"text-slate-600 dark:text-slate-300 text-sm\"\r\n />\r\n <span class=\"text-slate-700 dark:text-slate-200 text-xs font-medium\">\r\n {{ t(\"external\") }}\r\n </span>\r\n </span>\r\n } @else {\r\n <span\r\n class=\"inline-flex items-center gap-1 rounded-md bg-emerald-50 dark:bg-emerald-900/30 p-2\"\r\n >\r\n <mt-icon\r\n icon=\"user.users-01\"\r\n class=\"text-emerald-600 dark:text-emerald-300 text-sm\"\r\n />\r\n <span\r\n class=\"text-emerald-700 dark:text-emerald-200 text-xs font-medium\"\r\n >\r\n {{ t(\"internal\") }}\r\n </span>\r\n </span>\r\n }\r\n </ng-template>\r\n\r\n <ng-template #applicationLinkCol let-row>\r\n @if (isLinkedToCurrentApplication(row)) {\r\n <span\r\n class=\"inline-flex items-center gap-1 rounded-md bg-emerald-50 dark:bg-emerald-900/30 p-2\"\r\n >\r\n <mt-icon\r\n icon=\"user.user-check-01\"\r\n class=\"text-emerald-600 dark:text-emerald-300 text-sm\"\r\n />\r\n <span\r\n class=\"text-emerald-700 dark:text-emerald-200 text-xs font-medium\"\r\n >\r\n {{ t(\"linked\") }}\r\n </span>\r\n </span>\r\n } @else {\r\n <span\r\n class=\"inline-flex items-center gap-1 rounded-md bg-amber-50 dark:bg-amber-900/30 p-2\"\r\n >\r\n <mt-icon\r\n icon=\"general.link-broken-01\"\r\n class=\"text-amber-600 dark:text-amber-300 text-sm\"\r\n />\r\n <span class=\"text-amber-700 dark:text-amber-200 text-xs font-medium\">\r\n {{ t(\"not-linked\") }}\r\n </span>\r\n </span>\r\n }\r\n </ng-template>\r\n\r\n <ng-template #emailCol let-row>\r\n <span\r\n class=\"block max-w-64 truncate\"\r\n mtTruncateTooltip\r\n tooltipPosition=\"top\"\r\n >{{ row.email }}</span\r\n >\r\n </ng-template>\r\n\r\n <mt-table\r\n [tabs]=\"tabs()\"\r\n [(activeTab)]=\"activeTab\"\r\n [data]=\"users()\"\r\n [columns]=\"tableColumns()\"\r\n [actions]=\"tableActions()\"\r\n [rowActions]=\"rowActions()\"\r\n [generalSearch]=\"true\"\r\n [showFilters]=\"false\"\r\n [loading]=\"loading()\"\r\n storageKey=\"users-groups-users-table\"\r\n >\r\n </mt-table>\r\n </div>\r\n</ng-container>\r\n", styles: [""], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "ngmodule", type: SkeletonModule }, { kind: "component", type: Table, selector: "mt-table", inputs: ["filters", "data", "columns", "rowActions", "size", "showGridlines", "stripedRows", "selectableRows", "clickableRows", "generalSearch", "lazyLocalSearch", "searchScope", "showFilters", "filterMode", "filterCloseOnOutsideClick", "loading", "updating", "lazy", "lazyLocalSort", "lazyTotalRecords", "reorderableColumns", "reorderableRows", "dataKey", "storageKey", "storageMode", "persistStateExclude", "exportable", "printable", "groupable", "groupCountMap", "cellClickFilter", "freezeActions", "virtualScroll", "virtualScrollItemSize", "scrollHeight", "printTitle", "exportFilename", "actionShape", "rowActionsLoadingFn", "tableLayout", "noCard", "tabs", "tabsOptionLabel", "tabsOptionValue", "activeTab", "actions", "captionStartTemplate", "captionEndTemplate", "emptyTitle", "emptyDescription", "emptyActionLabel", "emptyActionIcon", "externalFiltersActive", "paginatorPosition", "alwaysShowPaginator", "rowsPerPageOptions", "pageSize", "currentPage", "first", "filterTerm", "groupBy", "sortField", "sortDirection"], outputs: ["selectionChange", "cellChange", "lazyLoad", "columnReorder", "rowReorder", "rowClick", "emptyAction", "filtersCleared", "rowActionsRequested", "filtersChange", "activeTabChange", "onTabChange", "pageSizeChange", "currentPageChange", "firstChange", "filterTermChange", "groupByChange", "sortFieldChange", "sortDirectionChange"] }, { kind: "component", type: Icon, selector: "mt-icon", inputs: ["icon"] }, { kind: "directive", type: TranslocoDirective, selector: "[transloco]", inputs: ["transloco", "translocoParams", "translocoScope", "translocoRead", "translocoPrefix", "translocoLang", "translocoLoadingTpl"] }, { kind: "directive", type: TruncateTooltip, selector: "[mtTruncateTooltip]" }] });
1971
2612
  }
1972
2613
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: Users, decorators: [{
1973
2614
  type: Component,
@@ -2192,7 +2833,7 @@ class GroupForm {
2192
2833
  }
2193
2834
  }
2194
2835
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: GroupForm, deps: [], target: i0.ɵɵFactoryTarget.Component });
2195
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.8", type: GroupForm, isStandalone: true, selector: "mt-group-form", inputs: { groupForEdit: { classPropertyName: "groupForEdit", publicName: "groupForEdit", isSignal: true, isRequired: false, transformFunction: null } }, providers: [DialogService], viewQueries: [{ propertyName: "userCol", first: true, predicate: ["userCol"], descendants: true, isSignal: true }], ngImport: i0, template: "<ng-container *transloco=\"let t; prefix: 'users-groups'\">\r\n <div [class]=\"'flex flex-col gap-1 p-4 ' + modal.contentClass\">\r\n @if (!getGroupFormLoading()) {\r\n <form class=\"col-span-1\">\r\n <mt-dynamic-form\r\n [formConfig]=\"groupFormConfig()\"\r\n [formControl]=\"groupFormControl\"\r\n />\r\n </form>\r\n\r\n @if (groupForEdit()) {\r\n <div class=\"flex gap-3 items-end mt-6 pt-4 border-t-1 border-surface\">\r\n <mt-dynamic-form\r\n class=\"flex-1\"\r\n [formConfig]=\"internalUserFormConfig()\"\r\n [formControl]=\"internalUserFormControl\"\r\n />\r\n <mt-button\r\n icon=\"general.plus\"\r\n class=\"mb-1\"\r\n variant=\"outlined\"\r\n (click)=\"onAddUser()\"\r\n [disabled]=\"\r\n addUserToGroupLoading() ||\r\n isUserExistInMembers() ||\r\n !internalUserFormControl.value?.userField\r\n \"\r\n />\r\n </div>\r\n\r\n <mt-table\r\n noCard\r\n [data]=\"selectedGroup()?.members || []\"\r\n [columns]=\"tableColumns()\"\r\n [rowActions]=\"rowActions()\"\r\n storageKey=\"users-groups-group-members-table\"\r\n [generalSearch]=\"false\"\r\n [showFilters]=\"false\"\r\n [loading]=\"addUserToGroupLoading()\"\r\n >\r\n </mt-table>\r\n <ng-template #userCol let-row>\r\n <div class=\"flex items-center gap-2\">\r\n <mt-avatar [icon]=\"'custom.user-pp'\"> </mt-avatar>\r\n {{ row?.displayName }}\r\n </div>\r\n </ng-template>\r\n }\r\n } @else {\r\n <p-skeleton class=\"my-4 mt-7\" height=\"3rem\" />\r\n <p-skeleton class=\"my-4\" height=\"3rem\" />\r\n <p-skeleton class=\"my-4\" height=\"3rem\" />\r\n }\r\n </div>\r\n\r\n <div [class]=\"modal.footerClass\">\r\n <mt-button\r\n [label]=\"t('cancel')\"\r\n variant=\"outlined\"\r\n [disabled]=\"createUpdateGroupLoading()\"\r\n (click)=\"ref.close(false)\"\r\n />\r\n <mt-button\r\n [label]=\"selectedGroup() ? t('save') : t('add')\"\r\n (click)=\"onSubmit()\"\r\n [loading]=\"createUpdateGroupLoading()\"\r\n [disabled]=\"!this.groupFormControl.valid || createUpdateGroupLoading()\"\r\n />\r\n </div>\r\n</ng-container>\r\n", styles: [":host{display:contents}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "component", type: Button, selector: "mt-button", inputs: ["icon", "label", "tooltip", "class", "type", "styleClass", "severity", "badge", "variant", "badgeSeverity", "size", "iconPos", "autofocus", "fluid", "raised", "rounded", "text", "plain", "outlined", "link", "disabled", "loading", "pInputs", "ariaLabel"], outputs: ["onClick", "onFocus", "onBlur"] }, { kind: "directive", type: TranslocoDirective, selector: "[transloco]", inputs: ["transloco", "translocoParams", "translocoScope", "translocoRead", "translocoPrefix", "translocoLang", "translocoLoadingTpl"] }, { kind: "ngmodule", type: SkeletonModule }, { kind: "component", type: i1.Skeleton, selector: "p-skeleton", inputs: ["styleClass", "shape", "animation", "borderRadius", "size", "width", "height"] }, { kind: "component", type: DynamicForm, selector: "mt-dynamic-form", inputs: ["formConfig", "forcedHiddenFieldKeys", "forcedDisabledFieldKeys", "preserveForcedHiddenValues", "visibleSectionKeys", "externalValues", "serverFieldErrors"], outputs: ["runtimeMessagesChange"] }, { kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i1$1.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { kind: "directive", type: i1$1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1$1.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],[formArray],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i1$1.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { kind: "component", type: Avatar, selector: "mt-avatar", inputs: ["label", "icon", "image", "styleClass", "size", "shape", "badge", "badgeSize", "badgeSeverity"], outputs: ["onImageError"] }, { kind: "component", type: Table, selector: "mt-table", inputs: ["filters", "data", "columns", "rowActions", "size", "showGridlines", "stripedRows", "selectableRows", "clickableRows", "generalSearch", "lazyLocalSearch", "showFilters", "filterMode", "filterCloseOnOutsideClick", "loading", "updating", "lazy", "lazyLocalSort", "lazyTotalRecords", "reorderableColumns", "reorderableRows", "dataKey", "storageKey", "storageMode", "persistStateExclude", "exportable", "printable", "groupable", "groupCountMap", "cellClickFilter", "freezeActions", "virtualScroll", "virtualScrollItemSize", "scrollHeight", "printTitle", "exportFilename", "actionShape", "rowActionsLoadingFn", "tableLayout", "noCard", "tabs", "tabsOptionLabel", "tabsOptionValue", "activeTab", "actions", "captionStartTemplate", "captionEndTemplate", "emptyTitle", "emptyDescription", "emptyActionLabel", "emptyActionIcon", "externalFiltersActive", "paginatorPosition", "alwaysShowPaginator", "rowsPerPageOptions", "pageSize", "currentPage", "first", "filterTerm", "groupBy", "sortField", "sortDirection"], outputs: ["selectionChange", "cellChange", "lazyLoad", "columnReorder", "rowReorder", "rowClick", "emptyAction", "filtersCleared", "rowActionsRequested", "filtersChange", "activeTabChange", "onTabChange", "pageSizeChange", "currentPageChange", "firstChange", "filterTermChange", "groupByChange", "sortFieldChange", "sortDirectionChange"] }] });
2836
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.8", type: GroupForm, isStandalone: true, selector: "mt-group-form", inputs: { groupForEdit: { classPropertyName: "groupForEdit", publicName: "groupForEdit", isSignal: true, isRequired: false, transformFunction: null } }, providers: [DialogService], viewQueries: [{ propertyName: "userCol", first: true, predicate: ["userCol"], descendants: true, isSignal: true }], ngImport: i0, template: "<ng-container *transloco=\"let t; prefix: 'users-groups'\">\r\n <div [class]=\"'flex flex-col gap-1 p-4 ' + modal.contentClass\">\r\n @if (!getGroupFormLoading()) {\r\n <form class=\"col-span-1\">\r\n <mt-dynamic-form\r\n [formConfig]=\"groupFormConfig()\"\r\n [formControl]=\"groupFormControl\"\r\n />\r\n </form>\r\n\r\n @if (groupForEdit()) {\r\n <div class=\"flex gap-3 items-end mt-6 pt-4 border-t-1 border-surface\">\r\n <mt-dynamic-form\r\n class=\"flex-1\"\r\n [formConfig]=\"internalUserFormConfig()\"\r\n [formControl]=\"internalUserFormControl\"\r\n />\r\n <mt-button\r\n icon=\"general.plus\"\r\n class=\"mb-1\"\r\n variant=\"outlined\"\r\n (click)=\"onAddUser()\"\r\n [disabled]=\"\r\n addUserToGroupLoading() ||\r\n isUserExistInMembers() ||\r\n !internalUserFormControl.value?.userField\r\n \"\r\n />\r\n </div>\r\n\r\n <mt-table\r\n noCard\r\n [data]=\"selectedGroup()?.members || []\"\r\n [columns]=\"tableColumns()\"\r\n [rowActions]=\"rowActions()\"\r\n storageKey=\"users-groups-group-members-table\"\r\n [generalSearch]=\"false\"\r\n [showFilters]=\"false\"\r\n [loading]=\"addUserToGroupLoading()\"\r\n >\r\n </mt-table>\r\n <ng-template #userCol let-row>\r\n <div class=\"flex items-center gap-2\">\r\n <mt-avatar [icon]=\"'custom.user-pp'\"> </mt-avatar>\r\n {{ row?.displayName }}\r\n </div>\r\n </ng-template>\r\n }\r\n } @else {\r\n <p-skeleton class=\"my-4 mt-7\" height=\"3rem\" />\r\n <p-skeleton class=\"my-4\" height=\"3rem\" />\r\n <p-skeleton class=\"my-4\" height=\"3rem\" />\r\n }\r\n </div>\r\n\r\n <div [class]=\"modal.footerClass\">\r\n <mt-button\r\n [label]=\"t('cancel')\"\r\n variant=\"outlined\"\r\n [disabled]=\"createUpdateGroupLoading()\"\r\n (click)=\"ref.close(false)\"\r\n />\r\n <mt-button\r\n [label]=\"selectedGroup() ? t('save') : t('add')\"\r\n (click)=\"onSubmit()\"\r\n [loading]=\"createUpdateGroupLoading()\"\r\n [disabled]=\"!this.groupFormControl.valid || createUpdateGroupLoading()\"\r\n />\r\n </div>\r\n</ng-container>\r\n", styles: [":host{display:contents}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "component", type: Button, selector: "mt-button", inputs: ["icon", "label", "tooltip", "class", "type", "styleClass", "severity", "badge", "variant", "badgeSeverity", "size", "iconPos", "autofocus", "fluid", "raised", "rounded", "text", "plain", "outlined", "link", "disabled", "loading", "pInputs", "ariaLabel"], outputs: ["onClick", "onFocus", "onBlur"] }, { kind: "directive", type: TranslocoDirective, selector: "[transloco]", inputs: ["transloco", "translocoParams", "translocoScope", "translocoRead", "translocoPrefix", "translocoLang", "translocoLoadingTpl"] }, { kind: "ngmodule", type: SkeletonModule }, { kind: "component", type: i1.Skeleton, selector: "p-skeleton", inputs: ["styleClass", "shape", "animation", "borderRadius", "size", "width", "height"] }, { kind: "component", type: DynamicForm, selector: "mt-dynamic-form", inputs: ["formConfig", "forcedHiddenFieldKeys", "forcedDisabledFieldKeys", "preserveForcedHiddenValues", "visibleSectionKeys", "externalValues", "serverFieldErrors"], outputs: ["runtimeMessagesChange"] }, { kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i1$1.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { kind: "directive", type: i1$1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1$1.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],[formArray],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i1$1.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { kind: "component", type: Avatar, selector: "mt-avatar", inputs: ["label", "icon", "image", "styleClass", "size", "shape", "badge", "badgeSize", "badgeSeverity"], outputs: ["onImageError"] }, { kind: "component", type: Table, selector: "mt-table", inputs: ["filters", "data", "columns", "rowActions", "size", "showGridlines", "stripedRows", "selectableRows", "clickableRows", "generalSearch", "lazyLocalSearch", "searchScope", "showFilters", "filterMode", "filterCloseOnOutsideClick", "loading", "updating", "lazy", "lazyLocalSort", "lazyTotalRecords", "reorderableColumns", "reorderableRows", "dataKey", "storageKey", "storageMode", "persistStateExclude", "exportable", "printable", "groupable", "groupCountMap", "cellClickFilter", "freezeActions", "virtualScroll", "virtualScrollItemSize", "scrollHeight", "printTitle", "exportFilename", "actionShape", "rowActionsLoadingFn", "tableLayout", "noCard", "tabs", "tabsOptionLabel", "tabsOptionValue", "activeTab", "actions", "captionStartTemplate", "captionEndTemplate", "emptyTitle", "emptyDescription", "emptyActionLabel", "emptyActionIcon", "externalFiltersActive", "paginatorPosition", "alwaysShowPaginator", "rowsPerPageOptions", "pageSize", "currentPage", "first", "filterTerm", "groupBy", "sortField", "sortDirection"], outputs: ["selectionChange", "cellChange", "lazyLoad", "columnReorder", "rowReorder", "rowClick", "emptyAction", "filtersCleared", "rowActionsRequested", "filtersChange", "activeTabChange", "onTabChange", "pageSizeChange", "currentPageChange", "firstChange", "filterTermChange", "groupByChange", "sortFieldChange", "sortDirectionChange"] }] });
2196
2837
  }
2197
2838
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: GroupForm, decorators: [{
2198
2839
  type: Component,
@@ -2612,7 +3253,7 @@ class Groups {
2612
3253
  });
2613
3254
  }
2614
3255
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: Groups, deps: [], target: i0.ɵɵFactoryTarget.Component });
2615
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "21.2.8", type: Groups, isStandalone: true, selector: "mt-groups", ngImport: i0, template: "<ng-container *transloco=\"let t; prefix: 'users-groups'\">\r\n <div class=\"mt-5\">\r\n <mt-table\r\n [(activeTab)]=\"activeTab\"\r\n [data]=\"allGroups()\"\r\n [columns]=\"tableColumns()\"\r\n [actions]=\"tableActions()\"\r\n [rowActions]=\"rowActions()\"\r\n [generalSearch]=\"true\"\r\n [showFilters]=\"false\"\r\n [loading]=\"loading()\"\r\n storageKey=\"users-groups-groups-table\"\r\n >\r\n </mt-table>\r\n </div>\r\n</ng-container>\r\n", styles: [".groups{padding:2rem}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "ngmodule", type: SkeletonModule }, { kind: "component", type: Table, selector: "mt-table", inputs: ["filters", "data", "columns", "rowActions", "size", "showGridlines", "stripedRows", "selectableRows", "clickableRows", "generalSearch", "lazyLocalSearch", "showFilters", "filterMode", "filterCloseOnOutsideClick", "loading", "updating", "lazy", "lazyLocalSort", "lazyTotalRecords", "reorderableColumns", "reorderableRows", "dataKey", "storageKey", "storageMode", "persistStateExclude", "exportable", "printable", "groupable", "groupCountMap", "cellClickFilter", "freezeActions", "virtualScroll", "virtualScrollItemSize", "scrollHeight", "printTitle", "exportFilename", "actionShape", "rowActionsLoadingFn", "tableLayout", "noCard", "tabs", "tabsOptionLabel", "tabsOptionValue", "activeTab", "actions", "captionStartTemplate", "captionEndTemplate", "emptyTitle", "emptyDescription", "emptyActionLabel", "emptyActionIcon", "externalFiltersActive", "paginatorPosition", "alwaysShowPaginator", "rowsPerPageOptions", "pageSize", "currentPage", "first", "filterTerm", "groupBy", "sortField", "sortDirection"], outputs: ["selectionChange", "cellChange", "lazyLoad", "columnReorder", "rowReorder", "rowClick", "emptyAction", "filtersCleared", "rowActionsRequested", "filtersChange", "activeTabChange", "onTabChange", "pageSizeChange", "currentPageChange", "firstChange", "filterTermChange", "groupByChange", "sortFieldChange", "sortDirectionChange"] }, { kind: "directive", type: TranslocoDirective, selector: "[transloco]", inputs: ["transloco", "translocoParams", "translocoScope", "translocoRead", "translocoPrefix", "translocoLang", "translocoLoadingTpl"] }] });
3256
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "21.2.8", type: Groups, isStandalone: true, selector: "mt-groups", ngImport: i0, template: "<ng-container *transloco=\"let t; prefix: 'users-groups'\">\r\n <div class=\"mt-5\">\r\n <mt-table\r\n [(activeTab)]=\"activeTab\"\r\n [data]=\"allGroups()\"\r\n [columns]=\"tableColumns()\"\r\n [actions]=\"tableActions()\"\r\n [rowActions]=\"rowActions()\"\r\n [generalSearch]=\"true\"\r\n [showFilters]=\"false\"\r\n [loading]=\"loading()\"\r\n storageKey=\"users-groups-groups-table\"\r\n >\r\n </mt-table>\r\n </div>\r\n</ng-container>\r\n", styles: [".groups{padding:2rem}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "ngmodule", type: SkeletonModule }, { kind: "component", type: Table, selector: "mt-table", inputs: ["filters", "data", "columns", "rowActions", "size", "showGridlines", "stripedRows", "selectableRows", "clickableRows", "generalSearch", "lazyLocalSearch", "searchScope", "showFilters", "filterMode", "filterCloseOnOutsideClick", "loading", "updating", "lazy", "lazyLocalSort", "lazyTotalRecords", "reorderableColumns", "reorderableRows", "dataKey", "storageKey", "storageMode", "persistStateExclude", "exportable", "printable", "groupable", "groupCountMap", "cellClickFilter", "freezeActions", "virtualScroll", "virtualScrollItemSize", "scrollHeight", "printTitle", "exportFilename", "actionShape", "rowActionsLoadingFn", "tableLayout", "noCard", "tabs", "tabsOptionLabel", "tabsOptionValue", "activeTab", "actions", "captionStartTemplate", "captionEndTemplate", "emptyTitle", "emptyDescription", "emptyActionLabel", "emptyActionIcon", "externalFiltersActive", "paginatorPosition", "alwaysShowPaginator", "rowsPerPageOptions", "pageSize", "currentPage", "first", "filterTerm", "groupBy", "sortField", "sortDirection"], outputs: ["selectionChange", "cellChange", "lazyLoad", "columnReorder", "rowReorder", "rowClick", "emptyAction", "filtersCleared", "rowActionsRequested", "filtersChange", "activeTabChange", "onTabChange", "pageSizeChange", "currentPageChange", "firstChange", "filterTermChange", "groupByChange", "sortFieldChange", "sortDirectionChange"] }, { kind: "directive", type: TranslocoDirective, selector: "[transloco]", inputs: ["transloco", "translocoParams", "translocoScope", "translocoRead", "translocoPrefix", "translocoLang", "translocoLoadingTpl"] }] });
2616
3257
  }
2617
3258
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: Groups, decorators: [{
2618
3259
  type: Component,
@@ -2621,9 +3262,1076 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImpor
2621
3262
 
2622
3263
  // store/index.ts
2623
3264
 
3265
+ /**
3266
+ * "Replace by" (user replacement) contract, as the backend serves it under
3267
+ * `api/identity/users/replacement`. Source: Pplus5.BE
3268
+ * `Docs/User-Replacement/Simple-Replacement-Flow.md` and
3269
+ * `Application.Abstractions/UserReplacement/UserReplacementOperationContracts.cs`.
3270
+ *
3271
+ * One confirmation starts a replacement; the server finds the work and hands
3272
+ * it over in the background. Screens start, list, watch, show results and
3273
+ * cancel. They never search for or list the person's places themselves: the
3274
+ * discovery, capabilities and successor-check routes were removed. Enums come
3275
+ * back as text.
3276
+ */
3277
+ const USER_REPLACEMENT_OPERATION_CONTRACT = 'user-replacement-operation-v1';
3278
+ /** The server is working on these: the screens poll them. */
3279
+ const ACTIVE_STATUSES = ['Preparing', 'Running'];
3280
+ /** Finished on its own. */
3281
+ const FINISHED_STATUSES = [
3282
+ 'Completed',
3283
+ 'CompletedWithWarnings',
3284
+ ];
3285
+ /** Nothing else will happen. */
3286
+ const CLOSED_STATUSES = ['Cancelled', 'Expired'];
3287
+ /** Results that an admin has to finish by hand. */
3288
+ const MANUAL_RESULTS = [
3289
+ 'RequiresManualAction',
3290
+ 'Conflict',
3291
+ ];
3292
+ /** The number of items an admin has to finish by hand. */
3293
+ function manualCountOf(summary) {
3294
+ const byResult = summary.itemsByResult ?? {};
3295
+ return MANUAL_RESULTS.reduce((sum, key) => sum + (byResult[key] ?? 0), 0);
3296
+ }
3297
+ /**
3298
+ * Why a replacement stopped: the backend adds the stop code to
3299
+ * `warningCodes` (a `UserReplacement_*` failure key, or
3300
+ * `CollectorAuthorizationUnavailable`).
3301
+ */
3302
+ function stopCodeOf(summary) {
3303
+ return ((summary.warningCodes ?? []).find((code) => code === 'CollectorAuthorizationUnavailable' ||
3304
+ /^UserReplacement_\w+$/.test(code)) ?? null);
3305
+ }
3306
+ /**
3307
+ * The text key of the Stop / Close confirmation. Nothing moves while the
3308
+ * server is still finding work, so stopping then changes nothing.
3309
+ */
3310
+ function cancelConfirmKey(status) {
3311
+ if (status === 'Preparing')
3312
+ return 'stop-confirm-preparing';
3313
+ return ACTIVE_STATUSES.includes(status) ? 'stop-confirm' : 'close-confirm';
3314
+ }
3315
+
3316
+ const TONE_BOX = {
3317
+ neutral: 'border-surface bg-content',
3318
+ info: 'border-primary-200 bg-primary-50 dark:border-primary-800 dark:bg-primary-950',
3319
+ success: 'border-emerald-200 bg-emerald-50 text-emerald-800 dark:border-emerald-900 dark:bg-emerald-950 dark:text-emerald-200',
3320
+ warning: 'border-amber-200 bg-amber-50 text-amber-800 dark:border-amber-900 dark:bg-amber-950 dark:text-amber-200',
3321
+ danger: 'border-red-200 bg-red-50 text-red-800 dark:border-red-900 dark:bg-red-950 dark:text-red-200',
3322
+ };
3323
+ const TONE_PILL = {
3324
+ neutral: 'border-surface bg-surface-50 text-muted-color dark:bg-surface-900',
3325
+ info: 'border-primary-200 bg-primary-50 text-primary-700 dark:border-primary-800 dark:bg-primary-950 dark:text-primary-200',
3326
+ success: 'border-emerald-200 bg-emerald-50 text-emerald-700 dark:border-emerald-900 dark:bg-emerald-950 dark:text-emerald-200',
3327
+ warning: 'border-amber-200 bg-amber-50 text-amber-700 dark:border-amber-900 dark:bg-amber-950 dark:text-amber-200',
3328
+ danger: 'border-red-200 bg-red-50 text-red-700 dark:border-red-900 dark:bg-red-950 dark:text-red-200',
3329
+ };
3330
+ /** Pill colour per replacement status; unlisted ones are neutral. */
3331
+ const STATUS_TONE = {
3332
+ Preparing: 'info',
3333
+ Running: 'info',
3334
+ Completed: 'success',
3335
+ CompletedWithWarnings: 'warning',
3336
+ ManualActionRequired: 'warning',
3337
+ Paused: 'warning',
3338
+ AwaitingRestart: 'warning',
3339
+ };
3340
+
3341
+ /** Finished results: moved, already with the successor, or kept as history. */
3342
+ const DONE_RESULTS = [
3343
+ 'Applied',
3344
+ 'AlreadySatisfied',
3345
+ 'Preserved',
3346
+ ];
3347
+ const PLACE_ICON = {
3348
+ LevelRecord: 'education.briefcase-01',
3349
+ ModuleRecord: 'file.file-02',
3350
+ Request: 'dev.git-branch-01',
3351
+ Escalation: 'map.flag-01',
3352
+ };
3353
+ /**
3354
+ * The words for one result: its place (project, module record, request or
3355
+ * escalation, with names and an Open link), a headline naming the field, role,
3356
+ * step or task, and one sentence saying what happened with the people's
3357
+ * names. Without `display` (an older backend) it falls back to the store and
3358
+ * scope labels the screen showed before.
3359
+ */
3360
+ function describeResult(item, text, names) {
3361
+ const technical = [
3362
+ text.store(item.store),
3363
+ item.recordId,
3364
+ item.field,
3365
+ item.resultCode,
3366
+ ]
3367
+ .filter(Boolean)
3368
+ .join(' · ');
3369
+ return {
3370
+ place: placeOf(item, text),
3371
+ headline: headlineOf(item, text),
3372
+ detail: sentenceOf(item, text, names),
3373
+ technical,
3374
+ foldable: item.display?.subjectKind === 'TeamRole' &&
3375
+ DONE_RESULTS.includes(item.resultStatus ?? ''),
3376
+ };
3377
+ }
3378
+ function placeOf(item, text) {
3379
+ const display = item.display;
3380
+ if (!display) {
3381
+ const where = `${text.code('scopes', item.scope)} #${item.scopeId}`;
3382
+ return {
3383
+ key: `${item.scope}:${item.scopeId}`,
3384
+ icon: 'layout.list',
3385
+ title: where,
3386
+ context: '',
3387
+ openUrl: null,
3388
+ };
3389
+ }
3390
+ const kind = display.placeKind;
3391
+ const id = display.moduleDataId ??
3392
+ display.requestId ??
3393
+ display.escalationInstanceId ??
3394
+ display.levelDataId ??
3395
+ item.scopeId;
3396
+ const join = (...parts) => parts.filter((part) => !!part && part.trim()).join(' · ');
3397
+ const schema = join(display.moduleName, display.levelName, display.workspaceName);
3398
+ let title;
3399
+ let context;
3400
+ if (!display.placeVisible) {
3401
+ title = text.t('place.hidden');
3402
+ context = join(kind === 'Request' ? display.processName : null, text.code('place.kinds', kind, ''), schema);
3403
+ }
3404
+ else if (kind === 'Request') {
3405
+ title =
3406
+ display.recordName || display.processName || text.t('place.request');
3407
+ context = join(display.recordName ? display.processName : null, schema);
3408
+ }
3409
+ else if (kind === 'Escalation') {
3410
+ title = display.recordName || text.t('place.escalation');
3411
+ context = join(text.t('place.escalation'), schema);
3412
+ }
3413
+ else {
3414
+ title = display.recordName || text.code('place.kinds', kind, kind);
3415
+ context = schema;
3416
+ }
3417
+ const canOpen = display.placeVisible &&
3418
+ display.templateId != null &&
3419
+ display.levelId != null &&
3420
+ display.levelDataId != null;
3421
+ return {
3422
+ key: `${kind}:${id}:${display.placeVisible ? 1 : 0}`,
3423
+ icon: display.placeVisible
3424
+ ? (PLACE_ICON[kind] ?? 'layout.list')
3425
+ : 'security.lock-01',
3426
+ title,
3427
+ context,
3428
+ // The client app's project route, opened by the browser (not the admin
3429
+ // router), like the dashboard builder's "open entity" action.
3430
+ openUrl: canOpen
3431
+ ? `/${display.templateId}/explore/${display.levelId}/${display.levelDataId}/level-workspace`
3432
+ : null,
3433
+ };
3434
+ }
3435
+ function headlineOf(item, text) {
3436
+ const display = item.display;
3437
+ const subject = display?.subject?.trim() || null;
3438
+ switch (display?.subjectKind) {
3439
+ case 'Field':
3440
+ return subject ?? text.t('subjects.field');
3441
+ case 'TeamRole':
3442
+ return subject
3443
+ ? text.t('subjects.team-role', { subject })
3444
+ : text.t('subjects.team-role-unnamed');
3445
+ case 'ApprovalStep':
3446
+ return subject
3447
+ ? text.t('subjects.approval-step', { subject })
3448
+ : text.t('subjects.approval-step-unnamed');
3449
+ case 'RequestCustody':
3450
+ return text.t('subjects.request-custody');
3451
+ case 'EscalationStep':
3452
+ return subject
3453
+ ? text.t('subjects.escalation-step', { subject })
3454
+ : text.t('subjects.escalation-step-unnamed');
3455
+ case 'Task':
3456
+ return subject
3457
+ ? text.t('subjects.task', { subject })
3458
+ : text.t('subjects.task-unnamed');
3459
+ case 'EntityList':
3460
+ return subject
3461
+ ? text.t('subjects.list', { subject })
3462
+ : text.t('subjects.list-unnamed');
3463
+ default:
3464
+ return text.store(item.store);
3465
+ }
3466
+ }
3467
+ /**
3468
+ * What happened, with the people's names when a sentence exists for the
3469
+ * result code; otherwise the result code's own text, or for work left to an
3470
+ * admin with no code, the reason (as before).
3471
+ */
3472
+ function sentenceOf(item, text, names) {
3473
+ if (item.resultCode) {
3474
+ const sentence = text.code('sentences', item.resultCode, '');
3475
+ if (sentence)
3476
+ return text.t(`sentences.${item.resultCode}`, {
3477
+ name: names.name,
3478
+ successor: names.successor,
3479
+ });
3480
+ return text.code('result-codes', item.resultCode);
3481
+ }
3482
+ return MANUAL_RESULTS.includes(item.resultStatus ?? '')
3483
+ ? text.code('reasons', item.reason, '')
3484
+ : '';
3485
+ }
3486
+ function groupByPlace(rows) {
3487
+ const groups = new Map();
3488
+ for (const row of rows) {
3489
+ const key = row.words.place.key;
3490
+ let group = groups.get(key);
3491
+ if (!group) {
3492
+ group = { place: row.words.place, rows: [], foldedTeamRoles: 0 };
3493
+ groups.set(key, group);
3494
+ }
3495
+ if (row.words.foldable)
3496
+ group.foldedTeamRoles++;
3497
+ else
3498
+ group.rows.push(row);
3499
+ }
3500
+ return [...groups.values()];
3501
+ }
3502
+
3503
+ /** The server works in the background; the drawer only re-reads it. */
3504
+ const POLL_INTERVAL_MS = 5000;
3505
+ /** Stop watching (not the work) after this many failed reads in a row. */
3506
+ const MAX_FAILURES = 10;
3507
+ const RESULTS_PAGE_SIZE = 200;
3508
+ /** While the server works, the results are re-read at most this often. */
3509
+ const RESULTS_REFRESH_MS = 15000;
3510
+ /** Rows drawn at once; "Show more" adds the next batch. */
3511
+ const ROWS_STEP = 50;
3512
+ const NOT_CHECKED = 'NotChecked';
3513
+ const RESULT_TONE = {
3514
+ Applied: 'success',
3515
+ AlreadySatisfied: 'success',
3516
+ RequiresManualAction: 'warning',
3517
+ Conflict: 'warning',
3518
+ };
3519
+ const wait = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
3520
+ function contractMajor(version) {
3521
+ return /-v(\d+)$/.exec(version ?? '')?.[1] ?? null;
3522
+ }
3523
+ /**
3524
+ * One replacement, in a drawer over the Replacements list. The opener keeps
3525
+ * its id in the URL (`?id=`), so a refresh reopens it. The server does the
3526
+ * work in the background; the drawer shows a generic "processing" card while
3527
+ * it does, then the results (what needs an admin first). Its footer holds
3528
+ * Close and, while `canCancel` allows, Stop / Close replacement; nothing else
3529
+ * (starting again lives on the Users page). It never shows places or scan
3530
+ * counts: the backend asks screens not to.
3531
+ *
3532
+ * Opened through `ModalService`, so it gets the root injector: it never
3533
+ * navigates; the opener clears `?id=` when it closes.
3534
+ */
3535
+ class UserReplacementDetails {
3536
+ modal = inject(ModalService);
3537
+ ref = inject(ModalRef);
3538
+ api = inject(UserReplacementService);
3539
+ facade = inject(UsersGroupsFacade);
3540
+ confirmation = inject(ConfirmationService);
3541
+ toast = inject(ToastService);
3542
+ transloco = inject(TranslocoService);
3543
+ destroyRef = inject(DestroyRef);
3544
+ text = new ReplacementText(this.transloco);
3545
+ /** The replacement to show; set once by the opener. */
3546
+ operationId = input.required(...(ngDevMode ? [{ debugName: "operationId" }] : /* istanbul ignore next */ []));
3547
+ destroyed = false;
3548
+ /** Bumped per results load, so an older load arriving late is dropped. */
3549
+ resultsRequest = 0;
3550
+ resultsLoadedAt = 0;
3551
+ users = this.facade.users;
3552
+ language = toSignal(this.transloco.langChanges$, {
3553
+ initialValue: this.transloco.getActiveLang(),
3554
+ });
3555
+ summary = signal(null, ...(ngDevMode ? [{ debugName: "summary" }] : /* istanbul ignore next */ []));
3556
+ loading = signal(true, ...(ngDevMode ? [{ debugName: "loading" }] : /* istanbul ignore next */ []));
3557
+ loadError = signal(null, ...(ngDevMode ? [{ debugName: "loadError" }] : /* istanbul ignore next */ []));
3558
+ watching = signal(false, ...(ngDevMode ? [{ debugName: "watching" }] : /* istanbul ignore next */ []));
3559
+ /** Watching gave up after repeated failures; reopening the drawer retries. */
3560
+ watchStopped = signal(false, ...(ngDevMode ? [{ debugName: "watchStopped" }] : /* istanbul ignore next */ []));
3561
+ cancelling = signal(false, ...(ngDevMode ? [{ debugName: "cancelling" }] : /* istanbul ignore next */ []));
3562
+ actionError = signal(null, ...(ngDevMode ? [{ debugName: "actionError" }] : /* istanbul ignore next */ []));
3563
+ items = signal([], ...(ngDevMode ? [{ debugName: "items" }] : /* istanbul ignore next */ []));
3564
+ itemsLoading = signal(false, ...(ngDevMode ? [{ debugName: "itemsLoading" }] : /* istanbul ignore next */ []));
3565
+ itemsError = signal(null, ...(ngDevMode ? [{ debugName: "itemsError" }] : /* istanbul ignore next */ []));
3566
+ showDetails = signal(false, ...(ngDevMode ? [{ debugName: "showDetails" }] : /* istanbul ignore next */ []));
3567
+ selectedTab = signal(null, ...(ngDevMode ? [{ debugName: "selectedTab" }] : /* istanbul ignore next */ []));
3568
+ rowLimit = signal(ROWS_STEP, ...(ngDevMode ? [{ debugName: "rowLimit" }] : /* istanbul ignore next */ []));
3569
+ search = new FormControl('', { nonNullable: true });
3570
+ searchText = toSignal(this.search.valueChanges, {
3571
+ initialValue: '',
3572
+ });
3573
+ status = computed(() => this.summary()?.status ?? null, ...(ngDevMode ? [{ debugName: "status" }] : /* istanbul ignore next */ []));
3574
+ isActive = computed(() => ACTIVE_STATUSES.includes(this.status() ?? ''), ...(ngDevMode ? [{ debugName: "isActive" }] : /* istanbul ignore next */ []));
3575
+ isFinished = computed(() => FINISHED_STATUSES.includes(this.status() ?? ''), ...(ngDevMode ? [{ debugName: "isFinished" }] : /* istanbul ignore next */ []));
3576
+ /**
3577
+ * Results are outcomes after confirmation, not a list of places being
3578
+ * found: while the server prepares, the drawer shows only the status card.
3579
+ */
3580
+ showResults = computed(() => {
3581
+ const summary = this.summary();
3582
+ return (!!summary &&
3583
+ summary.status !== 'Preparing' &&
3584
+ (summary.itemCount > 0 || this.items().length > 0));
3585
+ }, ...(ngDevMode ? [{ debugName: "showResults" }] : /* istanbul ignore next */ []));
3586
+ contractOutdated = computed(() => {
3587
+ const summary = this.summary();
3588
+ return (!!summary &&
3589
+ contractMajor(summary.contractVersion) !==
3590
+ contractMajor(USER_REPLACEMENT_OPERATION_CONTRACT));
3591
+ }, ...(ngDevMode ? [{ debugName: "contractOutdated" }] : /* istanbul ignore next */ []));
3592
+ sourceName = computed(() => this.nameOf(this.summary()?.sourceUserId), ...(ngDevMode ? [{ debugName: "sourceName" }] : /* istanbul ignore next */ []));
3593
+ successorName = computed(() => this.nameOf(this.summary()?.defaultSuccessorUserId), ...(ngDevMode ? [{ debugName: "successorName" }] : /* istanbul ignore next */ []));
3594
+ sourceInitials = computed(() => initialsOf(this.sourceName()), ...(ngDevMode ? [{ debugName: "sourceInitials" }] : /* istanbul ignore next */ []));
3595
+ successorInitials = computed(() => initialsOf(this.successorName()), ...(ngDevMode ? [{ debugName: "successorInitials" }] : /* istanbul ignore next */ []));
3596
+ statusClass = computed(() => TONE_PILL[STATUS_TONE[this.status() ?? ''] ?? 'neutral'], ...(ngDevMode ? [{ debugName: "statusClass" }] : /* istanbul ignore next */ []));
3597
+ createdAt = computed(() => validDate(this.summary()?.createdAtUtc), ...(ngDevMode ? [{ debugName: "createdAt" }] : /* istanbul ignore next */ []));
3598
+ updatedAt = computed(() => validDate(this.summary()?.updatedAtUtc), ...(ngDevMode ? [{ debugName: "updatedAt" }] : /* istanbul ignore next */ []));
3599
+ canCancel = computed(() => !this.cancelling() && !!this.summary()?.canCancel, ...(ngDevMode ? [{ debugName: "canCancel" }] : /* istanbul ignore next */ []));
3600
+ /** While the server works it is "Stop"; afterwards "Close". */
3601
+ cancelIsStop = computed(() => this.isActive(), ...(ngDevMode ? [{ debugName: "cancelIsStop" }] : /* istanbul ignore next */ []));
3602
+ manualCount = computed(() => {
3603
+ const summary = this.summary();
3604
+ return summary ? manualCountOf(summary) : 0;
3605
+ }, ...(ngDevMode ? [{ debugName: "manualCount" }] : /* istanbul ignore next */ []));
3606
+ notCheckedCount = computed(() => this.summary()?.itemsByResult?.[NOT_CHECKED] ??
3607
+ this.rows().filter((row) => row.notChecked).length, ...(ngDevMode ? [{ debugName: "notCheckedCount" }] : /* istanbul ignore next */ []));
3608
+ /** Why a stopped replacement stopped, translated. */
3609
+ stopReason = computed(() => {
3610
+ const summary = this.summary();
3611
+ const code = summary ? stopCodeOf(summary) : null;
3612
+ return code ? this.codeText(code) : '';
3613
+ }, ...(ngDevMode ? [{ debugName: "stopReason" }] : /* istanbul ignore next */ []));
3614
+ /** The one card that says where the replacement is and what to do now. */
3615
+ card = computed(() => {
3616
+ this.language();
3617
+ const summary = this.summary();
3618
+ if (!summary)
3619
+ return null;
3620
+ const names = {
3621
+ name: this.sourceName(),
3622
+ successor: this.successorName(),
3623
+ };
3624
+ const card = (tone, icon, title, body = '', progress = false) => ({ tone, icon, title, body, progress });
3625
+ switch (summary.status) {
3626
+ case 'Preparing':
3627
+ case 'Running':
3628
+ return card('info', 'arrow.refresh-cw-02', this.text.t('next.processing-title'), this.text.t('next.processing-body', names), !this.watchStopped());
3629
+ case 'Completed':
3630
+ return card('success', 'general.check-circle', this.text.t('next.completed-title'),
3631
+ // Common now that only active work is collected: say so plainly.
3632
+ summary.itemCount === 0
3633
+ ? this.text.t('next.completed-none-body', names)
3634
+ : this.text.t('next.completed-body', names));
3635
+ case 'CompletedWithWarnings':
3636
+ return card('warning', 'alert.alert-triangle', this.text.t('next.completed-gaps-title'), this.text.t('next.completed-gaps-body', names));
3637
+ case 'ManualActionRequired':
3638
+ return card('warning', 'alert.alert-triangle', this.manualCount()
3639
+ ? this.text.t('next.manual-title', { count: this.manualCount() })
3640
+ : this.text.t('next.manual-other-title'), [
3641
+ this.manualCount()
3642
+ ? this.text.t('next.manual-body')
3643
+ : this.stopReason(),
3644
+ this.text.t('next.manual-close', names),
3645
+ ]
3646
+ .filter(Boolean)
3647
+ .join(' '));
3648
+ case 'Paused':
3649
+ return card('warning', 'media.pause-circle', this.text.t('next.paused-title'), [this.stopReason(), this.text.t('next.paused-body')]
3650
+ .filter(Boolean)
3651
+ .join(' '));
3652
+ case 'AwaitingRestart':
3653
+ return card('warning', 'arrow.refresh-cw-02', this.text.t('next.restart-title'), this.text.t('next.restart-body', names));
3654
+ case 'Expired':
3655
+ return card('neutral', 'time.clock', this.text.t('next.expired-title'), this.text.t('next.expired-body'));
3656
+ default:
3657
+ return card('neutral', 'general.slash-circle-01', this.text.t('next.cancelled-title'), (summary.itemsByResult?.['Applied'] ?? 0) > 0
3658
+ ? this.text.t('next.cancelled-body', names)
3659
+ : this.text.t('next.cancelled-none-body'));
3660
+ }
3661
+ }, ...(ngDevMode ? [{ debugName: "card" }] : /* istanbul ignore next */ []));
3662
+ cardBoxClass = computed(() => TONE_BOX[this.card()?.tone ?? 'neutral'], ...(ngDevMode ? [{ debugName: "cardBoxClass" }] : /* istanbul ignore next */ []));
3663
+ /** The card's icon colour: the tone triple's text colour, primary for info. */
3664
+ cardIconClass = computed(() => {
3665
+ switch (this.card()?.tone) {
3666
+ case 'info':
3667
+ return 'text-primary';
3668
+ case 'neutral':
3669
+ return 'text-muted-color';
3670
+ default:
3671
+ return '';
3672
+ }
3673
+ }, ...(ngDevMode ? [{ debugName: "cardIconClass" }] : /* istanbul ignore next */ []));
3674
+ /** Every warning code the backend sent, translated, for "Technical details". */
3675
+ technicalDetails = computed(() => {
3676
+ this.language();
3677
+ return (this.summary()?.warningCodes ?? []).map((code) => this.codeText(code));
3678
+ }, ...(ngDevMode ? [{ debugName: "technicalDetails" }] : /* istanbul ignore next */ []));
3679
+ rows = computed(() => {
3680
+ this.language();
3681
+ const active = this.isActive();
3682
+ const names = { name: this.sourceName(), successor: this.successorName() };
3683
+ return this.items().map((item) => {
3684
+ const notChecked = item.resultStatus === NOT_CHECKED ||
3685
+ item.resultCode === 'PlaceCouldNotBeRead';
3686
+ const [status, tone] = item.resultStatus
3687
+ ? [
3688
+ this.text.code('results', item.resultStatus),
3689
+ RESULT_TONE[item.resultStatus] ?? 'neutral',
3690
+ ]
3691
+ : [
3692
+ active ? this.text.t('waiting') : this.text.t('not-done'),
3693
+ 'neutral',
3694
+ ];
3695
+ // The place, what it is about and what happened, in the admin's words.
3696
+ const words = describeResult(item, this.text, names);
3697
+ return {
3698
+ itemId: item.itemId,
3699
+ words,
3700
+ status,
3701
+ statusDetail: words.detail,
3702
+ statusClass: TONE_PILL[tone],
3703
+ resultKey: item.resultStatus,
3704
+ notChecked,
3705
+ search: [
3706
+ words.place.title,
3707
+ words.place.context,
3708
+ words.headline,
3709
+ words.detail,
3710
+ words.technical,
3711
+ status,
3712
+ ]
3713
+ .join(' ')
3714
+ .toLowerCase(),
3715
+ };
3716
+ });
3717
+ }, ...(ngDevMode ? [{ debugName: "rows" }] : /* istanbul ignore next */ []));
3718
+ /** Needs you first, so the admin sees their part before anything else. */
3719
+ tabs = computed(() => {
3720
+ this.language();
3721
+ const rows = this.rows();
3722
+ const checked = rows.filter((row) => !row.notChecked);
3723
+ const tabs = [];
3724
+ const add = (value, label, match) => {
3725
+ const badge = checked.filter(match).length;
3726
+ if (badge)
3727
+ tabs.push({ value, label, badge });
3728
+ };
3729
+ add('manual', this.text.t('tabs.manual'), (row) => MANUAL_RESULTS.includes(row.resultKey ?? ''));
3730
+ add('done', this.text.t('tabs.done'), (row) => DONE_RESULTS.includes(row.resultKey ?? ''));
3731
+ add('waiting', this.isActive()
3732
+ ? this.text.t('tabs.waiting')
3733
+ : this.text.t('tabs.not-done'), (row) => !row.resultKey);
3734
+ const notChecked = rows.length - checked.length;
3735
+ if (notChecked)
3736
+ tabs.push({
3737
+ value: 'notChecked',
3738
+ label: this.text.t('tabs.not-checked'),
3739
+ badge: notChecked,
3740
+ });
3741
+ if (tabs.length > 1)
3742
+ tabs.push({
3743
+ value: 'all',
3744
+ label: this.text.t('tabs.all'),
3745
+ badge: rows.length,
3746
+ });
3747
+ return tabs;
3748
+ }, ...(ngDevMode ? [{ debugName: "tabs" }] : /* istanbul ignore next */ []));
3749
+ activeTab = computed(() => {
3750
+ const tabs = this.tabs();
3751
+ const selected = this.selectedTab();
3752
+ return tabs.some((tab) => tab.value === selected)
3753
+ ? selected
3754
+ : (tabs[0]?.value ?? 'all');
3755
+ }, ...(ngDevMode ? [{ debugName: "activeTab" }] : /* istanbul ignore next */ []));
3756
+ filteredRows = computed(() => {
3757
+ const rows = this.rows();
3758
+ const query = this.searchText().trim().toLowerCase();
3759
+ const inTab = (() => {
3760
+ switch (this.activeTab()) {
3761
+ case 'notChecked':
3762
+ return rows.filter((row) => row.notChecked);
3763
+ case 'manual':
3764
+ return rows.filter((row) => !row.notChecked && MANUAL_RESULTS.includes(row.resultKey ?? ''));
3765
+ case 'done':
3766
+ return rows.filter((row) => !row.notChecked && DONE_RESULTS.includes(row.resultKey ?? ''));
3767
+ case 'waiting':
3768
+ return rows.filter((row) => !row.notChecked && !row.resultKey);
3769
+ default:
3770
+ return rows;
3771
+ }
3772
+ })();
3773
+ return query ? inTab.filter((row) => row.search.includes(query)) : inTab;
3774
+ }, ...(ngDevMode ? [{ debugName: "filteredRows" }] : /* istanbul ignore next */ []));
3775
+ visibleRows = computed(() => this.filteredRows().slice(0, this.rowLimit()), ...(ngDevMode ? [{ debugName: "visibleRows" }] : /* istanbul ignore next */ []));
3776
+ hiddenRowCount = computed(() => this.filteredRows().length - this.visibleRows().length, ...(ngDevMode ? [{ debugName: "hiddenRowCount" }] : /* istanbul ignore next */ []));
3777
+ /** The drawn rows under their place (project, record, request, escalation). */
3778
+ visibleGroups = computed(() => groupByPlace(this.visibleRows()), ...(ngDevMode ? [{ debugName: "visibleGroups" }] : /* istanbul ignore next */ []));
3779
+ ngOnInit() {
3780
+ this.destroyRef.onDestroy(() => (this.destroyed = true));
3781
+ if (!this.users().length)
3782
+ this.facade.getUsers();
3783
+ void this.open();
3784
+ }
3785
+ selectTab(value) {
3786
+ this.selectedTab.set(value);
3787
+ this.rowLimit.set(ROWS_STEP);
3788
+ }
3789
+ showMore() {
3790
+ this.rowLimit.update((limit) => limit + ROWS_STEP);
3791
+ }
3792
+ // ---------------------------------------------------------------------------
3793
+ // Loading
3794
+ // ---------------------------------------------------------------------------
3795
+ async open() {
3796
+ const operationId = this.operationId();
3797
+ this.loading.set(true);
3798
+ try {
3799
+ this.summary.set(await firstValueFrom(this.api.get(operationId)));
3800
+ }
3801
+ catch (error) {
3802
+ if (!this.destroyed)
3803
+ this.loadError.set(this.text.error(replacementErrorKey(error)));
3804
+ return;
3805
+ }
3806
+ finally {
3807
+ if (!this.destroyed)
3808
+ this.loading.set(false);
3809
+ }
3810
+ if (this.contractOutdated())
3811
+ return;
3812
+ await this.loadResults();
3813
+ if (this.isActive())
3814
+ await this.watch();
3815
+ }
3816
+ /** Re-read the summary; keeps the current one when that fails too. */
3817
+ async reloadSummary() {
3818
+ try {
3819
+ const summary = await firstValueFrom(this.api.get(this.operationId()));
3820
+ if (!this.destroyed)
3821
+ this.summary.set(summary);
3822
+ }
3823
+ catch {
3824
+ // The old summary stays visible; the caller already shows the failure.
3825
+ }
3826
+ }
3827
+ /** All result pages; skipped while the server is still preparing. */
3828
+ async loadResults() {
3829
+ if (this.status() === 'Preparing')
3830
+ return;
3831
+ const operationId = this.operationId();
3832
+ const request = ++this.resultsRequest;
3833
+ const isLatest = () => !this.destroyed && request === this.resultsRequest;
3834
+ this.itemsLoading.set(true);
3835
+ this.itemsError.set(null);
3836
+ const items = [];
3837
+ try {
3838
+ let afterItemId = 0;
3839
+ // Keyset paging: `nextAfterItemId` null is the last page.
3840
+ for (;;) {
3841
+ const page = await firstValueFrom(this.api.results(operationId, afterItemId, RESULTS_PAGE_SIZE));
3842
+ if (!isLatest())
3843
+ return;
3844
+ items.push(...page.items);
3845
+ if (page.nextAfterItemId == null || !page.items.length)
3846
+ break;
3847
+ afterItemId = page.nextAfterItemId;
3848
+ }
3849
+ this.items.set(items);
3850
+ this.resultsLoadedAt = Date.now();
3851
+ }
3852
+ catch (error) {
3853
+ if (isLatest())
3854
+ this.itemsError.set(this.text.error(replacementErrorKey(error)));
3855
+ }
3856
+ finally {
3857
+ if (isLatest())
3858
+ this.itemsLoading.set(false);
3859
+ }
3860
+ }
3861
+ // ---------------------------------------------------------------------------
3862
+ // Watching: the server does the work, the drawer re-reads it.
3863
+ // ---------------------------------------------------------------------------
3864
+ async watch() {
3865
+ if (this.watching())
3866
+ return;
3867
+ const operationId = this.operationId();
3868
+ this.watching.set(true);
3869
+ this.watchStopped.set(false);
3870
+ let failures = 0;
3871
+ try {
3872
+ while (!this.destroyed && this.isActive()) {
3873
+ await wait(POLL_INTERVAL_MS);
3874
+ if (this.destroyed)
3875
+ return;
3876
+ try {
3877
+ const before = this.summary();
3878
+ const next = await firstValueFrom(this.api.get(operationId));
3879
+ if (this.destroyed)
3880
+ return;
3881
+ this.summary.set(next);
3882
+ failures = 0;
3883
+ // While handing over, keep the results moving now and then.
3884
+ const moved = before?.status !== next.status ||
3885
+ before?.pendingItemCount !== next.pendingItemCount;
3886
+ if (moved &&
3887
+ next.status === 'Running' &&
3888
+ Date.now() - this.resultsLoadedAt >= RESULTS_REFRESH_MS)
3889
+ void this.loadResults();
3890
+ }
3891
+ catch (error) {
3892
+ if (this.destroyed)
3893
+ return;
3894
+ if (++failures >= MAX_FAILURES) {
3895
+ // The work itself goes on; only this drawer stopped watching.
3896
+ this.actionError.set(this.text.error(replacementErrorKey(error)));
3897
+ this.watchStopped.set(true);
3898
+ return;
3899
+ }
3900
+ }
3901
+ }
3902
+ }
3903
+ finally {
3904
+ this.watching.set(false);
3905
+ }
3906
+ if (this.destroyed)
3907
+ return;
3908
+ // It finished or stopped while the drawer watched: show the outcome.
3909
+ await this.loadResults();
3910
+ const card = this.card();
3911
+ if (card && this.status() !== 'Cancelled') {
3912
+ if (card.tone === 'success')
3913
+ this.toast.success(card.title);
3914
+ else
3915
+ this.toast.info(card.title);
3916
+ }
3917
+ }
3918
+ // ---------------------------------------------------------------------------
3919
+ // Stop / Close
3920
+ // ---------------------------------------------------------------------------
3921
+ cancel() {
3922
+ const summary = this.summary();
3923
+ if (!summary || !this.canCancel())
3924
+ return;
3925
+ const stop = this.cancelIsStop();
3926
+ const label = stop ? this.text.t('stop') : this.text.t('close');
3927
+ this.confirmation.confirm({
3928
+ type: 'dialog',
3929
+ header: stop ? this.text.t('stop-title') : this.text.t('close-title'),
3930
+ message: this.text.t(cancelConfirmKey(summary.status), {
3931
+ name: this.sourceName(),
3932
+ successor: this.successorName(),
3933
+ }),
3934
+ icon: 'general.x-circle',
3935
+ acceptLabel: label,
3936
+ rejectLabel: this.text.t('keep'),
3937
+ acceptButton: { severity: 'danger' },
3938
+ accept: () => void this.doCancel(),
3939
+ });
3940
+ }
3941
+ async doCancel() {
3942
+ this.cancelling.set(true);
3943
+ this.actionError.set(null);
3944
+ try {
3945
+ const summary = await firstValueFrom(this.api.cancel(this.operationId()));
3946
+ if (this.destroyed)
3947
+ return;
3948
+ this.summary.set(summary);
3949
+ this.toast.success(this.text.t('closed-toast'));
3950
+ void this.loadResults();
3951
+ }
3952
+ catch (error) {
3953
+ if (this.destroyed)
3954
+ return;
3955
+ // `ProcessingBusy`: it did not stop; the admin can try again.
3956
+ this.actionError.set(this.text.error(replacementErrorKey(error)));
3957
+ await this.reloadSummary();
3958
+ }
3959
+ finally {
3960
+ this.cancelling.set(false);
3961
+ }
3962
+ }
3963
+ close() {
3964
+ this.ref.close();
3965
+ }
3966
+ /** A warning or stop code: failure keys and limits live in two groups. */
3967
+ codeText(code) {
3968
+ return /^UserReplacement_\w+$/.test(code)
3969
+ ? this.text.error(code)
3970
+ : this.text.code('blockers', code);
3971
+ }
3972
+ nameOf(userId) {
3973
+ if (!userId)
3974
+ return '';
3975
+ const user = this.users().find((candidate) => candidate.id === userId);
3976
+ return user?.displayName || user?.userName || userId;
3977
+ }
3978
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: UserReplacementDetails, deps: [], target: i0.ɵɵFactoryTarget.Component });
3979
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.8", type: UserReplacementDetails, isStandalone: true, selector: "mt-user-replacement-details", inputs: { operationId: { classPropertyName: "operationId", publicName: "operationId", isSignal: true, isRequired: true, transformFunction: null } }, ngImport: i0, template: "<ng-container *transloco=\"let t; prefix: 'users-groups.replacement'\">\r\n <div class=\"flex flex-col gap-4 p-4\" [class]=\"modal.contentClass\">\r\n @if (loading()) {\r\n <p-skeleton height=\"7rem\" borderRadius=\"0.375rem\" />\r\n <p-skeleton height=\"6rem\" borderRadius=\"0.375rem\" />\r\n <p-skeleton height=\"12rem\" borderRadius=\"0.375rem\" />\r\n } @else if (loadError()) {\r\n <div\r\n class=\"flex items-start gap-2 rounded-md border border-red-200 bg-red-50 p-4 text-sm text-red-700 dark:border-red-900 dark:bg-red-950 dark:text-red-200\"\r\n role=\"alert\"\r\n >\r\n <mt-icon icon=\"alert.alert-circle\" class=\"mt-0.5 shrink-0\" />\r\n <span>{{ loadError() }}</span>\r\n </div>\r\n } @else if (contractOutdated()) {\r\n <div\r\n class=\"rounded-md border border-amber-200 bg-amber-50 p-4 text-sm text-amber-700 dark:border-amber-900 dark:bg-amber-950 dark:text-amber-200\"\r\n >\r\n {{ t(\"contract-outdated\") }}\r\n </div>\r\n } @else if (summary(); as replacement) {\r\n <!-- Who \u2192 who, the status, and when -->\r\n <section\r\n class=\"flex flex-col gap-3 rounded-md border border-surface bg-content p-4\"\r\n >\r\n <div class=\"flex items-center gap-3\">\r\n <div class=\"flex min-w-0 flex-1 items-center gap-3\">\r\n <mt-avatar\r\n [label]=\"sourceInitials()\"\r\n shape=\"circle\"\r\n styleClass=\"bg-surface-100! text-color! dark:bg-surface-800!\"\r\n />\r\n <div class=\"min-w-0\">\r\n <div class=\"text-xs text-muted-color\">{{ t(\"from\") }}</div>\r\n <div class=\"truncate font-semibold\" [title]=\"sourceName()\">\r\n {{ sourceName() }}\r\n </div>\r\n </div>\r\n </div>\r\n <mt-icon\r\n icon=\"arrow.arrow-right\"\r\n class=\"shrink-0 text-lg text-muted-color rtl:rotate-180\"\r\n />\r\n <div class=\"flex min-w-0 flex-1 items-center gap-3\">\r\n <mt-avatar\r\n [label]=\"successorInitials()\"\r\n shape=\"circle\"\r\n styleClass=\"bg-primary-50! text-primary-700! dark:bg-primary-950! dark:text-primary-200!\"\r\n />\r\n <div class=\"min-w-0\">\r\n <div class=\"text-xs text-muted-color\">{{ t(\"to\") }}</div>\r\n <div class=\"truncate font-semibold\" [title]=\"successorName()\">\r\n {{ successorName() }}\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n\r\n <div\r\n class=\"flex flex-wrap items-center gap-x-4 gap-y-2 border-t border-surface pt-3 text-xs text-muted-color\"\r\n >\r\n <span\r\n class=\"rounded-md border px-2 py-0.5 font-semibold\"\r\n [class]=\"statusClass()\"\r\n >{{ text.code(\"statuses\", replacement.status) }}</span\r\n >\r\n @if (createdAt(); as created) {\r\n <span class=\"flex items-center gap-1\">\r\n <mt-icon icon=\"time.calendar\" />\r\n {{ t(\"started\") }}\r\n <span class=\"tabular-nums text-color\">{{\r\n created | mtDateFormat: \"dateTime\"\r\n }}</span>\r\n </span>\r\n }\r\n @if (updatedAt(); as updated) {\r\n <span class=\"flex items-center gap-1\">\r\n <mt-icon icon=\"time.clock\" />\r\n {{ t(\"updated\") }}\r\n <span class=\"tabular-nums text-color\">{{\r\n updated | mtDateFormat: \"dateTime\"\r\n }}</span>\r\n </span>\r\n }\r\n </div>\r\n </section>\r\n\r\n <!-- Where it is, in one sentence -->\r\n @if (card(); as status) {\r\n <section\r\n class=\"flex flex-col gap-3 rounded-md border p-4\"\r\n [class]=\"cardBoxClass()\"\r\n role=\"status\"\r\n >\r\n <div class=\"flex items-start gap-3\">\r\n <mt-icon\r\n [icon]=\"status.icon\"\r\n class=\"mt-0.5 shrink-0 text-xl\"\r\n [class]=\"cardIconClass()\"\r\n />\r\n <div class=\"flex min-w-0 flex-1 flex-col gap-1\">\r\n <div class=\"font-semibold\">{{ status.title }}</div>\r\n @if (status.body) {\r\n <div class=\"text-sm\">{{ status.body }}</div>\r\n }\r\n @if (isFinished() && notCheckedCount() > 0) {\r\n <div class=\"text-sm opacity-80\">\r\n {{ t(\"not-checked-note\", { count: notCheckedCount() }) }}\r\n </div>\r\n }\r\n </div>\r\n </div>\r\n\r\n @if (status.progress) {\r\n <p-progressbar mode=\"indeterminate\" [style]=\"{ height: '4px' }\" />\r\n }\r\n\r\n @if (actionError()) {\r\n <div\r\n class=\"flex items-start gap-2 rounded-md border border-red-200 bg-red-50 p-3 text-sm text-red-700 dark:border-red-900 dark:bg-red-950 dark:text-red-200\"\r\n role=\"alert\"\r\n >\r\n <mt-icon icon=\"alert.alert-circle\" class=\"mt-0.5 shrink-0\" />\r\n <span>{{ actionError() }}</span>\r\n </div>\r\n }\r\n </section>\r\n }\r\n\r\n <!-- The results: outcomes after Start, what needs an admin first -->\r\n @if (showResults()) {\r\n <section class=\"flex flex-col gap-3\">\r\n <h3 class=\"text-sm font-semibold\">{{ t(\"results-title\") }}</h3>\r\n\r\n @if (tabs().length > 1) {\r\n <mt-tabs\r\n [options]=\"tabs()\"\r\n [active]=\"activeTab()\"\r\n (activeChange)=\"selectTab($event)\"\r\n mode=\"underline\"\r\n size=\"small\"\r\n />\r\n }\r\n @if (rows().length > 8) {\r\n <mt-text-field\r\n [formControl]=\"search\"\r\n icon=\"general.search-lg\"\r\n [placeholder]=\"t('search-results')\"\r\n />\r\n }\r\n\r\n @if (itemsError()) {\r\n <div\r\n class=\"rounded-md border border-red-200 bg-red-50 p-3 text-sm text-red-700 dark:border-red-900 dark:bg-red-950 dark:text-red-200\"\r\n role=\"alert\"\r\n >\r\n {{ itemsError() }}\r\n </div>\r\n } @else if (itemsLoading() && !items().length) {\r\n <div class=\"flex flex-col gap-2\">\r\n @for (row of [1, 2, 3]; track row) {\r\n <p-skeleton height=\"3.5rem\" borderRadius=\"0.375rem\" />\r\n }\r\n </div>\r\n } @else if (!filteredRows().length) {\r\n <div\r\n class=\"rounded-md border border-dashed border-surface p-4 text-center text-sm text-muted-color\"\r\n >\r\n {{ t(\"no-matching-results\") }}\r\n </div>\r\n } @else {\r\n <ul class=\"rounded-md border border-surface bg-content\">\r\n @for (group of visibleGroups(); track group.place.key) {\r\n <li class=\"border-t border-surface first:border-t-0\">\r\n <!-- The place: project, record, request or escalation -->\r\n <div\r\n class=\"flex items-center gap-3 bg-surface-50 px-3 py-2 dark:bg-surface-900\"\r\n >\r\n <mt-icon\r\n [icon]=\"group.place.icon\"\r\n class=\"shrink-0 text-muted-color\"\r\n />\r\n <div class=\"min-w-0 flex-1\">\r\n <div\r\n class=\"truncate text-sm font-semibold\"\r\n [title]=\"group.place.title\"\r\n >\r\n {{ group.place.title }}\r\n </div>\r\n @if (group.place.context) {\r\n <div\r\n class=\"truncate text-xs text-muted-color\"\r\n [title]=\"group.place.context\"\r\n >\r\n {{ group.place.context }}\r\n </div>\r\n }\r\n </div>\r\n @if (group.place.openUrl) {\r\n <a\r\n class=\"flex shrink-0 items-center gap-1 text-xs text-primary hover:underline\"\r\n [href]=\"group.place.openUrl\"\r\n target=\"_blank\"\r\n rel=\"noopener\"\r\n >\r\n {{ t(\"open-project\") }}\r\n <mt-icon\r\n icon=\"general.link-external-01\"\r\n class=\"rtl:-scale-x-100\"\r\n />\r\n </a>\r\n }\r\n </div>\r\n <ul>\r\n @for (row of group.rows; track row.itemId) {\r\n <li\r\n class=\"flex items-start gap-3 border-t border-surface p-3\"\r\n >\r\n <div class=\"flex min-w-0 flex-1 flex-col gap-0.5\">\r\n <span class=\"text-sm font-medium\">{{\r\n row.words.headline\r\n }}</span>\r\n @if (row.statusDetail) {\r\n <span class=\"text-xs text-muted-color\">{{\r\n row.statusDetail\r\n }}</span>\r\n }\r\n @if (showDetails() && row.words.technical) {\r\n <span\r\n class=\"truncate font-mono text-[11px] text-muted-color\"\r\n [title]=\"row.words.technical\"\r\n >{{ row.words.technical }}</span\r\n >\r\n }\r\n </div>\r\n <span\r\n class=\"shrink-0 whitespace-nowrap rounded-md border px-2 py-0.5 text-xs font-medium\"\r\n [class]=\"row.statusClass\"\r\n >{{ row.status }}</span\r\n >\r\n </li>\r\n }\r\n @if (group.foldedTeamRoles) {\r\n <li\r\n class=\"flex items-center gap-2 border-t border-surface px-3 py-2 text-xs text-muted-color\"\r\n >\r\n <mt-icon icon=\"general.check-circle\" class=\"shrink-0\" />\r\n {{ t(\"team-note\", { count: group.foldedTeamRoles }) }}\r\n </li>\r\n }\r\n </ul>\r\n </li>\r\n }\r\n </ul>\r\n @if (hiddenRowCount() > 0) {\r\n <mt-button\r\n class=\"self-center\"\r\n [label]=\"t('show-more', { count: hiddenRowCount() })\"\r\n icon=\"arrow.chevron-down\"\r\n variant=\"outlined\"\r\n size=\"small\"\r\n (click)=\"showMore()\"\r\n />\r\n }\r\n }\r\n </section>\r\n }\r\n\r\n <!-- One general limit, with every backend code behind a toggle -->\r\n <div class=\"flex flex-col gap-1 text-xs text-muted-color\">\r\n <div class=\"flex items-start gap-1.5\">\r\n <mt-icon icon=\"general.info-circle\" class=\"mt-px shrink-0\" />\r\n <span>{{ t(\"notices.supported-only\") }}</span>\r\n </div>\r\n @if (technicalDetails().length) {\r\n <button\r\n type=\"button\"\r\n class=\"ms-5 flex items-center gap-1 self-start text-primary hover:underline\"\r\n [attr.aria-expanded]=\"showDetails()\"\r\n (click)=\"showDetails.set(!showDetails())\"\r\n >\r\n <mt-icon\r\n [icon]=\"showDetails() ? 'arrow.chevron-up' : 'arrow.chevron-down'\"\r\n />\r\n {{ showDetails() ? t(\"hide-details\") : t(\"show-details\") }}\r\n </button>\r\n @if (showDetails()) {\r\n <ul class=\"ms-5 flex list-disc flex-col gap-0.5 ps-4\">\r\n @for (detail of technicalDetails(); track $index) {\r\n <li>{{ detail }}</li>\r\n }\r\n </ul>\r\n }\r\n }\r\n </div>\r\n }\r\n </div>\r\n\r\n <!-- Close, and Stop / Close replacement while the backend allows it -->\r\n <div [class]=\"modal.footerClass\">\r\n @if (canCancel()) {\r\n <mt-button\r\n [label]=\"cancelIsStop() ? t('stop') : t('close')\"\r\n icon=\"general.x-circle\"\r\n severity=\"danger\"\r\n variant=\"outlined\"\r\n [loading]=\"cancelling()\"\r\n (click)=\"cancel()\"\r\n />\r\n }\r\n <mt-button [label]=\"t('dismiss')\" (click)=\"close()\" />\r\n </div>\r\n</ng-container>\r\n", dependencies: [{ kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i1$1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1$1.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { kind: "directive", type: TranslocoDirective, selector: "[transloco]", inputs: ["transloco", "translocoParams", "translocoScope", "translocoRead", "translocoPrefix", "translocoLang", "translocoLoadingTpl"] }, { kind: "component", type: Avatar, selector: "mt-avatar", inputs: ["label", "icon", "image", "styleClass", "size", "shape", "badge", "badgeSize", "badgeSeverity"], outputs: ["onImageError"] }, { kind: "component", type: Button, selector: "mt-button", inputs: ["icon", "label", "tooltip", "class", "type", "styleClass", "severity", "badge", "variant", "badgeSeverity", "size", "iconPos", "autofocus", "fluid", "raised", "rounded", "text", "plain", "outlined", "link", "disabled", "loading", "pInputs", "ariaLabel"], outputs: ["onClick", "onFocus", "onBlur"] }, { kind: "component", type: Icon, selector: "mt-icon", inputs: ["icon"] }, { kind: "component", type: Tabs, selector: "mt-tabs", inputs: ["options", "optionLabel", "optionValue", "active", "mode", "moreLabel", "defaultIcon", "size", "fluid", "disabled", "searchThreshold"], outputs: ["activeChange", "onChange"] }, { kind: "component", type: TextField, selector: "mt-text-field", inputs: ["field", "hint", "label", "placeholder", "class", "type", "readonly", "pInputs", "required", "maxLength", "icon", "iconPosition"] }, { kind: "ngmodule", type: ProgressBarModule }, { kind: "component", type: i2.ProgressBar, selector: "p-progressBar, p-progressbar, p-progress-bar", inputs: ["value", "showValue", "styleClass", "valueStyleClass", "unit", "mode", "color"] }, { kind: "ngmodule", type: SkeletonModule }, { kind: "component", type: i1.Skeleton, selector: "p-skeleton", inputs: ["styleClass", "shape", "animation", "borderRadius", "size", "width", "height"] }, { kind: "pipe", type: MTDateFormatPipe, name: "mtDateFormat" }] });
3980
+ }
3981
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: UserReplacementDetails, decorators: [{
3982
+ type: Component,
3983
+ args: [{ selector: 'mt-user-replacement-details', imports: [
3984
+ ReactiveFormsModule,
3985
+ TranslocoDirective,
3986
+ Avatar,
3987
+ Button,
3988
+ Icon,
3989
+ Tabs,
3990
+ TextField,
3991
+ ProgressBarModule,
3992
+ SkeletonModule,
3993
+ MTDateFormatPipe,
3994
+ ], template: "<ng-container *transloco=\"let t; prefix: 'users-groups.replacement'\">\r\n <div class=\"flex flex-col gap-4 p-4\" [class]=\"modal.contentClass\">\r\n @if (loading()) {\r\n <p-skeleton height=\"7rem\" borderRadius=\"0.375rem\" />\r\n <p-skeleton height=\"6rem\" borderRadius=\"0.375rem\" />\r\n <p-skeleton height=\"12rem\" borderRadius=\"0.375rem\" />\r\n } @else if (loadError()) {\r\n <div\r\n class=\"flex items-start gap-2 rounded-md border border-red-200 bg-red-50 p-4 text-sm text-red-700 dark:border-red-900 dark:bg-red-950 dark:text-red-200\"\r\n role=\"alert\"\r\n >\r\n <mt-icon icon=\"alert.alert-circle\" class=\"mt-0.5 shrink-0\" />\r\n <span>{{ loadError() }}</span>\r\n </div>\r\n } @else if (contractOutdated()) {\r\n <div\r\n class=\"rounded-md border border-amber-200 bg-amber-50 p-4 text-sm text-amber-700 dark:border-amber-900 dark:bg-amber-950 dark:text-amber-200\"\r\n >\r\n {{ t(\"contract-outdated\") }}\r\n </div>\r\n } @else if (summary(); as replacement) {\r\n <!-- Who \u2192 who, the status, and when -->\r\n <section\r\n class=\"flex flex-col gap-3 rounded-md border border-surface bg-content p-4\"\r\n >\r\n <div class=\"flex items-center gap-3\">\r\n <div class=\"flex min-w-0 flex-1 items-center gap-3\">\r\n <mt-avatar\r\n [label]=\"sourceInitials()\"\r\n shape=\"circle\"\r\n styleClass=\"bg-surface-100! text-color! dark:bg-surface-800!\"\r\n />\r\n <div class=\"min-w-0\">\r\n <div class=\"text-xs text-muted-color\">{{ t(\"from\") }}</div>\r\n <div class=\"truncate font-semibold\" [title]=\"sourceName()\">\r\n {{ sourceName() }}\r\n </div>\r\n </div>\r\n </div>\r\n <mt-icon\r\n icon=\"arrow.arrow-right\"\r\n class=\"shrink-0 text-lg text-muted-color rtl:rotate-180\"\r\n />\r\n <div class=\"flex min-w-0 flex-1 items-center gap-3\">\r\n <mt-avatar\r\n [label]=\"successorInitials()\"\r\n shape=\"circle\"\r\n styleClass=\"bg-primary-50! text-primary-700! dark:bg-primary-950! dark:text-primary-200!\"\r\n />\r\n <div class=\"min-w-0\">\r\n <div class=\"text-xs text-muted-color\">{{ t(\"to\") }}</div>\r\n <div class=\"truncate font-semibold\" [title]=\"successorName()\">\r\n {{ successorName() }}\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n\r\n <div\r\n class=\"flex flex-wrap items-center gap-x-4 gap-y-2 border-t border-surface pt-3 text-xs text-muted-color\"\r\n >\r\n <span\r\n class=\"rounded-md border px-2 py-0.5 font-semibold\"\r\n [class]=\"statusClass()\"\r\n >{{ text.code(\"statuses\", replacement.status) }}</span\r\n >\r\n @if (createdAt(); as created) {\r\n <span class=\"flex items-center gap-1\">\r\n <mt-icon icon=\"time.calendar\" />\r\n {{ t(\"started\") }}\r\n <span class=\"tabular-nums text-color\">{{\r\n created | mtDateFormat: \"dateTime\"\r\n }}</span>\r\n </span>\r\n }\r\n @if (updatedAt(); as updated) {\r\n <span class=\"flex items-center gap-1\">\r\n <mt-icon icon=\"time.clock\" />\r\n {{ t(\"updated\") }}\r\n <span class=\"tabular-nums text-color\">{{\r\n updated | mtDateFormat: \"dateTime\"\r\n }}</span>\r\n </span>\r\n }\r\n </div>\r\n </section>\r\n\r\n <!-- Where it is, in one sentence -->\r\n @if (card(); as status) {\r\n <section\r\n class=\"flex flex-col gap-3 rounded-md border p-4\"\r\n [class]=\"cardBoxClass()\"\r\n role=\"status\"\r\n >\r\n <div class=\"flex items-start gap-3\">\r\n <mt-icon\r\n [icon]=\"status.icon\"\r\n class=\"mt-0.5 shrink-0 text-xl\"\r\n [class]=\"cardIconClass()\"\r\n />\r\n <div class=\"flex min-w-0 flex-1 flex-col gap-1\">\r\n <div class=\"font-semibold\">{{ status.title }}</div>\r\n @if (status.body) {\r\n <div class=\"text-sm\">{{ status.body }}</div>\r\n }\r\n @if (isFinished() && notCheckedCount() > 0) {\r\n <div class=\"text-sm opacity-80\">\r\n {{ t(\"not-checked-note\", { count: notCheckedCount() }) }}\r\n </div>\r\n }\r\n </div>\r\n </div>\r\n\r\n @if (status.progress) {\r\n <p-progressbar mode=\"indeterminate\" [style]=\"{ height: '4px' }\" />\r\n }\r\n\r\n @if (actionError()) {\r\n <div\r\n class=\"flex items-start gap-2 rounded-md border border-red-200 bg-red-50 p-3 text-sm text-red-700 dark:border-red-900 dark:bg-red-950 dark:text-red-200\"\r\n role=\"alert\"\r\n >\r\n <mt-icon icon=\"alert.alert-circle\" class=\"mt-0.5 shrink-0\" />\r\n <span>{{ actionError() }}</span>\r\n </div>\r\n }\r\n </section>\r\n }\r\n\r\n <!-- The results: outcomes after Start, what needs an admin first -->\r\n @if (showResults()) {\r\n <section class=\"flex flex-col gap-3\">\r\n <h3 class=\"text-sm font-semibold\">{{ t(\"results-title\") }}</h3>\r\n\r\n @if (tabs().length > 1) {\r\n <mt-tabs\r\n [options]=\"tabs()\"\r\n [active]=\"activeTab()\"\r\n (activeChange)=\"selectTab($event)\"\r\n mode=\"underline\"\r\n size=\"small\"\r\n />\r\n }\r\n @if (rows().length > 8) {\r\n <mt-text-field\r\n [formControl]=\"search\"\r\n icon=\"general.search-lg\"\r\n [placeholder]=\"t('search-results')\"\r\n />\r\n }\r\n\r\n @if (itemsError()) {\r\n <div\r\n class=\"rounded-md border border-red-200 bg-red-50 p-3 text-sm text-red-700 dark:border-red-900 dark:bg-red-950 dark:text-red-200\"\r\n role=\"alert\"\r\n >\r\n {{ itemsError() }}\r\n </div>\r\n } @else if (itemsLoading() && !items().length) {\r\n <div class=\"flex flex-col gap-2\">\r\n @for (row of [1, 2, 3]; track row) {\r\n <p-skeleton height=\"3.5rem\" borderRadius=\"0.375rem\" />\r\n }\r\n </div>\r\n } @else if (!filteredRows().length) {\r\n <div\r\n class=\"rounded-md border border-dashed border-surface p-4 text-center text-sm text-muted-color\"\r\n >\r\n {{ t(\"no-matching-results\") }}\r\n </div>\r\n } @else {\r\n <ul class=\"rounded-md border border-surface bg-content\">\r\n @for (group of visibleGroups(); track group.place.key) {\r\n <li class=\"border-t border-surface first:border-t-0\">\r\n <!-- The place: project, record, request or escalation -->\r\n <div\r\n class=\"flex items-center gap-3 bg-surface-50 px-3 py-2 dark:bg-surface-900\"\r\n >\r\n <mt-icon\r\n [icon]=\"group.place.icon\"\r\n class=\"shrink-0 text-muted-color\"\r\n />\r\n <div class=\"min-w-0 flex-1\">\r\n <div\r\n class=\"truncate text-sm font-semibold\"\r\n [title]=\"group.place.title\"\r\n >\r\n {{ group.place.title }}\r\n </div>\r\n @if (group.place.context) {\r\n <div\r\n class=\"truncate text-xs text-muted-color\"\r\n [title]=\"group.place.context\"\r\n >\r\n {{ group.place.context }}\r\n </div>\r\n }\r\n </div>\r\n @if (group.place.openUrl) {\r\n <a\r\n class=\"flex shrink-0 items-center gap-1 text-xs text-primary hover:underline\"\r\n [href]=\"group.place.openUrl\"\r\n target=\"_blank\"\r\n rel=\"noopener\"\r\n >\r\n {{ t(\"open-project\") }}\r\n <mt-icon\r\n icon=\"general.link-external-01\"\r\n class=\"rtl:-scale-x-100\"\r\n />\r\n </a>\r\n }\r\n </div>\r\n <ul>\r\n @for (row of group.rows; track row.itemId) {\r\n <li\r\n class=\"flex items-start gap-3 border-t border-surface p-3\"\r\n >\r\n <div class=\"flex min-w-0 flex-1 flex-col gap-0.5\">\r\n <span class=\"text-sm font-medium\">{{\r\n row.words.headline\r\n }}</span>\r\n @if (row.statusDetail) {\r\n <span class=\"text-xs text-muted-color\">{{\r\n row.statusDetail\r\n }}</span>\r\n }\r\n @if (showDetails() && row.words.technical) {\r\n <span\r\n class=\"truncate font-mono text-[11px] text-muted-color\"\r\n [title]=\"row.words.technical\"\r\n >{{ row.words.technical }}</span\r\n >\r\n }\r\n </div>\r\n <span\r\n class=\"shrink-0 whitespace-nowrap rounded-md border px-2 py-0.5 text-xs font-medium\"\r\n [class]=\"row.statusClass\"\r\n >{{ row.status }}</span\r\n >\r\n </li>\r\n }\r\n @if (group.foldedTeamRoles) {\r\n <li\r\n class=\"flex items-center gap-2 border-t border-surface px-3 py-2 text-xs text-muted-color\"\r\n >\r\n <mt-icon icon=\"general.check-circle\" class=\"shrink-0\" />\r\n {{ t(\"team-note\", { count: group.foldedTeamRoles }) }}\r\n </li>\r\n }\r\n </ul>\r\n </li>\r\n }\r\n </ul>\r\n @if (hiddenRowCount() > 0) {\r\n <mt-button\r\n class=\"self-center\"\r\n [label]=\"t('show-more', { count: hiddenRowCount() })\"\r\n icon=\"arrow.chevron-down\"\r\n variant=\"outlined\"\r\n size=\"small\"\r\n (click)=\"showMore()\"\r\n />\r\n }\r\n }\r\n </section>\r\n }\r\n\r\n <!-- One general limit, with every backend code behind a toggle -->\r\n <div class=\"flex flex-col gap-1 text-xs text-muted-color\">\r\n <div class=\"flex items-start gap-1.5\">\r\n <mt-icon icon=\"general.info-circle\" class=\"mt-px shrink-0\" />\r\n <span>{{ t(\"notices.supported-only\") }}</span>\r\n </div>\r\n @if (technicalDetails().length) {\r\n <button\r\n type=\"button\"\r\n class=\"ms-5 flex items-center gap-1 self-start text-primary hover:underline\"\r\n [attr.aria-expanded]=\"showDetails()\"\r\n (click)=\"showDetails.set(!showDetails())\"\r\n >\r\n <mt-icon\r\n [icon]=\"showDetails() ? 'arrow.chevron-up' : 'arrow.chevron-down'\"\r\n />\r\n {{ showDetails() ? t(\"hide-details\") : t(\"show-details\") }}\r\n </button>\r\n @if (showDetails()) {\r\n <ul class=\"ms-5 flex list-disc flex-col gap-0.5 ps-4\">\r\n @for (detail of technicalDetails(); track $index) {\r\n <li>{{ detail }}</li>\r\n }\r\n </ul>\r\n }\r\n }\r\n </div>\r\n }\r\n </div>\r\n\r\n <!-- Close, and Stop / Close replacement while the backend allows it -->\r\n <div [class]=\"modal.footerClass\">\r\n @if (canCancel()) {\r\n <mt-button\r\n [label]=\"cancelIsStop() ? t('stop') : t('close')\"\r\n icon=\"general.x-circle\"\r\n severity=\"danger\"\r\n variant=\"outlined\"\r\n [loading]=\"cancelling()\"\r\n (click)=\"cancel()\"\r\n />\r\n }\r\n <mt-button [label]=\"t('dismiss')\" (click)=\"close()\" />\r\n </div>\r\n</ng-container>\r\n" }]
3995
+ }], propDecorators: { operationId: [{ type: i0.Input, args: [{ isSignal: true, alias: "operationId", required: true }] }] } });
3996
+
3997
+ const PAGE_SIZE = 25;
3998
+ /** Rows the server is still working on are re-read this often while shown. */
3999
+ const REFRESH_ACTIVE_MS = 8000;
4000
+ /** The query parameter that holds the replacement open in the drawer. */
4001
+ const OPEN_PARAM = 'id';
4002
+ const DRAWER_CLASS = '!w-[90%] !max-w-[40rem] !absolute !shadow-none';
4003
+ /**
4004
+ * Every replacement in this application, open ones first by default: the way
4005
+ * back to one after its drawer was closed, and where an abandoned one is
4006
+ * closed. The only row action besides Open comes from `canCancel`.
4007
+ *
4008
+ * One replacement opens in a drawer over the list. Its id lives in the URL
4009
+ * (`?id=`), so a refresh or a link from the Users page opens it again.
4010
+ */
4011
+ class UserReplacements {
4012
+ api = inject(UserReplacementService);
4013
+ facade = inject(UsersGroupsFacade);
4014
+ router = inject(Router);
4015
+ route = inject(ActivatedRoute);
4016
+ confirmation = inject(ConfirmationService);
4017
+ modal = inject(ModalService);
4018
+ toast = inject(ToastService);
4019
+ transloco = inject(TranslocoService);
4020
+ destroyRef = inject(DestroyRef);
4021
+ text = new ReplacementText(this.transloco);
4022
+ /** The drawer now open, and the replacement it shows. */
4023
+ drawer = null;
4024
+ personCol = viewChild.required('personCol');
4025
+ statusCol = viewChild.required('statusCol');
4026
+ startedCol = viewChild.required('startedCol');
4027
+ users = this.facade.users;
4028
+ language = toSignal(this.transloco.langChanges$, {
4029
+ initialValue: this.transloco.getActiveLang(),
4030
+ });
4031
+ /** Bumped on every reload so an older page arriving late is dropped. */
4032
+ request = 0;
4033
+ /**
4034
+ * All by default: most replacements finish within seconds, so "Open" alone
4035
+ * would look empty right after one is started.
4036
+ */
4037
+ filter = signal('All', ...(ngDevMode ? [{ debugName: "filter" }] : /* istanbul ignore next */ []));
4038
+ replacements = signal([], ...(ngDevMode ? [{ debugName: "replacements" }] : /* istanbul ignore next */ []));
4039
+ nextCursor = signal(null, ...(ngDevMode ? [{ debugName: "nextCursor" }] : /* istanbul ignore next */ []));
4040
+ loading = signal(true, ...(ngDevMode ? [{ debugName: "loading" }] : /* istanbul ignore next */ []));
4041
+ loadingMore = signal(false, ...(ngDevMode ? [{ debugName: "loadingMore" }] : /* istanbul ignore next */ []));
4042
+ error = signal(null, ...(ngDevMode ? [{ debugName: "error" }] : /* istanbul ignore next */ []));
4043
+ workingIds = signal([], ...(ngDevMode ? [{ debugName: "workingIds" }] : /* istanbul ignore next */ []));
4044
+ tabs = computed(() => {
4045
+ this.language();
4046
+ return [
4047
+ { label: this.text.t('list.tabs.all'), value: 'All' },
4048
+ { label: this.text.t('list.tabs.active'), value: 'Active' },
4049
+ { label: this.text.t('list.tabs.history'), value: 'History' },
4050
+ ];
4051
+ }, ...(ngDevMode ? [{ debugName: "tabs" }] : /* istanbul ignore next */ []));
4052
+ rows = computed(() => {
4053
+ this.language();
4054
+ return this.replacements().map((replacement) => {
4055
+ const sourceName = this.nameOf(replacement.sourceUserId);
4056
+ return {
4057
+ operationId: replacement.operationId,
4058
+ sourceName,
4059
+ sourceInitials: initialsOf(sourceName),
4060
+ successorName: this.nameOf(replacement.defaultSuccessorUserId),
4061
+ status: replacement.status,
4062
+ statusLabel: this.text.code('statuses', replacement.status),
4063
+ statusClass: TONE_PILL[STATUS_TONE[replacement.status] ?? 'neutral'],
4064
+ detail: this.detailOf(replacement),
4065
+ createdAt: validDate(replacement.createdAtUtc),
4066
+ replacement,
4067
+ };
4068
+ });
4069
+ }, ...(ngDevMode ? [{ debugName: "rows" }] : /* istanbul ignore next */ []));
4070
+ columns = computed(() => {
4071
+ this.language();
4072
+ return [
4073
+ {
4074
+ key: 'sourceName',
4075
+ label: this.text.t('list.columns.people'),
4076
+ type: 'custom',
4077
+ customCellTpl: this.personCol(),
4078
+ },
4079
+ {
4080
+ key: 'statusLabel',
4081
+ label: this.text.t('list.columns.status'),
4082
+ type: 'custom',
4083
+ customCellTpl: this.statusCol(),
4084
+ },
4085
+ {
4086
+ key: 'createdAt',
4087
+ label: this.text.t('started'),
4088
+ type: 'custom',
4089
+ customCellTpl: this.startedCol(),
4090
+ },
4091
+ ];
4092
+ }, ...(ngDevMode ? [{ debugName: "columns" }] : /* istanbul ignore next */ []));
4093
+ rowActions = computed(() => {
4094
+ this.language();
4095
+ return [
4096
+ {
4097
+ icon: 'general.eye',
4098
+ tooltip: this.text.t('list.open'),
4099
+ color: 'primary',
4100
+ variant: 'outlined',
4101
+ action: (row) => this.open(row.operationId),
4102
+ },
4103
+ {
4104
+ icon: 'general.x-circle',
4105
+ tooltip: this.text.t('list.close'),
4106
+ color: 'danger',
4107
+ variant: 'outlined',
4108
+ action: (row) => this.close(row),
4109
+ hidden: (row) => !row.replacement.canCancel,
4110
+ loading: (row) => this.workingIds().includes(row.operationId),
4111
+ },
4112
+ ];
4113
+ }, ...(ngDevMode ? [{ debugName: "rowActions" }] : /* istanbul ignore next */ []));
4114
+ emptyTitle = computed(() => {
4115
+ this.language();
4116
+ return this.text.t(`list.empty.${this.filter()}-title`);
4117
+ }, ...(ngDevMode ? [{ debugName: "emptyTitle" }] : /* istanbul ignore next */ []));
4118
+ emptyDescription = computed(() => {
4119
+ this.language();
4120
+ return this.text.t(`list.empty.${this.filter()}-body`);
4121
+ }, ...(ngDevMode ? [{ debugName: "emptyDescription" }] : /* istanbul ignore next */ []));
4122
+ ngOnInit() {
4123
+ if (!this.users().length)
4124
+ this.facade.getUsers();
4125
+ void this.reload();
4126
+ // Keep the counters of replacements the server is working on moving.
4127
+ const timer = setInterval(() => void this.refreshActive(), REFRESH_ACTIVE_MS);
4128
+ this.destroyRef.onDestroy(() => clearInterval(timer));
4129
+ // The drawer follows `?id=`: set by a row, the Users page, or a refresh.
4130
+ this.route.queryParamMap
4131
+ .pipe(map((params) => params.get(OPEN_PARAM)), distinctUntilChanged(), takeUntilDestroyed(this.destroyRef))
4132
+ .subscribe((id) => this.syncDrawer(id));
4133
+ // Leaving the tab takes the drawer with it.
4134
+ this.destroyRef.onDestroy(() => this.dismissDrawer());
4135
+ }
4136
+ setFilter(filter) {
4137
+ if (filter === this.filter())
4138
+ return;
4139
+ this.filter.set(filter);
4140
+ void this.reload();
4141
+ }
4142
+ async reload() {
4143
+ const request = ++this.request;
4144
+ this.loading.set(true);
4145
+ this.error.set(null);
4146
+ try {
4147
+ const page = await firstValueFrom(this.api.list({ filter: this.filter(), pageSize: PAGE_SIZE }));
4148
+ if (request !== this.request)
4149
+ return;
4150
+ this.replacements.set(page.items);
4151
+ this.nextCursor.set(page.nextAfterOperationId);
4152
+ }
4153
+ catch (error) {
4154
+ if (request !== this.request)
4155
+ return;
4156
+ this.replacements.set([]);
4157
+ this.nextCursor.set(null);
4158
+ this.error.set(this.text.error(replacementErrorKey(error)));
4159
+ }
4160
+ finally {
4161
+ if (request === this.request)
4162
+ this.loading.set(false);
4163
+ }
4164
+ }
4165
+ async loadMore() {
4166
+ const cursor = this.nextCursor();
4167
+ if (!cursor || this.loadingMore())
4168
+ return;
4169
+ const request = this.request;
4170
+ this.loadingMore.set(true);
4171
+ try {
4172
+ const page = await firstValueFrom(this.api.list({
4173
+ filter: this.filter(),
4174
+ afterOperationId: cursor,
4175
+ pageSize: PAGE_SIZE,
4176
+ }));
4177
+ if (request !== this.request)
4178
+ return;
4179
+ this.replacements.update((current) => [...current, ...page.items]);
4180
+ this.nextCursor.set(page.nextAfterOperationId);
4181
+ }
4182
+ catch (error) {
4183
+ if (request !== this.request)
4184
+ return;
4185
+ // A cursor the server no longer accepts: the message says to refresh.
4186
+ this.toast.error(this.text.error(replacementErrorKey(error)));
4187
+ }
4188
+ finally {
4189
+ this.loadingMore.set(false);
4190
+ }
4191
+ }
4192
+ /** Open a replacement in the drawer, through the URL. */
4193
+ open(operationId) {
4194
+ void this.router.navigate([], {
4195
+ relativeTo: this.route,
4196
+ queryParams: { [OPEN_PARAM]: operationId },
4197
+ queryParamsHandling: 'merge',
4198
+ });
4199
+ }
4200
+ // ---------------------------------------------------------------------------
4201
+ // The drawer
4202
+ // ---------------------------------------------------------------------------
4203
+ syncDrawer(id) {
4204
+ if (id === this.drawer?.id)
4205
+ return;
4206
+ this.dismissDrawer();
4207
+ if (!id)
4208
+ return;
4209
+ const ref = this.modal.openModal(UserReplacementDetails, 'drawer', {
4210
+ header: this.text.t('details-title'),
4211
+ styleClass: DRAWER_CLASS,
4212
+ position: 'end',
4213
+ appendTo: 'page-content',
4214
+ dismissableMask: true,
4215
+ dismissible: true,
4216
+ inputValues: { operationId: id },
4217
+ });
4218
+ const drawer = { id, ref };
4219
+ this.drawer = drawer;
4220
+ ref.onClose.pipe(take(1)).subscribe(() => {
4221
+ // Replaced by another drawer, or the list itself is going away.
4222
+ if (this.drawer !== drawer)
4223
+ return;
4224
+ this.drawer = null;
4225
+ // Its status may have changed (stopped, closed, finished).
4226
+ void this.reload();
4227
+ void this.router.navigate([], {
4228
+ relativeTo: this.route,
4229
+ queryParams: { [OPEN_PARAM]: null },
4230
+ queryParamsHandling: 'merge',
4231
+ replaceUrl: true,
4232
+ });
4233
+ });
4234
+ }
4235
+ /** Close the drawer without touching the URL (the caller owns it). */
4236
+ dismissDrawer() {
4237
+ const drawer = this.drawer;
4238
+ this.drawer = null;
4239
+ drawer?.ref.close();
4240
+ }
4241
+ close(row) {
4242
+ const stop = ACTIVE_STATUSES.includes(row.status);
4243
+ const label = stop ? this.text.t('stop') : this.text.t('close');
4244
+ this.confirmation.confirm({
4245
+ type: 'dialog',
4246
+ header: stop ? this.text.t('stop-title') : this.text.t('close-title'),
4247
+ message: this.text.t(cancelConfirmKey(row.status), {
4248
+ name: row.sourceName,
4249
+ successor: row.successorName,
4250
+ }),
4251
+ icon: 'general.x-circle',
4252
+ acceptLabel: label,
4253
+ rejectLabel: this.text.t('keep'),
4254
+ acceptButton: { severity: 'danger' },
4255
+ accept: () => void this.doClose(row),
4256
+ });
4257
+ }
4258
+ async doClose(row) {
4259
+ const id = row.operationId;
4260
+ this.workingIds.update((ids) => [...ids, id]);
4261
+ try {
4262
+ const closed = await firstValueFrom(this.api.cancel(id));
4263
+ this.toast.success(this.text.t('closed-toast'));
4264
+ this.replace(closed);
4265
+ // A closed replacement no longer belongs under "Open".
4266
+ if (this.filter() === 'Active')
4267
+ void this.reload();
4268
+ }
4269
+ catch (error) {
4270
+ // `ProcessingBusy`: it did not stop; the message says to try again.
4271
+ this.toast.error(this.text.error(replacementErrorKey(error)));
4272
+ void this.reload();
4273
+ }
4274
+ finally {
4275
+ this.workingIds.update((ids) => ids.filter((value) => value !== id));
4276
+ }
4277
+ }
4278
+ async refreshActive() {
4279
+ const active = this.replacements().filter((replacement) => ACTIVE_STATUSES.includes(replacement.status));
4280
+ for (const replacement of active) {
4281
+ try {
4282
+ this.replace(await firstValueFrom(this.api.get(replacement.operationId)));
4283
+ }
4284
+ catch {
4285
+ // The next tick tries again; the row keeps its last counters.
4286
+ }
4287
+ }
4288
+ }
4289
+ replace(replacement) {
4290
+ this.replacements.update((current) => current.map((row) => row.operationId === replacement.operationId ? replacement : row));
4291
+ }
4292
+ detailOf(replacement) {
4293
+ const moved = replacement.itemsByResult?.['Applied'] ?? 0;
4294
+ switch (replacement.status) {
4295
+ // Processing: the status says it all; no counts (backend guide).
4296
+ case 'Preparing':
4297
+ case 'Running':
4298
+ return '';
4299
+ case 'ManualActionRequired': {
4300
+ const count = manualCountOf(replacement);
4301
+ return count
4302
+ ? this.text.t('list.detail.needs-you', { count })
4303
+ : this.text.t('list.detail.stopped');
4304
+ }
4305
+ case 'Paused':
4306
+ return this.text.t('list.detail.stopped');
4307
+ case 'AwaitingRestart':
4308
+ return this.text.t('list.detail.restart');
4309
+ case 'Completed':
4310
+ case 'CompletedWithWarnings':
4311
+ return replacement.itemCount === 0
4312
+ ? this.text.t('list.detail.nothing')
4313
+ : this.text.t('list.detail.moved', { count: moved });
4314
+ default:
4315
+ return moved ? this.text.t('list.detail.moved', { count: moved }) : '';
4316
+ }
4317
+ }
4318
+ nameOf(userId) {
4319
+ if (!userId)
4320
+ return '';
4321
+ const user = this.users().find((candidate) => candidate.id === userId);
4322
+ return user?.displayName || user?.userName || userId;
4323
+ }
4324
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: UserReplacements, deps: [], target: i0.ɵɵFactoryTarget.Component });
4325
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.8", type: UserReplacements, isStandalone: true, selector: "mt-user-replacements", viewQueries: [{ propertyName: "personCol", first: true, predicate: ["personCol"], descendants: true, isSignal: true }, { propertyName: "statusCol", first: true, predicate: ["statusCol"], descendants: true, isSignal: true }, { propertyName: "startedCol", first: true, predicate: ["startedCol"], descendants: true, isSignal: true }], ngImport: i0, template: "<ng-container *transloco=\"let t; prefix: 'users-groups.replacement'\">\r\n <ng-template #personCol let-row>\r\n <div class=\"flex min-w-0 items-center gap-3\">\r\n <mt-avatar\r\n [label]=\"row.sourceInitials\"\r\n shape=\"circle\"\r\n styleClass=\"bg-surface-100! text-color! dark:bg-surface-800!\"\r\n />\r\n <div class=\"flex min-w-0 flex-col\">\r\n <span class=\"truncate font-medium\">{{ row.sourceName }}</span>\r\n <span class=\"flex min-w-0 items-center gap-1 text-xs text-muted-color\">\r\n <mt-icon icon=\"arrow.arrow-right\" class=\"shrink-0 rtl:rotate-180\" />\r\n <span class=\"truncate\">{{ row.successorName }}</span>\r\n </span>\r\n </div>\r\n </div>\r\n </ng-template>\r\n\r\n <ng-template #statusCol let-row>\r\n <div class=\"flex flex-col items-start gap-1\">\r\n <span\r\n class=\"whitespace-nowrap rounded-md border px-2 py-0.5 text-xs font-medium\"\r\n [class]=\"row.statusClass\"\r\n >{{ row.statusLabel }}</span\r\n >\r\n @if (row.detail) {\r\n <span class=\"text-xs tabular-nums text-muted-color\">{{\r\n row.detail\r\n }}</span>\r\n }\r\n </div>\r\n </ng-template>\r\n\r\n <ng-template #startedCol let-row>\r\n @if (row.createdAt) {\r\n <span class=\"whitespace-nowrap tabular-nums\">{{\r\n row.createdAt | mtDateFormat: \"dateTime\"\r\n }}</span>\r\n }\r\n </ng-template>\r\n\r\n <div class=\"mt-5 flex flex-col gap-4\">\r\n <div class=\"flex justify-end\">\r\n <mt-button\r\n [label]=\"t('refresh')\"\r\n icon=\"arrow.refresh-cw-02\"\r\n variant=\"outlined\"\r\n size=\"small\"\r\n [disabled]=\"loading()\"\r\n (click)=\"reload()\"\r\n />\r\n </div>\r\n\r\n @if (error()) {\r\n <div\r\n class=\"flex items-start gap-2 rounded-md border border-red-200 bg-red-50 p-3 text-sm text-red-700 dark:border-red-900 dark:bg-red-950 dark:text-red-200\"\r\n >\r\n <mt-icon icon=\"alert.alert-circle\" class=\"mt-0.5 shrink-0\" />\r\n <span>{{ error() }}</span>\r\n </div>\r\n }\r\n\r\n <mt-table\r\n [tabs]=\"tabs()\"\r\n [activeTab]=\"filter()\"\r\n (activeTabChange)=\"setFilter($event)\"\r\n [data]=\"rows()\"\r\n [columns]=\"columns()\"\r\n [rowActions]=\"rowActions()\"\r\n [loading]=\"loading()\"\r\n [generalSearch]=\"true\"\r\n [clickableRows]=\"true\"\r\n (rowClick)=\"open($event.operationId)\"\r\n dataKey=\"operationId\"\r\n [emptyTitle]=\"emptyTitle()\"\r\n [emptyDescription]=\"emptyDescription()\"\r\n />\r\n\r\n @if (nextCursor() && !loading()) {\r\n <mt-button\r\n class=\"self-center\"\r\n [label]=\"t('list.load-more')\"\r\n icon=\"arrow.chevron-down\"\r\n variant=\"outlined\"\r\n size=\"small\"\r\n [loading]=\"loadingMore()\"\r\n (click)=\"loadMore()\"\r\n />\r\n }\r\n </div>\r\n</ng-container>\r\n", dependencies: [{ kind: "directive", type: TranslocoDirective, selector: "[transloco]", inputs: ["transloco", "translocoParams", "translocoScope", "translocoRead", "translocoPrefix", "translocoLang", "translocoLoadingTpl"] }, { kind: "component", type: Table, selector: "mt-table", inputs: ["filters", "data", "columns", "rowActions", "size", "showGridlines", "stripedRows", "selectableRows", "clickableRows", "generalSearch", "lazyLocalSearch", "searchScope", "showFilters", "filterMode", "filterCloseOnOutsideClick", "loading", "updating", "lazy", "lazyLocalSort", "lazyTotalRecords", "reorderableColumns", "reorderableRows", "dataKey", "storageKey", "storageMode", "persistStateExclude", "exportable", "printable", "groupable", "groupCountMap", "cellClickFilter", "freezeActions", "virtualScroll", "virtualScrollItemSize", "scrollHeight", "printTitle", "exportFilename", "actionShape", "rowActionsLoadingFn", "tableLayout", "noCard", "tabs", "tabsOptionLabel", "tabsOptionValue", "activeTab", "actions", "captionStartTemplate", "captionEndTemplate", "emptyTitle", "emptyDescription", "emptyActionLabel", "emptyActionIcon", "externalFiltersActive", "paginatorPosition", "alwaysShowPaginator", "rowsPerPageOptions", "pageSize", "currentPage", "first", "filterTerm", "groupBy", "sortField", "sortDirection"], outputs: ["selectionChange", "cellChange", "lazyLoad", "columnReorder", "rowReorder", "rowClick", "emptyAction", "filtersCleared", "rowActionsRequested", "filtersChange", "activeTabChange", "onTabChange", "pageSizeChange", "currentPageChange", "firstChange", "filterTermChange", "groupByChange", "sortFieldChange", "sortDirectionChange"] }, { kind: "component", type: Avatar, selector: "mt-avatar", inputs: ["label", "icon", "image", "styleClass", "size", "shape", "badge", "badgeSize", "badgeSeverity"], outputs: ["onImageError"] }, { kind: "component", type: Button, selector: "mt-button", inputs: ["icon", "label", "tooltip", "class", "type", "styleClass", "severity", "badge", "variant", "badgeSeverity", "size", "iconPos", "autofocus", "fluid", "raised", "rounded", "text", "plain", "outlined", "link", "disabled", "loading", "pInputs", "ariaLabel"], outputs: ["onClick", "onFocus", "onBlur"] }, { kind: "component", type: Icon, selector: "mt-icon", inputs: ["icon"] }, { kind: "pipe", type: MTDateFormatPipe, name: "mtDateFormat" }] });
4326
+ }
4327
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: UserReplacements, decorators: [{
4328
+ type: Component,
4329
+ args: [{ selector: 'mt-user-replacements', imports: [TranslocoDirective, Table, Avatar, Button, Icon, MTDateFormatPipe], template: "<ng-container *transloco=\"let t; prefix: 'users-groups.replacement'\">\r\n <ng-template #personCol let-row>\r\n <div class=\"flex min-w-0 items-center gap-3\">\r\n <mt-avatar\r\n [label]=\"row.sourceInitials\"\r\n shape=\"circle\"\r\n styleClass=\"bg-surface-100! text-color! dark:bg-surface-800!\"\r\n />\r\n <div class=\"flex min-w-0 flex-col\">\r\n <span class=\"truncate font-medium\">{{ row.sourceName }}</span>\r\n <span class=\"flex min-w-0 items-center gap-1 text-xs text-muted-color\">\r\n <mt-icon icon=\"arrow.arrow-right\" class=\"shrink-0 rtl:rotate-180\" />\r\n <span class=\"truncate\">{{ row.successorName }}</span>\r\n </span>\r\n </div>\r\n </div>\r\n </ng-template>\r\n\r\n <ng-template #statusCol let-row>\r\n <div class=\"flex flex-col items-start gap-1\">\r\n <span\r\n class=\"whitespace-nowrap rounded-md border px-2 py-0.5 text-xs font-medium\"\r\n [class]=\"row.statusClass\"\r\n >{{ row.statusLabel }}</span\r\n >\r\n @if (row.detail) {\r\n <span class=\"text-xs tabular-nums text-muted-color\">{{\r\n row.detail\r\n }}</span>\r\n }\r\n </div>\r\n </ng-template>\r\n\r\n <ng-template #startedCol let-row>\r\n @if (row.createdAt) {\r\n <span class=\"whitespace-nowrap tabular-nums\">{{\r\n row.createdAt | mtDateFormat: \"dateTime\"\r\n }}</span>\r\n }\r\n </ng-template>\r\n\r\n <div class=\"mt-5 flex flex-col gap-4\">\r\n <div class=\"flex justify-end\">\r\n <mt-button\r\n [label]=\"t('refresh')\"\r\n icon=\"arrow.refresh-cw-02\"\r\n variant=\"outlined\"\r\n size=\"small\"\r\n [disabled]=\"loading()\"\r\n (click)=\"reload()\"\r\n />\r\n </div>\r\n\r\n @if (error()) {\r\n <div\r\n class=\"flex items-start gap-2 rounded-md border border-red-200 bg-red-50 p-3 text-sm text-red-700 dark:border-red-900 dark:bg-red-950 dark:text-red-200\"\r\n >\r\n <mt-icon icon=\"alert.alert-circle\" class=\"mt-0.5 shrink-0\" />\r\n <span>{{ error() }}</span>\r\n </div>\r\n }\r\n\r\n <mt-table\r\n [tabs]=\"tabs()\"\r\n [activeTab]=\"filter()\"\r\n (activeTabChange)=\"setFilter($event)\"\r\n [data]=\"rows()\"\r\n [columns]=\"columns()\"\r\n [rowActions]=\"rowActions()\"\r\n [loading]=\"loading()\"\r\n [generalSearch]=\"true\"\r\n [clickableRows]=\"true\"\r\n (rowClick)=\"open($event.operationId)\"\r\n dataKey=\"operationId\"\r\n [emptyTitle]=\"emptyTitle()\"\r\n [emptyDescription]=\"emptyDescription()\"\r\n />\r\n\r\n @if (nextCursor() && !loading()) {\r\n <mt-button\r\n class=\"self-center\"\r\n [label]=\"t('list.load-more')\"\r\n icon=\"arrow.chevron-down\"\r\n variant=\"outlined\"\r\n size=\"small\"\r\n [loading]=\"loadingMore()\"\r\n (click)=\"loadMore()\"\r\n />\r\n }\r\n </div>\r\n</ng-container>\r\n" }]
4330
+ }], propDecorators: { personCol: [{ type: i0.ViewChild, args: ['personCol', { isSignal: true }] }], statusCol: [{ type: i0.ViewChild, args: ['statusCol', { isSignal: true }] }], startedCol: [{ type: i0.ViewChild, args: ['startedCol', { isSignal: true }] }] } });
4331
+
2624
4332
  /**
2625
4333
  * Generated bundle index. Do not edit.
2626
4334
  */
2627
4335
 
2628
- export { AddUserToGroup, ClearSelectedGroup, CreateGroup, CreateUser, DeleteGroup, DeleteUser, DeleteUserFromGroup, GetGroup, GetGroupSummary, GetGroups, GetUser, GetUserLockStatuses, GetUserSummary, GetUsers, GroupForm, Groups, LinkUserToApplication, ResetUserPassword, UnlockUser, UpdateGroup, UpdateUser, UserForm, Users, UsersGroups, UsersGroupsActionKey, UsersGroupsFacade, UsersGroupsState };
4336
+ export { ACTIVE_STATUSES, AddUserToGroup, CLOSED_STATUSES, ClearSelectedGroup, CreateGroup, CreateUser, DeleteGroup, DeleteUser, DeleteUserFromGroup, FINISHED_STATUSES, GetGroup, GetGroupSummary, GetGroups, GetUser, GetUserLockStatuses, GetUserSummary, GetUsers, GroupForm, Groups, LinkUserToApplication, MANUAL_RESULTS, ResetUserPassword, USER_REPLACEMENT_OPERATION_CONTRACT, UnlockUser, UpdateGroup, UpdateUser, UserForm, UserReplacementService, UserReplacements, Users, UsersGroups, UsersGroupsActionKey, UsersGroupsFacade, UsersGroupsState, cancelConfirmKey, manualCountOf, stopCodeOf };
2629
4337
  //# sourceMappingURL=masterteam-users-groups.mjs.map